This is a migrated thread and some comments may be shown as answers.

Is it possible to create chart series mappings dynamically based on data received from a service?

2 Answers 55 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Douglas
Top achievements
Rank 1
Douglas asked on 20 Mar 2012, 01:13 AM
I am trying to create a chart based on data that I get from a service.

My data comes to me in this form:

    public class ReportData
    {
        public List<QueryResult> QueryResults { get; set; }
    }
    public class QueryResult
    {
        public DateTime DataDate { get; set; }
        public List<QueryComponent> DataItems { get; set; }
    }

    public class QueryComponent
    {
        public DateTime DataDate { get; set; }
        public string ItemName { get; set; }
        public double ItemValue { get; set; }
    }


What I am trying to do is bind this data to a chart where there are several series.  Each series is based on the "ItemName".  For example List<QueryComponent> is going to have several DataItems with the ItemName "Cars" and I want that to become a series in the chart.  ItemName can have many different values (i.e. Cars, Trucks, Bikes, People, Cats, Dogs, etc) and I do not know all of them.

Is it possible to dynamically create series mappings based on the data I receive?

2 Answers, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 22 Mar 2012, 10:28 AM
Hello Douglas,

It is possible to create series mappings dynamically in code; check this article here to get you started: http://www.telerik.com/help/silverlight/radchart-populating-with-data-data-binding-with-manual-series-mapping.html. You can also take advantage of the "multiple datasources" feature supported by RadChart (http://www.telerik.com/help/silverlight/radchart-populating-with-data-series-mapping-items-source.html) and provide the ItemsSource for each series on the series mapping level (set SeriesMapping.ItemsSource instead of RadChart.ItemsSource property).


Greetings,
Bart.
0
Douglas
Top achievements
Rank 1
answered on 23 Mar 2012, 12:18 AM
Thank you.  I was able to create the seriesmappings dynamically.
Tags
Chart
Asked by
Douglas
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Douglas
Top achievements
Rank 1
Share this question
or