How to adjust X = Y numberaxis scale

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
olbrich
Posts: 19
Joined: Fri Dec 27, 2013 9:39 am
antibot: No, of course not.

How to adjust X = Y numberaxis scale

Post by olbrich » Wed Sep 14, 2016 3:54 pm

Hi David,

im sorry, but can't figure out how to adjust x and y axis to have identical scale factors
when resizing the window or zooming. What is the preferred method?

For example in the XYShapeRendererDemo circle show always remain a cirlce
and square should remain square.

If you show real word geometry coordinates both axis [m] should have the same scale.

Or how to set the plot area to fixed and square dimension.

best regards
Markus

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: How to adjust X = Y numberaxis scale

Post by paradoxoff » Wed Sep 14, 2016 6:29 pm

I don't think that there is an easy solution for this.
You need to calculate the ratio between the length of one "primary axis" and its range and make sure that this ratio is applied to the other axes.
If you only need to monitor the behaviouor during zooming, to could try to override the zoom-method in the ChartPanel class and do some normalization before you call the uoom-methods on the XYPlot.
Keeping this "ratio of ratios" also consistent when changeing the size of the ChartPanel is far more complicated, since the size of the datas area is only known after the renderingh is finished and in order to keep the "ratio of ratios" constant, you would have the value range of the "non-primary" axes and redraw the plot.
I will think about that. Maybe there is a solution that is not "dirty".

olbrich
Posts: 19
Joined: Fri Dec 27, 2013 9:39 am
antibot: No, of course not.

Re: How to adjust X = Y numberaxis scale

Post by olbrich » Thu Sep 15, 2016 8:24 am

thanks, yes i already override the zoom method, thats nearly ok,
but as you say, i am searching for a not "dirty" solution adjusting the axis' factors.

Using JFreeCharts since 1997 i could not imagine that there is no option for that too.
;-)

best regards
Markus

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: How to adjust X = Y numberaxis scale

Post by paradoxoff » Sat Sep 17, 2016 7:36 pm

I think there are simply too many "events" where such a mechanism would have to intervene:
- the values in the dataset have changed, and the axes auto adfust their range. We need a decision which axis is the "master" (and gets its optimal range). The slaves would then get a range tha will maintain the same "(java2D length)/(data range)" ratio. What if this ratio for a given axis is too short for all values to show up?
- the user is changeing the size of the ChartPanel. What is the "correct" ation of such a mechanism? Shall the data range be extended/shrinked so that a constant ratio between the bigger/smaller java 2D length is maintained, or should the range of the axes be left constant, and only size changes which maintain a constant aspect ration be allowed?
- The user is zooming. SImilar questions as above.

BTW, I do not know any interactive software that supports such a feature.

olbrich
Posts: 19
Joined: Fri Dec 27, 2013 9:39 am
antibot: No, of course not.

Re: How to adjust X = Y numberaxis scale

Post by olbrich » Mon Sep 19, 2016 2:02 pm

many thanks for this investigations ....

yes of course youre completely right....

But have a louk at your XYShapeRendererDemo example.
Is it really the expected behaviour that the shapes are shared when resizing the window,
so each circle becomes an ellipse?


I would name it "lockAxisRatio(domainAxis, rangeAxes, RatioLockType)"
RatioLockType= DomainToRange this defines the master is Range || RangeToDomain this defines the master is Domain.
In all cases that the axis scale of the dependend axis changes, it takes into acount the master axis scale and
the upper end of the dependend axis is not calculted by axisSpace, but by master axis' scale.

A second chance is the scrollbar. The depend axis could extend the panel size so scrollbars appear.



May be you have an idea for a simple workaround ? Locking the the drawing panel ratio using preferredSize() mininimum size()?

best regards Markus

Locked