Highcharts Motion Areaspline

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: 'areaspline'
    },
    title: {
        text: 'Fruit consumption during a week'
    },
    legend: {
        layout: 'vertical',
        align: 'left',
        verticalAlign: 'top',
        x: 150,
        y: 100,
        floating: true,
        borderWidth: 1,
        backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
    },
    xAxis: {
        categories: [
            'Monday',
            'Tuesday',
            'Wednesday',
            'Thursday',
            'Friday',
            'Saturday',
            'Sunday'
        ],
        plotBands: [{ // visualize the weekend
            from: 4.5,
            to: 6.5,
            color: 'rgba(68, 170, 213, .2)'
        }]
    },
    yAxis: {
        title: {
            text: 'Fruit units'
        }
    },
    tooltip: {
        shared: true,
        valueSuffix: ' units'
    },
    credits: {
        enabled: false
    },
    plotOptions: {
        areaspline: {
            fillOpacity: 0.5
        }
    },
    motion: {
        enabled: true,
        axisLabel: 'Week',
        labels: [
            "Week 31", "Week 32", "Week 33", "Week 34",
            "Week 35", "Week 36", "Week 37", "Week 38",
            "Week 39", "Week 40", "Week 41"
        ],
        series: [0, 1], // The series which holds points to update
        updateInterval: 15,
        magnet: {
            round: 'floor', // ceil / floor / round
            step: 0.02
        }
    },
    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]
            }, {
                sequence: [1, 5, 2, 7, 7, 1, 6, 9, 2, 5, 1]
            }, {
                sequence: [7, 1, 9, 3, 7, 4, 3, 8, 7, 1, 4]
            }, {
               ...