I'm trying to draw a chart with one line representing temperatures through the day but I need different segments of the line to be in different colours (Think yellow for day time temperatures and dark blue for night time temperatures for example).
I've tried with ShinobiCharts and also with MPAndroidCharts/iOS-Charts. And can't find a way to get it to work.
Any suggestion as to how to achieve a line chart specifying different colours for each line's segment? Suggestions of other more suited libraries for this job most welcome too!
Well, there are thousands of requirements and customizations people would want, but no one can satisfy them all. You better write your own code to meet your needs. If you need to customize the line color with arbitrary segments, you need to override the line renderer, and feed the color you want.
For example, in ios-charts, sub class the line chart data set, add a new property called segementColors
, and read color from it in the drawLinear
or drawCubic
function, and figure out what color you need at each segment.