简体   繁体   English

如何删除 Highcharts 中 SINGLE 图例的图例符号?

[英]How can I remove the legend symbol for a SINGLE legend in Highcharts?

I'm trying to change a single legend in Highcharts. Since Plot Lines and Bands can't have a legend, I've added an empty series so that when I select/de-select that legend, it would show/hide the plot lines.我正在尝试更改 Highcharts 中的单个图例。由于 Plot Lines and Bands 不能有图例,我添加了一个空系列,这样当我选择/取消选择该图例时,它会显示/隐藏 plot线。 Since my plot lines are vertical, I used this (code below) as my working around:因为我的 plot 行是垂直的,所以我使用这个(下面的代码)作为我的解决方法:

legend: {
        useHTML: true,
        labelFormatter: function() {
                        if (this.name == "Empty Series") {
                            return '<div class="my-plot-line-symbol" style="padding- 
                            left: 5px"> '+ this.name + '</div>';
                        } else {
                            return this.name;
                        }
                    }   
                },

...with the class being just a left border. ... class 只是左边框。

However, I cannot seem to remove the legend assigned to the empty series that I have.但是,我似乎无法删除分配给我的空系列的图例。 Basically it appears like this:基本上它看起来像这样:

<> | <> | My Plot Lines我的 Plot 线

(diamond as the default legend, "|" as the "class" I added) (菱形作为默认图例,“|”作为我添加的“类别”)

How can I remove the default legend for that single empty series?如何删除该单个空系列的默认图例?

Set marker.radius for the empty series to 0 :将空系列的marker.radius设置为0

    series: [..., {
        name: 'Collar',
        type: 'scatter',
        marker: {
            radius: 0
        }
    }]

Live demo: http://jsfiddle.net/BlackLabel/uhcnr8mf/现场演示: http://jsfiddle.net/BlackLabel/uhcnr8mf/

API Reference: https://api.highcharts.com/highcharts/series.scatter.marker.radius API 参考: https://api.highcharts.com/highcharts/series.scatter.marker.radius

Why are you returning HTML/JSX within the string?为什么要在字符串中返回 HTML/JSX? You could just simply do this..你可以简单地这样做..

return <div>
  ...
  ...
  ...
</div>

Is it not a valid syntax in vue.js?它不是 vue.js 中的有效语法吗? I'm actually working with React JS so maybe I'm wrong but atleast give this thing a try!我实际上正在使用 React JS,所以也许我错了,但至少试一试!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM