Xamarin Telerik - How to use the custom palette for ios

4 posts, 0 answers
  1. Chong
    Chong avatar
    4 posts
    Member since:
    Apr 2016

    Posted 06 Apr Link to this post

    i am using xamarin and i am going to create a chart, the third party component that i using for the chart is the telerik. The chart is the pie chart. I am following the document of the telerik which is

    http://docs.telerik.com/devtools/xamarin/controls/chart/how-to/chart-how-to-create-custom-palette

    In the end, the android work well. However when i debug in the simulator, the chart only show me one color which is the first colour of my palette. Is the telerik not support the custom palette for IOS?

    The following is my code

    var series = new PieSeries();

    series.ValueBinding = new Telerik.XamarinForms.Chart.PropertyNameDataPointBinding{PropertyName = "Value"};

    series.ItemsSource = data1;

    series.ShowLabels = true;

    series.ValueBinding = new PropertyNameDataPointBinding("Value");

    chart.Series.Add(series);

    chart.HeightRequest = 400;

    chart.Palette = CustomPalettes.CustomWhite;

    chartlayout.Children.Add(chart);

     

    Palette code:

    class CustomPalettes{

    static CustomPalettes(){

    CreateCustomWhitePalette();

    }

     

    public static ChartPalette CustomWhite { get; private set; }

     

    private static void CreateCustomWhitePalette(){

    ChartPalette palette = new ChartPalette();

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 35, 255), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(0, 255, 255), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(116, 255, 0), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 156, 0), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 0, 255), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 0, 153), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(0, 173, 204), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 51, 51), StrokeColor = Color.FromRgb(255, 255, 255) });

    palette.Entries.Add(new PaletteEntry() { FillColor = Color.FromRgb(255, 255, 51), StrokeColor = Color.FromRgb(255, 255, 255) });

    CustomWhite = palette;}}

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 08 Apr Link to this post

    Hello Chong,

    I tried to reproduce the reported behavior on our side and the code seems to be working as expected. I prepared a sample application using the RadPieChart with one PieSeries with 10 business data points and a custom palette. The custom palette is created as described in the referenced article. The only difference is your particular entries (in other words - the colors you use). The result under iOS is as the attached picture shows.

    In order to assist you we will need you to elaborate more on your scenario. What is the exact code for creating the business data points of the PieSeries? Also, we would like to ask you to provide us with a picture showing the final result.

    Regards,
    Pavel R. Pavlov
    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
  3. DevCraft banner
  4. Chong
    Chong avatar
    4 posts
    Member since:
    Apr 2016

    Posted 13 Apr in reply to Pavel R. Pavlov Link to this post

    Hi pavel, i am glad u support this, the above is my code, however the result is the below, may i have your source code file? or entire solution file
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 15 Apr Link to this post

    Hi Chong,

    I am sending you the setup that I used to achieve the referenced result on our side. Please take a look at the attached solution and let us know if you have any other questions.

    Regards,
    Pavel R. Pavlov
    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
DevCraft banner