문제

I guess there's tons of answers, but i have only found answers regarding the data update, not the chart itself.

In my case i have a chart that updates every X minutes. When the program starts, it looks in a file for some values. Lets say there's only one one value (one column in this case), and this value is 20. Then it shows it nice with 30 as maximum.

When it refresh, i do something like this

TheDiagram.Series.Clear()
Dim Serie_Value As New Series
With Serie_Value
    .Name = "MySerie"
    .ChartType = SeriesChartType.StackedColumn
    .Color = Color.Green
    With .Points
        .AddXY("MyName", theValueFromFile)
    End With
End With
TheDiagram.Series.Add(Serie_Value)

In this case, we say that the value now is 60, then the y-axis is still on 30 as max so that I can't see the end (top) of the column. How can I tell the chart/chartarea to "redraw yourself like you were rendered the first time"?

도움이 되었습니까?

해결책 2

Have you tried auto-scaling the y-axis?

' Auto axis scale
Chart1.ChartAreas("ChartArea1").AxisY.Minimum = [Double].NaN
Chart1.ChartAreas("ChartArea1").AxisY.Maximum = [Double].NaN

You should set those every time the chart refreshes, the axis should adjust automatically then.

다른 팁

To reset the auto scale just use this after loading the points into the chart.

Chart1.ResetAutoValues()

Available since .NET 4.0: Chart1.ChartAreas[0].RecalculateAxesScale();

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top