辋川集

木末芙蓉花,山中发红萼,涧户寂无人,纷纷开且落

By - 陳 思敬

离线使用 Google Charts

可能是因为我们过于喜爱 Gogole,一直固执的以为,Google Charts 是这个世界上最好的图表工具,没有之一:

  • 使用方便
  • 配色美观

但有一个致命的缺陷,提供免费服务,但不开源,也不允许离线使用,这让身在墙内的我们,痛苦不堪。

Q:Can I download and host the chart code locally, or on an intranet?
A:Sorry; our terms of service do not allow you to download and save or host the google.load or google.visualization code.

但我想,出于学习和研究的需求,hack 一下,Google 也不会怪罪下来的,对吧?
方法:
借助 HttpWatch,观察网络加载,请求什么,我就 wget 什么,合并为本地 Javascript 文件,配置对应的 CSS 路径,最后实现本地服务。
感谢 Bingal 的不懈尝试。
最终我们成功了:
这里是 Demo:
http://christen.cn/lab/chart/index.html
可用 HttpWatch 观察,除了以下组件之外:

  • 表格
  • 仪表盘
  • 世界地图
  • 树型映射

都实现了离线使用,但目测它们在日常开发中,应用不多。

Leave a Reply

Your email address will not be published.
*
*