Reputation: 2177
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"?
Upvotes: 0
Views: 6402
Reputation: 1473
Available since .NET 4.0: Chart1.ChartAreas[0].RecalculateAxesScale();
Upvotes: 0
Reputation: 53
To reset the auto scale just use this after loading the points into the chart.
Chart1.ResetAutoValues()
Upvotes: 3
Reputation: 604
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.
Upvotes: 0