Hide Legend for invisible Chartseries

Hi Syncfusion team,

i have a chart with 3 chartseries, sometimes the third series should not be displayed. How can i remove the third label in the legend:


Can i customize the legend with a template und when yes, can you give me an example?

Thanks in advance 
gisela

7 Replies 1 reply marked as answer

SM Srihari Muthukaruppan Syncfusion Team August 27, 2020 07:13 AM UTC

Hi Gisela, 
 
We have analysed your query. From that, we would like to let you know that we can achieve your requirement by using name property in the chart. We have attached our demo sample link for your reference. Please find the below code snippet and screenshot. 
  
  
Code Snippet: 

 
// add your additional code here  
     <ChartSeriesCollection> 
            <ChartSeries DataSource="@DataSource" XName="x" YName="y" Name="Vorjahr" Fill="Grey" Type="ChartSeriesType.Column"> 
            </ChartSeries> 
            <ChartSeries DataSource="@DataSource" XName="x" YName="y1" Name="lst" Fill="Green" Type="ChartSeriesType.Column"> 
            </ChartSeries> 
            <ChartSeries DataSource="@DataSource" XName="x" YName="y2" Type="ChartSeriesType.Column"> 
            </ChartSeries> 
        </ChartSeriesCollection> 
// add your additional code here 
  
Screenshot: 
   
 
Let us know if you have any concerns. 
 
Regards, 
Srihari M 


Marked as answer

GI gisela August 27, 2020 01:18 PM UTC

Hello Srihari,

thank you for your quick answer.
Your sample works, but is that logical?
I think it would be better if the legend for an invisible chartseries (property "visible = false) wasn't shown.

Thanks
Gisela


SM Srihari Muthukaruppan Syncfusion Team August 31, 2020 01:00 PM UTC

Hi Gisela, 
 
We are sorry for the inconvenience. 
 
It’s the default behaviour to show a legend item in disabled state, when its appropriate series is not visible on the chart, so that whenever you dynamically click on that disabled legend item, you can get back that series visible on the chart (the legend item will also get changed to enabled mode). 
 
As per your requested scenario now, to hide that legend item from the UI, when its corresponding series visible property is set to false, it should be able to be handled via the LegendRender event for which we have logged an improvement task to support legend customization. And you can keep track of it from the below feedback portal link.    
 
 
This feature will be included in our upcoming Vol-3 main release and if you have any more specification/precise replication procedure or a scenario to be tested, you can add it as a comment in the portal. 
 
Please let us know, if you need any further assistance on this. 
 
Regards, 
Srihari M 



SM Srihari Muthukaruppan Syncfusion Team October 6, 2020 01:36 PM UTC

Hi Gisela,  
  
Sorry for the inconvenience.  
   
Due to some technical difficulties, we couldn't include this in our volume 3 release. We will include this feature in our volume 4 release which is expected to be rolled out by the mid of December 2020. We appreciate your patience until then.  
   
Regards,  
Srihari 



SM Srihari Muthukaruppan Syncfusion Team December 21, 2020 11:43 AM UTC

Hi Gisela, 
 
Sorry for the inconvenience.   
    
Due to complexity in implementation, we are unable include this feature in our volume 4 release. We will consider this feature in our volume 1 release which is expected to be rolled out by the end of March 2021. We appreciate your patience until then.   
    
Regards,   
Srihari 



DG Durga Gopalakrishnan Syncfusion Team April 2, 2021 11:18 AM UTC

Hi Gisela, 
 
We regret for inconvenience caused. This feature will be available in our upcoming Volume 2 Main Release which is expected to be rolled out at end of June 2021. We appreciate your patience until then. 
 
Regards, 
Durga G


DG Durga Gopalakrishnan Syncfusion Team December 28, 2022 08:46 AM UTC

Hi Gisela,


We are glad to announce that our Essential Studio 2022 Volume 4 release v20.4.0.38 is rolled out; we have included the reported requirement and is available for download under the following link.


https://www.syncfusion.com/forums/179561/essential-studio-2022-volume-4-main-release-v20-4-0-38-is-available-for-download


<SfChart>

    <ChartEvents OnLegendItemRender="LegendEvent"></ChartEvents>

</SfChart>

@code {

public void LegendEvent(LegendRenderEventArgs args)

    {

        Console.WriteLine(args.Text);

    }

}


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/ChartLegRender630302245.zip


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,          

Durga Gopalakrishnan.


Loader.
Up arrow icon