| 23 |
liveuser |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
|
2 |
<html>
|
|
|
3 |
|
|
|
4 |
<head>
|
|
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
6 |
<title>amCharts examples</title>
|
|
|
7 |
<link rel="stylesheet" href="style.css" type="text/css">
|
|
|
8 |
<link href='http://fonts.googleapis.com/css?family=Covered+By+Your+Grace' rel='stylesheet' type='text/css'>
|
|
|
9 |
<script src="../amcharts/amcharts.js" type="text/javascript"></script>
|
|
|
10 |
<script src="../amcharts/serial.js" type="text/javascript"></script>
|
|
|
11 |
<script src="../amcharts/pie.js" type="text/javascript"></script>
|
|
|
12 |
<!-- theme files. you only need to include the theme you use.
|
|
|
13 |
feel free to modify themes and create your own themes -->
|
|
|
14 |
<script src="../amcharts/themes/light.js" type="text/javascript"></script>
|
|
|
15 |
<script src="../amcharts/themes/dark.js" type="text/javascript"></script>
|
|
|
16 |
<script src="../amcharts/themes/black.js" type="text/javascript"></script>
|
|
|
17 |
<script src="../amcharts/themes/chalk.js" type="text/javascript"></script>
|
|
|
18 |
<script src="../amcharts/themes/patterns.js" type="text/javascript"></script>
|
|
|
19 |
<script>
|
|
|
20 |
// in order to set theme for a chart, all you need to include theme file
|
|
|
21 |
// located in amcharts/themes folder and set theme property for the chart.
|
|
|
22 |
|
|
|
23 |
var chart1;
|
|
|
24 |
var chart2;
|
|
|
25 |
|
|
|
26 |
makeCharts("light", "#FFFFFF");
|
|
|
27 |
|
|
|
28 |
// Theme can only be applied when creating chart instance - this means
|
|
|
29 |
// that if you need to change theme at run time, youhave to create whole
|
|
|
30 |
// chart object once again.
|
|
|
31 |
|
|
|
32 |
function makeCharts(theme, bgColor, bgImage) {
|
|
|
33 |
|
|
|
34 |
if (chart1) {
|
|
|
35 |
chart1.clear();
|
|
|
36 |
}
|
|
|
37 |
if (chart2) {
|
|
|
38 |
chart2.clear();
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
// background
|
|
|
42 |
if (document.body) {
|
|
|
43 |
document.body.style.backgroundColor = bgColor;
|
|
|
44 |
document.body.style.backgroundImage = "url(" + bgImage + ")";
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
// column chart
|
|
|
48 |
chart1 = AmCharts.makeChart("chartdiv1", {
|
|
|
49 |
type: "serial",
|
|
|
50 |
theme: theme,
|
|
|
51 |
dataProvider: [{
|
|
|
52 |
"year": 2005,
|
|
|
53 |
"income": 23.5,
|
|
|
54 |
"expenses": 18.1
|
|
|
55 |
}, {
|
|
|
56 |
"year": 2006,
|
|
|
57 |
"income": 26.2,
|
|
|
58 |
"expenses": 22.8
|
|
|
59 |
}, {
|
|
|
60 |
"year": 2007,
|
|
|
61 |
"income": 30.1,
|
|
|
62 |
"expenses": 23.9
|
|
|
63 |
}, {
|
|
|
64 |
"year": 2008,
|
|
|
65 |
"income": 29.5,
|
|
|
66 |
"expenses": 25.1
|
|
|
67 |
}, {
|
|
|
68 |
"year": 2009,
|
|
|
69 |
"income": 24.6,
|
|
|
70 |
"expenses": 25
|
|
|
71 |
}],
|
|
|
72 |
categoryField: "year",
|
|
|
73 |
startDuration: 1,
|
|
|
74 |
|
|
|
75 |
categoryAxis: {
|
|
|
76 |
gridPosition: "start"
|
|
|
77 |
},
|
|
|
78 |
valueAxes: [{
|
|
|
79 |
title: "Million USD"
|
|
|
80 |
}],
|
|
|
81 |
graphs: [{
|
|
|
82 |
type: "column",
|
|
|
83 |
title: "Income",
|
|
|
84 |
valueField: "income",
|
|
|
85 |
lineAlpha: 0,
|
|
|
86 |
fillAlphas: 0.8,
|
|
|
87 |
balloonText: "[[title]] in [[category]]:<b>[[value]]</b>"
|
|
|
88 |
}, {
|
|
|
89 |
type: "line",
|
|
|
90 |
title: "Expenses",
|
|
|
91 |
valueField: "expenses",
|
|
|
92 |
lineThickness: 2,
|
|
|
93 |
fillAlphas: 0,
|
|
|
94 |
bullet: "round",
|
|
|
95 |
balloonText: "[[title]] in [[category]]:<b>[[value]]</b>"
|
|
|
96 |
}],
|
|
|
97 |
legend: {
|
|
|
98 |
useGraphSettings: true
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
});
|
|
|
102 |
|
|
|
103 |
// pie chart
|
|
|
104 |
chart2 = AmCharts.makeChart("chartdiv2", {
|
|
|
105 |
type: "pie",
|
|
|
106 |
theme: theme,
|
|
|
107 |
dataProvider: [{
|
|
|
108 |
"country": "Czech Republic",
|
|
|
109 |
"litres": 156.9
|
|
|
110 |
}, {
|
|
|
111 |
"country": "Ireland",
|
|
|
112 |
"litres": 131.1
|
|
|
113 |
}, {
|
|
|
114 |
"country": "Germany",
|
|
|
115 |
"litres": 115.8
|
|
|
116 |
}, {
|
|
|
117 |
"country": "Australia",
|
|
|
118 |
"litres": 109.9
|
|
|
119 |
}, {
|
|
|
120 |
"country": "Austria",
|
|
|
121 |
"litres": 108.3
|
|
|
122 |
}, {
|
|
|
123 |
"country": "UK",
|
|
|
124 |
"litres": 65
|
|
|
125 |
}, {
|
|
|
126 |
"country": "Belgium",
|
|
|
127 |
"litres": 50
|
|
|
128 |
}],
|
|
|
129 |
titleField: "country",
|
|
|
130 |
valueField: "litres",
|
|
|
131 |
balloonText: "[[title]]<br><b>[[value]]</b> ([[percents]]%)",
|
|
|
132 |
legend: {
|
|
|
133 |
align: "center",
|
|
|
134 |
markerType: "circle"
|
|
|
135 |
}
|
|
|
136 |
});
|
|
|
137 |
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
</script>
|
|
|
142 |
</head>
|
|
|
143 |
|
|
|
144 |
<body style="font-size:15px;">Select theme:
|
|
|
145 |
<a href="#" onclick="makeCharts('light', '#ffffff');">Light</a> |
|
|
|
146 |
<a href="#" onclick="makeCharts('dark', '#282828')">Dark</a> |
|
|
|
147 |
<a href="#" onclick="makeCharts('black', '#222222')">Black</a> |
|
|
|
148 |
<a href="#" onclick="makeCharts('patterns', '#ffffff')">Patterns</a> |
|
|
|
149 |
<a href="#" onclick="makeCharts('chalk', '#282828', 'images/board.jpg')">Chalk</a>
|
|
|
150 |
<div id="chartdiv1" style="width: 600px; height: 400px;"></div>
|
|
|
151 |
<div id="chartdiv2" style="width: 600px; height: 400px;"></div>
|
|
|
152 |
</body>
|
|
|
153 |
|
|
|
154 |
</html>
|