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

How to Dynamic SliceStyleSelector

2 Answers 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kadir Kilicoglu
Top achievements
Rank 1
Kadir Kilicoglu asked on 05 Dec 2013, 12:36 PM
Hi,

I've a problem with the SliceStyleSelector. Actually i couldn't find a decent example. I'm struggling with the piechart and binding custom object which includes Color property in object. What i want to do is take that color property and bind it to slice style (fill) but how? Try to bind Color property to Setters Value but it raised a exception that can't bind to read-only value. I've found something like http://www.telerik.com/community/forums/wpf/charting-kit/pie-chart---dynamic-slice-styles-issue.aspx But it shows basic implementation. Is there any detailed example or anyone show an example?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 09 Dec 2013, 03:26 PM
Hi Kadir,
Unfortunately such scenario is not supported. Sorry for the inconvenience caused.

Regards,
Kiril Stanoev
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Till
Top achievements
Rank 1
answered on 24 Oct 2014, 08:47 PM
Hey,

I have the same requirements for my app, looked at the link you provided and found a solution:

Create a custom StyleSelector for you chart. Inside the SelectStyle override method access the DataObject that you provide via a Binding to the ItemsSource of your PieSeries like this:
var color = ((SimpleTimesheet.Portable.ViewModel.ChartItem) (((Telerik.Charting.DataPoint) (item)).DataItem)).Color;
and just return a new Style with the color from your Databound Object:
var style = new Style(typeof(Path));
style.Setters.Add(
    new Setter(
        Shape.FillProperty,
        new SolidColorBrush(color.ToMediaColor())
    ));
return style;


Hope this helps. Let me know if you need an example.
Best
Till
            
Tags
Chart
Asked by
Kadir Kilicoglu
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Till
Top achievements
Rank 1
Share this question
or