Fl_chart: Bar graphs draw below the bottom axis when minY is set

Created on 29 Jul 2020  路  7Comments  路  Source: imaNNeoFighT/fl_chart

When using a bar graph, if the minY value is set on the BarGraphData then the bars draw below the bottom axis covering the titles.

The can be reproduced with the example application. Open the file bar_chart_sample3.dart and add minY: 5 at line 21 (just above the line maxY: 20).

Here is how it looks without a maxY value set
no minY

Here is how it looks with a maxY set to 5
minY set to 5

Flutter 1.17.5
FlChart 0.11.0

Thank you for a great library!

Bar Chart bug

Most helpful comment

@imaNNeoFighT Thanks for the effort. Much appreciated!

All 7 comments

Would it work to change lines 209 and 237 of bar_chart_painter.dart (https://github.com/imaNNeoFighT/fl_chart/blob/master/lib/src/chart/bar_chart/bar_chart_painter.dart#L237) from

final bottom = getPixelY(0, drawSize);
to
final bottom = getPixelY(max(data.minY ?? 0, 0), drawSize);

to fix the issue?

Hi, sorry for the late answer,
you are exactly correct, and you got it.
Make a PR and fix it by yourself :)
Also, you should fix this issue for the negative values too (check line 247 too)
Thanks for reporting and contributing.
Cheers!

And thanks for your great explanation.

@imaNNeoFighT Thanks for the answer. Looks like our project is blocked by this issue. Do you have any updates?

Okay,
I'm on it :)

Sorry for the delay, fixed in 0.11.1,
check it out.

Thanks for reporting and contributing.

@imaNNeoFighT Thanks for the effort. Much appreciated!

Was this page helpful?
0 / 5 - 0 ratings