Hi,
I'm working with SfCartesianChart.
I am wondering if I could build my own custom checkbox legend using legend builder so that it would behave same as the default legend - when the user clicks on one of the legend element, the checkbox would be unchecked (it would not be hidden) and keep the functionality.
Here is an sample image that I would like to apply:
As you can see on the image bottom, there are 6 different legends that have checkbox so that when the user clicks on one of it, the checkbox would be unchecked with the corresponding data in the chart would
Thank you.
Thanks.
However, from the sample above, it seems like when I uncheck multiple series the chart still renders unchecked series. Also, re-rendering the whole chart whenever the legend is pressed seems bit awkward compared to the built-in toggle of legend which just hides the toggled series instead of re-rendering the whole chart.
Here is the behavior the above sample shows up when I unchecked multiple legend.
Some other workaround I have been thinking of are:
legendItemBuilder: (legendText, series, point, seriesIndex) {
Checkbox(
onChanged: () { series.isVisible = !series.isVisible} // something like this
),
}
legendItemBuilder: (legendText, series, point, seriesIndex) {
// a property from series that could determine if the matching legend is clicked or not
}
Legend(
isVisible: true,
selectedImage: AssetImage('checkedIcon.png'),
unselectedImage: AssetImage('uncheckedIcon.png'),
)
Thank You.