将d3.js SVG代码转换为独立程序 - 任何建议? [英] Converting d3.js SVG code to a standalone program -- any suggestions?
问题描述
我有一些用d3.js编写的生成SVG图表的脚本。我想生成这些图表与一个独立的程序 - 什么是最简单的方法,我可以转换这些脚本以批处理模式运行,没有浏览器?
I have some scripts written with d3.js that generate SVG charts. I'd like to generate those charts with a standalone program -- what is the easiest way I can convert those scripts to run in batch mode, without a browser?
推荐答案
您可以:
Convert this to a node.js program. You'd have access to the filesystem and would be able to save generated SVGs easily. You'd need node-canvas to replace the HTML canvas. See this d3 example to get started using d3 with node.
您可以使用Chrome中的文件系统API与现有脚本将文件写入硬盘。这可能更容易,因为你只需要实现文件系统代码在你已经有了。有关写入本地文件系统的信息,请参见此html5rocks文章。
You could use the filesystem APIs in Chrome with your existing scripts to write files to the hard disk. This may be easier, because you would just need to implement the filesystem code on top of what you have already. See this html5rocks article for information on writing to the local file system.
这篇关于将d3.js SVG代码转换为独立程序 - 任何建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!