imaNNeo / imaNNeo/fl_chart

stopLineDrawingOnTouchedSpots or toggleLineDrawingOnTouchedSpots

Open
#1,251 3 comments 0 reactions 0 assignees View on GitHub
Line Chart question
Dominant language
Dart
Stars
7.6k
Forks
2k
Avg merge
9d 1h
Merged PRs (30d)
2

Description

** Don't make a duplicate issue.
Checked and could not find.

**Is your feature request related to a problem? Please describe.**
Yes, I will have to re draw the whole graph to update how the line is drawn. A feature to stop drawing the line on the touch spot would be nice.

**Describe the solution you'd like**
```dart
LineChartBarData(
stopLineDrawingOnTouchedSpots: true,
...etc
;)
```
Or the following, where we simply toggle the drawing between touched.
```dart
LineChartBarData(
toggleLineDrawingOnTouchedSpots: true,
...etc
;)
```

**Describe alternatives you've considered**

I already have something in place:
1. First I detect the touch spot index, and calculate it's percentage using spots length (tap on 3rd spot out of 10? => 30%).
2. Then use the percentage and draw different lines with
```dart
LineChartBarData(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: const [
Colors.red,
Colors.transparent,
],
stops: [
tapPercentage,
tapPercentage,
],
),
```
5. Finally, Re draw when touched. Sadly, it's a bit buggy and does an extra render. Attached is a video of how it is looking now, and you can notice that dragging my finger to another point triggers a re draw of the full line, even when that case is not triggered in my code.

**Additional context**

https://user-images.githubusercontent.com/108520495/216626327-4cdad008-1d82-4f0f-ac07-d5c2cb9886f3.mov

Contributor guide

Open the contributing guide

Research direction

Start with the LineChartBarData API and the touch/redraw behavior described in the issue, including the existing gradient workaround and attached video. Define whether the feature should stop or toggle line drawing at touched spots, then verify that moving between touched points produces the requested line behavior without requiring a full-line redraw.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.