Create svg with 100% width height

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Locked
min9ox2
Posts: 1
Joined: Fri Oct 14, 2016 8:21 am
antibot: No, of course not.

Create svg with 100% width height

Post by min9ox2 » Tue Oct 18, 2016 4:09 am

Is there anyway I can pass width height as percentage when creating SVGGraphics2D? I couldn't find percentage in SVGUnits neither.
Or is there anyway to change width & height later after elements are placed? I'm getting the elements from the database and it would be great if I could define width & height after finding out left most & right most coordinates of my elements.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Create svg with 100% width height

Post by david.gilbert » Mon Oct 24, 2016 10:03 pm

Do you just want to scale your image in a web page? Maybe the following post is helpful:

https://css-tricks.com/scale-svg/

I have to admit I didn't realise that % is a valid unit in the SVG width and height attributes so I need to spend a little more time looking at this. For sure you can't specify percentage using the current version of SVG, but maybe the viewBox attribute will do what you need.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked