fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

Can 'showingTooltipIndicators' and 'lineTouchData' be used at the same time in fl_chart

Open alaayousf opened this issue 4 years ago • 4 comments

alaayousf avatar Nov 29 '21 21:11 alaayousf

Provide more details

imaNNeo avatar Dec 04 '21 21:12 imaNNeo

Hi I think I have the same question.

If I set enabled = false on LineTouchData then the "permanent" tooltips appear from the showingTooltipIndicators field. However, if I set enabled = true on LineTouchData then the permanent tooltips will not show up.

My use case calls for both. I want to "always" show a tooltip for min and max values on my graph but when a user taps/drags on the graph I want to hide those tooltips and show LineTouchData UI. Hopefully that makes sense. Thanks!

SpaceWaffles avatar Feb 02 '22 20:02 SpaceWaffles

Follow up, you can get this behavior like so:

LineTouchData get lineTouchData => LineTouchData(
        touchCallback: (touchEvent, response) {
          if (touchEvent is FlTapUpEvent || touchEvent is FlPanEndEvent) {
            if (touchingGraph) {
              setState(() {
                touchingGraph = false;
              });
            }
          } else if (touchEvent is FlTapDownEvent || touchEvent is FlPanStartEvent) {
            if (!touchingGraph) {
              setState(() {
                touchingGraph = true;
              });
            }
          }
        },
        handleBuiltInTouches: true,
        enabled: touchingGraph,
...

Where touchingGraph is a bool you can declare somewhere in your class.

SpaceWaffles avatar Feb 02 '22 21:02 SpaceWaffles

Thanks man, it worked just fine

‫في الأربعاء، 2 فبراير 2022 في 11:40 م تمت كتابة ما يلي بواسطة ‪Brendan‬‏ <‪ @.***‬‏>:‬

Follow up, you can get this behavior like so:

LineTouchData get lineTouchData => LineTouchData( touchCallback: (touchEvent, response) { if (touchEvent is FlTapUpEvent || touchEvent is FlPanEndEvent) { if (touchingGraph) { setState(() { touchingGraph = false; }); } } else if (touchEvent is FlTapDownEvent || touchEvent is FlPanStartEvent) { if (!touchingGraph) { setState(() { touchingGraph = true; }); } } }, handleBuiltInTouches: true, enabled: touchingGraph, ...

Where touchingGraph is a bool you can declare somewhere in your class.

— Reply to this email directly, view it on GitHub https://github.com/imaNNeoFighT/fl_chart/issues/831#issuecomment-1028383341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOYERELI6EADK7DBJCEUMSTUZGQEVANCNFSM5JAF4SVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

alaayousf avatar Feb 03 '22 10:02 alaayousf

The above workaround only works when I have one graph, but if I have several and when tracking one at a time, I want to highlight the corresponding points on the rest, @SpaceWaffles solution is not suitable. Perhaps someone found where this restriction is specifically imposed and for what reason ?

ihorkozar avatar Oct 10 '22 14:10 ihorkozar