我对视觉基础很新。我的程序让你输入参数(a,b,c,xmin,xmax,ymin,ymax和数据点数)来绘制抛物线。当输入更多数据点时,抛物线看起来很好。问题是如果有4个数据点,则抛物线不均匀2个点。我真的很难找到解决方案,所以任何指导都会非常感激。
这是我的代码:
Public Sub FillGraph()
myChart.Series(0).Points.Clear()
myChart.Series(0).ChartType = _
DataVisualization.Charting.SeriesChartType.Line
If IsNumeric(txtxMax.Text) And IsNumeric(txtxMin.Text) And IsNumeric(txtyMax.Text) And IsNumeric(txtyMin.Text) Then
ymin = CDbl(txtyMin.Text)
ymax = CDbl(txtyMax.Text)
xmax = CDbl(txtxMax.Text)
xmin = CDbl(txtxMin.Text)
dataPts = CDbl(txtDataPts.Text)
a = CInt(txtA.Text)
b = CInt(txtB.Text)
c = CInt(txtC.Text)
Dim x As Integer
For x = CInt((-dataPts / 2)) To CInt(dataPts / 2)
myChart.ChartAreas(0).Axes(0).Maximum = xmax
myChart.ChartAreas(0).Axes(0).Minimum = xmin
myChart.ChartAreas(0).Axes(1).Maximum = ymax
myChart.ChartAreas(0).Axes(1).Minimum = ymin
myChart.Series(0).Points.AddXY(x, (a * (x ^ 2)) + (b * x) + c)
Next
End If
End Sub
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabCtrl.SelectedIndexChanged
If TabCtrl.SelectedIndex = 2 Then
Call FillGraph()
Call FillLbls()
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
myChart.Series(0).Color = Color.Red
myChart.Series(0).BorderWidth = 5
End Sub