echarts中自定义toolbox,onclick事件不能获取return中的变量值

在vue开发中,echarts自定义图标,点击图标展示曲线图中数据和,平均值,最大值,引用return的变量后,但是不能获取这些数据。

在 formatter 函数中进行操作返回具体内容,类似以下这种:


  tooltip: {
    // ...
    formatter: (params) => {
      if (!params) {
        return;
      }
      let str = `${params[0].axisValue}<br/>`;
      params.map((item, index) => {
        str += `<span style="background:${params[index].color};border-radius: 50%;height:8px;width:8px;display:inline-block;margin-right:5px"></span>
        ${item.seriesName}:<span style="margin-left:20px;font-weight:500">${(`${formDate(item.data)}`)}</span><br/>`;
      });
      return str;
    },
    trigger: 'axis',
  },