douliao7354 2017-12-18 02:08 采纳率: 0%
浏览 57
已采纳

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

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 2017-12-18 05:19
    关注

    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/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。