[英]VB - displaying chart from datagridview
I am willing to show a Line chart that is based from datagridview, but I would like to be able to show not only all the x values, but showing only each 5 or 10 values, for example I had record of temperature in my room every hour in 10 days, so I got 24x10 = 240 data, but I would like to be able to show only the value in each every 3 hour showed on the chart. 我愿意显示一个基于datagridview的折线图,但我希望不仅可以显示所有x值,而且还可以仅显示每个5或10个值,例如,我每个房间的温度记录10天的小时数,因此我获得了24x10 = 240的数据,但是我希望只能在图表上每3小时显示一次值。 another ex.
另一个前。 I have data from 1-100 I want to show chart only from each data 5,10,15,20,... how is it possibly done ?
我有1-100的数据,我只想显示每个数据5,10,15,20的图表,...该怎么做?
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
Chart1.Series(0).Points.Clear()
For Count As Integer = 0 To dataGridView1.Rows.Count - 1
Chart1.Series(0).Points.AddXY(dataGridView1.Item(0, Count).Value, dataGridView1.Item(2, Count).Value)
Next
the code above has successfully showed the normal line chart. 上面的代码已成功显示正常的折线图。
Skip the points you don't want to plot in the loop using Mod in vb.net 使用vb.net中的Mod跳过不想在循环中绘制的点
Dim divisor = 3
Chart1.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
Chart1.Series(0).Points.Clear()
For count As Integer = 0 To DataGridView1.Rows.Count - 1
If (DataGridView1.Item(0, count).Value Mod divisor = 0) Then
Chart1.Series(0).Points.AddXY(DataGridView1.Item(0, count).Value, DataGridView1.Item(2, count).Value)
End If
Next count
This skips all x values into which 3 does not divide without a remainder. 这样会跳过所有x值,其中3不除而没有余数。 You can change
Dim divisor = 3
to Dim divisor = 5
to skip all x values into which 5 does not divide without a remainder, etc. 您可以将
Dim divisor = 3
更改为Dim divisor = 5
以跳过所有x值,其中5不会除无余数,等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.