Dynamically Adding Series

6 posts, 0 answers
  1. Gareth McNicol
    Gareth McNicol avatar
    22 posts
    Member since:
    Nov 2006

    Posted 27 Feb 2012 Link to this post

    Is there a way of dynamically adding series to the chart view at runtime?  Ideally within an MVVM implementation although that's not strictly necessary.

    Thanks,

    Gareth.  
  2. Gareth McNicol
    Gareth McNicol avatar
    22 posts
    Member since:
    Nov 2006

    Posted 29 Feb 2012 Link to this post

    It's stupendously easy it's just a shame that the online html help is so damned clunky. 
  3. UI for WPF is Visual Studio 2017 Ready
  4. Lars
    Lars avatar
    6 posts
    Member since:
    Nov 2010

    Posted 23 May 2012 Link to this post


    Can you give a brief hint how to do it ?

    Lars
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 28 May 2012 Link to this post

    Hi Lars,

    I am not sure about Gareth's scenario, but generally adding series to RadChartView would involve adding a CartesianSeries (Bar, Line, Area, Spline, SplineArea, ScatterPoint, ScatterLine, ScatterArea, Ohlc, Candlestick) to the RadCartesianChart.Series collection, adding a PieSeries to RadPieChart or adding PolarSeries (PolarPoint, PolarLine, PolarArea, RadarPoint, RadarLine, RadarArea) to RadPolarChart.

    BarSeries ser = new BarSeries();
    ser.ValueBinding = new PropertyNameDataPointBinding("Value");
    ser.CategoryBinding = new PropertyNameDataPointBinding("Category");
    chart.Series.Add(ser);
    ser.ItemsSource = mySource;


    Best regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Gareth McNicol
    Gareth McNicol avatar
    22 posts
    Member since:
    Nov 2006

    Posted 28 May 2012 Link to this post

    Yes,

    That's pretty much how I did it.  Worked first time.

    One suggestion I'd make is to have some sort of lambda to setup the propertyname binding, rather than using magic strings.

    so 

    new PropertyNameDatapointBinding(() => boundObj.PropertyName);

  7. Lars
    Lars avatar
    6 posts
    Member since:
    Nov 2010

    Posted 29 May 2012 Link to this post

    Ok, thanks a lot. We started out with binding to the SeriesMappingCollection of the RadChart which seems to work for now. Unfortunately, RadChartView does not support inverse axis which is essential for us in some scenarios.

    Lars
Back to Top
UI for WPF is Visual Studio 2017 Ready