Answer to Stack Overflow question: http://stackoverflow.com/questions/38789340/highcharts-graphing-precipitation-types-volumes-and-intensity-over-time

Mike Zavarello

by Mike Zavarello

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

JavaScript

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Precipitation'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },
        yAxis: [{
            min: 0,
            title: {
                text: 'Preipitation volume (mm)'
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            }
        },{
            min: 0,
            title: {
                text: 'Preipitation intensity (mm/hr)'
            },
            opposite: true
        }],
        legend: {
            //align: 'bottom',
            //x: -30,
            //verticalAlign: 'bottom',
            //y: 25,
            //floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
            borderColor: '#CCC',
            borderWidth: 1,
            shadow: false
        },
        tooltip: {
            headerFormat: '<b>{point.x}</b><br/>',
            pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
        },
        plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                    style: {
                        textShadow: '0 0 3px black'
                    }
                }
            }
        },
        series: [{
            name: 'rain',
            data: [5, 3, 4, 7, 2],
            color: '#b3b3ff'
        }, {
            name: 'sleet',
            data: [2, 2, 3, 2, 1],
            color: '#d9b3ff'
        }, {
            name: 'snow',
            data: [3, 4, 4, 2, 5],
           ...