Highcharts为长数据添加省略号

时间:2017-01-27 07:58:26

标签: javascript jquery highcharts

在下面的链接中,左侧和右侧数据显示不正确,我想在中心调整饼图并为可见数据添加省略号。

jsfiddle url:

http://jsfiddle.net/f0bqnba3

图片:

enter image description here

代码:

$(function () {
    Highcharts.chart('container', {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        },
        title: {
            text: 'Browser market shares January, 2015 to May, 2015'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    }
                }
            }
        },
        series: [{
            name: 'Brands',
            colorByPoint: true,
            data: [{
                name: 'National Institute of Information Technology and science laboratory',
                y: 56.33
            }, {
                name: 'Chrome',
                y: 24.03,
                sliced: true,
                selected: true
            }, {
                name: 'Firefox',
                y: 10.38
            }, {
                name: 'Safari',
                y: 4.77
            }, {
                name: 'Opera',
                y: 0.91
            }, {
                name: 'National Institute of Proprietary or Undetectable',
                y: 0.2
            }]
        }]
    });
});

1 个答案:

答案 0 :(得分:0)

在绘图选项中设置标签的宽度

plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                style: {
                    width: '100px'
                },
                enabled: true,
                color: '#000000',
                maxStaggerLines:1,                    
                connectorColor: '#000000',
                format: '<b>{point.name}</b>: {point.percentage:.1f} %'                   

            },
        }
    },

您的http://xsltransform.net/pPJ8LVQ/3