格式化的子类Microsoft图表控件X坐标标签要像在Excel中生成的图表 [英] Formatting Microsoft Chart Control X Axis labels for sub-categories to be like charts generated in Excel

查看:169
本文介绍了格式化的子类Microsoft图表控件X坐标标签要像在Excel中生成的图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,试图复制已被使用.NET中的Microsoft图表控件在Microsoft Excel 2007中生成的图表

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

该图是显示前5项每月(每月可以有不同的5个条目)一年,然后显示一些指标的细分

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

我可以得到完美的数据精,问题归结为一个事实,即Excel图表中已格式化的X轴标签图如下图所示:

这是我们希望轴格式,因此对于那些在该月的5个子类别的每个月份名称仅列出一次。

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.

但我不知道如何重现此使用Microsoft图表控件,当我使用相同的数据图表控制它格式化X轴(忽略颜色等):

我已绑定的数据,使x轴值为一月AAA-BBB,我想,也许我需要月份部分分离出来,转换成可以被格式化/单独分组一些其他的坐标值。

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.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

我已成功地使用一系列CustomLabel年代,我手动定位是在正确的部分。

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"
}

这篇关于格式化的子类Microsoft图表控件X坐标标签要像在Excel中生成的图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆