Skip to content

Instantly share code, notes, and snippets.

@xuexue
xuexue / gist:3626348
Created September 4, 2012 20:55
Raw Data
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
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();
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',
// 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]
});
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)'