Jfreechart and jfreesvg compatibility

A discussion forum for JFreeSVG (a fast, lightweight, SVG generator for the Java platform).
Locked
Eugene_T
Posts: 6
Joined: Thu Aug 06, 2015 10:09 am
antibot: No, of course not.

Jfreechart and jfreesvg compatibility

Post by Eugene_T » Thu Aug 06, 2015 10:13 am

Can I reuse the code created for generating jfreechart (via image) for generating svg files?
I want to use images in pdf reports and svg on the client, but it would be nice if I use the same data model - only change option image or svg
Thanks

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

Re: Jfreechart and jfreesvg compatibility

Post by david.gilbert » Thu Aug 06, 2015 5:54 pm

Yes, that's exactly the point of JFreeSVG...it's an implementation of the Graphics2D API (that JFreeChart uses for rendering) that accumulates all drawing operations into SVG elements. Once you have configured a JFreeChart object instance, you can render it to the screen or PNG or JPEG or SVG or PDF just by changing the Graphics2D instance to an appropriate implementation (if you look in the draw() method for the JFreeChart class you'll see that it takes a Graphics2D argument).

You can see in this demo that the creation of the chart is separate from the output to SVG:

https://github.com/jfree/jfreesvg/blob/ ... Demo1.java
David Gilbert
JFreeChart Project Leader

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

Eugene_T
Posts: 6
Joined: Thu Aug 06, 2015 10:09 am
antibot: No, of course not.

Re: Jfreechart and jfreesvg compatibility

Post by Eugene_T » Tue Aug 25, 2015 9:24 am

Ok, thanks. Got it!

Locked