Open Zil85 opened 6 years ago
My workaround for this problem is to set desiredMaxRows to the number of legend entries divided with 2 rounded up, as follows:
charts.SeriesLegend(
horizontalFirst: false,
desiredMaxRows: (numberOfLegendEntries / 2).ceil()
)
There seems to be an issue with the SeriesLegend of Charts when using desiredMaxColumns.
If the 'desiredMaxColumns' parameter is set to a a value lower then the number of series in the chart and the number of series isn't exactly divisible by the 'desiredMaxColumns' an exception is thrown. Basically if the final row of the legend holds fewer entries then the rest the error occurs.
For example if there are 3 series in the chart. Setting desiredMaxColumns = 1 works fine and produces 3 rows of 1. Label1 Label2 Label3
Setting desiredMaxColumns >= 3 works fine and produces 1 row of 3. Label1 Label2 Label3
Setting desiredMaxColumns = 2, throws an exception. Expected result Label1 Label2 Label3
The exception given
Full code to reproduce the issue:
Result from flutter doctor: