Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Sep 28, 2015 7:40 pm

Hello forum's people: I'm newe using Spire.Xls. I have a chart with 4 series. How can I insert data labels (X,Y) to my chart type ScatterSmoothedLineMarkers to see it in every serie?

Thanks a lot.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Tue Sep 29, 2015 3:42 am

Hello,

Thanks for your inquiry.
Please try the code snippet:
Code: Select all
  foreach (ChartSerie serie in chart.Series)
            {
                serie.DataPoints.DefaultDataPoint.DataLabels.HasValue = true;
                serie.DataPoints.DefaultDataPoint.DataLabels.HasSeriesName = false;
            }



Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Sep 29, 2015 5:20 pm

Hello Amy.Zhao: Thanks a lot for your sample, I want see data labels like an Excel chart, but still a can´t see X and Y data labels, in this case only Y label data is visible.

Thanks again.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Wed Sep 30, 2015 2:03 am

Hello,

Thanks for your feedback. I used the code to generate the chart and both its X and Y data labels are visible, attached the screenshot of the result.
Would you please share us your code to help us do an investigation? If you have test document, please also send us it.
Thank you.

Best Regards,
Amy
E-iceblue support team
Attachments
001.PNG
001.PNG (24.34 KiB) Viewed 6454 times
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Oct 02, 2015 11:12 am

Hello,

Has your issue been resolved ? If not, could you please share us your code to help us do an investigation ?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Thu Oct 08, 2015 3:25 am

Hi Amy.zhao: I'm working with vb.net 2008, and this is my code:
Dim chart As Chart = Nothing
wb.Version = ExcelVersion.Version2010
wb.CreateEmptySheets(1)

Dim sheet As Worksheet = wb.Worksheets(0)
sheet.Name = "Chart data"

chart = sheet.Charts.Add(ExcelChartType.ScatterSmoothedLineMarkers)

chart.DataRange = sheet.Range("B2:E6")
chart.SeriesDataFromRange = False

chart.LeftColumn = 8
chart.TopRow = 2
chart.RightColumn = 14
chart.BottomRow = 17

chart.ChartTitle = "Sales by year"
chart.ChartTitleArea.IsBold = True
chart.ChartTitleArea.Size = 12

Dim cs1 As Charts.ChartSerie = chart.Series(0)
cs1.CategoryLabels = sheet.Range("A2:A6")
cs1.Name = "P1"
cs1.Values = sheet.Range("B2:B6")
cs1.DataFormat.ShowActiveValue = True

Dim cs2 As Charts.ChartSerie = chart.Series(1)
cs2.Name = "P2"
cs2.CategoryLabels = sheet.Range("A2:A6")
cs2.Values = sheet.Range("C2:C6")
cs2.DataFormat.ShowActiveValue = True

Dim cs3 As Charts.ChartSerie = chart.Series(2)
cs3.Name = "P3"
cs3.CategoryLabels = sheet.Range("A2:A6")
cs3.Values = sheet.Range("D2:D6")
cs3.DataFormat.ShowActiveValue = True

Dim cs4 As Charts.ChartSerie = chart.Series(3)
cs4.Name = "P4"
cs4.CategoryLabels = sheet.Range("A2:A6")
cs4.Values = sheet.Range("E2:E6")
cs4.DataFormat.ShowActiveValue = True

For Each serie As Charts.ChartSerie In chart.Series
serie.DataPoints.DefaultDataPoint.DataLabels.HasValue = True
serie.DataPoints.DefaultDataPoint.DataLabels.HasSeriesName = False
Next

wb.SaveToFile(strPath)

But I don't see (x,y) data label.
Attachments
ChartTesting.png
ChartTesting.png (35.7 KiB) Viewed 6430 times
Last edited by QMark on Thu Oct 08, 2015 3:36 am, edited 2 times in total.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Thu Oct 08, 2015 3:30 am

And I want it this way:
Attachments
ChartTestingII.png
ChartTestingII.png (37.46 KiB) Viewed 6430 times

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Thu Oct 08, 2015 8:46 am

Hello,

Thanks for providing.
I have tested your code but still didn't reproduce your issue. I used Spire.XLS Pack Hotfix Version:7.8.26 (http://www.e-iceblue.com/Download/downl ... t-now.html), please try it and then tell me your test result. Thanks.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Oct 09, 2015 4:08 am

Hello Amy.Zhao I'll try with the pack hotfix you had indicated and I'll let you know the results.
Thanks a lot again.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Mon Oct 12, 2015 7:27 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 22, 2015 5:04 am

Hello Amy.Zhao: I was solving other stuf. Today I've made the changes you indicate, but now I got an exception 'spr861' in the code line Dim wb As New Workbook . What's means that?

Thanks.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Thu Oct 22, 2015 5:51 am

I've reinstall spire.xls_7.8.msi and then change \e-iceblue\Spire.XLS\Bin\NET3.5 with Bin\NET3.5 from Spire.XLS Pack Hotfix Version:7.8.26 and run the program without problems but I still don't see X,Y label. only Y label.
what am I doing wrong?

Thanks.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Thu Oct 22, 2015 7:55 am

Hi,

I shared my test application, it was created with vb.net 2010, please run it on your side and tell me how it works.
The downloading link is http://www.e-iceblue.com//downloads//demo//5907.zip

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 22, 2015 4:19 pm

Dear Amy.Zhao: I've found the problem. I create the WokBook from cero:
wb.Version = ExcelVersion.Version2010
wb.CreateEmptySheets(1)

but you read an existing one:
wb.LoadFromFile("..\\..\\Bool1.xlsx")

That's the diference, I change my code reading the Workbook you have in your sample and labels X and Y are corrects.

And I need create the document from cero.

Thanks.

QMark
 
Posts: 10
Joined: Mon Sep 28, 2015 7:27 pm

Fri Oct 23, 2015 2:33 am

Hi,

Thanks for your reply.
Sorry for inconvenience, I have recreated your issue and posted it to our dev team. We will inform you when it is fixed.
Welcome to write to us again for further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS