echarts - 自定义工具箱功能不起作用

发布于 2025-01-20 19:46:31 字数 1371 浏览 4 评论 0原文

我正在尝试向 echart 添加自定义工具箱功能,但收到以下错误:

Uncaught TypeError: Bind must be called on a function
    at bind (<anonymous>)
    at echarts.js:80214:30
    at each (echarts.js:423:24)
    at createIconPaths (echarts.js:80158:11)
    at DataDiffer.processFeature (echarts.js:80104:11)
    at DataDiffer._performRestAdd (echarts.js:30822:31)
    at DataDiffer._executeOneToOne (echarts.js:30739:14)
    at DataDiffer.execute (echarts.js:30702:79)
    at ToolboxView.render (echarts.js:80047:143)
    at echarts.js:29722:27

我尝试添加的功能如下:

myTool1: {
  show: true,
  title: 'custom method',
  icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
  onclick: function () {
                    alert('myTool1')
           }
}

看起来 onclick 功能选项未正确传递给 featureManager in埃图表。

有人经历过类似的事情吗?知道如何解决这个问题吗?

我使用的是echarts版本5.3.2

I 'm trying to add a custom toolbox feature to an echart and I'm getting the following error:

Uncaught TypeError: Bind must be called on a function
    at bind (<anonymous>)
    at echarts.js:80214:30
    at each (echarts.js:423:24)
    at createIconPaths (echarts.js:80158:11)
    at DataDiffer.processFeature (echarts.js:80104:11)
    at DataDiffer._performRestAdd (echarts.js:30822:31)
    at DataDiffer._executeOneToOne (echarts.js:30739:14)
    at DataDiffer.execute (echarts.js:30702:79)
    at ToolboxView.render (echarts.js:80047:143)
    at echarts.js:29722:27

The feature I'm trying to add is the following:

myTool1: {
  show: true,
  title: 'custom method',
  icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
  onclick: function () {
                    alert('myTool1')
           }
}

It looks like that the onclick feature option is not passed correctly to the featureManager in echarts.

Has anyone experienced something similar? Any idea how to solve this?

I'm using echarts version 5.3.2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

徒留西风 2025-01-27 19:46:31

外部功能;

alertFun():void {
  alert('myTool1')
}

埃图表

myTool1: {
  show: true,
  title: 'custom method',
  icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
  onclick: () => this.alertFun()
}

outSide function;

alertFun():void {
  alert('myTool1')
}

Echarts

myTool1: {
  show: true,
  title: 'custom method',
  icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
  onclick: () => this.alertFun()
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文