Last active
December 22, 2015 11:39
-
-
Save EusthEnoptEron/6467544 to your computer and use it in GitHub Desktop.
Minimal code to render an AnyChart chart with PhantomJS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<anychart> | |
<settings> | |
<animation enabled="True" /> | |
</settings> | |
<charts> | |
<chart plot_type="CategorizedVertical"> | |
<data_plot_settings default_series_type="Bar" enable_3d_mode="true" z_aspect="2.5"> | |
<bar_series group_padding="0.2"> | |
<tooltip_settings enabled="true" /> | |
</bar_series> | |
</data_plot_settings> | |
<chart_settings> | |
<title enabled="true"> | |
<text>Simple Single-Series Column Chart</text> | |
</title> | |
</chart_settings> | |
<data> | |
<series name="Series 1" palette="Default"> | |
<point name="P1" y="128.14" /> | |
<point name="P2" y="112.61" /> | |
<point name="P3" y="163.21" /> | |
<point name="P4" y="229.98" /> | |
<point name="P5" y="90.54" /> | |
<point name="P6" y="104.19" /> | |
<point name="P7" y="150.67" /> | |
<point name="P8" y="120.43" /> | |
<point name="P9" y="143.76" /> | |
<point name="P10" y="191.34" /> | |
<point name="P11" y="134.17" /> | |
<point name="P12" y="145.72" /> | |
<point name="P13" y="222.56" /> | |
<point name="P14" y="187.12" /> | |
<point name="P15" y="154.32" /> | |
<point name="P16" y="133.08" /> | |
</series> | |
</data> | |
</chart> | |
</charts> | |
</anychart> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"), | |
xml = fs.read("chart.xml"), | |
page = require('webpage').create(); | |
page.viewportSize = { width: 400, height : 400 }; | |
page.content = '<html><body><div id="content"></div></body></html>'; | |
page.injectJs("lib/AnyChart.js"); | |
page.injectJs("lib/AnyChartHTML5.js"); | |
page.evaluate(function(xml) { | |
AnyChart.renderingType = anychart.RenderingType.SVG_ONLY; | |
var chart = new AnyChart(); | |
chart.setData(xml); | |
chart.write('content'); | |
}, xml); | |
page.render('chart.png'); | |
phantom.exit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
mkdir -p lib | |
wget -O lib/AnyChartHTML5.js http://anychart.com/products/anychart/js/AnyChartHTML5.js?v=6.0.12r39628 | |
wget -O lib/AnyChart.js http://anychart.com/products/anychart/js/AnyChart.js?v=6.0.12r39628 | |
wget -O phantomjs.tar.bz2 http://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-i686.tar.bz2 | |
tar -xjvf phantomjs.tar.bz2 phantomjs-1.9.1-linux-i686/bin/phantomjs | |
mv phantomjs-1.9.1-linux-i686/bin/phantomjs phantomjs | |
rm -rf phantomjs-1.9.1-linux-i686 phantomjs.tar.bz2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment