如何逐行显示? [英] How to display chart by row value?
问题描述
test1 | test2 | test3 | test4 |
125 | 143 | 144 | 123
123 | 123 | 154 | 134
这是一张表,通常用于显示我们采用列值的图表,第一列是x轴,第二列是y轴...
现在我的问题是我需要根据上面的表格显示它...是否有任何代码我可以按行而不是列来显示我的表格在图表上方???
如何将我的表格显示在图表上?
参考
http://www.dotnetfox.com/articles/bind -Asp-Net-chart-control-from-database-using-C-Sharp-1056.aspx [ ^ ]
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control。 aspx [ ^ ]
显示如何根据数据绑定X和Y访问。
希望这有帮助
根据评论添加示例代码段
string [] x = new 串跨度> [dt.Columns.Count];
string [] y = new string [dt.Columns.Count];
for ( int i = 0 ; i < dt.Columns.Count; i ++)
{
if (i == 0 )
{
// 获取行值并分配给stringarray如果需要整数转换为整数
x = Array.ConvertAll(dt.Rows [i] .ItemArray,item => item.ToString ());
}
else if (i == 1 )
{
y = Array.ConvertAll(dt.Rows [i] .ItemArray,item = > item.ToString());
}
}
注意:
无效检查未完成的项目,你应该照顾那些
现在使用这个尝试绑定X和Y轴
嗨所有我也面临同样的问题plz发布一些。
我的任务是我有一个datagridview我想读取2个组合框的列是x asix其他是y asxis。如何从datagridview组合框中读取列名,当我从2个组合框中选择轴时,值应该出现在图表上。我有其他的combobox3使用我希望更改类型的图表,如列,行,点plz邮政编码来实现此任务
请注意:仅使用C#和sql
test1|test2|test3|test4|
125 |143 |144 |123
123 |123 |154 |134
this is a table , usually to show a chart we are taking the columns value ,first column is x axis and second column is y axis...
now my problem is I need to show it according to my table above...is there any code that i can read by row instead of column to show my table above in chart ???
how to show my table above into chart?
Refer
http://www.dotnetfox.com/articles/bind-Asp-Net-chart-control-from-database-using-C-Sharp-1056.aspx[^]
http://blogs.msdn.com/b/alexgor/archive/2009/02/21/data-binding-ms-chart-control.aspx[^]
Shows how to bind the X and Y access according to the Data.
Hope this helps
Adding a sample code snippet as per the comment
string[] x = new string[dt.Columns.Count]; string[] y = new string[dt.Columns.Count]; for (int i = 0; i < dt.Columns.Count; i++) { if (i == 0) { //fetching the row values and assigning to stringarray if need integers convert to integers x = Array.ConvertAll( dt.Rows[i].ItemArray,item=>item.ToString()); } else if (i==1) { y = Array.ConvertAll(dt.Rows[i].ItemArray, item => item.ToString()); } }
Note:
Null checks for the items not done, you should take care of those
Now using this try to bind the X and Y axis
hi all am also facing same problem plz post some.
in my task is that i have a datagridview i want to read the columns to 2 comboboxs is for x asix other is for y asxis . how to read column name from datagridview combobox and when i select axis from 2 combobox that values should come on chart. i have other combobox3 using that i want change type of chart like column,line,points plz post code to implement this task
note that : using C# and sql only
这篇关于如何逐行显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!