W3C home > Mailing lists > Public > www-svg@w3.org > October 2001

RE: Changing the Y axis

From: Frank Steggink <fsteggink@isis.nl>
Date: Wed, 10 Oct 2001 14:51:43 +0200
Message-ID: <01C1519B.143A4B70.fsteggink@isis.nl>
To: "'albert valls'" <albert_nexus@hotmail.com>, "www-svg@w3.org" <www-svg@w3.org>
Hello Albert,

I'm afraid it's not possible to change the SVG coordinate system in such a 
way that the positive direction of the Y-axis is pointing upwards. It would 
be very useful if this could be implemented in the next version of the SVG 
specification, since such a coordinate system is common practice in a 
Geographical Information Systems (GIS) environment, and in other 
environments as well.
There are two ways to achieve your goal, i.e. simulating an upward-pointing 
Y-axis.
1. Switch the sign of your Y-values: positive values will be negative and 
vice versa. This way you're actually modifying your data, which is a thing 
I don't prefer. Texts, however, will stay normal.
2. SVG transformations (see ch. 7 of the current SVG specification). Place 
an SVG g-element as a container around all your data and apply the 
following transformation: "matrix(1,0,0,-1,0,0)". This will just flip your 
Y-values, and will not perform a transformation. Keep in your mind that, in 
order to see your data (and not an empty screen), you need to change the 
viewBox attribute in the outer svg-element. The second value (min y) must 
be made negative, and you should also substract the height of your viewbox, 
to avoid viewing just below the area you're interested in. The disadvantage 
of using this method is that your text will be displayed upside down. It is 
possible to transform your text elements separately, but it's some extra 
work (place it outside the group on which you applied the transformation, 
and translate your text twice the distance of the y-value in the negative 
y-direction, and perhaps also apply a correction for the text height). I 
haven't tested this method to translate texts yet, since I was able to 
avoid using texts so far.
So far I'm seeing both methods as a work-around for the "problem" that the 
direction of the Y-axis can't be adjusted. The choice between the 
above-described methods is: an easy workaround with which texts will be 
displayed correctly vs. a harder workaround with which you don't have to 
change the data you want to display. From a point of view of data integrity 
I prefer the second method, despite its disadvantages.
With kind regards,

Frank Steggink

On Wednesday, October 10, 2001 13:48, albert valls 
[SMTP:albert_nexus@hotmail.com] wrote:
> It's possible to change the coordinate system to make the Y axis work 
from
> bottom to top instead of top to bottom which is the default??
>
>
> thanks
>
> _________________________________________________________________
> Descargue GRATUITAMENTE MSN Explorer en http://explorer.msn.es/intl.asp
Received on Wednesday, 10 October 2001 08:55:56 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:21 GMT