I am having issues attempting to replicate a chart that has been generated in Microsoft Excel 2007 by using the Microsoft Chart Control for .Net
The chart is showing the TOP 5 entries for each Month (each month could have a different 5 entries) of the year and then showing a breakdown of some metrics
I can get the data perfectly fine, the issue comes down to the fact that in the Excel chart it has formatted the X-Axis labels as shown in the following image: Which is how we want the axis formatted so that each Month name is only listed once for the 5 sub categories that are for that month.
But I do not know how to reproduce this using the Microsoft Chart Control, when I use the same data for the chart control it formats the X-Axis as (ignore colors and such): I have bound the data so that the XAxis value is "January AAA-BBB", I'm thinking that maybe I need to separate out the Month portion into some other axis value that can be formatted/grouped separately.
Any help would be appreciated.
From the Design tab, Data group, select Select Data. In the dialog box under Horizontal (Category) Axis Labels, click Edit. In the Axis label range enter the cell references for the x-axis or use the mouse to select the range, click OK. Click OK.
I have managed to use a series of CustomLabel's that I manually position to be under the correct "sections".
foreach (string monthName in monthNames)
{
CustomLabel monthLabel = new CustomLabel(startOffset, endOffset, monthName, 1, LabelMarkStyle.Box);
theChart.ChartAreas["Default"].AxisX.CustomLabels.Add(monthLabel);
//increment startOffset and endOffset enough to position the next label
//under the correct "section"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With