Highcharts Demo

author(s): Torstein Hønsi

HTML

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



<div id="container"></div>

CSS

@import url("https://code.highcharts.com/css/highcharts.css");

#container {
    height: 400px;
    margin: auto;
    min-width: 310px;
    max-width: 600px;
}

.highcharts-boxplot-series .highcharts-point {
    stroke-width: 2px;
}

.highcharts-boxplot-box {
    fill: #f0f0e0;
    stroke-dasharray: 4, 2;
}

.highcharts-boxplot-median {
    stroke: #0c5da5;
    stroke-width: 3px;
}

.highcharts-boxplot-stem {
    stroke: #a63400;
    stroke-dasharray: 1, 2;
    stroke-width: 1px;
}

.highcharts-boxplot-whisker {
    stroke: #3d9200;
    stroke-width: 3px;
}

.highcharts-plot-line-label tspan {
    fill: gray;
}

JavaScript

Highcharts.chart('container', {

    chart: {
        type: 'boxplot',
        styledMode: true
    },

    title: {
        text: 'Highcharts Box Plot Example'
    },

    legend: {
        enabled: false
    },

    xAxis: {
        categories: ['1', '2', '3', '4', '5'],
        title: {
            text: 'Experiment No.'
        }
    },

    yAxis: {
        title: {
            text: 'Observations'
        },
        plotLines: [{
            value: 932,
            color: 'red',
            width: 1,
            label: {
                text: 'Theoretical mean: 932',
                align: 'center',
                style: {
                    color: 'gray'
                }
            }
        }]
    },

    series: [{
        name: 'Observations',
        data: [
            [760, 801, 848, 895, 965],
            [733, 853, 939, 980, 1080],
            [714, 762, 817, 870, 918],
            [724, 802, 806, 871, 950],
            [834, 836, 864, 882, 910]
        ],
        tooltip: {
            headerFormat: '<em>Experiment No {point.key}</em><br/>'
        }
    }, {
        name: 'Outlier',
        colorIndex: 0,
        type: 'scatter',
        data: [ // x, y positions where 0 is the first category
            [0, 644],
            [4, 718],
            [4, 951],
            [4, 969]
        ],
        marker: {
            fillColor: 'white',
            lineWidth: 1
            // lineColor: Highcharts.getOptions().colors[0]
        },
        tooltip: {
            pointFormat: 'Observation: {point.y}'
        }
    }]

});