BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
Hello,
I have a chart with many series, which can be toggled on and off by tapping the corresponding legend entry. I would like to toggle less important of them off programmatically on start-up using my own configuration. I don't want to program the whole legend by my own. I like the standard legend and only want to have it in the state, as I have clicked on a couple of legend entries. There is a function cartesianToggle() in common/utils/helper.dart which seems to be the thing, I'm looking for, but it needs the internal state object to be passed in. Is there any possibility to achieve the goal?
Regards,
Werner
Hi Werner Kolov,
You can programmatically control the visibility of the
legend by using the isVisible
property, which is available in the chart series class. This property can be
used to toggle the visibility of a series. When the legend is enabled for a
series, the visibility of its corresponding legend item will also be collapsed.
Please refer to the code snippet below for more information.
SfCartesianChart( legend: Legend(isVisible: true, position: LegendPosition.top), series: <ChartSeries<_SalesData, String>>[ LineSeries<_SalesData, String>( dataSource: data, xValueMapper: (_SalesData sales, _) => sales.year, yValueMapper: (_SalesData sales, _) => sales.size, name: 'Line Series', isVisible: false ), ], ), |
Regards,
Lavanya A.
Thank you very much!
Hi Werner Kolov,
Most Welcome. Kindly get back to us if you have further queries. We are always happy to assist you.
Regards,
Lavanya A.