LineChartBarData: entry order causes invalid graph
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
When adding entries to LineChartBarData the line is drawn in the order the FlSpot s have on the list rather than respecting the order of the x positions.
**To Reproduce**
```dart
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FlChart Bug',
home: SizedBox(
width: 1000,
height: 1000,
child: Center(
child: SizedBox(
width: 800,
height: 800,
child: LineChart(
LineChartData(
minY: 0,
maxY: 50,
titlesData: const FlTitlesData(show: false),
lineBarsData: [
LineChartBarData(
spots: const [
FlSpot(10, 20),
FlSpot(30, 10),
FlSpot(20, 30)
],
),
]
)
),
),
)
),
);
}
}
```
**Screenshots**

**Versions**
Flutter (Channel stable, 3.10.0, on Garuda Linux 6.3.9-zen1-1-zen, locale en_US.UTF-8)
`fl_chart: ^0.63.0`
Contributor guide
Research direction
Start by running the supplied Flutter example and trace the LineChartBarData spots through the LineChart rendering path. Check how unsorted FlSpot entries are handled during drawing. Done means the reported input renders from lowest to highest x position, with regression coverage for the unsorted entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- data-visualization, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100