Profile Picture

Controlling scaling of X and Y axis...

Posted By Robert Mortensen 10 Years Ago
Author
Message
Robert Mortensen
Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 3, Visits: 1
We have geometric data that we'd like to plot on a 2D Cartesian line chart. It is crucial that the scaling of the X and Y axis match and/or are controllable. That is, 1 unit in X should be the same length as 1 unit (or otherwise specified number of units) in Y. The only way I have been able to achieve this is by setting the ranges for the X and Y axis, setting the width and height of the NChart to the same ratio as X range to Y range and setting the Fit2DAxisContent property to false. While this makes the plot area the right size (aspect ratio), the labels and titles of the axes can be outside the content area. When Fit2DAxisContent is true, the labels and axes are inside the content area, but the plot area gets the wrong aspect ratio. I really need the plot area the right aspect ratio AND the labels and titles within the content area.

Please help me solve this problem.

Thanks....

Nevron Support
Posted 10 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 6 hours ago
Posts: 3,054, Visits: 4,012
Hi Robert,

Check out the All Examples\Panels\Chart\Aspect example. It shows how to configure the chart so that one unit on x equals exactly one unit on y. The following code extends on the example to create a chart which always has a proportion of 2:1 and a fixed range - [0:20] on x and [0:10] on y:

NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

// set aspect as 2:1
chart.Width = 20;
chart.Height = 10;

// use the aspect of the plot area (chart without axes)
chart.UsePlotAspect = true;
// fit axes in the box as well
chart.Fit2DAxisContent = true;

chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 20), true, true);
chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 10), true, true);

Hope this helps - let us know if you meet any problems.

Best Regards,
Nevron Support Team



Robert Mortensen
Posted 10 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: Forum Members
Last Active: 10 Years Ago
Posts: 3, Visits: 1
Excellent! That did it, I knew I was missing something. I had everything except chart.UsePlotAspect = true.

Thanks for the help!
Bob



Similar Topics


Reading This Topic