折线图柱状图利用tooltip添加事件

描述:当前是关于Echarts图表中的 示例。
 
            option = {
  tooltip:{
    trigger: 'axis',
    triggerOn:'click',
    alwaysShowContent:true,
    formatter:()=>{
       return null
    },
    axisPointer:{
      lineStyle:{
        color:'rgba(0,0,0,.1)'
      }
    }
  },
  backgroundColor:"#fff",
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  color:[
     '#f07426'
  ],
  series: [
    {
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line',
      silent:false,
      symbolSize:0
    }
  ]
};
myChart.on('showTip',(e)=>{
  console.log(e);
  [...document.querySelectorAll('.clickp')].map((n)=>n.remove());
  let text = `
  <li>
    <b>dataIndex:</b>${e.dataIndex}
  </li>
  <li>
    <b>点了x轴的:</b>${option.xAxis.data[e.dataIndex]}
  </li>
  <li>
    <b>seriesIndex:</b>${e.seriesIndex}
  </li>`
  let p = document.createElement('p');
  p.classList.add('clickp');
  p.innerHTML = text;
  p.style.position = 'fixed';
  p.style.left = '110px';
  p.style.top = 0;
  p.style.background='#fff'
  document.body.append(p)
})