Highcharts为长数据添加省略号 [英] Highcharts add ellipsis for long data

查看:574
本文介绍了Highcharts为长数据添加省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

jsfiddle url:





代码:

  $($)$($)$函数(){
Highcharts.chart('容器',{
图:{
plotBorderWidth:null,
plotBorderWidth:null,
plotShadow:false,
类型:'pie'
},
标题:{
text:'浏览器市场份额2015年1月至2015年5月'
},
工具提示:{
pointFor mat:'{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'
}
}
}
},
系列:[{
name:'Brands',
colorByPoint:true,
数据:[{
名称:'国立信息技术与科学实验室',
y:56.33
},{
名称:'Chrome',
y:24.03,
sliced:true,
selected:true
},{
name:'Firefox',
y:10.38
},{
名称:'Safari',
y:4.77
},{
名称:'Opera',
y:0.91
},{
名称:'国家专有或不可检测研究所',$ b $由:0.2
}]
}]
});
});


解决方案

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

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

},
}
},

您的叉子小提琴


In the below link , left and right side data is not showing properly, I want to adjust pie chart in center and add ellipsis for visible data.

jsfiddle url :

http://jsfiddle.net/f0bqnba3

Image :

Code:

$(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
            }]
        }]
    });
});

解决方案

set width for lables in plot options

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} %'                   

            },
        }
    },

Your Fork fiddle

这篇关于Highcharts为长数据添加省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆