imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.77k stars 1.74k forks source link

[Feature Request] Ability to replace LineTouchTooltipData widget #1612

Open NotTsunami opened 6 months ago

NotTsunami commented 6 months ago

Is your feature request relasted to a problem? Please describe. SideTitles() allows the user to override the titles widget with practically anything they want, making the axis titles very flexible and extendable as needed, but I have some use cases where I would like to stylize the tooltip created by LineTouchTooltipData().

More specifically, I'd like to be able to stylize the container or even extend functionality of the tooltip widget. Currently I am working with some signal processing, and I'd like to be able to extend the tooltip to add left/right arrows to move a marker to the previous or next peaks in the signal, respectively. We draw the tooltips above the chart using the showOnTopOfTheChartBoxArea property ofLineTouchTooltipData, but we would like to extend the functionality of the tooltips.

Describe the solution you'd like It would be fantastic if we could change the function getTooltipItems from {List<LineTooltipItem?> Function(List<LineBarSpot>)} to something like {Widget Function(LineBarSpot) getTitlesWidget = defaultGetTooltipItems}.

leonidlist commented 6 months ago

+1, also have a case where I'd like to use a Widget instead of String value

Selnikhin commented 6 months ago

+1

Ramzes5614 commented 6 months ago

+1 Guys, thanks for the great package. We would also like to see this feature

NotTsunami commented 6 months ago

I realize this might be a larger task since it looks like the library is rendering the tooltips with the Canvas API, which doesn't directly support rendering widgets (correct me if I am wrong), so this might require a larger refactor to move the tooltips to an OverlayEntry.

imaNNeo commented 5 months ago

I realize this might be a larger task since it looks like the library is rendering the tooltips with the Canvas API, which doesn't directly support rendering widgets (correct me if I am wrong), so this might require a larger refactor to move the tooltips to an OverlayEntry.

Yes, exactly you're correct. We need to use Overlays API to draw our tooltips, this way we can use widgets. But it is a huge work, I would be happy if you could contribute to the project. You can also sponsor this project to help me work more.