Dear list,One extremely useful feature of Veusz is its ability to export to SVG, which is finally becoming a widespread standard for 2D graphics and animation over the web.
A very exiting feature of SVG is the possibility to combine it with Javascript, allowing user interaction.
Matplotlib, a pure plotting library for python, also allows SVG export. SVG rendering may be fine-tuned by setting attributes directly on each element. For example, one can set the "id" of a curve, an axis, etc from the code, and then see this attribute set in the xml output.
The ability to directly set element ID is fundamental in order to subsequently allow user interaction with the SVG output.
This page exemplifies the use of matplotlib in order to produce an interactive historgram:
http://matplotlib.org/examples/user_interfaces/svg_histogram.htmlYou find the output in the attachment (svg_histogram.svg). Open in a web browser. By clicking on the labels, it is possibile to show/hide the corresponding set of data. This was obtained by injecting a inline js script which references to specific elements by their ids, operating on their properties (opacity).
This kind of automatic operation is impossible on a vesuz output, because the SVG export procedure does not set any traceable element ID on the objects.
With a one-line patch I could ad a random unique ID to each element (by using the python id() built-in). After line 110 of svg_export.py (in method SVGElement.__init__):
if 'id=' not in attrb: attrb+=' id="%i"' % id(self)After this I can manually edit the svg, refering to objects by using this "id" (see attachment veusz_out.svg).
But this is really not the solution to the problem of traceability of SVG elements up to Veusz's internal document tree.
Imagine a curve having the same ID of the corresponding xy widgets.An axis being composed of a group of elements: the main group has an id corresponding to the axis name in the document tree, then all lines, ticks, texts are comprised under the same group.
...If the internal Veusz document tree could be transparently mapped into an svg object hierarchy of groups, having traceable element ids, interaction with the graph could easily be obtained. One could automatically inject a script in order to hide/show a large number of curves, along with their axis. Or to switch between pages (multi-page output!).
Or to zoom-in/out (this seems more difficult...).Clearly it would not be possible (and would not make any sense) to reproduce all veusz functionality onto an SVG file. But those rich output files could be immediately published on the web, exchanged by email, etc, allowing the viewer to customize a little bit its graph and see it in different ways.
Does anybody have any thoughts about this? Best regards, Daniele
<<attachment: svg_histogram.svg>>
<<attachment: veusz_out.svg>>
_______________________________________________ Veusz-discuss mailing list [email protected] https://mail.gna.org/listinfo/veusz-discuss
