【发布时间】:2019-03-15 20:44:42
【问题描述】:
我在 Visual Basic 中创建了一个折线图来显示用户每天摄入的卡路里量。但是,我的用户要求我包含一个滚动条,以便沿 x 轴前后滚动以查看更多天数。
不幸的是,我以前从未做过这样的事情,在查看 Stack Overflow 和谷歌搜索后,我看不到任何人这样做的例子。
这是我目前的图表截图:
这里是代码:
Cursor.Current = Cursors.WaitCursor
CalorieChartView = True
BurntChartView = False
NetChartView = False
Dim Series As Series = CalorieChart.Series(0)
'keeps track of if the chart is empty, starting as true
Dim empty As Boolean = True
'Clears the chart
Series.Points.Clear()
'Draws the chart in dark red
Series.Color = Color.DarkRed
'The legend text is changed
Series.LegendText = "Calories Consumed"
'For each of the past 8 days, a point is plotted with how many calories were eaten in that day
For i = -7 To 0
Series.Points.Add(User.GetCaloriesEaten(User.Username, Date.Now.AddDays(i)))
Series.Points(7 + i).AxisLabel = Date.Now.AddDays(i).ToString("dd/MM/yyyy")
'If any of the points are not 0
If User.GetCaloriesEaten(User.Username, Date.Now.AddDays(i)) <> 0 Then
'the chart is not empty
empty = False
End If
Next
HandleEmpty(empty)
Cursor.Current = Cursors.Default
我将不胜感激。
【问题讨论】:
-
@MaciejLos 如果您想要 50 个代表,您可以将其写成答案
-
如果对您有帮助,我可以将其发布为答案。所以,让我知道,我会尽快发布。