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

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

主站蜘蛛池模板: 柳河县| 阿拉善盟| 陆丰市| 兴宁市| 洪江市| 汪清县| 宁夏| 博乐市| 镇原县| 京山县| 白沙| 连城县| 科尔| 中牟县| 山阳县| 漳浦县| 阿拉善右旗| 砀山县| 合水县| 万载县| 崇左市| 陕西省| 富阳市| 永康市| 泾源县| 鸡西市| 涿鹿县| 东乡县| 莱西市| 同仁县| 泾川县| 闻喜县| 马龙县| 监利县| 年辖:市辖区| 鹤岗市| 东阳市| 高陵县| 莎车县| 资阳市| 高陵县|