Highcharts Motion Bars
author(s): Lars Cabrera
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<script src="https://cdn.jsdelivr.net/gh/larsac07/Motion-Highcharts-Plugin/motion.js"></script>
<div id="container"></div>
CSS
@import "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css";
#container {
height: 400px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}
#play-controls {
text-align: center;
width: 100%;
padding: 5px 0 1em 0;
}
#play-controls * {
display: inline-block;
vertical-align: middle;
}
#play-pause-button {
width: 30px;
height: 30px;
text-align: center;
font-size: 15px;
outline: none;
cursor: pointer;
}
#play-range {
margin: 2.5%;
width: 70%;
}
#play-output {
font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
}
JavaScript
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
motion: {
enabled: true,
axisLabel: 'year',
labels: [2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010],
series: [0, 1], // The series which holds points to update
updateInterval: 20,
magnet: {
type: 'both', // thumb / point / both
round: 'floor', // ceil / floor / round
smoothThumb: true, // defaults to true
step: 0.01
}
},
series: [{
name: 'Jane',
data: [
{
sequence: [1, 5, 2, 7, 7, 1, 6, 9, 2, 5, 1]
}, {
sequence: [5, 5, 7, 7, 3, 8, 9, 9, 1, 7, 3]
}, {
sequence: [7, 1, 9, 3, 7, 4, 3, 8, 7, 1, 4]
}
]
}, {
name: 'John',
data: [
{
sequence: [7, 1, 9, 3, 7, 4, 3, 8, 7, 1, 4]
}, {
sequence: [1, 5, 2, 7, 7, 1, 6, 9, 2, 5, 1]
}, {
sequence: [9, 1, 7, 3, 3, 2, 1, 4, 5, 6, 7]
}
]
}]
});