Category labels on charts


#1

Hi,

Is it possible to put in custom text for the category markers on a chart. This would be for a bar chart where you can compare values by quarter and year side by side, e.g:

|
| _ _ _
| _ | | | | _ _ _ | | _
| | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | |
|----------|----------|----------|----------|
Q1 2005 Q2 2005 Year 2005 Year 2006

I have everything working, except having numbers running 1, 2, 3 etc instead of the text ‘Q1 2005’, ‘Q2 2005’, etc along the bottom.

Any help you can offer will be most appreciated,

Thanks,

a


#2

Please use NSeries.CategoryData to set it. Please check the following sample code:

Excel excel = new Excel();
Cells cells = excel.Worksheets[0].Cells;
cells["A1"].PutValue(2);
cells["A2"].PutValue(5);
cells["A3"].PutValue(3);
cells["A4"].PutValue(6);
cells["B1"].PutValue(4);
cells["B2"].PutValue(3);
cells["B3"].PutValue(6);
cells["B4"].PutValue(7);

cells["C1"].PutValue("Q1");
cells["C2"].PutValue("Q2");
cells["C3"].PutValue("Y1");
cells["C4"].PutValue("Y2");

int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.Column, 11, 0, 27, 13);

Chart chart = excel.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:B4", true);

chart.NSeries.CategoryData = "C1:C4";


#3

That’s great, not sure how I missed it in the documentation!

Thank you very much Laurence.

a