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

onLegendTapped is not getting called for the pie chart in the flutter version 3.19.4 #1835

Open Nanagoud007 opened 2 weeks ago

Nanagoud007 commented 2 weeks ago

Bug description

i am rendering pie chart with legend on click on that it has to trigger the functionality but it is not happening here is the code snippet

Steps to reproduce

run the code snippet to produce

Code sample

Code sample ```dart Widget _pie_chart() { return Expanded( child: OverView2Function().isPiechartLoading.value ? Padding( padding: const EdgeInsets.all(8.0), child: Container( height: 300, child: Center( child: CircularProgressIndicator(), ), ), ) : OverView2Function().connectorStatus.isNotEmpty ? SfCircularChart( // tooltipBehavior: _tooltipBehavior, title: ChartTitle( text: 'Connector Status', alignment: ChartAlignment.center, ), legend: Legend( isVisible: true, textStyle: TextStyle( decoration: TextDecoration.underline, color: Colors.blue[900]), toggleSeriesVisibility: false), onLegendTapped: (LegendTapArgs legendTapArgs) { AppUtil.printData(legendTapArgs.pointIndex.toString(), isError: true); final int? index = legendTapArgs.pointIndex; final ConnectorStatusModel selectedStatus = OverView2Function().connectorStatus[index!]; OverView2Function().getConnectorListByStatus(status: selectedStatus.status!); GoRouter.of(AppUtil.context!).go(MyRoutes.connector_list_by_status + '?status=${selectedStatus.status}'); }, // ignore: strict_raw_type series: [ PieSeries( dataSource: OverView2Function().connectorStatus, pointColorMapper: (ConnectorStatusModel data, _) { return OverView2Function() .getTileColor(staus: data.status!); }, xValueMapper: (ConnectorStatusModel data, _) => data.status, yValueMapper: (ConnectorStatusModel data, _) => data.count, dataLabelSettings: const DataLabelSettings( isVisible: true, labelIntersectAction: LabelIntersectAction.shift, labelPosition: ChartDataLabelPosition.outside, connectorLineSettings: ConnectorLineSettings( type: ConnectorType.line, length: '15%')), //radius: '100%', ) ], ) : const Center( child: Text( 'No Data Found', ), ), ); } ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Stack Traces

Stack Traces ```dart [Add the Stack Traces here] ```

On which target platforms have you observed this bug?

Web

Flutter Doctor output

Doctor output ```console [Add your output here] ```
LokeshPalani commented 2 weeks ago

Hi @Nanagoud007,

We would like to inform you that when setting toggleSeriesVisibility to false in the Legend and tap on the Legend, the onLegendTapped callback will not be triggered. The toggleSeriesVisibility indicates that legend item should be interactive or not, when it is set to false, the onLegendTapped callback will not get triggered and this is the default behaviour. You can achieve your requirement by using the GestureDetector widget in the legendItemBuilder property for the Legend. By doing this, you can get interaction details from the GestureDetector widget in onTap callback when tapping on the Legend. We have shared a user guide documentation link for your reference below. Please let us know if you have any further needs.

UG Link, https://help.syncfusion.com/flutter/circular-charts/legend#legend-item-template

Regards, Lokesh P.