2

I have a LineChart where the default behaviour is that a tooltip with the y value shows up when you touch the chart.

How would i be able to get the x and y values of the point touched on the chart to save it in a variable for example.

It has to be in this property of the LineChart:

lineTouchData: LineTouchData(enabled: true),
msmsms
  • 81
  • 6

1 Answers1

2

you need more parameters in your LineTouchData property. The touch callback will send you a list of touched spots

LineTouchData(
          enabled: true,
          touchCallback: (event, response) {
            if (event is FlTapUpEvent) {
              if (response != null && response.lineBarSpots != null) {
                // print(event);
                // print(response);
              }
            }
          },
        ),
Zayin Krige
  • 3,229
  • 1
  • 35
  • 34