douliao7354
douliao7354
采纳率0%
2017-12-18 02:08

如何仅在钻取饼上显示数据标签?

hey guys i have did a bar chart drilldown to a pie chart so there is something called as "plotOptions" and "datalabels" in it, the datalabels shows the value of each bar/slice but i want the datalabel to only show on the pie chart and not the bar chart currently it is showing on the bar chart like this: enter image description here

As you can see the value "264.50%" and "164.50", i dont want to show that value. But i cant remove the datalabel from the code otherwise it wont show me on my pie chart as well.

so how can i remove it only from the bar chart? My code is as below:

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

</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duan0818 duan0818 4年前

    You can pass dataLables enable false in any level series you don`t want to see data labels

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

    http://jsfiddle.net/fw3bdjzw/

    点赞 评论 复制链接分享

相关推荐