Hi,
It works absolutely fine, no issue what so ever for setting Category data for chart’s data series.
I think there is an issue with your code setting for CategoryData, please check your own code for setting category data range, you may debug it thoroughly.
Here is the sample code, you may refer to it and run it test it, it works fine.
Sample code:
Dim workbook As New Aspose.Cells.Workbook()
Dim sheet As Aspose.Cells.Worksheet = workbook.Worksheets(0)
sheet.Name = “Data”
Dim cells As Aspose.Cells.Cells = workbook.Worksheets(0).Cells
workbook.ChangePalette(Color.Orange, 53)
workbook.ChangePalette(Color.LightBlue, 54)
workbook.ChangePalette(Color.LightCoral, 55)
workbook.ChangePalette(Color.Indigo, 52)
Dim colors() As Color = workbook.Colors
cells(“A1”).PutValue(“Region”)
cells(“A2”).PutValue(“France”)
cells(“A3”).PutValue(“Germany”)
cells(“A4”).PutValue(“England”)
cells(“A5”).PutValue(“Sweden”)
cells(“B1”).PutValue(“Sale”)
cells(“B2”).PutValue(32)
cells(“B3”).PutValue(62)
cells(“B4”).PutValue(06)
Dim sheetIndex As Integer = workbook.Worksheets.Add(Aspose.Cells.SheetType.Chart)
sheet = workbook.Worksheets(sheetIndex)
sheet.Name = “Chart”
Dim chartIndex As Integer = 0
chartIndex = sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Pie, 1, 3, 25, 12)
Dim c As Aspose.Cells.Charts.Chart = sheet.Charts(chartIndex)
c.Legend.TextFont.Name = “Arial”
c.Legend.TextFont.Size = 7
c.Legend.Position = Aspose.Cells.Charts.LegendPositionType.Right
c.ChartArea.BackgroundMode = Aspose.Cells.Charts.BackgroundMode.Transparent
c.NSeries.Add(“Data!B2:B5”, True)
c.NSeries.CategoryData = “Data!A2:A5”
Dim datalabels As Aspose.Cells.Charts.DataLabels
For i As Integer = 0 To c.NSeries.Count - 1
datalabels = c.NSeries(i).DataLabels
datalabels.ShowPercentage = True
datalabels.NumberFormat = “0%”
datalabels.Position = Aspose.Cells.Charts.LabelPositionType.OutsideEnd
datalabels.TextFont.Name = “Arial”
datalabels.TextFont.Size = 7
Next i
workbook.Save(“e:\test2\out_piecharttesting.xlsx”)
If you still find the issue, we need your complete runnable code (same as mine (above)) or a console application to reproduce the issue (you may zip it prior attaching here). Also give us your template Excel files. We will check it soon.
Also we recommend you to use our latest version v7.1.0.
Thank you.