[Bug] Bar touch not working when BarChartRodData and BackgroundBarChartRodData have the same fromY/toY
- Dominant language
- Dart
- Stars
- 7.6k
- Forks
- 2k
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 2
Description
Hello,
I found a bug related to BarChartGroupData. When setting both barChartRodData and backgroundBarChartRodData with the same fromY and toY values, touch detection doesn't work as expected.
Specifically, in the touchCallback: (FlTouchEvent event, barTouchResponse) the barTouchResponse.spot returns null.
This can be reproduced even in the latest version using the default example bar_chart_sample1.dart.
For example:
```
return BarChartGroupData(
x: x,
barRods: [
BarChartRodData(
fromY: y,
toY: 10,
color: isTouched ? widget.touchedBarColor : barColor,
width: width,
borderSide: isTouched
? BorderSide(color: widget.touchedBarColor.darken(80))
: const BorderSide(color: Colors.white, width: 0),
backDrawRodData: BackgroundBarChartRodData(
show: true,
fromY: y,
toY: 10,
color: widget.barBackgroundColor,
),
),
],
showingTooltipIndicators: showTooltips,
);
```
When trying to touch the bar with the above configuration, no touch is detected.
I confirmed that this issue does not occur up to version 0.63.
It seems like this bug might have been introduced while applying recent changes related to supporting negative values in BackgroundBarChartRodData.
Thanks!
Contributor guide
Research direction
Start with the default bar_chart_sample1.dart example and its touchCallback, reproducing the case where BarChartRodData and BackgroundBarChartRodData share fromY and toY. Trace how barTouchResponse.spot is calculated for the bar, especially the handling of negative values, and verify that touching the bar returns a non-null spot without breaking the version 0.63 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100