我想尝试使用 SVG 作为显示数据驱动的图形、图表等的一种方式。数据以 xml 的形式存在,我将使用 XQuery 来生成 xml。从 xml 创建 SVG 应该考虑哪些选项(例如图形库)?非常感谢。
4 回答
使用 SVG 的一种方法是使用 AT&T 的 GraphViz 包 - 使用 XQuery 从 XML 生成点格式的中间文本文件,并使用 GraphViz 进行图形布局和 SVG 生成。
If you're working with the SVG in Java, you could consider:
- SVG Salamander - https://svgsalamander.dev.java.net/
- Batik - http://xmlgraphics.apache.org/batik/
Batik is much larger (with tons of other stuff) so if SVG Salamander works for you I'd go with that.
I'm not sure from your question, though, whether you're looking for something to work with the SVG or something to create the SVG. If the latter, SVG is XML so you could use your XQuery to create the SVG output (which then can be interpreted in a browser by an SVG plugin or handled in Java with one of the above suggestions). Hope that helps.
查看ChartSVG。
这是W3C的一个示例,它使用 Javascript 从 xml 创建一个堆叠条形图作为 SVG。我想做类似的事情,但使用图形库(或???)而不是 js 来处理轴、标签、标题、数据点等的构造。根据玩这个的结果,下一步将是用户与图表的交互。谢谢。