Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...