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

Customise colour for DonutSeries

4 Answers 57 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Veteran
Benjamin asked on 29 Aug 2019, 06:09 AM

Would like to know how to i customise/change the colour for each slices in the donut series. 

 

The legend to also follow the customised color

4 Answers, 1 is accepted

Sort by
0
Benjamin
Top achievements
Rank 1
Veteran
answered on 29 Aug 2019, 06:38 AM

This is my current code.

01.<telerikChart:RadPieChart x:Name="Chart1">
02.                <telerikChart:RadPieChart.BindingContext>
03.                    <local:ViewModel />
04.                </telerikChart:RadPieChart.BindingContext>
05.                <telerikChart:RadPieChart.Series>
06.                    <telerikChart:DonutSeries InnerRadiusFactor="0.8" ShowLabels="false"
07.                                  ValueBinding="Value"
08.                                 LabelBinding="Category"
09.                                LegendTitleBinding="Name"
10.                                  ItemsSource="{Binding Data}" />
11.                </telerikChart:RadPieChart.Series>
12.                <telerikChart:RadPieChart.Palette>
13.                    <telerikChart:ChartPalette>
14.                        <telerikChart:ChartPalette.Entries>
15.                            <telerikChart:PaletteEntry FillColor="DarkBlue"  StrokeColor="DarkBlue" />
16.                            <telerikChart:PaletteEntry FillColor="LightBlue" StrokeColor="LightBlue" />
17.                        </telerikChart:ChartPalette.Entries>
18.                    </telerikChart:ChartPalette>
19.                </telerikChart:RadPieChart.Palette>
20.                <telerikChart:RadPieChart.ChartBehaviors>
21.                    <telerikChart:ChartTooltipBehavior TriggerMode="Tap" />
22.                </telerikChart:RadPieChart.ChartBehaviors>
23.            </telerikChart:RadPieChart>
24.            <telerikChart:RadLegend LegendProvider="{x:Reference Name=Chart1}" />

When user tap on a slice, the colour got changed. how do i prevent this?

Also, can i also check how do i show the tooltip when user tap on a slice.

0
Yana
Telerik team
answered on 29 Aug 2019, 10:52 AM

Hello Benjamin,

Thank you for sending the snippet you're using. 

Creating a ChartPalette is the proper way to customize the slices' colors  - you just need to add a few more entries to cover all the data items.  The legend follows the same palette set to the Chart.

As to the selection of slices -  you can prevent it by setting AllowSelect property of the DonutSeries to False.

I have attached a sample XAML page based on the provided snippet to show you how this would work - please download it and give it a try.

Lastly, about the tootips - currently the ToolTipBehavior does not work properly for PieChart, we have this logged as a bug report in our feedback portal, you can track its status at the link below:

https://feedback.telerik.com/xamarin/1366403-piechart-tooltip-behavior-is-not-working-properly

Let me know if I can help with anything else.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Benjamin
Top achievements
Rank 1
Veteran
answered on 29 Aug 2019, 02:29 PM

Hi Yana

Thanks for your reply. In the meantime, is there any workaround for the tooltip issue? as it is a very important function for my app

0
Yana
Telerik team
answered on 29 Aug 2019, 02:38 PM

Hi Benjamin,

We've previously researched this issue, so I can immediately reply - there isn't a feasible workaround I could suggest at the moment.  It's quite a complicated issue in the native Chart controls and we're having it in mind, still, I cannot commit to any timeframe for providing a fix. We will update the feedback item as soon as there is any progress on it.

Regards,
Yana
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Benjamin
Top achievements
Rank 1
Veteran
Answers by
Benjamin
Top achievements
Rank 1
Veteran
Yana
Telerik team
Share this question
or