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

  • 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:

主站蜘蛛池模板: 古交市| 辽阳县| 磐安县| 贵州省| 名山县| 通渭县| 彩票| 通河县| 抚州市| 和龙市| 凤阳县| 华池县| 柳州市| 沁源县| 玉屏| 孟州市| 平顺县| 霞浦县| 富蕴县| 驻马店市| 西乌珠穆沁旗| 济阳县| 读书| 金寨县| 呈贡县| 新河县| 买车| 互助| 丹江口市| 隆化县| 栖霞市| 大竹县| 崇文区| 张家界市| 都江堰市| 肃北| 卢龙县| 讷河市| 林甸县| 会昌县| 屏南县|