Warm tip: This article is reproduced from serverfault.com, please click

javascript-高图:删除标记附带的图例

(javascript - Highcharts: Removing the legend Symbol that comes with marker)

发布于 2020-11-30 08:25:30

我有一个启用标记的折线图我也有自己的自定义图例格式化程序

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>';
        }
    }

由于有了标记,我的自定义图例符号旁边又增加了一行。我尝试使用此解决方案LINK销毁我的标记符号: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)

请帮忙。谢谢

Questioner
Kavvya Ramarathnam
Viewed
0
ppotaczek 2020-11-30 23:52:18

可以设置symbolWidth为0,以使其不可见,而不是破坏图例符号

    legend: {
        ...,
        symbolWidth: 0
    }

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

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