I have a chart in a project that I am working on that I require to update its values as each textbox is input so the user can track the linearity.
The only way I can think of with my basic knowledge is to calculate the chart at each textbox value entered but this would be crazy over 12 textboxes.
Currently i have it working from a button Click
(See Code below). However, I would like it to update as each value is entered - Any Direction with this would be greatly appreciated.
Private Sub ChartBtn_Click(sender As Object, e As EventArgs) Handles ChartBtn.Click
'Average Repeatability at 5K Test Point
Dim A5K1 As Integer = CInt(T5K1.Text)
Dim A5K2 As Integer = CInt(T5K2.Text)
Dim A5K3 As Integer = CInt(T5K3.Text)
Dim average = (A5K1 + A5K2 + A5K3) / 3
'Chart Setup
With Testpoint_Chart.ChartAreas(0)
.AxisX.Title = "Pressure (Psi)"
.AxisX.Minimum = 1000
.AxisX.Maximum = 10000
.AxisY.Interval = 1000
.AxisY.Title = "Test Points (ft.lb)"
If T10K.Text > Math.Ceiling(tst_MaxOutput.Text / 1000) * 1000 Then
.AxisY.Maximum = Math.Ceiling(T10K.Text / 1000) * 1000
Else
.AxisY.Maximum = Math.Ceiling(tst_MaxOutput.Text / 1000) * 1000
End If
End With
Testpoint_Chart.Series.Clear()
Testpoint_Chart.Series.Add("Test Data")
Testpoint_Chart.Series.Add("Max Torque")
'Max Torque
With Testpoint_Chart.Series("Max Torque")
.IsVisibleInLegend = True
.ChartType = SeriesChartType.Line
.IsValueShownAsLabel = False
.Color = Color.Red
Dim xmaxvals() As Integer = ({1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000})
Dim ymaxvals() As Integer = {tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text, tst_MaxOutput.Text}
.Points.DataBindXY(xmaxvals, ymaxvals)
End With
'Test Points
With Testpoint_Chart.Series("Test Data")
.IsVisibleInLegend = True
.ChartType = SeriesChartType.Line
.IsValueShownAsLabel = True
Dim xvals() As Integer = ({1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000})
Dim yvals() As Integer = {T1K.Text, T2K.Text, T3K.Text, T4K.Text, average, T6K.Text, T7K.Text, T8K.Text, T9K.Text, T10K.Text}
.Points.DataBindXY(xvals, yvals)
End With
End Sub
You can subscribe to the event "TextChanged" for each textbox. Here is a demo with four textBoxes(A,B,C,D) you can refer to. In the event "TextChanged", you can use "switch" statement to judge the changed textBox. Then rebind the chart's data and update it.