如何解决使用vb.net绘制实时折线图
因此,我想使用vb.net绘制实时折线图...我在Githup中找到了一个示例 关于LineChart但它非常复杂,我的想法非常简单:两个列表:
Double的1-List1(包含每日利润)
字符串的2-List2(包含最近7天的日期)
问题是我非常困惑如何编辑此代码以符合我的想法,这是我第一次使用图表!谢谢
代码:
Imports LiveCharts
Imports LiveCharts.Wpf
Imports LiveCharts.WinForms
Public Class Form1
Private Const CryptoCurrency_BTC As String = "$"
Private Const AxisX_Title As String = "Days"
Private Const AxisY_Title As String = "Profit"
Private Const AxisY_MinValue As Decimal = 1000
Private Const AxisY_MaxOffsetValue As Decimal = 1000
Private Sub Form1_Load(sender As Object,e As EventArgs) Handles MyBase.Load
Dim DaysValue As New List(Of String)({1,2,3,4,5,6,7})
'For i As Integer = 0 To 30
' DaysValue.AddRange("f")
'Next
Dim ProfitAmount As New List(Of Integer)()
For i As Integer = 300 To 400
ProfitAmount.Add(i)
i += 7
Next
GraphCreate(ProfitAmount,DaysValue)
' draw series USDValue/Day
Dim Rates As New ChartValues(Of Integer)
For i As Integer = 0 To DaysValue.Count - 1
Rates.Add(DaysValue(i))
Next
' draw the line and add the serie on the graph
Dim Series As New SeriesCollection
Dim Line As New LineSeries
With Line
.Title = CryptoCurrency_BTC
.Values = Rates
End With
Series.Add(Line)
MainChart.Series = Series
End Sub
Private Sub GraphCreate(ByVal ProfitAmount As List(Of Integer),ByVal DaysList As List(Of String))
Try
' adding the axis Y with USD value
Dim AsseY As New Axis
With AsseY
.Title = AxisY_Title
.Labels = ProfitAmount
End With
' if there are some data,delete it
If MainChart.AxisY.Count <> 0 Then MainChart.AxisY.Clear()
MainChart.AxisY.Add(AsseY)
' adding axis X
Dim AsseX As New Axis
With AsseX
.Title = AxisX_Title
.Labels = DaysList
End With
' if there are some data,delete it
If MainChart.AxisX.Count <> 0 Then MainChart.AxisX.Clear()
MainChart.AxisX.Add(AsseX)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。