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

MVVM - Control color of area series on dynamically generated graph

3 Answers 56 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Tarun
Top achievements
Rank 1
Tarun asked on 15 Mar 2014, 01:26 PM
I am generating 2 to 4 area series dynamically by referring below link from telerik documentation:

http://www.telerik.com/help/wpf/radchartview-features-chartseriesprovider.html

But these dynamic area series are showing default colors.

Is there a property I could use to control the color of dynamically generated Area series? My application is using MVVM pattern. 

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 19 Mar 2014, 04:59 PM
Hello Tarun,

You can bind the Fill property of the AreaSeries via Style. In order to follow the MVVM pattern you can implement a Converter to change the color of the series. We prepared a sample project based on the mentioned help article and added such Converter class which selects a Brush depending on a property from the AreaSeries's ViewModel.

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
       {
           var series = value as SeriesProviderDataItem;
           if (series != null)
           {
               if (series.SeriesName == "SerieA")
               {
                   return ABrush;
               }
               else if (series.SeriesName == "SerieB")
               {
                   return BBrush;
               }
               else
                   return CBrush;
           }
           return null;

Please examine the provided solution and let us know if you need any further assistance.

Regards,
Boris Penev
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
Dev
Top achievements
Rank 1
answered on 20 Mar 2014, 04:43 PM
Hi Boris,

I tried your solution but it is also taking default colors and not showing the colors you are assigning through converter.
Can you please check it?


Regards,
Dev
0
Boris
Telerik team
answered on 25 Mar 2014, 09:26 AM
Hello Dev,

You may get different colors if you use older version of telerik control binaries - for example Q3 2013.
Attached you can find a project with our latest Q1 2014 binaries where the colors are shown as in the attached picture.

Regards,
Boris Penev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
ChartView
Asked by
Tarun
Top achievements
Rank 1
Answers by
Boris
Telerik team
Dev
Top achievements
Rank 1
Share this question
or