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),
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);
}
}
},
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With