Search code examples
highchartshighcharts-ngangular2-highcharts

Plot Option in High Charts


I use "Column" type High chart to Show two different data sets in my application. Both data are marked in a same column chart as different series. But I need to set two various plotOption{} for the graphs.

Highcharts is throwing error if I set the property within the Series[].

If I set the Property using plotOptions{}, the property is getting applied for both the column Charts.

eg:

 series: [
    {
      type: 'column',
      name: 'Data1',
      data: data1,
      color: "#31598a",
      index: 0,
      legendIndex: 0
    },
    {
      type: 'column',
      name: 'Data2',
      data: data2,
      color: "#7e95a5",
    }]

here, I want to use the property "linkedTo: ':previous'" only for the 'data2' series..

 plotOptions: {
    column: {
      grouping: false,
      shadow: false,
      borderWidth: 0,
      pointPadding: 0.3,
      pointWidth:12
    }

Defining the property inside this plotOptions is applying it to both the column series..

Is there anyway to apply property only to one particular series??

Thanks in Advance.


Solution

  • You should define individual options for series directly and it should works.

    To workaround, you can create a new type of series, which will differ only by the type name from the column series and use it in plotOptions:

    var H = Highcharts;
    
    H.seriesType('column2', 'column');
    
    
    H.chart('container', {
        plotOptions: {
            column: {
                ...
            },
            column2: {
                ...
            }
        },
    
        series: [{
                type: 'column',
                ...
            },
            {
                type: 'column2',
                ...
            }
        ]
    });
    

    Live demo: http://jsfiddle.net/BlackLabel/omz0u7gs/