将d3.js SVG代码转换为独立程序 - 任何建议? [英] Converting d3.js SVG code to a standalone program -- any suggestions?

查看:189
本文介绍了将d3.js SVG代码转换为独立程序 - 任何建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些用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?

推荐答案

您可以:


  1. 将其转换为 node.js 程序。您将有权访问文件系统,并能够轻松地保存生成的SVG。您需要节点画布才能替换HTML画布。请参见此d3示例以开始对节点使用d3。

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆