防止或删除额外的系列 Y 轴点添加到图表?
Prevent or remove an extra Series Y-axis Point from being added to Chart?
如何删除或阻止将“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);
谢谢。
尝试 chart.ChartAreas[0].AxisY.Maximum = 100;
- jstreet。
如何删除或阻止将“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);
谢谢。
尝试 chart.ChartAreas[0].AxisY.Maximum = 100;
- jstreet。