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

Dynamically change palette by value at run time.

1 Answer 236 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Trump
Top achievements
Rank 1
Trump asked on 16 Nov 2017, 01:48 AM

I use ChartView and BarSeries. I want different bar has different color. I defined six colors. So I defined the palette as below. However it is hard coded. Now I want to change the color by the value at the run time. Say less than 100 use color 1, 100~200 use color 2 etc. Not sure how?

<telerik:ChartPaletette x:key="myPalette">
      <telerik:ChartPalette.GlobalEntries>
            <telerik:PaletteEntry Fill="#FE24C532" />
            <telerik:PaletteEntry Fill="#FE54C5A1" />
            <telerik:PaletteEntry Fill="#FE2AC5D5" />
            <telerik:PaletteEntry Fill="#FE00CF4A" />
            <telerik:PaletteEntry Fill="#FE54A531" />
            <telerik:PaletteEntry Fill="#FE2CC5C1" />
       </telerik:ChartPalette.GlobalEntries>
</telerik:ChartPaletette x:key="myPalette">

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Nov 2017, 08:22 AM
Hello Trump,

Instead of using a palette you can use the series DefaultVisualStyle and bind it to a color from the data point view model. Or you can use an IValueConverter to get the corresponding color. Read more about this in the Binding the Color of Series Items article.

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
Trump
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or