官术网_书友最值得收藏!

  • Highcharts Essentials
  • Bilal Shahid
  • 156字
  • 2021-08-05 17:35:53

Negatively stacked bar charts

In this example, we will compare the average book consumption data for the year 2014 with the year 2012 using negative stacking. Copy the code from the previous example and include the data series for the year 2012, as shown in the following code:

series: [{
  name: '2014',
  data: [16, 17, 18, 13,15, 21]
}, {
  name: '2012',
  data: [-14, -15, -19, -19, -14, -19]
}]

To enable negative stacking, the data series must contain values in negative. We can now enable the stacking in the plotOptions component, as shown in the following code:

plotOptions: {
  series: {
    dataLabels: {
      enabled: true,
      formatter: function() {
        return this.y + '%';
      }
    },
    stacking: 'normal'
  }
}

However, the negatively stacked bars won't show until we change the min property in yAxis from 0 to -25.

Refresh the page and you should see a negatively stacked bar chart, as shown in the following screenshot:

主站蜘蛛池模板: 鲜城| 元朗区| 沛县| 张家川| 海安县| 昔阳县| 集贤县| 石景山区| 浮山县| 龙井市| 阳原县| 庆阳市| 社旗县| 衡山县| 枣强县| 华池县| 新化县| 北安市| 陇南市| 苍梧县| 克山县| 宜君县| 定边县| 武汉市| 青冈县| 阜新| 庄河市| 沾益县| 安溪县| 瑞丽市| 保亭| 巨野县| 贡嘎县| 海盐县| 文昌市| 城步| 新乐市| 泽库县| 买车| 明水县| 绥中县|