Category data are not visible properly

Hi Team,

I have created a column chart. But category data is missing for some of the columns. I am attaching the visual studio file for your reference. Please look into this matter and reply me asap.

Thanks in advance.

Hi,


Please add the following lines of code to your code, it works fine with the output Excel file as per your needs.

chart.CategoryAxis.TickLabelSpacing = 1
chart.CategoryAxis.TickMarkSpacing = 1

Since you have long category axis labels to be displayed on the axis line, so you have to specify the tick labels spacing accordingly, by default, MS Excel shows in a compact manner.

Also, if you need to capture all the category labels in the output image of chart, please extend the size of the chart object’s width and height accordingly.

See the complete sample code added to your code segment that works fine.

Sample code:


chart.NSeries.Add(“B2:B16”, True)
chart.NSeries.CategoryData = “A2:A16”
chart.NSeries.IsColorVaried = True

Dim i As Integer
For i = 0 To chart.NSeries.Count - 1 Step i + 1
chart.NSeries(i).DataLabels.Position = LabelPositionType.OutsideEnd

Next

chart.CategoryAxis.TickLabelSpacing = 1
chart.CategoryAxis.TickMarkSpacing = 1

'Set the legend position type
chart.Legend.Position = LegendPositionType.Right
chart.ChartObject.Width = 600
chart.ChartObject.Height = 550

chart.ToImage(“e:\test2\output.bmp”)

PictureBox1.Image = chart.ToImage()
workbook.Save(“e:\test2\outPie.xls”)

Hope, this helps.

Thank you.