如何强制一个图表来自动调整Y轴最大? [英] How do I force a chart to auto adjust Y Axis Maximum?
问题描述
我有一个.NET的图表,我感到填充在运行时
I have a .NET chart which I am populating at runtime
图表显示在报表中。对于我的报告每个波段,我清除所有的系列,并添加回使用code
The chart appears within a report. For each band in my report, I clear all the series and add them back in using code
Series s = new Series();
s.Font = new Font("Verdana", 8f);
int i = 0;
foreach (var month in line.Months)
{
DataPoint p = new DataPoint();
p.XValue = i;
p.YValues = new Double[] { month.LineValue ?? 0 };
s.Points.Add(p);
i++;
}
当我填充图中的第二次,Y轴最大停留在2000年,也就是不被重新计算
When I populate the chart the second time, the Y Axis maximum stays on 2000, i.e. is not being recalculated
如何强制重新计算?
我在Y轴
如果我尝试在Y轴设置IsLogarithmic为真,我得到一个图表的一λ,而不是
If I try to set IsLogarithmic to true on the Y Axis I get a X instead of a chart
我在使用Visual Studio 2010与System.Windows.forms.DataVisualization.Charting.Chart
I am using Visual Studio 2010 with the System.Windows.forms.DataVisualization.Charting.Chart
保
推荐答案
<一个href="http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.axis.maximum.aspx">The文档说默认为 Axis.Maximum
属性为NaN(非数字),所以你应该能够通过设置重新启用自动缩放功能回该值。
The docs say the default for the Axis.Maximum
property is NaN (not a number), so you should be able to re-enable the automatic scaling functionality by setting it back to that value.
这样的事情...
chart.ChartAreas[0].AxisY.Maximum = Double.NaN;
这篇关于如何强制一个图表来自动调整Y轴最大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!