Click here to Skip to main content
16,019,983 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Comments
JoCodes 6-Jan-14 22:29pm    
There are different kind of charts? What do you need?
acing wei 6-Jan-14 23:06pm    
microsoft charting display in column 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

C#
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
 
Share this answer
 
v3
Comments
acing wei 6-Jan-14 23:08pm    
all of the binding is bind using column...can i read it from row??
JoCodes 6-Jan-14 23:51pm    
May be I m not clear . You have a tabular data representation which means it contains columns and rows. What ever row values we have are just corresponding values only.Can you please make it bit clear with an example?
acing wei 7-Jan-14 1:01am    
test1|test2|test3|test4|
125 |143 |144 |123
123 |123 |154 |134
i want my chart to show x value as test1, test 2, test 3 ,test 4 and my y value is the number in the table..

name |value|
test1|125
test2|143
test3|144
most of the example they take x value from name and y value from value..then it will plot he chart..but what i want is from row..
JoCodes 7-Jan-14 1:19am    
Table means HTML table control and its first row is the X axis?
acing wei 7-Jan-14 1:24am    
table is my new datatable... yes first row is x axis , second and third row is y axis..how to do that?
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900