PDA

View Full Version : how to specify file name during saving chart as image



ravindran
8 Oct 2013, 6:24 PM
Currently, I use chart.save({ type: 'image/png' });
which leads to the svg io service of sencha and downloads the image as a chart

1. I want to know If i can specify the filename under which it should be downloaded.
eg. chart.save({
filename : 'chartimage_1',
type: 'image/png' });
2. Is there a way I could save the image without connecting to the sencha service ?

Thanks in advance.

existdissolve
9 Oct 2013, 5:07 PM
Currently, I use chart.save({ type: 'image/png' });
which leads to the svg io service of sencha and downloads the image as a chart

1. I want to know If i can specify the filename under which it should be downloaded.
eg. chart.save({
filename : 'chartimage_1',
type: 'image/png' });
2. Is there a way I could save the image without connecting to the sencha service ?

Thanks in advance.

Hi there--

1.) I don't believe you can. Happy to be corrected on this one, however.
2.) Yes, you most certainly can. To do so, you simply need to change the defaultUrl config to point to your desired endpoint (see http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.chart.Chart-method-save)

If you do generate your own image, you'll need a service on your server that is capable of transforming SVG into the desired image type (PNG, JPEG, etc.). There are others, but I've had good luck with the Batik (http://xmlgraphics.apache.org/batik/) library. It's pretty simple to implement.

ravindran
9 Oct 2013, 9:22 PM
Thank you.