【发布时间】:2014-06-01 16:00:04
【问题描述】:
我有一个这样的应用程序: 使用图表下方的文本框,用户可以设置图表 X 轴的最小值和最大值。这是它的代码:
private void textBoxXaxisMin_TextChanged(object sender, EventArgs e)
{
double x;
//checks if the input is a double and smaller than the max value
//if (Double.TryParse(this.textBoxXaxisMin.Text, out x) && x < chart1.ChartAreas[0].AxisX.Maximum)
if (Double.TryParse(this.textBoxXaxisMin.Text, out x))
{
this.textBoxXaxisMin.BackColor = Color.White;
chart1.ChartAreas[0].AxisX.Minimum = Convert.ToDouble(this.textBoxXaxisMin.Text);
//changeYScalaMin(chartCharacteristicCurvesThermoelemts, Convert.ToDouble(this.textBoxCharacteristicCurvesThermoelementXmin.Text), Convert.ToDouble(this.textBoxCharacteristicCurvesThermoelementXmax.Text));
//method to scale y axis
}
else
//if the textbox is not highlighted
this.textBoxXaxisMin.BackColor = Color.Orange;
//calls the Max Function to update the chart if the Max-value is now valid
double y;
//checks if the input is a double and greater than the min value
if (Double.TryParse(this.textBoxXaxisMax.Text, out y) && y > chart1.ChartAreas[0].AxisX.Minimum)
{
this.textBoxXaxisMax.BackColor = Color.White;
chart1.ChartAreas[0].AxisX.Maximum = Convert.ToDouble(this.textBoxXaxisMax.Text);
//method to scale y axis
}
else
//if the textbox is not highlighted
this.textBoxXaxisMax.BackColor = Color.Orange;
}
现在我想让 Y 轴自动缩放。 Y-min 应计算为(X-min 和 X-max)部分中所有系列的最小值,Y-max 应计算为所选部分中所有系列的最大值。我的问题是实施。
在本例中,Y-min 应更改为 50 左右。
我在GitHup 主持了这个洞示例项目。
【问题讨论】:
-
那你有什么问题? “我的问题在于实施”并没有给我们太多的继续。
-
@ChrisRyding 如何找到给定部分中所有系列的 Y 最小值。
标签: c# winforms charts axis scaling