fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

Add external touch handler for Pie Chart

Open samir7osny opened this issue 2 years ago • 1 comments

Regarding the case of stacked pie charts on each other, the touch handler will work on one of them only, check this issue #1307 as well.

To try this case and understand the issue, you can go to this commit ceb4e18 and check sample 4. image

This PR fixes this by adding the ability to calculate the touch response based on external parameter for the touched position, now you can use MouseRegion widget for example and add the stacked Pie charts inside it then pass the touched position to the charts and get the calculated response (check pie chart sample 4).

samir7osny avatar Nov 26 '23 01:11 samir7osny

There is a better solution to work with the low-level RenderBox/RenderObject and the HitTest topic.

https://github.com/imaNNeo/fl_chart/blob/803409c7c428579f968b276ad9f125ac3c7150d9/lib/src/chart/base/base_chart/render_base_chart.dart#L109

Basically, we need to run getResponseAtLocation() and return false if response is null (or something like that, you need to take a look)

https://github.com/imaNNeo/fl_chart/blob/803409c7c428579f968b276ad9f125ac3c7150d9/lib/src/chart/base/base_chart/render_base_chart.dart#L175-L177

btw, if you think it is a complicated topic (which is actually complicated), I can do that.

imaNNeo avatar Dec 01 '23 01:12 imaNNeo