1
我正在使用Microsoft Chart Controls for Microsoft .NET Framework 3.5,並且在獲取數據標記時出現問題。Microsoft .Net圖表控件未顯示標記
我在運行時生成圖表,所以不能只使用設計器。
Sub New()
MainChart = New Chart
MainChart.Size = New Drawing.Size(500, 200)
MainArea = New ChartArea()
With MainArea
.Name = "Default"
.AxisX.LabelStyle.Format = "MMM"
.AxisX.MajorGrid.Enabled = False
.AxisX.IsLabelAutoFit = False
.AxisY.MajorGrid.LineColor = Drawing.Color.Gainsboro
.AxisY.IsLabelAutoFit = True
.AxisY.Minimum = 0
.AxisY.Maximum = 50
End With
MainChart.ChartAreas.Add(MainArea)
MainSeries = New Series()
With MainSeries
.ChartArea = "Default"
.Name = "MainSeries"
.ChartType = SeriesChartType.Line ''# .FastLine would hide markers...
.IsXValueIndexed = True
.XValueType = ChartValueType.Date
.MarkerSize = 9
.MarkerStyle = MarkerStyle.Diamond
.ToolTip = "#VALX: #VAL"
End With
MainChart.Series.Add(MainSeries)
End Sub
我再添加使用
Public Sub AddDataPoint(ByVal X As Date, ByVal Y As Double)
MainSeries.Points.AddXY(X, Y)
End Sub
後的數據點了一堆,我可以將圖表保存爲圖像
Public Sub SaveImage(ByVal Filename As String)
MainChart.SaveImage(Filename, ChartImageFormat.Png)
End Sub
所有作品可愛,我也得到相當圖表。 唯一的問題是數據點上沒有標記。
任何人都可以闡明我做錯了什麼?