如何移除半圆环图的一个图例选项?

huangapple go评论137阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年3月7日 20:40:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75662099.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定