I am using MPChart libarary in my android project. I have Json which contain label,value and color for pie chart generation. I want to set same color from json to piechart eleme
Adding to what Philipp Jahoda answered...
You can also create an array that will contain customized colors and as many colors you want, you can add.
For example:
int [] color={ Color.rgb(100,221,23), Color.rgb(128,0,128), Color.rgb(255,136,0),
Color.rgb(255,0,0), Color.rgb(255,127,80), Color.rgb(47,95,255)
};
to get the rgb code you can first get the hex code of the color you want and then convert it into rgb code using online converters on google.
And now you can use this color array to give color to your elements of pie chart in this way :
PieDataSet dataSet= new PieDataSet(Yvalues,"Activities");
dataSet.setColors(color);
This method will help you to set your own colors and you can give colors to as many elements of pie chart.
But if you use all these methods:
setColors(int [] colors, Context c)
setColors(int [] colors)
setColors(ArrayList colors)
setColor(int color)
they will limit by allowing to use only five elements for pie chart and only few predefined colors.
Thankyou.