We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Margin control of chart using c#

I'm attempting to do as much of the code as I can in C# over XAML. How do you properly control the margins of a chart? I've been trying the code below but I'm getting errors. Any advice?


        SfChart chart = new SfChart();
            chart.Margin.Top = 60;
            chart.Margin.Left = 20;
            chart.Margin.Right = 20;
            chart.Margin.Bottom = 0;

2 Replies

JT Jason Traud May 31, 2016 09:39 PM UTC

I figured this out myself. I needed to do this:

Thickness chartMargin = new Thickness(20);
chart.Margin = chartMargin;




DA Devi Aruna Maharasi Murugan Syncfusion Team June 1, 2016 09:04 AM UTC

Hi Jason,  
  
Thanks for contacting Syncfusion Support. 
  
To achieve your requirement of setting margin for SfChart in C# use the following code sample. 
  
Code Sample:   
[C#]   
   
SfChart chart = new SfChart();   
   
//Thickness has been initialized for setting margin   
Thickness margin = new Thickness(20,10,20,10);   
   
//Newly initialized thickness object is assigned to the Chart Margin   
chart.Margin = margin;   
   
  
Please find the demo sample from the below link.  
  
Sample:Chart_Margin 
  
Regards, 
Devi M   


Loader.
Live Chat Icon For mobile
Up arrow icon