diff --git a/CHANGELOG.md b/CHANGELOG.md index 865897383..ebc2b9c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * **BUGFIX** (by @imaNNeoFighT): Fix tooltip issue on negative bar charts, #978. * **IMPROVEMENT** (by @imaNNeoFighT): Use Container to draw axis-based charts border. * **FEATURE** (by @FlorianArnould) Add the ability to select the RadarChart shape (circle or polygon), #1047. +* **BUGFIX** (by @imaNNeoFighT): Fix LineChart titles problem with single FlSpot, #1053. ## 0.51.0 * **FEATURE** (by @imaNNeoFighT): Add `SideTitleWidget` to help you use it in [SideTitles.getTitlesWidget]. It's a wrapper around your widget. It keeps your provided `child` widget close to the chart. It has `angle` and `space` properties to handle margin and rotation. There is a `axisSide` property that you should fill, it has provided to you in the MetaData object. Check the below sample: diff --git a/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart b/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart index 13efaebd9..ed2ab9272 100644 --- a/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart +++ b/lib/src/chart/base/axis_chart/side_titles/side_titles_widget.dart @@ -136,7 +136,11 @@ class SideTitlesWidget extends StatelessWidget { interval: interval, ); axisPositions = axisValues.map((axisValue) { - var portion = (axisValue - axisMin) / (axisMax - axisMin); + final axisDiff = axisMax - axisMin; + var portion = 0.0; + if (axisDiff > 0) { + portion = (axisValue - axisMin) / axisDiff; + } if (isVertical) { portion = 1 - portion; }