c#图表更改x轴上的最大值和最小值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15426129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 16:47:31  来源:igfitidea点击:

c# chart change max and min values on the x axis

c#charts

提问by Matthew The Terrible

Can someone tell me how to change the min and max values on the x axis on a C# chart? I want to go from 0 to 13, but it goes from -1 to 14 right now.

有人能告诉我如何更改 C# 图表 x 轴上的最小值和最大值吗?我想从 0 到 13,但现在从 -1 到 14。

采纳答案by Dutts

If you are using System.Windows.Forms.DataVizualisation.Chartingyou can set the Axis range by manipulating the chart's ChartAreasproperty. So something like

如果您正在使用,System.Windows.Forms.DataVizualisation.Charting您可以通过操作图表的ChartAreas属性来设置轴范围。所以像

myChart.ChartAreas[0].AxisX.Maximum = 13;
myChart.ChartAreas[0].AxisX.Minimum = 0;

回答by Jim Balkwill

You might try myChart.ChartAreas[0].AxisX.RoundAxisValues(). It is on by default for the Y axis and I find it generally works better for the X Axis as well.

你可以试试myChart.ChartAreas[0].AxisX.RoundAxisValues()。默认情况下,它在 Y 轴上是打开的,我发现它通常对 X 轴也能更好地工作。

回答by Marcin K.

This will work better :

这会更好地工作:

myChart.ChartAreas[0].AxisX.IsMarginVisible = false;

回答by Mohamed Fathallah

New Chart().SetYAxis("GPA",0,4);

New Chart().SetYAxis("GPA",0,4);

If You using The chart Class you could set the Y or X axis using the SetYAxis Method

如果您使用图表类,您可以使用 SetYAxis 方法设置 Y 或 X 轴

回答by user10965808

  • chart1.ChartAreas[0].AxisX.Minimum = 0;

  • chart1.ChartAreas[0].AxisX.Maximum = 10;

  • chart1.ChartAreas[0].AxisY.Minimum = -5;

  • chart1.ChartAreas[0].AxisY.Maximum = 5;

  • chart1.ChartAreas[0].AxisX.Minimum = 0;

  • chart1.ChartAreas[0].AxisX.Maximum = 10;

  • chart1.ChartAreas[0].AxisY.Minimum = -5;

  • chart1.ChartAreas[0].AxisY.Maximum = 5;