I want to create a LineChart using fl_chart and I need the tooltip background to change color based on touched spot
for example the color should be determined by this method
Color _getColor(List<int> intervals, double value) {
if (value >= intervals[0] && value < intervals[1]) {
return AppConstants.greenColor;
} else if (value >= intervals[1] && value < intervals[2]) {
return AppConstants.yellowColor;
}
return AppConstants.redColor;
}
current code:
LineTouchData(
touchTooltipData: LineTouchTooltipData(
tooltipBgColor: Colors.red,
fitInsideHorizontally: true,
fitInsideVertically: true,
tooltipRoundedRadius: 100,
getTooltipItems: (touchedSpots) {
return touchedSpots
.map(
(e) => LineTooltipItem(
e.y.toString(),
const TextStyle(),
),
)
.toList();
},
),
),