Stacked Column Chart: StackingGroup legend

I'm using the Stacked Column Chart with StackingGroup as per your sample:

https://blazor.syncfusion.com/documentation/chart/chart-types/stacked-column/#stacking-group

Is it possible to use the StackingGroup Name as legend ? Or at least, indicate somehow, why these columns are stacked? Because in your example, you don't really have a clue what's the meaning of these stacking bars.


1 Reply

DG Durga Gopalakrishnan Syncfusion Team July 29, 2021 01:10 PM UTC

Hi Davy, 

Greetings from Syncfusion. 

We have validated your reported scenario. As of now, we don’t have direct property to display the stacking group name as legend name. We suggest you to use OnLegendItemRender event to customize the legend text. This event will be triggered for each legend item rendering. In the sample, we have changed 1st and 3rd legend names based on provided stacking group name and cancelled 2nd and 4th legends.  

<SfChart> 
    <ChartEvents OnLegendItemRender="LegendRender"></ChartEvents> 
</SfChart> 
@code{ 
public int count = 0; 
    public void LegendRender(LegendRenderEventArgs args) 
    { 
        if (count == 1 || count == 3) 
        { 
            args.Cancel = true; 
        } 
        args.Text = count == 0 ? "A" : (count == 2 ? "B" : ""); 
        count = count + 1; 
    } 
} 

 

Kindly revert us if you have any concerns. 

Regards, 
Durga G 


Loader.
Up arrow icon