Hi there,
I have a problem with the XamPieChart. I want to fill the chart with a list which has only two entries. These entries are numbers.
And now i want something like this:
I got two numbers like 2 and 3 that together are the complete Pie. I want a PieChart which show me two slices. One slice should be 2/5 big and the other one 3/5.
Is that realizable?
Best regards
Cloud
Hi Cloud,
That can be done using a converter. The slices in xamPieChart use pre-defined colors in Brushes collection. You can define your own color collection inside Brushes and set the Brushes property of xamPieChart to it.
To demonstrate this, I am attaching the modified version of the sample. If you look in the XAML you will notice the Brushes collection using a converter for the names of the colors rather than static names. This way you can control the colors you wish to return from the converter based on the values of the slices. If you are going to have more than two slices, in my opinion it's best to define colors for each slice in the Brushes collection and add a condition in the converter for those colors, unless you want the two colors to be rotated for all slices.
Hopefully this will get you started, let me know if you have any questions.
Thank youSam
Hi Sam,
thanks that helped me.
But now i want to know, if it´s possible to change the color of one slice? Because now I have 2 slices with blue and red but i need red and green.
Thanks for help
Hello Cloud,
Take a look at the attached sample project, and let me know if that's what you are trying to achieve.
Thank you,
Sam