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

Bar chart color

1 Answer 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.
Gyan
Top achievements
Rank 1
Gyan asked on 13 Nov 2012, 07:19 AM
Hi
I want to set the bar color based on a property. I used a converter to do this but somehow the converter is not invoked.
My code is below

<

telerik:BarSeries.PointTemplate>

 

<DataTemplate>

 

<!--<Rectangle Fill="#B0127F" Width="50" />-->

 

<Rectangle Fill="{Binding ProjectStage, Converter={StaticResource StageToBrushConverter}}" Width="50" />

 

</DataTemplate>

 

</telerik:BarSeries.PointTemplate>

The commented line shows something that works. But with the binding and converter it doesn't.
What am I doing wrong?

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 13 Nov 2012, 03:06 PM
Hi Gyan,

Thanks for writing.
The XAML snippet that you posted does not work because you assume that the data context of the data template is your data object. In fact, it is an instance of the DataPoint class. This data point has a DataItem property which is a reference to your data object. So your binding should bind to DataItem.ProjectStage instead of just ProjectStage.

Please write again if you need further assistance.

Regards,
Victor
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
Tags
Chart
Asked by
Gyan
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or