2017-12-18 235 views
2

嘿傢伙我已經做了一個餅圖鑽取到一個餅圖,所以有一種叫做「plotOptions」和「datalabels」的東西,datalabels顯示每個bar/slice的值,但是我希望datalabel只顯示在餅圖而不是條形圖目前它顯示在這樣的條形圖上: enter image description here如何僅在鑽取餅圖上顯示數據標籤?

正如你可以看到值「264.50%」和「164.50」,我不想顯示該值。 但我不能刪除代碼中的數據標籤,否則它不會在我的餅圖上顯示我。

所以我怎樣才能從條形圖中刪除它?我的代碼如下:

<script> 
 

 
Highcharts.chart('container', { 
 
    chart: { 
 
     type: 'column' 
 
    }, 
 
    title: { 
 
     text: 'Chart' 
 
    }, 
 
    xAxis: { 
 
     type: 'category' 
 
    }, 
 
    yAxis: { 
 
     title: { 
 
      text: '' 
 
     } 
 

 
    }, 
 
    legend: { 
 
     enabled: false 
 
    }, 
 
    plotOptions: { 
 
     series: { 
 
      borderWidth: 0, 
 
      dataLabels: { 
 
       enabled: true, 
 
       formatter: function() { 
 
        var mychart = $('#container').highcharts(); 
 
        var mytotal = 0; 
 

 
        for (i = 0; i < mychart.series.length; i++) { 
 
         if (mychart.series[i].visible) { 
 
          mytotal = {!! $countTotalRecord['low confidence'] !!} + {!! $countTotalRecord['no answer'] !!} + {!! $countTotalRecord['missing intent'] !!} + {!! $countTotalRecord['webhook fail'] !!}; 
 
         } 
 
        } 
 
        var pcnt = (this.y/mytotal) * 100; 
 
        return Highcharts.numberFormat(pcnt) + '%'; 
 
       } 
 
      } 
 
     } 
 
    }, 
 

 
    tooltip: { 
 
     // headerFormat: '<span style="font-size:11px">{series.name}</span><br>', 
 
     pointFormat: '{point.name}: <b>{point.y}</b>' 
 
    }, 
 

 
    credits:{ 
 
     enabled: false 
 
    }, 
 

 
    series: [{ 
 
     name: 'front', 
 
     colorByPoint: true, 
 
     data: [{ 
 
      name: 'Total', 
 
      y: {!! $countTotalRecord['total'] !!}, 
 
      drilldown: 'total' 
 
     }, { 
 
      name: 'Match', 
 
      y: {!! $countTotalRecord['match'] !!}, 
 
      drilldown: 'match' 
 
     }] 
 
    }], 
 
    drilldown: { 
 
     series: [{ 
 
      name: 'total', 
 
      id: 'total', 
 
      type:'pie', 
 
      data: [ 
 
       [ 
 
        'Low Confidence', 
 
        {!! $countTotalRecord['low confidence'] !!} 
 
       ], 
 
       [ 
 
        'No Answer', 
 
        {!! $countTotalRecord['no answer'] !!} 
 
       ], 
 
       [ 
 
        'Missing Intent', 
 
        {!! $countTotalRecord['missing intent'] !!} 
 
       ], 
 
       [ 
 
        'Webhook Fail', 
 
        {!! $countTotalRecord['webhook fail'] !!} 
 
       ] 
 
      ] 
 
     }] 
 
    } 
 
}); 
 

 
</script>

回答

1

您可以通過dataLables讓你我想知道我看到數據的任何水平的一系列虛假標籤

series: [{ 
    name: 'Brands', 
    colorByPoint: true, 
    data: [{....}], 
    dataLabels: { 
      enabled: false, 
     } 
    }], 

http://jsfiddle.net/fw3bdjzw/

+0

是我也知道這種方式,但我喜歡我說我想要datalabelsto只顯示我的餅圖而不是條形圖。如果我將其改爲false,那麼它也不會在餅圖上顯示! @patata – anon

+0

試試這個http://jsfiddle.net/fw3bdjzw/2/。解釋我你想要什麼 – Patata

+0

是啊,這是即時通訊使用然後我調整它。你有沒有試過我提供的代碼?並看到圖片我想從上面的圖片中刪除的百分比 – anon