2017-03-06 139 views
-1

下面是代码链接:https://jsfiddle.net/chong789456/a77pj67b/3/Highcharts堆栈列问题

Highcharts.chart('container', { 
    chart: { 
     type: 'column' 
    }, 
    title: { 
     text: 'Stacked column chart' 
    }, 
    xAxis: { 
     categories: ["c1", "c2", "c3", "c4"], 
    }, 
    yAxis: { 
     min: 0, 
     title: { 
      text: 'Total fruit consumption' 
     } 
    }, 
    legend: { 
     align: 'right', 
     x: -30, 
     verticalAlign: 'top', 
     y: 25, 
     floating: true, 
     backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', 
     borderColor: '#CCC', 
     borderWidth: 1, 
     shadow: false 
    }, 
    tooltip: { 
     useHTML: true, 
     formatter: function() { 
      var tooltip = ''; 
      tooltip = '<b style="color:' + this.point.series.color + ';">Type: </b>' + this.point.series.name + '<br>'; 
      tooltip += '<b style="color:' + this.point.series.color + ';">Clicks: </b>' + Highcharts.numberFormat(this.point.y, 0, '.', ',') + '<br>'; 
      return tooltip; 
     } 
    }, 
    plotOptions: { 
     column: { 
      stacking: 'normal'   
     }, 
     series: { 
      minPointLength: 10 
     } 
    }, 
    series: [ 
     { 
      color: '#8fdc87', 
      name: 'orange', 
      data: [ 
       14943,0,3857,34 
      ] 
     },{ 
      color: '#7CB5EC', 
      name: 'apple', 
      data: [ 
       0,0,0,0 
      ] 
     }, 
    ], 
}); 

我有4个类别(C1,C2,C3,C4)和2系列(橙,苹果)。

问题是,对于类别c4,橙色的数字是34,苹果的数字是0,只有苹果show4在c4,你可以在图表中看到。我想橙色显示有和工具提示也应该显示类似: 类型:橙色 浏览次数:34

我感到困惑的是橙色不C4显示为它的点击是不为0,任何人都可以帮忙吗?谢谢吨!

============================================== ===

我已经解决了这个问题吧! :)这里是链接: https://jsfiddle.net/75zk3w08/1/

series: [ 
    { 
     color: '#8fdc87', 
     name: 'orange', 
     data: [ 
      14943,null,3857,34 
     ] 
    },{ 
     color: '#7CB5EC', 
     name: 'apple', 
     data: [ 
      null,null,null,null 
     ] 
    }, 
], 

唯一不同的这些2个例子是串联部。如果我将该值设置为空,那么它将不会显示在图表中。

回答

0

可以设置Y轴:{分:0,最大值:100} 最小和最大y axis.this会影响Y轴比例作为你的榜样 你只设置最小y轴请检查下面的

+0

https://jsfiddle.net/gourav012/a77pj67b/6/ – Gourav

+0

嗨Gourav,我已经通过设置系列值为null解决了这个问题。但是,仍然感谢您的帮助:) – Chong