【问题标题】:Formatting Microsoft Chart Control X Axis labels for sub-categories to be like charts generated in Excel将子类别的 Microsoft Chart Control X 轴标签格式化为 Excel 中生成的图表
【发布时间】:2011-02-01 03:58:35
【问题描述】:

我在尝试使用 Microsoft Chart Control for .Net 复制在 Microsoft Excel 2007 中生成的图表时遇到问题

图表显示了一年中每个月的 TOP 5 条目(每个月可能有不同的 5 个条目),然后显示一些指标的细分

我可以很好地获取数据,问题归结为在 Excel 图表中它已格式化 X 轴标签,如下图所示: 这就是我们希望轴的格式,以便每个月份名称仅针对该月份的 5 个子类别列出一次。

但我不知道如何使用 Microsoft 图表控件重现这一点,当我对图表控件使用相同的数据时,它会将 X 轴格式化为(忽略颜色等): 我已经绑定了数据,因此 XAxis 值是“January AAA-BBB”,我想也许我需要将 Month 部分分离成可以单独格式化/分组的其他轴值。

任何帮助将不胜感激。

【问题讨论】:

    标签: c# asp.net controls charts


    【解决方案1】:

    我已经设法使用了一系列我手动定位到正确“部分”下的 CustomLabel。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      相关资源
      最近更新 更多