简体   繁体   English

Highcharts:去掉marker自带的图例Symbol

[英]Highcharts: Removing the legend Symbol that comes with marker

I have a line chart with marker enabled .我有一个启用了标记的折线图。 I also have my own custom legend Formatter我也有自己的自定义图例 Formatter

legend: {
        enabled: true,
        useHTML: true,
        labelFormatter: function() {
            let symbol = '<span style="color:' + this.color + ';font-size:12px;">&#9644;</span>';
            return '<span style="font-size: 12px;">' + symbol +  ' ' + this.name  +  '</span>';
        }
    }

Because of my marker, I get an additional line next to my custom legend symbol.由于我的标记,我在自定义图例符号旁边多了一条线。 I tried destroying my marker symbols using this solution LINK: http://jsfiddle.net/Tr7nk/2621/ But, I am getting errors when toggling the legends我尝试使用此解决方案破坏我的标记符号链接: http://jsfiddle.net/Tr7nk/2621/但是,切换图例时出现错误

ERROR TypeError: Cannot read property 'isSVG' of undefined
    at E.destroy (highcharts.src.js:4424)
    at t.<anonymous> (chart.component.ts:271)
    at Function.each (jquery.min.js:2)

Please help.请帮忙。 thanks谢谢

Instead of destroying the legend symbol, you can set symbolWidth to 0, to make it invisible.您可以将symbolWidth设置为 0,以使其不可见,而不是破坏图例符号。

    legend: {
        ...,
        symbolWidth: 0
    }

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

API Reference: https://api.highcharts.com/highcharts/legend.symbolWidth API 参考: https://api.highcharts.com/highcharts/legend.symbolWidth

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

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