Pavan Skipo
Pavan Skipo

Reputation: 1857

Highcharts - Plotbands on a column chart

I want to show plotband between the x-axis region ( a to c ). I tried the following, but still the plotband is not getting detected.

https://jsfiddle.net/pavanskipo/nsoaveph/7/

Below is the sample TS Code:

Highcharts.chart('container', {
  chart: {
    type: 'column'
  },
  xAxis: {
    plotBands: [{
      to: 'a',
      color: "#FFAAAA",
      from: 'c'
    }],
    categories: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"],
    crosshair: true
  },
  yAxis: {
    min: 0,
  },
  tooltip: {
    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
      '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
    footerFormat: '</table>',
    shared: true,
    useHTML: true
  },
  plotOptions: {
    column: {
      pointPadding: 0.2,
      borderWidth: 0
    }
  },
  series: [{
    "color": "#8085e9",
    "data": [null, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1],
    "name": "Linux"
  }, {
    "color": "#f15c80",
    "data": [1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, null, null],
    "name": "Others"
  }]
});

Upvotes: 1

Views: 588

Answers (1)

ppotaczek
ppotaczek

Reputation: 39069

You need to set the from and to properties as numeric values:

xAxis: {
    plotBands: [{
        to: 2.5,
        color: "#FFAAAA",
        from: -0.5

    }],
    ...
},

Live demo: https://jsfiddle.net/BlackLabel/gmj8eq0u/

API Reference: https://api.highcharts.com/highcharts/xAxis.plotBands.from

Upvotes: 2

Related Questions