-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
I have a question about coloring the charts with gradients. I have not found this particular issue I am facing in the documentation (I hope I did not overlook it) so perhaps you could tell me if this one is even possible with MPChart.
I have a use case where I want to color a line chart's line with gradient based on some value range. This is the easy part and I have LineGradient
as follows:
val gradient = LinearGradient(
0f, 600f, 0f, 0f,
ContextCompat.getColor(context, R.color.colorBlueDark),
ContextCompat.getColor(context, R.color.colorPinkDark),
Shader.TileMode.CLAMP)
val paint = chart.renderer.paintRender
paint.setShader(gradient)
But I would like to fill the area below the chart as well with the color based on the color of the line above. An example of the desired output looks as follows:
I know I could use a static gradient like this:
dataSet.fillDrawable = ContextCompat.getDrawable(context, R.drawable.gradient)
dataSet.setDrawFilled(true)
but I would like to have a dynamic color fill based on the actual data values. Is something like this possible to do? Thank you very much for the clarification.