In my app I encountered a bug with horizontal bar charts that I want to fix.
What is the bug?
When rotating a bar chart to make it horizontal, the top titles (original "left titles") will completely disappear, as soon as the left titles (original "bottom titles") have more reserved space than the height of the chart.
EDIT: I just realized this is not only affecting horizontal/rotated charts, but vertical charts too. It´s just less likely to have so thin charts / large reserved space there! So basically all charts should be affected?
Luckily, it´s easy to reproduce, even in your examples. Here is the original:
Since the aspect ratio is pretty evened out, I need to put in a lot of reserved space to provoke it:
But if I change the aspect ratio and along with it the height of the widget, the issue appears much earlier:
Since in my app, I need very slim charts with just two bars, I get this issue very, very early, with a reserved space of 60 already. This is really annoying to work around.
As far as I see, the titles disappear in side_title_widget.dart line 183:
axisPositions = _getPositionsWithinChartRange(axisPositions, side);
axisPositions has 0 items after the call of _getPositionsWithinChartRange.
The issue is this bit:
final chartSize = Size(
widget.parentSize.width - thisSidePaddingTotal,
widget.parentSize.height - thisSidePaddingTotal,
).rotateByQuarterTurns(widget.axisChartData.rotationQuarterTurns);
The this side padding is subtracted from both sides and with rotation, the other side (that the padding is not for) is checked against. As soon as this gets negative, the titles are thrown out.
I can try to fix this and make a PR, if you want.
Versions
1.2.0
In my app I encountered a bug with horizontal bar charts that I want to fix.
What is the bug?
When rotating a bar chart to make it horizontal, the top titles (original "left titles") will completely disappear, as soon as the left titles (original "bottom titles") have more reserved space than the height of the chart.
EDIT: I just realized this is not only affecting horizontal/rotated charts, but vertical charts too. It´s just less likely to have so thin charts / large reserved space there! So basically all charts should be affected?
Luckily, it´s easy to reproduce, even in your examples. Here is the original:
Since the aspect ratio is pretty evened out, I need to put in a lot of reserved space to provoke it:
But if I change the aspect ratio and along with it the height of the widget, the issue appears much earlier:
Since in my app, I need very slim charts with just two bars, I get this issue very, very early, with a reserved space of 60 already. This is really annoying to work around.
As far as I see, the titles disappear in side_title_widget.dart line 183:
axisPositions = _getPositionsWithinChartRange(axisPositions, side);axisPositionshas 0 items after the call of_getPositionsWithinChartRange.The issue is this bit:
The this side padding is subtracted from both sides and with rotation, the other side (that the padding is not for) is checked against. As soon as this gets negative, the titles are thrown out.
I can try to fix this and make a PR, if you want.
Versions
1.2.0