I am still new at android development and all the app i’ve been dealing with so far are not graphical related. Now i am making a app that displays a graph, pie graph to be exact and im making this without any 3rd party libs. This is the tutorial which i followed.
Now the problem is the data which i will be using to construct the graph is dynamic, and so to assign each item with a color for the graph i need to generate a number of random colors for the canvas.drawColor. the number of colors will of course depend on my dynamic data which is determined at run time and the color value also needs to be generated.
Also it would be nice if the colors generated are vibrant colors that stands out.
I’ve never dealt with canvas, any idea how this can be done? Example code would be much appreciated.
Thanks
It would be quite hard to get different and usefull colors at runtime. The best is not to use so much randomness, but make an array of let’s say 20 fixed colors quite distinct and use the X first ones for your data. If you need more, then maybe use real random colors using random RGB values :