How do I save the generated chart as svg? I tried, using firebug,
accessing the svg node and saving the .innerHTML to a file, but for some
reason that didn't work (at least, pointing firefox to that saved file
just opened it as a .xml file, not a svg file)
I'm sure this is obvious but I'm missing something
Thanks
-pedro
1/ A bit of PHP code and an ajax request -
http://groups.google.com/group/protovis/browse_thread/thread/81efbb03...
2/ Use Rhino server side. The archives have a demo/test by me that writes
out a protovis generated SVG file to disk - zip of code that shows this is
here:
http://groups.google.com/group/protovis/attach/8a70b0e274255b36/rhino...
--
You received this message because you are subscribed to the Google Groups "protovis" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protovis+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protovis?hl=en.
> How do I save the generated chart as svg? I tried, using firebug,
> accessing the svg node and saving the .innerHTML to a file, but for some
> reason that didn't work (at least, pointing firefox to that saved file
> just opened it as a .xml file, not a svg file)
Pedro:
You have to add the appropriate DTD and namespace information to the XML
before it will be recognized as an SVG file ... here's a function that
we use to do it from C++ using Protovis with QWebKit:
Cheers,
Tim
const vtkStdString vtkQtProtovisView::GetSVG()
{
// We have to insert some boilerplate to our SVG so browsers will
render the image instead of displaying the source ...
std::string svg =
this->Internal->View->page()->mainFrame()->evaluateJavaScript("vis.scene[0].canvas.innerHTML").toString().toAscii().data();
svg.insert(svg.find(">"), " xmlns=\"http://www.w3.org/2000/svg\"
xmlns:xlink=\"http://www.w3.org/1999/xlink\"");
std::stringstream buffer;
buffer << "<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"no\"?>\n";
buffer << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
buffer << "<!-- Generated by the Titan Informatics Toolkit -->\n";
buffer << svg;
return buffer.str();
}
http://gitorious.org/protovis/protovis/trees/master/examples/downloadify
Mike