imaNNeo / imaNNeo/fl_chart

preventCurveOverShooting is difficult to limit overshoot in the x-axis direction

Open
#1,722 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
7.6k
Forks
2k
Avg merge
9d 1h
Merged PRs (30d)
2

Description

**Describe the bug**
When my spot have non-uniform distance in the x-axis. (such as spot1:x = 1 , spot2:x = 2 , spot3:x = 20 .....
Some curve will overshooting in the x-axis.
I have use ```preventCurveOverShooting```, if i use a bigger ```preventCurveOvershootingThreshold``` problem will be solved. but i will lose curve in some spot.

**To Reproduce**
```
import 'package:flutter/material.dart';
import 'package:fl_chart/fl_chart.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Container(
padding: const EdgeInsets.symmetric(vertical: 200, horizontal: 20),
child: SizedBox(
height: 300,
child: LineChart(
LineChartData(
lineBarsData: [
LineChartBarData(
spots: getSpotData(),
isCurved: true,
curveSmoothness: 0.5,
preventCurveOverShooting: true,
preventCurveOvershootingThreshold: 10,
)
],
),
),
),
),
// This trailing comma makes auto-formatting nicer for build methods.
),
);
}

List getSpotData() {
List spots = [];
spots.add(const FlSpot(1.0, 1));
spots.add(const FlSpot(2.0, 1));
spots.add(const FlSpot(20.0, 1));
spots.add(const FlSpot(21.0, 2));
spots.add(const FlSpot(22.0, 3));
return spots;
}
}
```

**Screenshots**
image

**Versions**
- Flutter version : 3.16.5
- FlChart version : 0.68.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the supplied Flutter reproduction with LineChart, LineChartBarData, FlSpot, and the preventCurveOverShooting settings as the starting point. Trace the line-chart curve calculation, then verify that non-uniform x distances no longer produce x-axis overshoot without losing the affected curve segments.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.