CSS animations
Since v 3.12.0 all elements of the chart can have class names set - all you need to do is setting <strong>addClassNames</strong> property of a chart to <strong>true</strong>. This feature allows you to control the look of a chart using CSS and even more - use CSS animation to highlight specific areas in your chart. Note, CSS animations are not available on all browsers - even modern IE doesn't support them. Be careful - CSS animations use a lot of CPU resources.
by joseph8691
HTML
<script src="http://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="http://www.amcharts.com/lib/3/serial.js"></script>
<script src="http://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
CSS
#chartdiv {
width : 120%;
height : 400px;
}
.amcharts-graph-g2 .amcharts-graph-stroke {
stroke-dasharray: 8px 3px;
stroke-linejoin: round;
stroke-linecap: round;
-webkit-animation: am-moving-dashes 1s linear infinite;
animation: am-moving-dashes 1s linear infinite;
}
@-webkit-keyframes am-moving-dashes {
100% {
stroke-dashoffset: -31px;
}
}
@keyframes am-moving-dashes {
100% {
stroke-dashoffset: -31px;
}
}
.lastBullet {
-webkit-animation: am-pulsating 1s ease-out infinite;
animation: am-pulsating 1s ease-out infinite;
}
@-webkit-keyframes am-pulsating {
0% {
stroke-opacity: 1;
stroke-width: 0px;
}
100% {
stroke-opacity: 0;
stroke-width: 50px;
}
}
@keyframes am-pulsating {
0% {
stroke-opacity: 1;
stroke-width: 0px;
}
100% {
stroke-opacity: 0;
stroke-width: 50px;
}
}
.amcharts-graph-column-front {
-webkit-transition: all .3s .3s ease-out;
transition: all .3s .3s ease-out;
}
.amcharts-graph-column-front:hover {
fill: #496375;
stroke: #496375;
-webkit-transition: all .3s ease-out;
transition: all .3s ease-out;
}
.amcharts-graph-g3 {
stroke-linejoin: round;
stroke-linecap: round;
stroke-dasharray: 500%;
stroke-dasharray: 0 \0/; /* fixes IE prob */
stroke-dashoffset: 0 \0/; /* fixes IE prob */
-webkit-animation: am-draw 40s;
animation: am-draw 40s;
}
@-webkit-keyframes am-draw {
0% {
stroke-dashoffset: 500%;
}
100% {
stroke-dashoffset: 0px;
}
}
@keyframes am-draw {
0% {
stroke-dashoffset: 500%;
}
100% {
stroke-dashoffset: 0px;
}
}
/* OVERWRITE OUR MAIN STYLE */
.demo-flipper-front.demo-panel-white, body {
background-color: #161616;
}
JavaScript
var chartData = [
{
"date": "2012-01-01",
"distance": 227,
"townName": "New York",
"townName2": "New York",
"townSize": 25,
"latitude": 40.71,
"duration": 408
},
{
"date": "2012-01-02",
"distance": 371,
"townName": "Washington",
"townSize": 14,
"latitude": 38.89,
"duration": 482
},
{
"date": "2012-01-03",
"distance": 433,
"townName": "Wilmington",
"townSize": 6,
"latitude": 34.22,
"duration": 562
},
{
"date": "2012-01-04",
"distance": 345,
"townName": "Jacksonville",
"townSize": 7,
"latitude": 30.35,
"duration": 379
},
{
"date": "2012-01-05",
"distance": 480,
"townName": "Miami",
"townName2": "Miami",
"townSize": 10,
"latitude": 25.83,
"duration": 501
},
{
"date": "2012-01-06",
"distance": 386,
"townName": "Tallahassee",
"townSize": 7,
"latitude": 30.46,
"duration": 443
},
{
"date": "2012-01-07",
"distance": 348,
"townName": "New Orleans",
"townSize": 10,
"latitude": 29.94,
"duration": 405
},
{
"date": "2012-01-08",
"distance": 238,
"townName": "Houston",
"townName2": "Houston",
"townSize": 16,
"latitude": 29.76,
"duration": 309
},
{
"date": "2012-01-09",
"distance": 218,
"townName": "Dalas",
"townSize": 17,
"latitude": 32.8,
"duration": 287
},
{
"date": "2012-01-10",
"distance": 349,
"townName": "Oklahoma City",
"townSize": 11,
"latitude": 35.49,
"duration": 485
},
{
"date": "2012-01-11",
"distance": 603,
"townName": "Kansas City",
"townSize": 10,
...