我正在创建一个图表控件,其图表类型为条形图。添加自定义标签时,标签显示不正确(第一个标签除外)。这发生在X轴和Y轴上。
代码
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;
答案 0 :(得分:0)
自定义标签构造函数中的RowIndex应为0.
clabelX = new CustomLabel(xpos, xpos + 1, x, 0, LabelMarkStyle.LineSideMark);