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

3 posts, 0 answers
  1. Douglas
    Douglas avatar
    15 posts
    Member since:
    Feb 2012

    Posted 19 Mar 2012 Link to this post

    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. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 22 Mar 2012 Link to this post

    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.
  3. DevCraft banner
  4. Douglas
    Douglas avatar
    15 posts
    Member since:
    Feb 2012

    Posted 22 Mar 2012 Link to this post

    Thank you.  I was able to create the seriesmappings dynamically.
Back to Top