自定义标签对齐问题 - ASP.Net BarChart

时间:2014-10-16 04:56:50

标签: c# asp.net .net charts bar-chart

我正在创建一个图表控件,其图表类型为条形图。添加自定义标签时,标签显示不正确(第一个标签除外)。这发生在X轴和Y轴上。

enter image description here

代码

            chBar.Series["Series1"].ChartType = SeriesChartType.Bar;
            chBar.Series["Series1"].XValueType = ChartValueType.String;
            chBar.Series["Series1"].YValueType = ChartValueType.String;
            chBar.Series["Series1"]["BarLabelStyle"] = "Center";
            chBar.Series["Series1"]["DrawingStyle"] = "Cylinder";
            chBar.Series["Series1"]["PointWidth"] = "0.6";


            int xpos = 0;

            //CustomLabel for Xaxis
            CustomLabel clabelX;
            CustomLabel clabelY;
            foreach(string x in axisXValues.Choices)
            {

                clabelX = new CustomLabel(xpos, xpos + 1, x, xpos, LabelMarkStyle.LineSideMark);
                chBar.ChartAreas[0].AxisX.CustomLabels.Add(clabelX);
                xpos++;
            }

            chBar.ChartAreas[0].AxisX.Minimum = 0;
            chBar.ChartAreas[0].AxisX.Maximum = 5;

1 个答案:

答案 0 :(得分:0)

自定义标签构造函数中的RowIndex应为0.

clabelX = new CustomLabel(xpos, xpos + 1, x, 0, LabelMarkStyle.LineSideMark);