英文:
How to remove one legend option for Semi circle donut?
问题
I need to leave just one legend option for this chart.
enter image description here
My code:
series: [{
name: 'Brands',
innerSize: '60%',
colorByPoint: true,
showInLegend: true,
data: [{
name: 'Chrome',
//showInLegend: true, ----doesn't work
y: 70.67,
}, {
name: 'Edge',
//showInLegend: true, ----doesn't work
y: 29.33
}]
}]
});
My demo: https://jsfiddle.net/artemShakun/otr34bm9/32/
I've tried to add showInLegend=true/false in series.data but it doesn't work.
英文:
I need to leave just one legend option for this chart.
enter image description here
My code:
series: [{
name: 'Brands',
innerSize: '60%',
colorByPoint: true,
showInLegend: true,
data: [{
name: 'Chrome',
//showInLegend: true, ----dosen't work
y: 70.67,
}, {
name: 'Edge',
//showInLegend: true, ----dosen't work
y: 29.33
} ]
}]
});
My demo: https://jsfiddle.net/artemShakun/otr34bm9/32/
I've tried to add showInLegend=true/false in series.data but it doesn't work.
答案1
得分: 0
以下是要翻译的代码部分:
(function(H) {
H.wrap(H.Legend.prototype, 'getAllItems', function(proceed) {
const items = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
items.pop();
return items;
});
}(Highcharts));
如果您需要其他内容的翻译,请提供具体文本。
英文:
It is not possible by using API options, but you can add this simple plugin below to achieve what you want.
(function(H) {
H.wrap(H.Legend.prototype, 'getAllItems', function(proceed) {
const items = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
items.pop();
return items;
});
}(Highcharts));
Live demo: https://jsfiddle.net/BlackLabel/ca94jsfm/
Docs: https://www.highcharts.com/docs/extending-highcharts/extending-highcharts
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论