I have a dashboard with multiple graphs and when the user overs one graph (showing the tooltips of the hovered dots) I want to show the tool tips on the other graphs if there are any dots at the same X value.
I'm trying to use the showTooltipIndicators but the tools tips are not showing. I can properly broadcast to all the charts as I also display a vertical line and it works fine.
Here is the code I use to populate teh showTooltipIndicators:
List<LineChartBarData> lines = [];
// populate the lines
List<LineBarSpot> forcedToolTips = [];
if (dateHighlight != null) { // dateHighlight is the X value i want to show the tooltips for
// we give a buffer so it doesn't have to be the exact date but a nearby
final buffer = const Duration(minutes: 5).inMilliseconds;
// we go through each line
for (int i = 0; i < lines.length; i++) {
final lineData = lines[i];
// find the spots that are within the buffer
lineData.spots.where((element) {
var highlight = dateHighlight!.toDouble();
return highlight > element.x - buffer &&
highlight < element.x + buffer;
}).forEach((spot) {
// adding to the force tool tips
print('$spot');
forcedToolTips.add(LineBarSpot(lineData, i, spot));
});
}
}
LineChartData(
showingTooltipIndicators: [ShowingTooltipIndicators(forcedToolTips)],
// ...
Here's a video showing that I can effectively broacast the X value properly:
I have a dashboard with multiple graphs and when the user overs one graph (showing the tooltips of the hovered dots) I want to show the tool tips on the other graphs if there are any dots at the same X value.
I'm trying to use the showTooltipIndicators but the tools tips are not showing. I can properly broadcast to all the charts as I also display a vertical line and it works fine.
Here is the code I use to populate teh showTooltipIndicators:
Here's a video showing that I can effectively broacast the X value properly:
Screencast from 2024-03-20 15-50-54.webm