Padding of charts

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Arction_LasseP

Energetic
Posts: 1
Joined: Wed Jun 03, 2020 10:56 am

Padding of charts

Post by Energetic » Wed Jun 03, 2020 11:22 am

Hello,
How can I define Padding for my charts in WPF? When I set Padding in XAML in the chart control nothing appears to change. Currently the last digits of the axis values (of an axis with no title) go exactly to the end of the lightning chart control area, but I would like to have a few pixels of distance with the chart background before the end of the control

Arction_LasseP
Posts: 74
Joined: Wed Mar 27, 2019 1:05 pm

Re: Padding of charts

Post by Arction_LasseP » Thu Jun 04, 2020 9:13 am

Hello,

I would say that the best option here is to set margins manually. By default, the margins in LightningChart are automatically calculated based on various components such as axis titles and labels and chart title. Therefore, you need to first disable AutoAdjustMargins -property:

Code: Select all

_chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
After this you can set margins manually. The syntax is slightly different depending on whether you are using WPF or WinForms:

Code: Select all

// In WPF:
_chart.ViewXY.Margins = new System.Windows.Thickness(50, 30, 50, 70); // Left, top, right, bottom

// In WinForms:
_chart.ViewXY.Margins = new Padding(50, 30, 50, 70);
Hope this helps.
Best regards,
Lasse