imaNNeo / imaNNeo/fl_chart

Line chart range annotation paint out of chart since 0.69.0

Open
#1,944 0 comments 1 reaction 0 assignees View on GitHub
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
![Image](https://github.com/user-attachments/assets/55e49949-b45d-4c5e-b34c-a04cee18766f)

v0.69.0 or above
![Image](https://github.com/user-attachments/assets/bb8a58b8-b192-4ccd-a21a-855a0bf1d092)

**Versions**
- Flutter 3.29.3
- fl_chart 0.68.0 and fl_chart 1.0.0

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.