F-loat / mpvue-echarts

📈 适用于 mpvue 的 echarts 组件
337 stars 91 forks source link

柱状图一点就消失了 #15

Closed houcz9 closed 6 years ago

houcz9 commented 6 years ago

柱状图一点就消失了,再点击出来了,经常闪烁

F-loat commented 6 years ago

原库就有这个问题,我再排查下,不行就得等他们更新了 https://github.com/ecomfe/echarts-for-weixin/issues/218

houcz9 commented 6 years ago

disableTouch=false禁用了触摸事件好了

F-loat commented 6 years ago

和触摸事件肯定是有关,但是也不能直接禁用了

F-loat commented 6 years ago

touchmove 事件做了去抖处理后基本不会出现那个问题了,你可以试下效果

// src/echarts.vue
touchMove(e) {
  if (!this.disableTouch && chart && e.mp.touches.length > 0) {
    const touch = e.mp.touches[0];
    if (this.timer) clearTimeout(this.timer);
    this.timer = setTimeout(() => {
      chart._zr.handler.dispatch('mousemove', {
        zrX: touch.x,
        zrY: touch.y,
      });
      console.log(touch.x, touch.y)
    }, 30)
  }
},
F-loat commented 6 years ago

更新最新版(v0.2.5)后,给柱状图设置 throttleTouch 属性即可

<mpvue-echarts :echarts="echarts" :onInit="onInit" throttleTouch />
houcz9 commented 6 years ago

ok,多谢