echarts 在worker线程中 无法实现tooltip

新手上路,请多包涵

Version

echarts 4.8.0

Steps to reproduce

1、仿照微信已实现 worker 线程绘制canvas 微信版echarts
2、实现 wx版 ec-canvas.js的touchaStart方法,方法可以触发,但handler.processGesture(wrapTouch(e), 'start')后canvas无响应

    touchStart(e) {
      if (this.chart && e.touches.length > 0) {

        var touch = e.touches[0];
        var handler = this.chart.getZr().handler;
        handler.dispatch('mousedown', {
          zrX: touch.x,
          zrY: touch.y
        });
        handler.dispatch('mousemove', {
          zrX: touch.x,
          zrY: touch.y
        });
        handler.processGesture(wrapTouch(e), 'start');
      }
    },

3、运行时差异, 微信版本和worker线程初始化的环境变量不一致,从而导致 var handler = this.chart.getZr().handler; 中 handler的值不一致

var env = {};

if (typeof genie === 'object' && typeof wx.getSystemInfoSync === 'function') {
    // In Weixin Application
    env = {
        browser: {},
        os: {},
        node: false,
        wxa: true, // Weixin Application
        canvasSupported: true,
        svgSupported: false,
        touchEventsSupported: true,
        domSupported: false
    };
}
else if (typeof document === 'undefined' && typeof self !== 'undefined') {
    // In worker
    env = {
        browser: {},
        os: {},
        node: false,
        worker: true,
        canvasSupported: true,
        domSupported: false
    };
}

image

What is expected?

显示 tooltip

What is actually happening?

不显示tooltip

阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题