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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Aligning zero on 2 y-axis

Thread ID:





61144 May 18,2007 11:44 AM UTC May 21,2007 11:01 AM UTC WinForms 3
Tags: Chart
Asked On May 18, 2007 11:44 AM UTC

I have to y axis with ranges of -100 to 400 and -200% to 500%. When data is plotted on the graph, bar columns using the secondary y-axis start half-way up from columns on the primary y-axis. I want 0 and the primary axis and 0 on the secondary axis to be in exactly the same place. How do I do this?


Rashidha F [Syncfusion]
Replied On May 18, 2007 01:16 PM UTC

Hi Marcus,

Thanks for using Syncfusion Products.

You can able to achieve your requirement using Axes offset property in Chart control.

The following code snippet which illustrates how to set Offset value in the primary and secondary axis.


//if axis as a secondary axis.
axis1.Offset = 45;

Please take a look at the attached sample.


Let me know if this helps.


Replied On May 18, 2007 01:53 PM UTC


I'm not really sure this helps because I don't want to have to define the range of values manually. How would I know what to set the Offset value to for either the primary or secondary axis?


Ramya R [Syncfusion]
Replied On May 21, 2007 11:01 AM UTC

Hi Marcus,

You can align the zeroth value of both PrimaryYAxis and secondaryYAxis by adjusting the location of the secondaryYAxis as shown in the code snippet below,

private float SecYLoc;
private double m;

if (axis1.Range.Min < 0)
m = -axis1.Range.Min;
m = axis1.Range.Min;

// To find the position of value 0 in Secondary Y axis
double n2 = (axis1.Size.Height * m) / (axis1.Range.Max - axis1.Range.Min);

SecYLoc = (float)(this.chartControl1.GetChartAreaCoordinateY(0) + n2 + this.chartControl1.ChartArea.RenderBounds.Top-this.chartControl1.ChartArea.ChartAreaMargins.Bottom);
axis1.LocationType = ChartAxisLocationType.Set;

// Changing Location of the Secondary axis to coincide 0 in both Y axes
axis1.Location = new PointF((float)(this.chartControl1.ChartArea.RenderBounds.Right), SecYLoc);


Please let me know whether this helps you.

Thanks & Regards,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon