COLD TOLD
COLD TOLD

Reputation: 13579

Highchart: Adding flags to a line chart

I have a question on how to add a flag to line chart, I tried several ways but nothing seems to work, I have a chart that looks like this for example

$(function () {
    $('#container').highcharts({
        title: {
            text: 'Monthly Average Temperature',
            x: -20 //center
        },
        subtitle: {
            text: 'Source: WorldClimate.com',
            x: -20
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar']
        },
        yAxis: {
            title: {
                text: 'Temperature (°C)'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: '°C'
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{
            name: 'Tokyo',
            data: [7.0, 6.9, 9.5]
        } ]
    });
});

http://jsfiddle.net/t2uekmx2/

and I would like to add flags to it like in the following chart

http://jsfiddle.net/1tc3agv5/

Thanks.

Upvotes: 0

Views: 1262

Answers (2)

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

You can use something like annotations extension which allows to add custom shapes in user-friendly form.

Upvotes: 1

Nishith Kant Chaturvedi
Nishith Kant Chaturvedi

Reputation: 4769

Flag is available in highstock.js only, its not available in highcharts.js, you should update your js libs and then create flag using

    {
            type : 'flags',
            data : [{
                x : yourX,
                title : 'title here',
                text : 'your text'
            }

See Updated fiddle , if you define type of xAxis as dateTime provide dateTime's value in flag's x: yourX.

Upvotes: 1

Related Questions