highchart 隱藏圖例中的某個圖例(legend)

 需求: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對象中

效果:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章