需求:highchart隱藏圖例中的某個圖例,只保留線,不要圖例
這裏D是不需要圖例的,要把D隱藏
代碼如下:
let report = { chart: { type: "spline", marginRight: 40, events: { load() { debugger; const chart = this; const allLegendItems = chart.legend.allItems; allLegendItems[allLegendItems.length - 1].legendGroup.hide(); } }, }, title: { text: "", },
注意點:這裏一定要把events放在chart對象中
效果: