Create svg with 100% width height

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Post Reply
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.

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

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:

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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited

Post Reply