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

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:

主站蜘蛛池模板: 双峰县| 弥渡县| 罗江县| 铜梁县| 灵石县| 上犹县| 三亚市| 宜宾县| 延边| 兴安盟| 南皮县| 呼玛县| 汤原县| 精河县| 宁武县| 深州市| 玉门市| 教育| 拜城县| 南华县| 遂平县| 横峰县| 游戏| 同德县| 宜章县| 三明市| 丰城市| 达尔| 汝城县| 广宗县| 洞口县| 隆化县| 玉山县| 三原县| 漳州市| 久治县| 遂昌县| 德阳市| 斗六市| 海阳市| 平远县|