imaNNeo / imaNNeo/fl_chart

How to translate localPosition of TouchEvent to coordinates of the LineChart? (projection)

Open
#801 6 comments 0 reactions 0 assignees View on GitHub
enhancement Fundamental
Dominant language
Dart
Stars
7.6k
Forks
2k
Avg merge
9d 1h
Merged PRs (30d)
2

Description

I am working on the LineChart, and I wish to allow users to drag points freely in the chart so that they can perform analysis on it. Analysis includes drawing a line based on 2 points of selection and calculate the length of the line.

The `LineTouchResponse` of `touchCallback` only returns coordinates of curves with given x-coordinate, but I wish the point can be dragged freely even outside the curve.

My current approach is to get the coordinate that user pointing at, and `setState` to draw a new point there. I am able to get `localPosition` (the pixel coordinate of the phone) from `FlTouchEvent.localPosition`, but I cannot draw a new point with the pixel coordinate. So is there a method to translate the `localPosition` to chart coordinates?

Contributor guide

Open the contributing guide

Research direction

Start with FlTouchEvent.localPosition, touchCallback, and LineTouchResponse to trace how touch coordinates are currently mapped to chart data. Check the LineChart interaction and projection entry points for an existing conversion path; done means arbitrary touch positions, including points outside curves, can be translated into chart coordinates for dragging and analysis.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile-dev
Issue type
Feature
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.