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

Chart Padding and Grid Lines

I am trying to render a simple square chart for a dashboard. I only want to show the chart's area, with no grid lines, no padding and have the chart area take the complete size that I am making the chart.

For example:
chart.Size = new System.Drawing.Size(100, 100);

But the chart itself renders very small within the 100 pixels (see attached). Also, how do I get rid of all the grid lines?

1 Reply

AT Anandaraj T Syncfusion Team February 26, 2014 01:04 PM UTC

 Hi Tony,

Thanks for using Syncfusion products.

We suggest you to disable "DrawGrid" property of axes and set "Transparent" color for "GridLineType.ForeColor" property of axes to remove the grid lines from chart.

Please refer the following code snippet to achieve this.
<code>
[CS]
           //Hiding axis grid lines
            model.PrimaryXAxis.DrawGrid = false;
            model.PrimaryYAxis.DrawGrid = false;
            model.PrimaryXAxis.GridLineType.ForeColor = Color.Transparent;
            model.PrimaryYAxis.GridLineType.ForeColor = Color.Transparent;
          
            //Setting font for axes
            model.PrimaryXAxis.Font = new Font("Arial", 5);
            model.PrimaryYAxis.Font = new Font("Arial", 5);
</code>

We suggest you to set "0" for "ElementSpacing" property of chart model to remove padding from chart.

Please refer the following code snippet to achieve this.
<code>
[CS]
           //Remove padding for chart
            model.ElementsSpacing = 0;
</code>

We have also created a simple sample for your requirement and the sample can be downloaded from the link below.

Please let us know if you have any concern.

Regards,
Anand

Attachment: ChartMvc_5da238af.zip

Loader.
Live Chat Icon For mobile
Up arrow icon