Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to turn off TouchTooltipData when touching a chart #33

Closed
davidmarinangeli opened this issue Jul 7, 2019 · 7 comments
Closed

How to turn off TouchTooltipData when touching a chart #33

davidmarinangeli opened this issue Jul 7, 2019 · 7 comments

Comments

@davidmarinangeli
Copy link

davidmarinangeli commented Jul 7, 2019

How can I avoid the popup data to show when I touch the LineChart ? I tried putting the object touchTooltipData: in LineTouchData at null but then my state is not updated correctly to my other widgets.

Another related question: how can I let the chart listen to normalPress and not only longPress? Each time I try to interact with the chart I have to "longpress" it

@davidmarinangeli
Copy link
Author

Solved with

lineTouchData: LineTouchData( touchResponseSink: controller.sink, touchTooltipData: TouchTooltipData( tooltipBgColor: Colors.blueGrey, getTooltipItems: (touchedSpots) { return touchedSpots.map((touchedSpot) { return null; }).toList(); })),

returning null at getTooltipItems did the trick 👍

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 7, 2019

Hi,
Well done about the trick, It is intentionally allowed to return null to prevent show the tooltip (maybe you want to disable it in first and last spot, you can retuen them null),
And about the normal touch, you're right currently we support only long touch, I will add normal touch to the chart ASAP

@davidmarinangeli
Copy link
Author

Keep rocking! Hope to send my first PR soon :D

@sukhcha-in
Copy link

Another related question: how can I let the chart listen to normalPress and not only longPress? Each time I try to interact with the chart I have to "longpress" it
@davidmarinangeli did you find solution for this?

@imaNNeo
Copy link
Owner

imaNNeo commented Jul 8, 2019

Guys, currently you can't implement normal touch events in the chart,
If it is important to you, please make an issue, then thumb it up, I will add it with high priority.

@davidmarinangeli
Copy link
Author

davidmarinangeli commented Jul 8, 2019

Hi,

Another related question: how can I let the chart listen to normalPress and not only longPress? Each time I try to interact with the chart I have to "longpress" it
@davidmarinangeli did you find solution for this?

As Iman told us the normal touch is a feature that will come eventually later. If you want to make an issue I will be really happy to thumb it up.

@jvcss
Copy link

jvcss commented Jun 28, 2024

awesome! and if you want to show only the tooltip for a specific line you can use this

LineChartData(
              lineTouchData: LineTouchData(touchTooltipData: LineTouchTooltipData(getTooltipItems: (touchedSpots) {
                return touchedSpots.map((touchedSpot) {
                  if (touchedSpot.barIndex == 0) { // show the tooltips for the first line defined in the list of `lineBarsData`
                    return LineTooltipItem(
                      '${touchedSpot.y}',
                      TextStyle(color: touchedSpot.bar.color),
                    );
                  }
                  return null; // hide tool tip for all other lines in the current chart that can have many lines.
                }).toList();
              })),
//...
)

in my case that was pretty usefull, thank you @davidmarinangeli
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants