Skip to content

Instantly share code, notes, and snippets.

View data_aggregation.js
var data = polyjs.data({
category: ['A', 'B', 'A', 'B', 'A', 'B', 'A', 'B'],
number: [10, 15, 12, 23, 23, 15, 9, 13]
});
polyjs.chart({
layer: {
data: data,
type: 'bar',
x: 'category',
y: 'sum(number)'
View fruits.js
// Data to be plotted
var prices = polyjs.data({ // prices of fruits
fruit: ['apple', 'banana', 'orange'],
price: [99, 79, 139]
});
var sales = polyjs.data({ // sales of fruits
fruit: ['apple', 'apple', 'apple', 'apple', 'apple', 'apple', 'apple', 'banana', 'banana', 'banana', 'banana', 'banana', 'banana', 'banana', 'orange', 'orange', 'orange', 'orange', 'orange', 'orange', 'orange'],
date: ['2013-04-01', '2013-04-02', '2013-04-03', '2013-04-04', '2013-04-05', '2013-04-06', '2013-04-07', '2013-04-01', '2013-04-02', '2013-04-03', '2013-04-04', '2013-04-05', '2013-04-06', '2013-04-07', '2013-04-01', '2013-04-02', '2013-04-03', '2013-04-04', '2013-04-05', '2013-04-06', '2013-04-07'],
sale: [20, 21, 26, 23, 19, 25, 15, 40, 52, 49, 43, 59, 41, 55, 30, 31, 33, 29, 25, 29, 35]
});
View barchart_1_old.js
var data = { fruits: ['apple', 'banana', 'orange'], values: [100, 120, 85] };
gg.graph(data)
.layer(
gg.layer.bar().map({
'x':'fruits',
'y':'values'
})
).opts({
'title':'Bar Chart with Polychart.js V1',
'dom':'#chart_bar_old',
View gist:5337253
var data= { fruits: ['apple', 'banana', 'orange'], values: [100, 120, 85] };
gg.graph(data)
.layer(gg.layer.bar().map({'x':'fruits', 'y':'values'}))
.opts({'title':'Bar Chart with Polychart.js V1', 'dom':'#chart_bar_old', 'width':400, 'height':200})
.render();
View gist:3626348
A 5.665396
A 5.300887
B 6.280863
B 6.283800
A 7.171414
B 6.417034
B 8.521771
A 4.706804
A 4.312119
A 4.354617