vb.net 在vb中将数据表绑定到图表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14864253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:19:58  来源:igfitidea点击:

bind Data table to chart in vb

vb.netchartsbind

提问by user2070144

I have a project that im working on at the moment in VB. Basically I have a Data Table in VB it populates with 4 columns and a variable number of rows, the column names are as follows;

我有一个项目正在 VB 中工作。基本上我在 VB 中有一个数据表,它填充了 4 列和可变行数,列名如下;

Gear, RPM, Speed, CO2

The data table appears in datagridview correctly but that's as far as I have gotten :/

数据表正确出现在 datagridview 中,但据我所知:/

What I am trying to do is to make a line chart called mainGraph to draw a graph based on these results, I'm getting stuck when trying to populate the chart.

我想要做的是制作一个名为 mainGraph 的折线图,以根据这些结果绘制图形,但在尝试填充图表时我陷入了困境。

ANY thoughts would be really appreciated.

任何想法将不胜感激。

回答by MonkeyDoug

I am guessing you are using the ms chart controls and not some 3rd party like Telerik.

我猜你正在使用 ms 图表控件,而不是像 Telerik 这样的 3rd 方。

This should be usefull http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx

这应该很有用http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx

Also, there is source code found at http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418

此外,还有在http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418 上找到的源代码

回答by Brendan Getz

in short this is a way to get things displayed

简而言之,这是一种显示内容的方法

mainGraph.Series(0).ChartType = DataVisualization.Charting.SeriesChartType.Line
mainGraph.Series(0).Points.DataBind(yourDataTable.DefaultView, "Speed", yourDataTable.DefaultView, "Gear")

These commands should make a line graph with Speed on your x axis, and Gear on your Y. Assigned to "Series(0)" To add more columns, you need to add more "Series"

这些命令应该制作一个折线图,速度在你的 x 轴上,齿轮在你的 Y 轴上。分配给“系列(0)”要添加更多列,您需要添加更多“系列”

mainGraph.Series.Add("RPM")

Do some thinking about how you want this data displayed. how would you like to set this graph up? I'm assuming you would want a line graph? What is going to be the X axis? Is there a missing column that needs to be "time" in the data table? do you want them all on one graph/chart area? If you would like more charts, then you need to add chart areas. A series can be assigned to a chart area.

考虑一下您希望如何显示这些数据。你想如何设置这个图表?我假设你想要一个折线图?X 轴将是什么?数据表中是否有需要“时间”的缺失列?你希望它们都在一个图形/图表区域吗?如果您想要更多图表,则需要添加图表区域。可以将系列分配给图表区域。

Hopefully this helps.

希望这会有所帮助。