Line chart range annotation paint out of chart since 0.69.0
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
While creating a mix chart of line chart and bar chart, we may use range annotation to create vertical or horizontal bar. Both direction work well on fl_chart version 0.68.0, however since fl_chart version 0.69.0 both direction bar chart will paint out of the chart border.
**To Reproduce**
Try to run the below code on fl_chart version 0.68.0 and 0.69.0 or above to compare the result.
This code will plot a chart in a domain from (0,0) to (100,100). Which will plot a line graph from (0,0) to (100,200) and a bar have a y value of 150. So both line and bar will grow out of chart area.
```
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
class Test extends StatelessWidget {
const Test({super.key});
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(child: const Placeholder()),
Expanded(
child: LineChart(
LineChartData(
gridData: const FlGridData(show: true),
borderData: FlBorderData(show: true),
clipData: const FlClipData.all(),
maxY: 100,
minY: 0,
rangeAnnotations: RangeAnnotations(
horizontalRangeAnnotations: [
HorizontalRangeAnnotation(
y1: 150,
y2: 0,
color: Colors.amber,
),
],
),
lineBarsData: [
LineChartBarData(spots: [FlSpot(0, 0), FlSpot(100, 200)]),
],
),
duration: Duration.zero,
),
),
],
);
}
}
```
**Screenshots**
v0.68.0

v0.69.0 or above

**Versions**
- Flutter 3.29.3
- fl_chart 0.68.0 and fl_chart 1.0.0
Contributor guide
Research direction
Start with the supplied Flutter reproduction using LineChart, RangeAnnotations, clipData, and maxY/minY, then compare behavior between fl_chart 0.68.0 and 0.69.0 or later. Trace the range annotation and line painting entry points to determine why values beyond the chart bounds escape clipping; done means both annotations and lines remain inside the chart border.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100