How to set legend position dynamically in SfChart?

Hello

I want to position the legend in the bottom left chart area. In the knowledge base (https://www.syncfusion.com/kb/4684/how-to-customize-the-legends-position), it is advised to use floating type with specifying offsetX and offsetY values. But if I hardcode offset values, if the window/chart area is resized, legend position may move to undesired positions. How can I make it responsive to window resizing?


Regards



1 Reply

SJ Sumathi Jayaraj Syncfusion Team December 4, 2015 10:56 AM UTC

Hi Yalcin,

 

Thanks for contacting Syncfusion support.

 

We can achieve your requirement by setting DockPosition with HorizontalAlignment to the ChartLegend.

 

Code snippet:

 

<chart:SfChart.Legend>

    <chart:ChartLegend DockPosition="Bottom" HorizontalAlignment="Left"/>

</chart:SfChart.Legend>

 

 

We have prepared a sample and please find the sample in the below attachment.

 

Regards,

Sumathi J


Attachment: Trendline_Sample_8376f1da.zip

Loader.
Up arrow icon