如何删除或阻止' 120' Y轴点被添加到我的列图表?我只想显示0到100之间的数据。
这是我创建图表的代码(System.Windows.Forms.DataVisualization.Charting):
Chart chart = new Chart();
string[] xAxis1 = { "a", "b", "c", "d", "e", "f" };
decimal[] yAxis1 = { 0, 20, 40, 60, 80, 100 };
string[] xAxis2 = { "a", "b", "c", "d", "e", "f" };
decimal[] yAxis2 = { 0, 20, 40, 60, 80, 100 };
string[] xAxis3 = { "a", "b", "c", "d", "e", "f" };
decimal[] yAxis3 = { 0, 20, 40, 60, 80, 100 };
chart.Series.Add("Benchmark");
chart.Series[0].ChartType = SeriesChartType.Column;
chart.Series[0].Points.DataBindXY(xAxis1, yAxis1);
chart.Series[0].Color = Color.Blue;
chart.Series.Add("Current");
chart.Series[1].ChartType = SeriesChartType.Column;
chart.Series[1].Points.DataBindXY(xAxis2, yAxis2);
chart.Series[1].Color = Color.Maroon;
chart.Series.Add("Recommended");
chart.Series[2].ChartType = SeriesChartType.Column;
chart.Series[2].Points.DataBindXY(xAxis3, yAxis3);
chart.Series[2].Color = Color.LawnGreen;
// Chart area
ChartArea area = new ChartArea();
chart.ChartAreas.Add(area);
// Chart Legend
Legend legend = new Legend();
legend.Docking = Docking.Bottom;
chart.Legends.Add(legend);
// Chart Size
chart.Size = new Size(500, 350);
谢谢。
答案 0 :(得分:1)
尝试chart.ChartAreas[0].AxisY.Maximum = 100;
- jstreet。