Visible axis range when using manual aspect ratio

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
quarz
Posts: 14
Joined: Mon Nov 11, 2013 11:23 am
Location: Russia, Moscow

Visible axis range when using manual aspect ratio

Post by quarz » Tue Nov 12, 2013 9:35 am

Hello.

A'm using ViewXY whith manual aspect ratio 1:1 and range 0..500 to both axis.
If window is not square, e.g. x dimension is larger, X axis range will automatic change to fill free window area.
The problem is that i can't get real (visible) axis range, because minimum and maximum returns 0, 500.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Visible axis range when using manual aspect ratio

Post by ArctionPasi » Tue Nov 12, 2013 11:00 am

Hi there.

When setting aspect ratio to 1, it means say 100 pixels in Y dimension and 100 pixels in X dimension correspond to equal axis ranges of say 500 and 500. If the graph is not a square (width and size the same), other axis will adjust its range so that it keeps the correct 100 pixels / 500 axis units. The meaning of aspect ratio is that it doesn't stretch the contents of chart. A circle will be circle after zooming or resizing of chart, not oval.
LightningChart Support Team, PT

quarz
Posts: 14
Joined: Mon Nov 11, 2013 11:23 am
Location: Russia, Moscow

Re: Visible axis range when using manual aspect ratio

Post by quarz » Tue Nov 12, 2013 11:33 am

I understand that.
At graph on the screen below AspectRatio set to Manual, ManualAspectRatioWH = 1 and for both axis SetRange(0, 500).
I'd like to get real visible axis range which should be about -180, 680 for X axis on the screen.
[img]axis%20range.png[/img]
Attachments
axis range.png
axis range.png (19.65 KiB) Viewed 16711 times

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Visible axis range when using manual aspect ratio

Post by ArctionPasi » Tue Nov 12, 2013 3:45 pm

Is this still an open question, do you need help with it?
LightningChart Support Team, PT

quarz
Posts: 14
Joined: Mon Nov 11, 2013 11:23 am
Location: Russia, Moscow

Re: Visible axis range when using manual aspect ratio

Post by quarz » Tue Nov 12, 2013 5:44 pm

Yes!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Visible axis range when using manual aspect ratio

Post by ArctionPasi » Tue Nov 12, 2013 9:50 pm

It's really hard for me to understand the problem you are experiencing, sorry. Could you explain it in some other way?

If you keep ViewXY.ZoomPanOptions.AspectRatioOptions.AspectRatio = Manual, and AspectRatioOptions.ManualAspectRatioWH = 1, you get the ranges as you presented in your picture. And that seems to be. Graph width is almost twice the graph height, and so is the X axis range when compared Y axis range.

If you want to set range of 0-500 to both axes, don't use aspect ratio at all. Set ViewXY.ZoomPanOptions.AspectRatioOptions.AspectRatio = Off.
Then use
xAxis.SetRange(0,500);
yAxis.SetRange(0,500);
LightningChart Support Team, PT

quarz
Posts: 14
Joined: Mon Nov 11, 2013 11:23 am
Location: Russia, Moscow

Re: Visible axis range when using manual aspect ratio

Post by quarz » Wed Nov 13, 2013 8:02 am

Ok, i'll try to explain another way.
After ViewXY.FitView() with enabled AspectRatio, showing boundaries are different from set by SetRange(), if the chart is not square.
And i want to get showing boundaries, wich could be larger then set by SetRange().

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Visible axis range when using manual aspect ratio

Post by ArctionPasi » Wed Nov 13, 2013 9:20 am

Can you include a code and a picture of the problem. :?:
LightningChart Support Team, PT

quarz
Posts: 14
Joined: Mon Nov 11, 2013 11:23 am
Location: Russia, Moscow

Re: Visible axis range when using manual aspect ratio

Post by quarz » Wed Nov 13, 2013 10:31 am

Ok, question is in sources.
I hope i was able to explain clearly
Attachments
AxisRange.rar
(85.7 KiB) Downloaded 973 times

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Visible axis range when using manual aspect ratio

Post by ArctionPasi » Wed Nov 13, 2013 11:22 am

You can't get 0...500 X range if you are using aspect ratio 1, and chart width is greater than height. When aspect ratio is used, X and Y axes are related together.

Please see this example code:

Code: Select all

m_chart.ViewXY.ZoomPanOptions.AspectRatioOptions.AspectRatio = ViewAspectRatio.Manual;
            m_chart.ViewXY.ZoomPanOptions.AspectRatioOptions.ManualAspectRatioWH = 1;
            m_chart.ViewXY.XAxes[0].LabelsAngle = 90;
            m_chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].SetRange(0, 500);
            m_chart.ViewXY.YAxes[0].SetRange(0, 500);

            FreeformPointLineSeries fpls = new FreeformPointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
            fpls.Points = new SeriesPoint[] { new SeriesPoint(0, 0), new SeriesPoint(0, 500), new SeriesPoint(500, 500), new SeriesPoint(500, 0), new SeriesPoint(0, 0) };
            m_chart.ViewXY.FreeformPointLineSeries.Add(fpls); 
It produces chart like this.
Aspect ratio, with a rectangle
Aspect ratio, with a rectangle
aspect.jpg (67.4 KiB) Viewed 16696 times
The fpls contains a square X: 0...500 and Y: 0...500. And it looks like a square, not like a rectangle.
As you can see, aspect ratio of 1 is kept. Value range of 0...500 in Y axis covers 310 px. Also in X axis value range of 0...500 covers 310 px.

If you want to define value range of X = 0...500 and Y = 0...500 for the axes and keep them like that, don't use aspect ratio.

The same without aspect ratio:

Code: Select all

m_chart.ViewXY.XAxes[0].LabelsAngle = 90;
            m_chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
            m_chart.ViewXY.XAxes[0].SetRange(0, 500);
            m_chart.ViewXY.YAxes[0].SetRange(0, 500);

            FreeformPointLineSeries fpls = new FreeformPointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
            fpls.Points = new SeriesPoint[] { new SeriesPoint(0, 0), new SeriesPoint(0, 500), new SeriesPoint(500, 500), new SeriesPoint(500, 0), new SeriesPoint(0, 0) };
            m_chart.ViewXY.FreeformPointLineSeries.Add(fpls); 
Produces chart like this:
No aspect ratio usedd
No aspect ratio usedd
aspect2.jpg (53.81 KiB) Viewed 16696 times
It is a rectangle, not square.
LightningChart Support Team, PT

Post Reply