rikard
rikard

Reputation: 151

Highstock flags onSeries

I am using highstock and wants to add flags to my graphs.

I have two charts in the same container and are using "onSeries" to add the flags on the correct chart. However, the flags are always applied to the upper graph eventhough I specify in the "onSeries" parameter in my flags config.

fiddler: https://jsfiddle.net/rick822/mtw0oxxy/

$(function () {
    $('#container').highcharts('StockChart', {

        chart: {
          height: 1800
        },
        title : {
            text : 'AAPL Stock Price'
        },
        yAxis: [
            {
              labels: {},
              title: {
                text: 'test1'
              },
              height: 100,
              opposite: false,
              offset: 0
            },
            {
              labels: {},
              title: {
                text: 'test2'
              },
              height: 100,
              top: 300,
              opposite: false,
              offset: 0
            }
        ],
        series : [{
                name : 'AAPL',
                data : [[1241136000000,18.18],[1243555200000,19.40],[1246320000000,20.35]],
                id: 'test1',
                tooltip: {
                    valueDecimals: 2
                }
                ,
                yAxis: 0
            },
            {
                name : 'AAPL',
                data : [[1241136000000,18.18],[1243555200000,19.40],[1246320000000,20.35]],
                id: 'test2',
                tooltip: {
                    valueDecimals: 2
                },
                yAxis: 1
            },
            {
              type: 'flags',
              data: [{x: 1241136000000, title: "TEST1" }],
              onSeries: 'test1',
              shape: 'squarepin',
              width: 16,
              fillColor: 'red'
            },
            {
              type: 'flags',
              data: [{x: 1243555200000, title: "TEST2" }],
              onSeries: 'test2',
              shape: 'squarepin',
              width: 16,
              fillColor: 'lightgreen'
            }
        ]
    });
});

Upvotes: 1

Views: 453

Answers (1)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

As you have several y-axis you also have to specify the associated y-axis for the flag series, at least when they are not going to be on the index 0 y-axis.

For example (JSFiddle):

{
  type: 'flags',
  data: [{x: 1241136000000, title: "TEST1" }],
  onSeries: 'test1',
  shape: 'squarepin',
  width: 16,
  fillColor: 'red',
  yAxis: 0
},
{
  type: 'flags',
  data: [{x: 1243555200000, title: "TEST2" }],
  onSeries: 'test2',
  shape: 'squarepin',
  width: 16,
  fillColor: 'lightgreen',
  yAxis: 1
}

Upvotes: 1

Related Questions