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

TooltipPosition.pointer don't work?

Hi, 

I want to show tooltip at where user tapped, so I tried to set tooltipPosition to TooltipPosition.pointer, but seems it don't work?


4 Replies 1 reply marked as answer

YG Yuvaraj Gajaraj Syncfusion Team April 6, 2023 07:30 AM UTC

Hi Zhu,


The TooltipPosition.pointer will work for a rectangle type series alone, it will show a tooltip when you tap anywhere in the column series segment. If you want to show the tooltip where is customer taps, this can be achieved with the help of the onChartTouchInteractionDown callback and showByPixel public method in the tooltip. We have shared the code snippet and related UG documentation below for your reference.


Code snippet:

late TooltipBehavior _tooltipBehavior;


@override
void initState() {
_tooltipBehavior = TooltipBehavior(enable: true);
super.initState();
}


SfCartesianChart(
onChartTouchInteractionDown: (tapArgs) {
_tooltipBehavior.showByPixel(
tapArgs.position.dx, tapArgs.position.dy);
},
tooltipBehavior: _tooltipBehavior,
)


UG,

https://help.syncfusion.com/flutter/cartesian-charts/methods#showbypixel-method-in-tooltipbehavior

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


Regards,

Yuvaraj.


Marked as answer

ZH Zhu April 9, 2023 03:15 AM UTC

Hi, Yuvaraj,


I tried it, it do work, but not as I expected, I realized that what I'm using is not tooltip, but trackball, which include 4 datas in a box.

So I tried  onChartTouchInteractionDown callback and show way on it, but then it only show once at top left corner of chart.

Here's the seetings:

_trackballBehavior = TrackballBehavior(

      lineType: TrackballLineType.horizontal, 

      activationMode: ActivationMode.singleTap,

      enable: true,

      tooltipAlignment: ChartAlignment.near, 

      shouldAlwaysShow: true, 

      tooltipDisplayMode: TrackballDisplayMode.groupAllPoints, 

    );

Any ideas?


Regards,

Zhu.



ZH Zhu April 9, 2023 03:26 AM UTC

Hi, Yuvaraj,


I tried to set  tooltipAlignment to ChartAlignment.far, it would not block the traces now, I think that's ok.

Thanks for the help.


Best Regards,

Zhu.



LP Lokesh Palani Syncfusion Team April 10, 2023 09:16 AM UTC

Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.


Loader.
Live Chat Icon For mobile
Up arrow icon