作者:mobiledu2502861763 | 来源:互联网 | 2023-05-19 13:25
开发环境VS2005,.NETFramework版本.NETFramework2.0,ChartFX版本7.0.2664.18481前几天的开发演习中用到了ChartFX控件,现将Cha
开发环境 VS2005,
.NET Framework 版本 .NET Framework 2.0,
ChartFX版本 7.0.2664.18481
前几天的开发演习中用到了ChartFX控件,现将ChartFX控件的简单用法整理如下。
)
MessageBox.Show("OK!")
End Sub
Private Sub Button3_Click()Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click()Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'' 刷新数据
setChartFX()
End Sub
Private Sub setChartFX()Sub setChartFX()
'' 右键菜单使用可
Chart1.ContextMenus = True
'' 工具栏表示
Chart1.ToolBar.Visible = True
'' 菜单栏表示
Chart1.MenuBar.Visible = True
'' DataGrid表示
Chart1.DataGrid.Visible = True
'' ChartFX边框
Chart1.Border = New ImageBorder(ImageBorderType.Pulsar, System.Drawing.Color.Silver)
'' ChartFX标题
Dim TitleDockable1 As ChartFX.WinForms.TitleDockable = New ChartFX.WinForms.TitleDockable
TitleDockable1.Text = "ChartFX Sample"
Me.Chart1.Titles.AddRange(New ChartFX.WinForms.TitleDockable() {TitleDockable1})
Chart1.Data.Clear()
'' 三条数据线
Chart1.Data.Series = 3
'' 50个数据节点
Chart1.Data.Points = 30
'' 右侧说明方框显示
Chart1.LegendBox.Visible = True
'' 方框位置
Chart1.LegendBox.Dock = DockArea.Right
'' 设置ChartFX属性
For serno As Integer = 0 To Chart1.Series.Count - 1
Dim sattr As SeriesAttributes
sattr = Chart1.Series(serno)
'' 表示模式
sattr.Gallery = Gallery.Curve
'' 右侧方框中显示内容
sattr.Text = "Test " & serno
'' 数据线颜色
If serno = 0 Then
sattr.Color = Color.Blue
ElseIf serno = 1 Then
sattr.Color = Color.Red
Else
sattr.Color = Color.Green
End If
Next
'' X轴名称
Chart1.AxisX.Title.Text = "X Value"
'' Y轴名称
Chart1.AxisY.Title.Text = "Y Value"
'' X轴分割单位
Chart1.AxisX.Step = 3
'' Y轴分割单位
Chart1.AxisY.Step = 20
'' X轴单元格表示
Chart1.AxisX.Grids.Major.Visible = True
'' Y轴单元格表示
Chart1.AxisY.Grids.Major.Visible = True
'' 数据线各点表示样式
Chart1.AllSeries.MarkerShape = MarkerShape.None
'' 填充模式
Chart1.AllSeries.FillMode = FillMode.Gradient
'Chart1.AllSeries.AlternateColor = Color.MintCream
'' 设置随即数据,以10为分割点,显示三条数据线
Dim random As New Random
Dim value As Integer
For i As Integer = 0 To Chart1.Data.Points - 1
value = random.Next(30, 100)
If i < 10 Then
Chart1.Data(0, i) = value
Chart1.Data(2, i) = Chart.Hidden
ElseIf i = 10 Then
Chart1.Data(0, i) = value
Chart1.Data(1, i) = value
Chart1.Data(2, i) = value
Else
Chart1.Data(0, i) = Chart.Hidden
Chart1.Data(1, i) = random.Next(30, 80)
Chart1.Data(2, i) = value
End If
Chart1.AxisX.Labels(i) = i & "#"
Next
'' 在分割点处划线(竖线)
Dim custom1 As New CustomGridLine
custom1.Value = 11
custom1.Color = System.Drawing.Color.Brown
custom1.Width = 1
Chart1.AxisX.CustomGridLines.Add(custom1)
Chart1.RecalculateScale()
Chart1.Refresh()
End Sub
End Class
显示效果如下