| 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 |
<script src="../amcharts/amcharts.js" type="text/javascript"></script>
|
|
|
9 |
<script src="../amcharts/serial.js" type="text/javascript"></script>
|
|
|
10 |
|
|
|
11 |
<script>
|
|
|
12 |
var chart;
|
|
|
13 |
|
|
|
14 |
var chartData = [
|
|
|
15 |
{
|
|
|
16 |
"year": "2003",
|
|
|
17 |
"europe": 2.5,
|
|
|
18 |
"namerica": 2.5,
|
|
|
19 |
"asia": 2.1,
|
|
|
20 |
"lamerica": 0.3,
|
|
|
21 |
"meast": 0.2,
|
|
|
22 |
"africa": 0.1
|
|
|
23 |
},
|
|
|
24 |
{
|
|
|
25 |
"year": "2004",
|
|
|
26 |
"europe": 2.6,
|
|
|
27 |
"namerica": 2.7,
|
|
|
28 |
"asia": 2.2,
|
|
|
29 |
"lamerica": 0.3,
|
|
|
30 |
"meast": 0.3,
|
|
|
31 |
"africa": 0.1
|
|
|
32 |
},
|
|
|
33 |
{
|
|
|
34 |
"year": "2005",
|
|
|
35 |
"europe": 2.8,
|
|
|
36 |
"namerica": 2.9,
|
|
|
37 |
"asia": 2.4,
|
|
|
38 |
"lamerica": 0.3,
|
|
|
39 |
"meast": 0.3,
|
|
|
40 |
"africa": 0.1
|
|
|
41 |
}
|
|
|
42 |
];
|
|
|
43 |
|
|
|
44 |
AmCharts.ready(function () {
|
|
|
45 |
// SERIAL CHART
|
|
|
46 |
chart = new AmCharts.AmSerialChart();
|
|
|
47 |
chart.dataProvider = chartData;
|
|
|
48 |
chart.categoryField = "year";
|
|
|
49 |
chart.plotAreaBorderAlpha = 0.2;
|
|
|
50 |
|
|
|
51 |
// AXES
|
|
|
52 |
// category
|
|
|
53 |
var categoryAxis = chart.categoryAxis;
|
|
|
54 |
categoryAxis.gridAlpha = 0.1;
|
|
|
55 |
categoryAxis.axisAlpha = 0;
|
|
|
56 |
categoryAxis.gridPosition = "start";
|
|
|
57 |
|
|
|
58 |
// value
|
|
|
59 |
var valueAxis = new AmCharts.ValueAxis();
|
|
|
60 |
valueAxis.stackType = "regular";
|
|
|
61 |
valueAxis.gridAlpha = 0.1;
|
|
|
62 |
valueAxis.axisAlpha = 0;
|
|
|
63 |
chart.addValueAxis(valueAxis);
|
|
|
64 |
|
|
|
65 |
// GRAPHS
|
|
|
66 |
// first graph
|
|
|
67 |
var graph = new AmCharts.AmGraph();
|
|
|
68 |
graph.title = "Europe";
|
|
|
69 |
graph.labelText = "[[value]]";
|
|
|
70 |
graph.valueField = "europe";
|
|
|
71 |
graph.type = "column";
|
|
|
72 |
graph.lineAlpha = 0;
|
|
|
73 |
graph.fillAlphas = 1;
|
|
|
74 |
graph.lineColor = "#C72C95";
|
|
|
75 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span style='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
76 |
chart.addGraph(graph);
|
|
|
77 |
|
|
|
78 |
// second graph
|
|
|
79 |
graph = new AmCharts.AmGraph();
|
|
|
80 |
graph.title = "North America";
|
|
|
81 |
graph.labelText = "[[value]]";
|
|
|
82 |
graph.valueField = "namerica";
|
|
|
83 |
graph.type = "column";
|
|
|
84 |
graph.lineAlpha = 0;
|
|
|
85 |
graph.fillAlphas = 1;
|
|
|
86 |
graph.lineColor = "#D8E0BD";
|
|
|
87 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span style='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
88 |
chart.addGraph(graph);
|
|
|
89 |
|
|
|
90 |
// third graph
|
|
|
91 |
graph = new AmCharts.AmGraph();
|
|
|
92 |
graph.title = "Asia-Pacific";
|
|
|
93 |
graph.labelText = "[[value]]";
|
|
|
94 |
graph.valueField = "asia";
|
|
|
95 |
graph.type = "column";
|
|
|
96 |
graph.lineAlpha = 0;
|
|
|
97 |
graph.fillAlphas = 1;
|
|
|
98 |
graph.lineColor = "#B3DBD4";
|
|
|
99 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span style='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
100 |
chart.addGraph(graph);
|
|
|
101 |
|
|
|
102 |
// fourth graph
|
|
|
103 |
graph = new AmCharts.AmGraph();
|
|
|
104 |
graph.title = "Latin America";
|
|
|
105 |
graph.labelText = "[[value]]";
|
|
|
106 |
graph.valueField = "lamerica";
|
|
|
107 |
graph.type = "column";
|
|
|
108 |
graph.lineAlpha = 0;
|
|
|
109 |
graph.fillAlphas = 1;
|
|
|
110 |
graph.lineColor = "#69A55C";
|
|
|
111 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span style='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
112 |
chart.addGraph(graph);
|
|
|
113 |
|
|
|
114 |
// fifth graph
|
|
|
115 |
graph = new AmCharts.AmGraph();
|
|
|
116 |
graph.title = "Middle-East";
|
|
|
117 |
graph.labelText = "[[value]]";
|
|
|
118 |
graph.valueField = "meast";
|
|
|
119 |
graph.type = "column";
|
|
|
120 |
graph.lineAlpha = 0;
|
|
|
121 |
graph.fillAlphas = 1;
|
|
|
122 |
graph.lineColor = "#B5B8D3";
|
|
|
123 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span style='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
124 |
chart.addGraph(graph);
|
|
|
125 |
|
|
|
126 |
// sixth graph
|
|
|
127 |
graph = new AmCharts.AmGraph();
|
|
|
128 |
graph.title = "Africa";
|
|
|
129 |
graph.labelText = "[[value]]";
|
|
|
130 |
graph.valueField = "africa";
|
|
|
131 |
graph.type = "column";
|
|
|
132 |
graph.lineAlpha = 0;
|
|
|
133 |
graph.fillAlphas = 1;
|
|
|
134 |
graph.lineColor = "#F4E23B";
|
|
|
135 |
graph.balloonText = "<span style='color:#555555;'>[[category]]</span><br><span class='font-size:14px'>[[title]]:<b>[[value]]</b></span>";
|
|
|
136 |
chart.addGraph(graph);
|
|
|
137 |
|
|
|
138 |
// LEGEND
|
|
|
139 |
var legend = new AmCharts.AmLegend();
|
|
|
140 |
legend.borderAlpha = 0.2;
|
|
|
141 |
legend.horizontalGap = 10;
|
|
|
142 |
chart.addLegend(legend);
|
|
|
143 |
|
|
|
144 |
// WRITE
|
|
|
145 |
chart.write("chartdiv");
|
|
|
146 |
});
|
|
|
147 |
|
|
|
148 |
// this method sets chart 2D/3D
|
|
|
149 |
function setDepth() {
|
|
|
150 |
if (document.getElementById("rb1").checked) {
|
|
|
151 |
chart.depth3D = 0;
|
|
|
152 |
chart.angle = 0;
|
|
|
153 |
} else {
|
|
|
154 |
chart.depth3D = 25;
|
|
|
155 |
chart.angle = 30;
|
|
|
156 |
}
|
|
|
157 |
chart.validateNow();
|
|
|
158 |
}
|
|
|
159 |
</script>
|
|
|
160 |
</head>
|
|
|
161 |
|
|
|
162 |
<body>
|
|
|
163 |
<div id="chartdiv" style="width: 600px; height: 400px;"></div>
|
|
|
164 |
<div style="margin-left:30px;">
|
|
|
165 |
<input type="radio" checked="true" name="group" id="rb1" onclick="setDepth()">2D
|
|
|
166 |
<input type="radio" name="group" id="rb2" onclick="setDepth()">3D
|
|
|
167 |
</div>
|
|
|
168 |
</body>
|
|
|
169 |
|
|
|
170 |
</html>
|