You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/09/07 00:22:02 UTC
[GitHub] [echarts] plainheart commented on issue #15648: Can I use `this` in formatter function? `this` is current echartsInstance(后续是否考虑在formatter函数中的 this 直接 指向当前的 echartsInstance )
plainheart commented on issue #15648:
URL: https://github.com/apache/echarts/issues/15648#issuecomment-913909379
Maybe you can bind the instance to your function manually.
For example,
```js
function getFormatter(instance, func) {
return func.bind(instance)
}
```
```js
chart1.setOption({
// ...
tooltip: {
formatter: getFormatter(chart1, function() {
console.log(this)
})
},
// ...
})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org