1
formatter: (params, ticket, callback) => {
            return `<div class='exp-charts-tooltip'>
                <a class='exp-charts-tooltip-link' href="javascript:void(0);" onClick=${myCustomFunc(123)}>查看</a>
            </div>`
}

How can i handle click event in echarts tooltip formatter, i want to handle event in react component, not global scope, thank you~

YIP
  • 11
  • 4

1 Answers1

1

Formatter know nothing about you frontend-framework, it makes no sense to return from it something except HTML. I'm not use React but there must be a way to call handler outside. Anyway you can try to handle click from the global scope:

document.querySelector('body').addEventListener('click', e => {
  if(e.target.classList.contains('exp-charts-tooltip-link')){
    // do something ...
  }
});
Sergey Fedorov
  • 3,696
  • 2
  • 17
  • 21