How to remove legend String when there value is 0 ( I remove graph when their value 0 in StackedColumnSeries)

I remove Graph when their value is 0 but i am not abel to remove legend String.


3 Replies 1 reply marked as answer

LP Lokesh Palani Syncfusion Team May 17, 2023 03:57 PM UTC

Hi nitish,


You can achieve your requirement by using the name property in the chart series. By using the name property, you can customize the legend text. We have provided a code snippet for your reference. Please inform us if you require any additional assistance.


Code snippet:

 series: <ChartSeries>[

StackedColumnSeries<ChartSampleDataString>(

namechartData.isNotEmpty ? 'Series' : '',

colorColors.red,

dataSourcechartData,

xValueMapper: (ChartSampleData data_) => data.x,

yValueMapper: (ChartSampleData data_) => data.y1,

   ),

 


Regards,

Lokesh.



NC nitish chauhan replied to Lokesh Palani May 23, 2023 07:01 AM UTC

Hi Lokesh

   I also remove graph data and remove legend item.



LP Lokesh Palani Syncfusion Team May 24, 2023 09:33 AM UTC

Hi Nitish,


You can achieve your requirement by using the isVisibleInLegend property in the series. By using this, you can remove the legend item when there is no data. We have shared a code snippet and sample for your reference. Please let us know if you need any further assistance.


Code snippet:

StackedColumnSeries<ChartSampleData, String>(

                color: Colors.blue,

                dataSource: chartData,

                isVisibleInLegend: chartData.isNotEmpty ? true : false,

                xValueMapper: (ChartSampleData data, _) => data.x,

                yValueMapper: (ChartSampleData data, _) => data.y2,

              ),

 


Regards,

Lokesh.


Attachment: chart_182341_44c6498a.zip

Marked as answer
Loader.
Up arrow icon