Skip to content

Issue with Trackball with CategoryAxis #52

@jfox454

Description

@jfox454

The following exception is thrown when using enabling a Trackball with a CategoryAxis x-axis.

════════ Exception caught by gesture library ═══════════════════════════════════
The following RangeError was thrown while dispatching a pointer event:
RangeError (index): Invalid value: Not in range 0..6, inclusive: 170

When the exception was thrown, this was the stack
#0 List.[] (dart:core-patch/growable_array.dart:147:60)
#1 _TrackballPainter._generateAllPoints
package:syncfusion_flutter_charts/…/user_interaction/trackball_painter.dart:631
#2 TrackballBehavior.show
package:syncfusion_flutter_charts/…/user_interaction/trackball.dart:206
#3 TrackballBehavior.onTouchDown
package:syncfusion_flutter_charts/…/user_interaction/trackball.dart:230
#4 _ContainerArea._bindInteractionWidgets.
package:syncfusion_flutter_charts/…/base/chart_base.dart:1636
...
Event: PointerDownEvent#19ffd(position: Offset(246.1, 405.0), timeStamp: 32:30:22.992000, pointer: 15, kind: touch, buttons: 1, down: true, pressure: 0.6, pressureMin: 0.0, pressureMax: 3.2, size: 0.1, radiusMajor: 91.8, radiusMinor: 91.8)
position: Offset(246.1, 405.0)
Target: RenderPointerListener#26a18 relayoutBoundary=up1
parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=391.4, 0.0<=h<=425.0)
size: Size(391.4, 425.0)
behavior: deferToChild
listeners: down, move, up
════════════════════════════════════════════════════════════════════════════════

This appears to be due to the following code in trackball_painter.dart (line 630):

} else if (axis is CategoryAxis) {
                        x = axis._visibleLabels[xValue.round()].text;
                      }

The _visibleLabel property of axis contains only 6 values due to the large number of x-values in my CategoryAxis, and these being truncated to display nicely.

I suspect this can be fixed by changing the code to:

} else if (axis is CategoryAxis) {
                        x = axis._labels[xValue.round()].text;
                      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions