demo.js
1.64 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
if(!!(window.addEventListener)) window.addEventListener('DOMContentLoaded', main);
else window.attachEvent('onload', main);
function main() {
lineChart();
pieChart();
}
function lineChart() {
var data = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : [65,59,90,81,56,55,40],
label : 'Tigers'
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : [28,48,40,19,96,27,100],
label : 'Bears'
}
]
};
var ctx = document.getElementById("lineChart").getContext("2d");
new Chart(ctx).Line(data);
legend(document.getElementById("lineLegend"), data);
// testing adding twice (should get same result)
legend(document.getElementById("lineLegend"), data);
}
function pieChart() {
var data = [
{
value: 30,
color:"#F38630",
label: 'Bears'
},
{
value : 50,
color : "#E0E4CC",
label: 'Lynxes'
},
{
value : 100,
color : "#69D2E7",
label: 'Reindeer'
}
];
var ctx = document.getElementById("pieChart").getContext("2d");
new Chart(ctx).Pie(data);
legend(document.getElementById("pieLegend"), data);
}