Legend position on the chart

I'm creating new chart and I would like to place the legend in the left upper corner inside the plot area:


But it seems like it's not possible.

chart.Legend.Position = OfficeLegendPosition.Top;
chart.Legend.IncludeInLayout = true;
chart.Legend.IsVerticalLegend = false;
chart.Legend.Layout.Top = 10;
chart.Legend.Layout.Left = 10;

With the code above I get a bit of a different result:



So, is it possible to achieve the layout presented on the first screen cap?

3 Replies

MR Manikandan Ravichandran Syncfusion Team April 1, 2020 12:50 PM UTC

Hi Lukasz,

Thank you contacting Syncfusion support.

Yes, you can change the “legend” position of chart in the desired position. We have prepared the sample for this and it can be downloaded from the following link.
https://www.syncfusion.com/downloads/support/forum/152882/ze/WinFormsAPP-1897436064

If you think, we misunderstood any of your requirement, then kindly provide us the completed runnable sample or modified sample of the above and screenshot/output presentation document of the expected result which will helpful to provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran



LR Lukasz Rolbiecki April 1, 2020 02:06 PM UTC

Hi Manikandan,
thank you for the answer.
We're one step closer it seems, I have couple of questions though:
1) when I decrease the size of the chart the plot area is moved to the left and huge margin is created - which is very unappealing visually
2) I'm also not sure how the top and left properties works - with the values given I would expect the legend to appear on the top left corner, instead it is shown in the middle.

I attached modified example.

Attachment: WinFormsAPP_f10108c6.zip


MR Manikandan Ravichandran Syncfusion Team April 2, 2020 05:33 PM UTC

Hi Lukasz,

Thank you for your update.

1) when I decrease the size of the chart the plot area is moved to the left and huge margin is created - which is very unappealing visually
When you decrease the size of the chart with manually positioned legend,  Microsoft PowerPoint view the manually positioned legend depends on its modified chart size. So, we suggest you adjust the legend size and location based on the modified chart size, as we done in the below sample.

2) I would expect the legend to appear on the top left corner, instead it is shown in the middle.
Microsoft PowerPoint only support default legend positions such as Top, Bottom, Left, Right and Top Right. Which locate the legend in Top center, Bottom center, Left center, Right center and Top Right corner of the chart. Syncfusion PowerPoint library also has same property
OfficeLegendPosition to place the legend. But, if you want to move the legend to top left corner means, you should adjust the legend position manually as we suggested earlier.
Please refer the screenshot for available legend positions in the Microsoft PowerPoint Presentation.


3).I'm also not sure how the top and left properties work -
As we mentioned above, if we set a legend position as Top, Microsoft PowerPoint will place the legend in top center of the chart. If you want to place the legend in top left corner means, kindly set the left value in negative to move the legend to left and set positive values for right.

We have modified you sample and it can be download from the following link.
https://www.syncfusion.com/downloads/support/forum/152882/ze/WinFormsAPP-2108986838

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran
 


Loader.
Up arrow icon