-
Notifications
You must be signed in to change notification settings - Fork 17
/
build-chart-images.js
57 lines (44 loc) · 1.25 KB
/
build-chart-images.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var count = 0;
// we'll need the THEMES and CHARTS globals
phantom.page.injectJs('examples/dist/all-charts.js');
function addCharts(theme) {
for (var n=0; n<CHARTS.length; n++) {
(function(_n) {
// create page
var page = require('webpage').create()
var chart = CHARTS[_n].id;
// define page size
page.viewportSize = {
width: 445,
height: 250
};
// define screenshot image size
page.clipRect = {
top: 0,
left: 0,
width: 445,
height: 250
};
var url = 'http://localhost:1337/examples/chart.html?chart=' + chart + '&theme=' + theme;
console.log('open: ' + url);
page.open(url, function (status) {
window.setTimeout(function () {
console.log('render: ' + url);
page.render('chart-images/chart-' + count + '.png');
page.close();
// exit phantom when all permutations have been resolved
if (++count >= THEMES.length * CHARTS.length) {
phantom.exit();
}
}, 1000);
});
})(n);
}
}
for (var i=0; i<THEMES.length; i++) {
(function(_i) {
setTimeout(function() {
addCharts(THEMES[_i]);
}, 3000 * _i);
})(i);
}