如何在 highcharts 的多图表中隐藏 0 值?
How to hide 0 values in multi chart in highcharts?
我想隐藏 0 值,这是我的图表:
http://jsfiddle.net/phsx2azc/
您在饼图下方看到四个值“0”,看起来很混乱,我需要隐藏“0”值。所以我的问题是......我怎样才能隐藏“0”
多图表中的值?
我希望你能帮助我! :(
$(function () {
$('#container').highcharts({
title: {
text: 'Percepción y Satisfacción Origen DOM'
},
xAxis: {
categories: ['Noviembre', 'Diciembre', 'Enero', 'Meta']
},
yAxis: {
labels: {
format: '{value=0}'
}
},
labels: {
items: [{
html: 'Insatisfacción DOM',
style: {
left: '50px',
top: '18px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
}]
},
plotOptions: {
series: {
depth: 45,
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
distance: 0.5,
format: '{total} ',
color: '#FFFFFF',
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif',
textShadow: '0 0 3px black'
},
},
showInLegend: true,
pointPadding: 0,
groupPadding: 0,
borderColor: '#303030',
stacking: 'normal',
//colorByPoint: true
}
},
series: [{// columnas positivas
type: 'column',
stacking: 'normal',
name: 'Positivos',
colors: ['#009999','#009999','#009999','#FFFF00'],
data: [35,32,39,38,0,0,0,0],
colorByPoint: true,
},
{//columnas negativas
type:'column',
name: 'Negativos',
data: [-9, -8, -8],
colorByPoint: false,
},
{
//aquí empieza el pie chart
type: 'pie',
name: 'Percepción Origen',
data: [{
name: 'Check in',
y: 14,
color: '#13035f',
}, {
name: 'Embarque',
y: 24,
color: '#f03215',
}, {
name: 'Falta información',
y: 20,
color: '#FE7943',
},
{
name: 'Infraestructura',
y: 20,
color: '#DAFAA8',
},
{
name: 'Amabilidad',
y: 20,
color: '#BEF16D',
},
{
name: 'Comportamiento',
y: 20,
color: '#3ED72D',
},
{
name: 'Atraso vuelo',
y: 20,
color: '#148307',
},
{
name: 'Solicitudes especiales',
y: 20,
color: '#41B9FB', // Joe's color
}
],
center: [380, 80],
size: 200,
showInLegend: true,
dataLabels: {
enabled: true
}
}]
});
});
您在数据标签上同时使用了 format
和 formatter
。所以 format
隐藏了 formatter
并且它甚至不会 运行 函数。删除它,并在您的格式中使用 this.y
而不是 this.data
:DEMO
我想隐藏 0 值,这是我的图表: http://jsfiddle.net/phsx2azc/
您在饼图下方看到四个值“0”,看起来很混乱,我需要隐藏“0”值。所以我的问题是......我怎样才能隐藏“0” 多图表中的值? 我希望你能帮助我! :(
$(function () {
$('#container').highcharts({
title: {
text: 'Percepción y Satisfacción Origen DOM'
},
xAxis: {
categories: ['Noviembre', 'Diciembre', 'Enero', 'Meta']
},
yAxis: {
labels: {
format: '{value=0}'
}
},
labels: {
items: [{
html: 'Insatisfacción DOM',
style: {
left: '50px',
top: '18px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
}]
},
plotOptions: {
series: {
depth: 45,
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
distance: 0.5,
format: '{total} ',
color: '#FFFFFF',
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif',
textShadow: '0 0 3px black'
},
},
showInLegend: true,
pointPadding: 0,
groupPadding: 0,
borderColor: '#303030',
stacking: 'normal',
//colorByPoint: true
}
},
series: [{// columnas positivas
type: 'column',
stacking: 'normal',
name: 'Positivos',
colors: ['#009999','#009999','#009999','#FFFF00'],
data: [35,32,39,38,0,0,0,0],
colorByPoint: true,
},
{//columnas negativas
type:'column',
name: 'Negativos',
data: [-9, -8, -8],
colorByPoint: false,
},
{
//aquí empieza el pie chart
type: 'pie',
name: 'Percepción Origen',
data: [{
name: 'Check in',
y: 14,
color: '#13035f',
}, {
name: 'Embarque',
y: 24,
color: '#f03215',
}, {
name: 'Falta información',
y: 20,
color: '#FE7943',
},
{
name: 'Infraestructura',
y: 20,
color: '#DAFAA8',
},
{
name: 'Amabilidad',
y: 20,
color: '#BEF16D',
},
{
name: 'Comportamiento',
y: 20,
color: '#3ED72D',
},
{
name: 'Atraso vuelo',
y: 20,
color: '#148307',
},
{
name: 'Solicitudes especiales',
y: 20,
color: '#41B9FB', // Joe's color
}
],
center: [380, 80],
size: 200,
showInLegend: true,
dataLabels: {
enabled: true
}
}]
});
});
您在数据标签上同时使用了 format
和 formatter
。所以 format
隐藏了 formatter
并且它甚至不会 运行 函数。删除它,并在您的格式中使用 this.y
而不是 this.data
:DEMO