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

Different color for each bar

4 Answers 417 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
ardmore
Top achievements
Rank 1
ardmore asked on 08 Nov 2017, 12:09 AM

I followed this Binding the Color Series-Items

However I can't get the different colors for the bars by using telerik:RadCartesianChart. Please advise me.

<telerik:BarSeries CategoryBinding="Category" ValueBinding="Value" ItemsSource="{Binding}">
        <telerik:BarSeries.PointTemplate>
            <DataTemplate>
                <Rectangle Fill="{Binding DataItem.Color}"/>
            </DataTemplate>
        </telerik:BarSeries.PointTemplate>
    </telerik:BarSeries>

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 08 Nov 2017, 02:20 PM
Hello Hui,

Can you tell me what exactly doesn't work? Also, can you send me some runnable code demonstrating the issue so I can test it locally?

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
ardmore
Top achievements
Rank 1
answered on 08 Nov 2017, 02:35 PM
No bar is shown.  I don't know what DataItem.Color is. Do I need to define a property named as "Color" in my ViewModel?
0
ardmore
Top achievements
Rank 1
answered on 09 Nov 2017, 01:39 AM
Again, I am sure that is not working unless by set up PaletteMode="DataPoint" and custom/select Palette. Is it a bug of the example?
0
Accepted
Martin Ivanov
Telerik team
answered on 10 Nov 2017, 08:14 AM
Hello Hui,

Yes, the Color property should be defined in the view model of the data point. You can see this shown in the Example Data Model Definition section of the article. In this section you can also find a fully runnable code which you can copy paste into a new project and it will run. Check also the attached project.

About the Palette, this has bigger priority than the color in the DefaultVisualStyle so if you have a palette set, the brush in the style won't be respected. 

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
ardmore
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
ardmore
Top achievements
Rank 1
Share this question
or