| 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 |
<style type="text/css">
|
|
|
11 |
|
|
|
12 |
.amcharts-graph-g1 .amcharts-graph-stroke {
|
|
|
13 |
stroke-dasharray: 3px 3px;
|
|
|
14 |
stroke-linejoin: round;
|
|
|
15 |
stroke-linecap: round;
|
|
|
16 |
-webkit-animation: am-moving-dashes 1s linear infinite;
|
|
|
17 |
animation: am-moving-dashes 1s linear infinite;
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
@-webkit-keyframes am-moving-dashes {
|
|
|
21 |
100% {
|
|
|
22 |
stroke-dashoffset: -30px;
|
|
|
23 |
}
|
|
|
24 |
}
|
|
|
25 |
@keyframes am-moving-dashes {
|
|
|
26 |
100% {
|
|
|
27 |
stroke-dashoffset: -30px;
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
.lastBullet {
|
|
|
33 |
-webkit-animation: am-pulsating 1s ease-out infinite;
|
|
|
34 |
animation: am-pulsating 1s ease-out infinite;
|
|
|
35 |
}
|
|
|
36 |
@-webkit-keyframes am-pulsating {
|
|
|
37 |
0% {
|
|
|
38 |
stroke-opacity: 1;
|
|
|
39 |
stroke-width: 0px;
|
|
|
40 |
}
|
|
|
41 |
100% {
|
|
|
42 |
stroke-opacity: 0;
|
|
|
43 |
stroke-width: 50px;
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
@keyframes am-pulsating {
|
|
|
47 |
0% {
|
|
|
48 |
stroke-opacity: 1;
|
|
|
49 |
stroke-width: 0px;
|
|
|
50 |
}
|
|
|
51 |
100% {
|
|
|
52 |
stroke-opacity: 0;
|
|
|
53 |
stroke-width: 50px;
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
.amcharts-graph-column-front {
|
|
|
58 |
-webkit-transition: all .3s .3s ease-out;
|
|
|
59 |
transition: all .3s .3s ease-out;
|
|
|
60 |
}
|
|
|
61 |
.amcharts-graph-column-front:hover {
|
|
|
62 |
fill: #496375;
|
|
|
63 |
stroke: #496375;
|
|
|
64 |
-webkit-transition: all .3s ease-out;
|
|
|
65 |
transition: all .3s ease-out;
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
.amcharts-graph-g2 {
|
|
|
70 |
stroke-linejoin: round;
|
|
|
71 |
stroke-linecap: round;
|
|
|
72 |
stroke-dasharray: 500%;
|
|
|
73 |
stroke-dasharray: 0 \0/; /* fixes IE prob */
|
|
|
74 |
stroke-dashoffset: 0 \0/; /* fixes IE prob */
|
|
|
75 |
-webkit-animation: am-draw 40s;
|
|
|
76 |
animation: am-draw 40s;
|
|
|
77 |
}
|
|
|
78 |
@-webkit-keyframes am-draw {
|
|
|
79 |
0% {
|
|
|
80 |
stroke-dashoffset: 500%;
|
|
|
81 |
}
|
|
|
82 |
100% {
|
|
|
83 |
stroke-dashoffset: 0px;
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
@keyframes am-draw {
|
|
|
87 |
0% {
|
|
|
88 |
stroke-dashoffset: 500%;
|
|
|
89 |
}
|
|
|
90 |
100% {
|
|
|
91 |
stroke-dashoffset: 0px;
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
</style>
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
<script>
|
|
|
102 |
// note, we have townName field with a name specified for each datapoint and townName2 with only some of the names specified.
|
|
|
103 |
// we use townName2 to display town names next to the bullet. And as these names would overlap if displayed next to each bullet,
|
|
|
104 |
// we created this townName2 field and set only some of the names for this purpse.
|
|
|
105 |
var chartData = [
|
|
|
106 |
{
|
|
|
107 |
"date": "2012-01-01",
|
|
|
108 |
"distance": 227,
|
|
|
109 |
"townName": "New York",
|
|
|
110 |
"townName2": "New York",
|
|
|
111 |
"townSize": 25,
|
|
|
112 |
"latitude": 40.71,
|
|
|
113 |
"duration": 408
|
|
|
114 |
},
|
|
|
115 |
{
|
|
|
116 |
"date": "2012-01-02",
|
|
|
117 |
"distance": 371,
|
|
|
118 |
"townName": "Washington",
|
|
|
119 |
"townSize": 14,
|
|
|
120 |
"latitude": 38.89,
|
|
|
121 |
"duration": 482
|
|
|
122 |
},
|
|
|
123 |
{
|
|
|
124 |
"date": "2012-01-03",
|
|
|
125 |
"distance": 433,
|
|
|
126 |
"townName": "Wilmington",
|
|
|
127 |
"townSize": 6,
|
|
|
128 |
"latitude": 34.22,
|
|
|
129 |
"duration": 562
|
|
|
130 |
},
|
|
|
131 |
{
|
|
|
132 |
"date": "2012-01-04",
|
|
|
133 |
"distance": 345,
|
|
|
134 |
"townName": "Jacksonville",
|
|
|
135 |
"townSize": 7,
|
|
|
136 |
"latitude": 30.35,
|
|
|
137 |
"duration": 379
|
|
|
138 |
},
|
|
|
139 |
{
|
|
|
140 |
"date": "2012-01-05",
|
|
|
141 |
"distance": 480,
|
|
|
142 |
"townName": "Miami",
|
|
|
143 |
"townName2": "Miami",
|
|
|
144 |
"townSize": 10,
|
|
|
145 |
"latitude": 25.83,
|
|
|
146 |
"duration": 501
|
|
|
147 |
},
|
|
|
148 |
{
|
|
|
149 |
"date": "2012-01-06",
|
|
|
150 |
"distance": 386,
|
|
|
151 |
"townName": "Tallahassee",
|
|
|
152 |
"townSize": 7,
|
|
|
153 |
"latitude": 30.46,
|
|
|
154 |
"duration": 443
|
|
|
155 |
},
|
|
|
156 |
{
|
|
|
157 |
"date": "2012-01-07",
|
|
|
158 |
"distance": 348,
|
|
|
159 |
"townName": "New Orleans",
|
|
|
160 |
"townSize": 10,
|
|
|
161 |
"latitude": 29.94,
|
|
|
162 |
"duration": 405
|
|
|
163 |
},
|
|
|
164 |
{
|
|
|
165 |
"date": "2012-01-08",
|
|
|
166 |
"distance": 238,
|
|
|
167 |
"townName": "Houston",
|
|
|
168 |
"townName2": "Houston",
|
|
|
169 |
"townSize": 16,
|
|
|
170 |
"latitude": 29.76,
|
|
|
171 |
"duration": 309
|
|
|
172 |
},
|
|
|
173 |
{
|
|
|
174 |
"date": "2012-01-09",
|
|
|
175 |
"distance": 218,
|
|
|
176 |
"townName": "Dalas",
|
|
|
177 |
"townSize": 17,
|
|
|
178 |
"latitude": 32.8,
|
|
|
179 |
"duration": 287
|
|
|
180 |
},
|
|
|
181 |
{
|
|
|
182 |
"date": "2012-01-10",
|
|
|
183 |
"distance": 349,
|
|
|
184 |
"townName": "Oklahoma City",
|
|
|
185 |
"townSize": 11,
|
|
|
186 |
"latitude": 35.49,
|
|
|
187 |
"duration": 485
|
|
|
188 |
},
|
|
|
189 |
{
|
|
|
190 |
"date": "2012-01-11",
|
|
|
191 |
"distance": 603,
|
|
|
192 |
"townName": "Kansas City",
|
|
|
193 |
"townSize": 10,
|
|
|
194 |
"latitude": 39.1,
|
|
|
195 |
"duration": 890
|
|
|
196 |
},
|
|
|
197 |
{
|
|
|
198 |
"date": "2012-01-12",
|
|
|
199 |
"distance": 534,
|
|
|
200 |
"townName": "Denver",
|
|
|
201 |
"townName2": "Denver",
|
|
|
202 |
"townSize": 18,
|
|
|
203 |
"latitude": 39.74,
|
|
|
204 |
"duration": 810
|
|
|
205 |
},
|
|
|
206 |
{
|
|
|
207 |
"date": "2012-01-13",
|
|
|
208 |
"townName": "Salt Lake City",
|
|
|
209 |
"townSize": 12,
|
|
|
210 |
"distance": 425,
|
|
|
211 |
"duration": 670,
|
|
|
212 |
"latitude": 40.75,
|
|
|
213 |
"alpha":0.4
|
|
|
214 |
},
|
|
|
215 |
{
|
|
|
216 |
"date": "2012-01-14",
|
|
|
217 |
"latitude": 36.1,
|
|
|
218 |
"duration": 470,
|
|
|
219 |
"townName": "Las Vegas",
|
|
|
220 |
"townName2": "Las Vegas",
|
|
|
221 |
"bulletClass": "lastBullet"
|
|
|
222 |
},
|
|
|
223 |
{
|
|
|
224 |
"date": "2012-01-15"
|
|
|
225 |
},
|
|
|
226 |
{
|
|
|
227 |
"date": "2012-01-16"
|
|
|
228 |
},
|
|
|
229 |
{
|
|
|
230 |
"date": "2012-01-17"
|
|
|
231 |
},
|
|
|
232 |
{
|
|
|
233 |
"date": "2012-01-18"
|
|
|
234 |
},
|
|
|
235 |
{
|
|
|
236 |
"date": "2012-01-19"
|
|
|
237 |
}
|
|
|
238 |
];
|
|
|
239 |
var chart;
|
|
|
240 |
|
|
|
241 |
AmCharts.ready(function () {
|
|
|
242 |
// SERIAL CHART
|
|
|
243 |
chart = new AmCharts.AmSerialChart();
|
|
|
244 |
chart.addClassNames = true;
|
|
|
245 |
chart.dataProvider = chartData;
|
|
|
246 |
chart.categoryField = "date";
|
|
|
247 |
chart.dataDateFormat = "YYYY-MM-DD";
|
|
|
248 |
chart.startDuration = 1;
|
|
|
249 |
chart.color = "#FFFFFF";
|
|
|
250 |
chart.marginLeft = 0;
|
|
|
251 |
|
|
|
252 |
// AXES
|
|
|
253 |
// category
|
|
|
254 |
var categoryAxis = chart.categoryAxis;
|
|
|
255 |
categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
|
|
|
256 |
categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
|
|
|
257 |
categoryAxis.autoGridCount = false;
|
|
|
258 |
categoryAxis.gridCount = 50;
|
|
|
259 |
categoryAxis.gridAlpha = 0.1;
|
|
|
260 |
categoryAxis.gridColor = "#FFFFFF";
|
|
|
261 |
categoryAxis.axisColor = "#555555";
|
|
|
262 |
// we want custom date formatting, so we change it in next line
|
|
|
263 |
categoryAxis.dateFormats = [{
|
|
|
264 |
period: 'DD',
|
|
|
265 |
format: 'DD'
|
|
|
266 |
}, {
|
|
|
267 |
period: 'WW',
|
|
|
268 |
format: 'MMM DD'
|
|
|
269 |
}, {
|
|
|
270 |
period: 'MM',
|
|
|
271 |
format: 'MMM'
|
|
|
272 |
}, {
|
|
|
273 |
period: 'YYYY',
|
|
|
274 |
format: 'YYYY'
|
|
|
275 |
}];
|
|
|
276 |
|
|
|
277 |
// as we have data of different units, we create three different value axes
|
|
|
278 |
// Distance value axis
|
|
|
279 |
var distanceAxis = new AmCharts.ValueAxis();
|
|
|
280 |
distanceAxis.title = "distance";
|
|
|
281 |
distanceAxis.gridAlpha = 0;
|
|
|
282 |
distanceAxis.axisAlpha = 0;
|
|
|
283 |
chart.addValueAxis(distanceAxis);
|
|
|
284 |
|
|
|
285 |
// latitude value axis
|
|
|
286 |
var latitudeAxis = new AmCharts.ValueAxis();
|
|
|
287 |
latitudeAxis.gridAlpha = 0;
|
|
|
288 |
latitudeAxis.axisAlpha = 0;
|
|
|
289 |
latitudeAxis.title = "duration and latitude";
|
|
|
290 |
latitudeAxis.offset = 83;
|
|
|
291 |
latitudeAxis.titleOffset = 10;
|
|
|
292 |
latitudeAxis.position = "right";
|
|
|
293 |
chart.addValueAxis(latitudeAxis);
|
|
|
294 |
|
|
|
295 |
// duration value axis
|
|
|
296 |
var durationAxis = new AmCharts.ValueAxis();
|
|
|
297 |
// the following line makes this value axis to convert values to duration
|
|
|
298 |
// it tells the axis what duration unit it should use. mm - minute, hh - hour...
|
|
|
299 |
durationAxis.duration = "mm";
|
|
|
300 |
durationAxis.durationUnits = {
|
|
|
301 |
DD: "d. ",
|
|
|
302 |
hh: "h ",
|
|
|
303 |
mm: "min",
|
|
|
304 |
ss: ""
|
|
|
305 |
};
|
|
|
306 |
durationAxis.gridAlpha = 0;
|
|
|
307 |
durationAxis.axisAlpha = 0;
|
|
|
308 |
durationAxis.inside = false;
|
|
|
309 |
durationAxis.position = "right";
|
|
|
310 |
chart.addValueAxis(durationAxis);
|
|
|
311 |
|
|
|
312 |
// GRAPHS
|
|
|
313 |
// distance graph
|
|
|
314 |
var distanceGraph = new AmCharts.AmGraph();
|
|
|
315 |
distanceGraph.valueField = "distance";
|
|
|
316 |
distanceGraph.title = "distance";
|
|
|
317 |
distanceGraph.type = "column";
|
|
|
318 |
distanceGraph.fillAlphas = 0.9;
|
|
|
319 |
distanceGraph.valueAxis = distanceAxis; // indicate which axis should be used
|
|
|
320 |
distanceGraph.balloonText = "[[value]] miles";
|
|
|
321 |
distanceGraph.legendValueText = "[[value]] mi";
|
|
|
322 |
distanceGraph.legendPeriodValueText = "total: [[value.sum]] mi";
|
|
|
323 |
distanceGraph.lineColor = "#263138";
|
|
|
324 |
distanceGraph.alphaField = "alpha";
|
|
|
325 |
chart.addGraph(distanceGraph);
|
|
|
326 |
|
|
|
327 |
// latitude graph
|
|
|
328 |
var latitudeGraph = new AmCharts.AmGraph();
|
|
|
329 |
latitudeGraph.valueField = "latitude";
|
|
|
330 |
latitudeGraph.id = "g1";
|
|
|
331 |
latitudeGraph.classNameField = "bulletClass";
|
|
|
332 |
latitudeGraph.title = "latitude/city";
|
|
|
333 |
latitudeGraph.type = "line";
|
|
|
334 |
latitudeGraph.valueAxis = latitudeAxis; // indicate which axis should be used
|
|
|
335 |
latitudeGraph.lineColor = "#786c56";
|
|
|
336 |
latitudeGraph.lineThickness = 1;
|
|
|
337 |
latitudeGraph.legendValueText = "[[description]]/[[value]]";
|
|
|
338 |
latitudeGraph.descriptionField = "townName";
|
|
|
339 |
latitudeGraph.bullet = "round";
|
|
|
340 |
latitudeGraph.bulletSizeField = "townSize"; // indicate which field should be used for bullet size
|
|
|
341 |
latitudeGraph.bulletBorderColor = "#786c56";
|
|
|
342 |
latitudeGraph.bulletBorderAlpha = 1;
|
|
|
343 |
latitudeGraph.bulletBorderThickness = 2;
|
|
|
344 |
latitudeGraph.bulletColor = "#000000";
|
|
|
345 |
latitudeGraph.labelText = "[[townName2]]"; // not all data points has townName2 specified, that's why labels are displayed only near some of the bullets.
|
|
|
346 |
latitudeGraph.labelPosition = "right";
|
|
|
347 |
latitudeGraph.balloonText = "latitude:[[value]]";
|
|
|
348 |
latitudeGraph.showBalloon = true;
|
|
|
349 |
latitudeGraph.animationPlayed = true;
|
|
|
350 |
chart.addGraph(latitudeGraph);
|
|
|
351 |
|
|
|
352 |
// duration graph
|
|
|
353 |
var durationGraph = new AmCharts.AmGraph();
|
|
|
354 |
durationGraph.id = "g2";
|
|
|
355 |
durationGraph.title = "duration";
|
|
|
356 |
durationGraph.valueField = "duration";
|
|
|
357 |
durationGraph.type = "line";
|
|
|
358 |
durationGraph.valueAxis = durationAxis; // indicate which axis should be used
|
|
|
359 |
durationGraph.lineColor = "#ff5755";
|
|
|
360 |
durationGraph.balloonText = "[[value]]";
|
|
|
361 |
durationGraph.lineThickness = 1;
|
|
|
362 |
durationGraph.legendValueText = "[[value]]";
|
|
|
363 |
durationGraph.bullet = "square";
|
|
|
364 |
durationGraph.bulletBorderColor = "#ff5755";
|
|
|
365 |
durationGraph.bulletBorderThickness = 1;
|
|
|
366 |
durationGraph.bulletBorderAlpha = 1;
|
|
|
367 |
durationGraph.dashLengthField = "dashLength";
|
|
|
368 |
durationGraph.animationPlayed = true;
|
|
|
369 |
chart.addGraph(durationGraph);
|
|
|
370 |
|
|
|
371 |
// CURSOR
|
|
|
372 |
var chartCursor = new AmCharts.ChartCursor();
|
|
|
373 |
chartCursor.zoomable = false;
|
|
|
374 |
chartCursor.categoryBalloonDateFormat = undefined;
|
|
|
375 |
chartCursor.cursorAlpha = 0;
|
|
|
376 |
chartCursor.valueBalloonsEnabled = false;
|
|
|
377 |
chartCursor.valueLineBalloonEnabled = true;
|
|
|
378 |
chartCursor.valueLineEnabled = true;
|
|
|
379 |
chartCursor.valueLineAlpha = 0.5;
|
|
|
380 |
chart.addChartCursor(chartCursor);
|
|
|
381 |
|
|
|
382 |
// LEGEND
|
|
|
383 |
var legend = new AmCharts.AmLegend();
|
|
|
384 |
legend.bulletType = "round";
|
|
|
385 |
legend.equalWidths = false;
|
|
|
386 |
legend.valueWidth = 120;
|
|
|
387 |
legend.useGraphSettings = true;
|
|
|
388 |
legend.color = "#FFFFFF";
|
|
|
389 |
chart.addLegend(legend);
|
|
|
390 |
|
|
|
391 |
// WRITE
|
|
|
392 |
chart.write("chartdiv");
|
|
|
393 |
});
|
|
|
394 |
</script>
|
|
|
395 |
</head>
|
|
|
396 |
|
|
|
397 |
<body style="background-color:#161616">
|
|
|
398 |
<div style="color:#ff5755; font-weight:bold; text-align:center;">Attention! CSS animations of SVG elements do not work on any version of IE</div>
|
|
|
399 |
<div id="chartdiv" style="width:100%; height:400px;"></div>
|
|
|
400 |
</body>
|
|
|
401 |
|
|
|
402 |
</html>
|