Skip to content

Commit

Permalink
fixed touch detection to select topmost spot. Spots are rendered in o…
Browse files Browse the repository at this point in the history
…rder so the last spot in the list is on "top" for the viewer. If spots intersect, touch should return the upmost spot, which we accomplish by reversing the loop for touch selection.
  • Loading branch information
elizabethzhenliu authored and imaNNeo committed Aug 26, 2024
1 parent 5a9606b commit 37371d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/chart/scatter_chart/scatter_chart_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ class ScatterChartPainter extends AxisChartPainter<ScatterChartData> {
) {
final data = holder.data;

for (var i = 0; i < data.scatterSpots.length; i++) {
for (var i = data.scatterSpots.length - 1; i >= 0; i--) {
// Reverse the loop to check the topmost spot first
final spot = data.scatterSpots[i];

final spotPixelX = getPixelX(spot.x, viewSize, holder);
Expand Down

0 comments on commit 37371d8

Please sign in to comment.