Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Resizing attributes in the svg root element

Resizing behaviour

Code Block
xml
xml
 viewBox="0 0 400 400" preserveAspectRatio="xMidYMid meet" 

The svg document is scaled to fit the display window and the aspect ratio is preserved.

Code Block
xml
xml
 viewBox="0 0 400 400" preserveAspectRatio="none" 

The svg document is scaled and stretched to fill the window (aspect ratio is not preserved).

Code Block
xml
xml
 width="1200" height="700" 

Only the region with coordinates 0 <= x <= 1200 and 0 <= y <= 700 pixels is shown. The svg document is not resized when the display window is resized.

Aligning text within svg text objects

By default text in an svg text object is left-aligned and the x and y coordinates of the object denote the upper-left corner of the object. To right-align text in an svg text object, add the following attribute to the text element:

Code Block
xml
xml
 text-anchor="end" 

The entire element would then e.g. be:

Code Block
xml
xml
 <text id="Delft" x="757.48602" y="308.03317" style="fill:#000099" text-anchor="end">%LASTVALUE(numberFormat1)% meter</text> 

When an object is right-aligned, then the x and y coordinates of the object denote the upper-right corner of the object.

The attribute text-anchor can also have the values "start" or "middle". To create multiple pieces of text with different alignments, use separate text objects.

When using right-alignment, the decimal separator for number values can be aligned by using the following number format:

Code Block
xml
xml
 {0,number,#.00} 

Here "#" means one or more decimals before the decimal separator and ".00" means that always two decimal places are shown (number is either rounded or padded with zero's).