echarts [Bug] If the parameter universalTransition is set, animating Zoom will not be correct

wn9m85ua  于 7个月前  发布在  Echarts
关注(0)|答案(1)|浏览(83)

Version

5.4.2

https://codesandbox.io/s/clever-hamilton-n3jt3p?file=/src/Chart.tsx

Steps to Reproduce

https://codesandbox.io/s/clever-hamilton-n3jt3p?file=/src/Chart.tsx
When mapping charts, when you click the add button, the animation often starts zooming in from zoom:1 instead of starting from the current chart state.
If the universalTransition property is commented out, the zoom animation will behave as expected, but the transition animations between charts will disappear.

Current Behavior

When mapping charts, when you click the add button, the animation often starts zooming in from zoom:1 instead of starting from the current chart state.
If the universalTransition property is commented out, the zoom animation will behave as expected, but the transition animations between charts will disappear.

Expected Behavior

When the universalTransition property is set, the zoom animation for mapping charts will behave as expected.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

zlwx9yxi

zlwx9yxi1#

Yes, looks like a bug related to combination of animation and universalTransition .
Workaround - replace following three functions in your code:

const setMap = () => {
    var op = mapOption();
    op.animation= true;   // restore animation for the transition
    myChart.current.setOption(op, true);
  };

  const add = () => {
    const options = myChart.current.getOption();
    myChart.current.setOption({
      animation: false,
      series: [
        {
          zoom: Math.min(options.series[0].zoom + 1, 10)
        }
      ]
    });
  };

  const sub = () => {
    const options = myChart.current.getOption();
    myChart.current.setOption({
      animation: false,
      series: [
        {
          zoom: Math.max(options.series[0].zoom - 1,0)
        }
      ]
    });
  };

相关问题