下面的代码使用3个图表区域来制作x-y散点图,并且x轴值通过数据操纵器按升序成功排序。但是,x轴标签未正确格式化为两个小数点精度。有什么建议?我之前已经成功地格式化了x轴和y轴,但有些东西否定了这个功能(?)
Dim chart2 As New Chart
chart2.Invalidate()
chart2.ChartAreas.Clear()
chart2.Legends.Clear()
chart2.Series.Clear()
Chart2.Width = 400
chart2.Height = 800
chart2.Top = 30
Chart2.Left = 10
Chart2.Visible = True
Chart2.Enabled = True
Dim numvalidpoints As Integer = 0
Controls.Add(chart2)
For k = 1 To 3
numvalidpoints = 10
Cnt = -1
Dim yValues(numvalidpoints - 1) As Double
Dim xValues(numvalidpoints - 1) As String
Dim delta As Single = 2 * Math.PI / numvalidpoints
For j = 0 To numvalidpoints - 1
Cnt += 1
yValues(Cnt) = Rnd()
xValues(Cnt) = yValues(Cnt)
Next
chart2.Series.Add(k - 1)
chart2.Series(k - 1).ChartType = SeriesChartType.Point '.Pie
chart2.Series(k - 1).IsXValueIndexed = False
chart2.Series(k - 1).Points.DataBindXY(xValues, yValues)
chart2.ChartAreas.Add(k - 1)
chart2.Series(k - 1).ChartArea = CStr(k - 1)
'chart2.ChartAreas(k - 1).AxisX.IntervalAutoMode = True
'chart2.ChartAreas(k - 1).AxisY.IntervalAutoMode = True
'chart2.ChartAreas(k - 1).AxisX.IsLabelAutoFit = True
'chart2.ChartAreas(k - 1).AxisY.IsLabelAutoFit = True
chart2.ChartAreas(k - 1).AxisX.IsMarginVisible = False
chart2.ChartAreas(k - 1).AxisX.IsLabelAutoFit = True
'chart2.Series(k - 1).Sort(PointSortOrder.Ascending, "X")
chart2.DataManipulator.Sort(PointSortOrder.Ascending, "AxisLabel", k - 1)
'Chart2.ChartAreas(k - 1).AxisX.MajorGrid.Enabled = False
'Chart2.ChartAreas(k - 1).AxisY.MajorGrid.Enabled = False
'Chart2.ChartAreas(k - 1).AxisX.LabelStyle.Font = New System.Drawing.Font("Arial", 75, System.Drawing.FontStyle.Regular)
'Chart2.ChartAreas(k - 1).AxisY.LabelStyle.Font = New System.Drawing.Font("Arial", 75, System.Drawing.FontStyle.Regular)
chart2.ChartAreas(k - 1).AxisX.LabelStyle.Format = "N2"
chart2.ChartAreas(k - 1).AxisY.LabelStyle.Format = "N2"
Next k
'Chart2.Refresh()
'Chart2.Invalidate()
chart2.BringToFront()