We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Display trackball

Is it possible to display trackball by double tapping and also hide trackball by double tapping


3 Replies

YG Yuvaraj Gajaraj Syncfusion Team April 5, 2023 10:26 AM UTC

Hi Bar,


You can achieve your requirement with the help of showByIndex and hide public methods in trackball and onPointDoubleTap callback in the series. Here you need to enable the shoulAlwaysShow property and set the activation mode to none in trackball behavior. Then call the showByIndex public method inside the onPointDoubleTap callback if the previous point index is not the same as the current point index from the callback like the wise call the hide method if both the point index is the same. We have shared the code snippet below for your reference.


Code snippet:

late TrackballBehavior _trackballBehavior;


int? pointIndex;


@override
void initState() {
_tooltipBehavior = TooltipBehavior(enable: true);
_trackballBehavior = TrackballBehavior(
enable: true,
shouldAlwaysShow: true,
activationMode: ActivationMode.none,
);
super.initState();
}


LineSeries(
onPointDoubleTap: (args) {
if (pointIndex == null || pointIndex != args.pointIndex) {
_trackballBehavior.showByIndex(args.pointIndex!);
pointIndex = args.pointIndex;
} else if (pointIndex == args.pointIndex) {
_trackballBehavior.hide();
pointIndex = null;
}
},
// Other required properties
)


UG,

https://help.syncfusion.com/flutter/cartesian-charts/callbacks#onpointdoubletap

https://help.syncfusion.com/flutter/cartesian-charts/methods#methods-in-trackballbehavior


Regards,

Yuvaraj.



BI Bar Ilan April 9, 2023 04:30 PM UTC

Is it possible to do it on all area of the chart and not only points?



LP Lokesh Palani Syncfusion Team April 10, 2023 08:27 AM UTC

Hi Bar,


Currently, we do not have support to display the trackball on all areas of the chart. You can achieve your requirement with the help of crosshairBehavior. By using crosshairBehavior, you can display the axis values on all areas of the chart and not only on points. We have shared the sample link and related UG Documentation below for your reference.


Sample,

https://flutter.syncfusion.com/#/cartesian-charts/user-interactions/crosshair


UG,

https://help.syncfusion.com/flutter/cartesian-charts/trackball-crosshair#crosshair


Regards,

Lokesh Palani.


Loader.
Up arrow icon