PDA

View Full Version : Getting the chart SVG data



fordprefect
9 Sep 2011, 3:41 PM
Hello,

Does anyone know how to get the svg for the charts? I'd like to render an image of them server side.

Thank you.

mitchellsimoens
10 Sep 2011, 5:55 AM
Unfortunately there is no easy method to call. However, SVG is just like divs and what not so you can get into the DOM and get all the tags.

fordprefect
12 Sep 2011, 2:20 PM
Thanks Mitchell,

I was able to get the svg markup for the chart and then save as a png with batik.

KartoPete
18 Jan 2012, 1:12 AM
It's easy to get the SVG from the DOM, but I have a tabpanel with charts in different tabs. If a tab is not opened or shown the SVG's path element doesn't exist in the DOM. Is there a way to render a chart or generate the full svg without having to show the chart on the screen?
Cheers,
Peter

rameshmn
6 Jun 2012, 1:16 AM
Hi Fordperfect
How to get SVG from the DOM?

Thanks,
Ramesh MN

fordprefect
6 Jun 2012, 1:35 PM
Hi Fordperfect
How to get SVG from the DOM?

Thanks,
Ramesh MN

Hi,

Since I was only showing one chart at a time I gave it an id (mychart) so I was able to grab the html of the chart that way. I'm sure you can do something similar:



var getSvgData = $("#mychart").html();

rameshmn
7 Jun 2012, 1:38 AM
Thanks a lot fordperfect... i can get the svg data...

kislay.kishore
18 Jun 2012, 11:01 PM
var getSvgData = $("#mychart").html();

does it work with extjs? I am getting " $ is not defined " error on firebug while trying to use this.

I know with JQuery it will work. However, not sure if it works with extjs as well...please throw some light on this.


Hi,

Since I was only showing one chart at a time I gave it an id (mychart) so I was able to grab the html of the chart that way. I'm sure you can do something similar:



var getSvgData = $("#mychart").html();

evant
18 Jun 2012, 11:19 PM
See: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.chart.Chart-method-save

stimpy
19 Jun 2012, 3:10 AM
Does the save method still post all the data to sencha everytime ?

If so the save method is not very useful for serious work or for those that develop behind a firewall.

evant
19 Jun 2012, 3:12 AM
The method that returns just the SVG string never hits the Sencha server.

In 4.1.1, it defaults to the Sencha server, but it's easily changeable via the API and there's also notes about the default in the docs.

stimpy
19 Jun 2012, 3:32 AM
Glad to hear

Are the 4.1.1 docs only visible for premium members ?

As of right now I see the save method calling

Ext.draw.Surface.save

which does not appear to exist and no note I can see as to the defaults.

evant
19 Jun 2012, 3:47 AM
http://www.sencha.com/forum/showthread.php?219836-Ext-JS-4.1.1-RC2-Now-Available

kislay.kishore
19 Jun 2012, 4:59 AM
The method that returns just the SVG string never hits the Sencha server.

What is that method? How can I use that method to get SVG string for a chart?

Right now, I am using the below code:



var chartCmp = Ext.getCmp('myChart').getEl();
var svg Data = chartCmp.dom.innerHTML ;

Please let me know the ExtJS's way to do the above?



The method that returns just the SVG string never hits the Sencha server.

In 4.1.1, it defaults to the Sencha server, but it's easily changeable via the API and there's also notes about the default in the docs.