Highcharts basic annotations demo

author(s): Sebastian Domas

by Kieran Dang

HTML

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

<div id="container" style="height: 400px; margin-top: 1em"></div>

CSS

#container {
    max-width: 800px;
    margin: 0 auto;
}

JavaScript

Highcharts.chart('container', {

    title: {
        text: 'Highcharts Annotations'
    },
            labels: {
                format: '{value}¢',
                style: {
                    color: Highcharts.getOptions().colors[1]
                }
            },

    series: [{
        data: [{
            y: 29,
            id: 'id'
        }, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }],

    xAxis: {
        tickInterval: 0.5,
        gridLineWidth: 1
    },

    annotations: [{
        labels: [{
                point: {
                    x: 3,
                    y: 129.2,
                    xAxis: 0,
                    yAxis: 0
                },
                text: 'x: {x}<br/>y: {y}'
            },
            {
                point: 'id',
                text: 'x: {x}<br/>y: {y}'
            }
        ],
        labelOptions: {
            x: 40,
            y: -10
        }
    }]
});