【发布时间】:2015-10-21 13:22:26
【问题描述】:
我可以通过更改图表下方文本框中的值(X-min 和 X-max)来操纵 x 轴的比例。最小值和最大值总是四舍五入为可被 10 整除的数字,没有余数。 (858 得到 860,-107 得到 -110)。现在我正在寻找一种解决方案来获得 X 轴刻度,它始终在 X 点“0”处有一条线(在图片中标记为红色)。
我正在使用 C#。
下面是部分代码:
private void textBoxXmax_TextChanged(object sender, EventArgs e)
{
double max, min;
Double.TryParse(this.textBoxXmin.Text, out min);
//checks if the Entering is a double number and if it is greater than the min value
if (Double.TryParse(this.textBoxXmax.Text, out max) && max > chartTest.ChartAreas[0].AxisX.Minimum)
{
max = Math.Round(max / 10) * 10; //round to tens (113->110)
//MessageBox.Show(x.ToString());
this.textBoxXmax.BackColor = Color.White;
chartTest.ChartAreas[0].AxisX.Maximum = max;
//chartCharacteristicCurvesResistanceThermometer.ChartAreas[0].AxisX.Interval = (max-min)/10;
//Problem should be here
//set the YScaleMax
changeYScala(chartTest);
}
else
//if not the textbox is highlighted
this.textBoxXmax.BackColor = Color.Orange;
//double y;
//checks if the Entering is a double number and if it is smaler than the max value
if (Double.TryParse(this.textBoxXmin.Text, out min) && min < chartTest.ChartAreas[0].AxisX.Maximum)
{
min = Math.Round(min / 10) * 10; //round to tens (113->110)
this.textBoxXmin.BackColor = Color.White;
chartTest.ChartAreas[0].AxisX.Minimum = min;
//same calculation for Interval here
changeYScala(chartTest);
}
else
//if not the textbox is highlighted
this.textBoxXmin.BackColor = Color.Orange;
}
【问题讨论】:
-
这是我如何缩放 X 轴的代码。但是我没有得到 Intervall,因为 X 点“0”处总是有一条线
标签: c# winforms charts axis scaling