Forum Xamarin.Forms

How to change color in Oxyplot PieChart

Basicly what title says i used code from basic example but i cant find a way to change slices. Is that even possible?

Tagged:

Best Answers

Answers

  • DejanObrezDejanObrez SIMember

    thank you very much altho i have a follow-up problem. It only changes color and sets background on transparent on iOS platform while i'm trying to do both, Android and iOS device.

    heres my basic snippet

    PieSlice sl1 = new PieSlice("Tuition", Convert.ToInt32(storage.tuition));
    
                sl1.Fill = OxyColors.AliceBlue;
    
                ps.Slices.Add(sl1);
    
                PieSlice sl2 = new PieSlice ("Spent tuition", Convert.ToInt32 (storage.spent_tuition));
    
                sl2.Fill = OxyColors.Green;
    
                ps.Slices.Add(sl2);
    

    and xaml

    <oxy:PlotView x:Name="oxy" Model="{Binding Model}" VerticalOptions="Center" BackgroundColor="Transparent" HorizontalOptions="Center" />

  • BrianRepettiBrianRepetti USUniversity ✭✭✭

    Try setting the background color on the Model as well.

  • DejanObrezDejanObrez SIMember

    sadly nothing, slices are still default and so is background. Any more ideas what could be done about that?

  • BrianRepettiBrianRepetti USUniversity ✭✭✭

    That is strange that they are not changing. I will have to give it a try myself.

  • DejanObrezDejanObrez SIMember

    thank you it was a great help, altho for any future readers i forgot to call OnPropertyChanged in order to get it working on both platforms.

Sign In or Register to comment.