echarts 折线图单独添加数据时动画不显示

kt06eoxx  于 2022-11-02  发布在  Echarts
关注(0)|答案(3)|浏览(388)

Version

5.0.2

Steps to reproduce

在官方demo中 https://echarts.apache.org/examples/zh/editor.html?c=line-smooth 更改示例:

var option = {
        grid: {
          left: "10%",
          right: "10%",
          borderWidth: 10,
        },
        dataZoom: [
          {
            type: "inside",
            start: 90,
            end: 100,
            // startValue: 
            xAxisIndex: [0],
            zoomLock: true,
            minValueSpan:5,
            maxValueSpan:15,
          },
        ],
        xAxis: {
          type: "category",
          boundaryGap: true,
          // data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          data: [],
        },
        yAxis: {
          boundaryGap: [0, "30%"],
          type: "value",
        },
        series: [
          {
            name: "common",
            // data: [820, 932, 901, 934, 1290, 1330, 1320],
            data: [],
            type: "line",
            smooth: true,
            symbol: "none",
            // areaStyle: {
            // normal: {}
            // },
            stack:'a',
            animationEasing: "quadraticOut",
            animationDuration: 300,
            animationDurationUpdate: 1000,
            animationEasingUpdate: "quarticIn",
          },
        ],
      };

 var category = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
      var data = [820, 932, 901, 934, 1290, 1330, 1320];

function run(){
     myChart.setOption(option);
}

setTimeout(function() {
    run();
}, 0);

      var i = 0;
      setInterval(() => {
        console.log("INTERVAL " .i);

//1. 此种方式添加数据会有动画显示
        // category.push("Mon");
        if (i == 0) {
            // 2. 此种方式添加不会显示动画
          category.push("Mon", "Tue", "Wed", "Thu", "Fri");
          console.log("aa");
        }
        i++;
        if (i == 5) i = 0;

        data.push(Math.random() * 1000);

        myChart.setOption({
          xAxis: {
            data: category,
          },
          series: {
            name: "common",
            data: data,
          },
        });
      }, 1000);
  1. 单独添加数据
    category.push("Mon");
  2. 先添加x轴多个数据
    category.push("Mon", "Tue", "Wed", "Thu", "Fri");

What is expected?

第一种方式添加数据也会显示动画

What is actually happening?

第一种方式会显示动画,第二种动画不显示

raogr8fs

raogr8fs1#

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure thatyou have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org . Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list .

Have a nice day! 🍵

s3fp2yjn

s3fp2yjn2#

@meetpasser It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

Animation does not show when adding data to line chart alone

roqulrg3

roqulrg33#

我也遇到同样的问题,是否有解决方案。

相关问题