syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.44k stars 672 forks source link

[SfCircularChart] Is it possible to add explodeGesture mode 'hover' for windows? #1826

Closed aike1202 closed 3 weeks ago

aike1202 commented 3 weeks ago

Use case

now available gesture types are [ActivationMode.singleTap] [ActivationMode.doubleTap] [ActivationMode.longPress] [ActivationMode.none] ,it show tooltip on mouse hover onwindows , but not explodeing

Proposal

enum ActivationMode {
 ....
 /// - ActivationMode.hover, activates on mouse hover on windows ,mac,web paltform.
  hover,
}
aike1202 commented 3 weeks ago

or is there any other way to archive this

LokeshPalani commented 3 weeks ago

Hi @aike1202,

You can achieve your requirement by combining TooltipBehavior with exploding. By adding a builder to TooltipBehavior, you can obtain the pointIndex that corresponds to the hovered segment index. This pointIndex can then be used as the explodeIndex. We have provided a code snippet, sample, and user guide documentation for your reference. Please let us know if you have any additional requirements.

UG Link,

https://help.syncfusion.com/flutter/circular-charts/tooltip#tooltip-template

Code Snippet:

SfCircularChart(
      tooltipBehavior: TooltipBehavior(
        enable: true,
        activationMode: ActivationMode.singleTap,
        color: Colors.transparent,
        duration: 0,
        builder: (data, point, series, pointIndex, seriesIndex) {
          SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
            if (pointIndex != _pointIndex) {
              setState(() {
                _pointIndex = pointIndex;
              });
            }
          });
          return const SizedBox(
            height: 0,
            width: 0,
          );
        },
      ),
      series: <CircularSeries>[
        DoughnutSeries<ChartSampleData, String>(
          explodeIndex: _pointIndex,
          dataSource: [
            ChartSampleData('Car', 70),
            ChartSampleData('Motorcycle', 20),
            ChartSampleData('Truck', 50),
            ChartSampleData('Bike', 40),
            ChartSampleData('Flight', 30),
          ],
          xValueMapper: (ChartSampleData chartData, _) => chartData.details,
          yValueMapper: (ChartSampleData chartData, _) => chartData.count,
          cornerStyle: CornerStyle.bothCurve,
          strokeColor: Colors.white,
          explode: true,
        )
      ],
);

Regards, Lokesh P.

github_1826.zip

aike1202 commented 3 weeks ago

thanks it works fine