philogb / jit

The JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web
http://thejit.org
Other
1.51k stars 297 forks source link

Graph Export (SVG?) #24

Closed gossi closed 14 years ago

gossi commented 14 years ago

I would like to have an ability to export the graph. Images or SVG would be really sweet.

philogb commented 14 years ago

Hi,

I'm not planning in adding this functionality built-in the toolkit, since I'm not sure I'd be supported by all browsers and the API could change, but there's a lib that does that and that could be combined with the toolkit.

You can find it here: http://www.nihilogic.dk/labs/canvas2image/ .

The code would be something like:

var viz = new $jit.Viz(...) //whatever Viz might be...
...
viz.refresh();
...
Canvas2Image.saveAsPNG(viz.canvas.getCtx().canvas);

Let me know how this goes.

philogb commented 14 years ago

Oh, this would only work 100% with canvas based labels and nodes.

gossi commented 14 years ago

Yep, I discovered this canvas ability as well and did some experimenting around it. Unfortunately, this only works with the current viewport of the canvas. To get the whole graph exported, I need the maximum dimensions of the graph with current zoom value, set it from the outside, export, set it back - than we could do amazing stuff with it :) So, this is already captured in the issues #35 and #13 (I guess).