convert an animated SVG?

930 views
Skip to first unread message

jerome cukier

unread,
Nov 23, 2011, 8:03:27 AM11/23/11
to d3-js
Hello all,
usually when I do d3/protovis chart I provide a static image as an
alternative for lesser browsers.
is there a way to do the same with animated SVG, like a conversion to
either an animated gif or a movie format?
best,
jerome

Chris Viau

unread,
Nov 23, 2011, 10:05:27 AM11/23/11
to d3...@googlegroups.com
I use to take a video capture with Camstudio or command line tools (xvidcap, ffmpeg).

jerome cukier

unread,
Nov 23, 2011, 10:38:19 AM11/23/11
to d3-js
yes that was my initial thought but I wondered whether there was a -
painless- way to process an svg file.

On 23 nov, 16:05, Chris Viau <christophev...@gmail.com> wrote:
> I use to take a video capture with Camstudio <http://camstudio.org/> or

jerome cukier

unread,
Nov 23, 2011, 10:38:54 AM11/23/11
to d3-js
that said, let them switch out of IE. camstudio it is.

Jason Davies

unread,
Nov 23, 2011, 10:48:31 AM11/23/11
to d3...@googlegroups.com
On Wed, Nov 23, 2011 at 07:38:19AM -0800, jerome cukier wrote:
> yes that was my initial thought but I wondered whether there was a -
> painless- way to process an svg file.

If your visualisation can generate SVG for each frame, you could render
each frame into a PNG using something like Batik and then compose them
into an animated GIF (or simply show each PNG at a particular frame rate
using JavaScript). I'm not sure that's *painless* though. :)

Assuming you're using D3's transitions, this may not be that
straightforward as you'd have to fix the frame rate somehow: override
Date.now() perhaps, and maybe override window.requestAnimationFrame to
serialise the SVG.

So yeah, some kind of video capture is probably simplest for now if you
don't need absolute control over the frame rate.

--
Jason Davies, http://www.jasondavies.com/

Mike Bostock

unread,
Nov 23, 2011, 10:56:13 AM11/23/11
to d3...@googlegroups.com
There's another example of using D3 with node-canvas to render images:

https://github.com/mbostock/d3/blob/master/examples/node-canvas/us-counties.js

Mike

Jon Frost

unread,
Nov 23, 2011, 11:22:22 AM11/23/11
to d3...@googlegroups.com
There we go, that way the various SVG --> Canvas instructions could
effectively be streamed down to clients. I'll have to try that, and
thanks again for your trailblazing!

And now that node.js now runs on windows it will likely be built out
even faster due to that much more interest.

Reply all
Reply to author
Forward
0 new messages