I Have the following DataSet structure:
Basically I am tracking the price of products from a number of sources over a number of days.
How would I bind this dataset to a Line Grid so that the y axis shows the price, the x axis shows the Day and lines on the grid show the variation in price by make (different color line for each source)
Any pointers would be great!
4 Answers, 1 is accepted
The following sample code snippet demonstrates how you can create a DataSet with two DataTables and bind the Chart to them. Note that the RadChart's DataSource is set to be the DataSet and each ChartSeries is bound to the columns of the DataTables by the following properties;
- DataLabelsColumn for the XAxis which specifies to what property the XAxis Labels should be bound.
- DataYColumn - the YValues for the Line's datapoints.
Feel free to customize the code sample so that it meets your requirements.
the Telerik team
I have tried your example but I seem to be having a problem. Please see the attached screen grab of the chart that is produced using your code. The second line does not seem to be created using the random data in the datatable??
With my original example I use the following code to create a dataset that contains a number of datatables (one for each MakeID)
I then use the following
but it only seem to create a graph with one line, Can you see what I'm doing wrong?
using the above code will populate a bar chart showing all the columns in my dataset but only the data for the first datatable. If I comment out :
RadChart1.DataSource = dsNew;
and reload the page (via postback from a button) the chart works as expected and shows the legend that lists all the names of all my datatables within the dataset and the line graph shows a line for each datatable with the correct data plotted. If I then refresh the page and cause the postback I just get an empty graph..
Not really sure what is going on. Surly binding a DataSet like this to a graph is a common task? Any help would be great!
The following source code is working as expected on our local tests - creates 2 Line Series where the data for each is taken from DataTable. Note that there is no need to set the DataSet as DataSource for the RadChart in this case since the Series Items are bound directly to DataTables:
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.