MPAndroidChart icon indicating copy to clipboard operation
MPAndroidChart copied to clipboard

The size of barchart changed when it invalidate()

Open li11011 opened this issue 2 years ago • 2 comments

I used the barchart to display some data, and i need to update the chart when data changed, so i call the invalidate() method to update the bar chart. Howerver, when this methond called, the width and the height of the barchart changed, it become smaller. I used the AndroidAutoSize for the screen adaptation work, will it be the reason? poor english, sorry.

li11011 avatar May 19 '22 02:05 li11011

It's very excited to find the solution after a few hours, my colleague helped me. As for my situation, I used the AndroidAutoSize lib, my colleague remind me the density may be changed by mpandroidchart, so i track the source code and found the density really changed. The barchart calculate the margin by the density, so the size has changed.

the solution of mine is to call the autosize method before i update the chart.

AutoSize.autoConvertDensity(context, sizeIndp, isBaseOnWidth)

so the size of chart won't be changed again.

li11011 avatar May 19 '22 08:05 li11011

Can you share some of code here

WaqasYousafy786 avatar Jul 05 '23 05:07 WaqasYousafy786