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

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

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:

  1. series: [{
  2. name: 'Brands',
  3. innerSize: '60%',
  4. colorByPoint: true,
  5. showInLegend: true,
  6. data: [{
  7. name: 'Chrome',
  8. //showInLegend: true, ----doesn't work
  9. y: 70.67,
  10. }, {
  11. name: 'Edge',
  12. //showInLegend: true, ----doesn't work
  13. y: 29.33
  14. }]
  15. }]
  16. });

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:

  1. series: [{
  2. name: 'Brands',
  3. innerSize: '60%',
  4. colorByPoint: true,
  5. showInLegend: true,
  6. data: [{
  7. name: 'Chrome',
  8. //showInLegend: true, ----dosen't work
  9. y: 70.67,
  10. }, {
  11. name: 'Edge',
  12. //showInLegend: true, ----dosen't work
  13. y: 29.33
  14. } ]
  15. }]
  16. });

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

以下是要翻译的代码部分:

  1. (function(H) {
  2. H.wrap(H.Legend.prototype, 'getAllItems', function(proceed) {
  3. const items = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  4. items.pop();
  5. return items;
  6. });
  7. }(Highcharts));

如果您需要其他内容的翻译,请提供具体文本。

英文:

It is not possible by using API options, but you can add this simple plugin below to achieve what you want.

  1. (function(H) {
  2. H.wrap(H.Legend.prototype, 'getAllItems', function(proceed) {
  3. const items = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  4. items.pop();
  5. return items;
  6. });
  7. }(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:

确定