Customise colour for DonutSeries

5 posts, 0 answers
  1. Benjamin
    Benjamin avatar
    11 posts
    Member since:
    May 2018

    Posted 29 Aug Link to this post

    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

  2. Benjamin
    Benjamin avatar
    11 posts
    Member since:
    May 2018

    Posted 29 Aug in reply to Benjamin Link to this post

    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.

  3. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 29 Aug Link to this post

    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
  4. Benjamin
    Benjamin avatar
    11 posts
    Member since:
    May 2018

    Posted 29 Aug in reply to Yana Link to this post

    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

  5. Yana
    Admin
    Yana avatar
    4916 posts

    Posted 29 Aug Link to this post

    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
Back to Top