使用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 (将#修改为@)