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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Aligning zero on 2 y-axis

Thread ID:

Created:

Updated:

Platform:

Replies:

61144 May 18,2007 11:44 AM UTC May 21,2007 11:01 AM UTC Windows Forms 3
loading
Tags: Chart
Marcus
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?

Thanks
Marcus

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.

this.chartControl1.PrimaryYAxis.Offset=45;

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

Please take a look at the attached sample.

http://websamples.syncfusion.com/samples/Chart.Windows/F61144/main.htm

Let me know if this helps.

Regards,
Rashidha.

Marcus
Replied On May 18, 2007 01:53 PM UTC

Hi,

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?

thanks
Marcus

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;
else
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);

this.chartControl1.Redraw(true);

Please let me know whether this helps you.

Thanks & Regards,
Ramya.


CONFIRMATION

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.

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

;