MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

LineChart : Change circle color after apply gradient color

Open lequetur opened this issue 8 years ago • 2 comments

Hi,

i have a problem about my linechart's circles. I use this method to make a Gradient LineChart :

Paint paint = mChart.getRenderer().getPaintRender(); int height = mChart.getHeight(); LinearGradient linGrad = new LinearGradient(0, 0, 0, height, getResources().getColor(R.color.red_chart), getResources().getColor(R.color.green_chart), Shader.TileMode.MIRROR); paint.setShader(linGrad);

After I write this to change circle's color :

lineDataSetCircle.setCircleColor(Color.WHITE);

But now the circle's color stay red and clearColor change nothing :/

How can I change this please ?

lequetur avatar Mar 06 '17 14:03 lequetur

I have the same issue, the reason setCircleColor does not work is the circles are cached as bitmaps at location (radius,radius) and uses the same renderpaint as line. so circle gets the color from gradient at that location. these cached bitmaps are positioned on the data point to display on chart.

so setCircleColor with gradient has no effect. also the circle color doesnot change with the gradient aswell. in order to achieve this LineRenderer Class has to be modified to draw circles with different color, may be clone render paint and remove shader to draw circle.

lokesh1210 avatar Mar 13 '17 03:03 lokesh1210

Is there a way around this? Still relevant on v3.1.0

eden-stuff avatar Jun 15 '22 12:06 eden-stuff