Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization animation failure in ECharts #2932

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

CrystalWindSnake
Copy link
Contributor

This PR is aimed at solving the issue where ECharts charts' animations are interrupted by resize operations.

Below is a code snippet to reproduce the issue:

option = {
    "xAxis": {
        "type": "category",
        "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
    },
    "yAxis": {"type": "value"},
    "series": [{"data": [150, 230, 224, 218, 135, 147, 260], "type": "line"}],
    "animationDuration": 5000,
}

ui.echart(option)

The expected behavior is that when the chart is initially displayed, the line chart should have a fade-in animation from left to right, lasting for 5 seconds.

@falkoschindler falkoschindler self-requested a review April 22, 2024 17:20
Copy link
Contributor

@falkoschindler falkoschindler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this neat pull request, @CrystalWindSnake!
I never thought about ECharts' animations. It makes sense to wait for them to finish before canceling them with resizing the chart. I just hope nobody is confused because the chart now only starts resizing after a short animation duration. But I guess you usually don't start resizing the window right after loading the page.
Let's merge! 🙂

@falkoschindler falkoschindler added the bug Something isn't working label Apr 23, 2024
@falkoschindler falkoschindler added this to the 1.4.23 milestone Apr 23, 2024
@falkoschindler falkoschindler merged commit efd3bd6 into zauberzeug:main Apr 23, 2024
1 check passed
falkoschindler added a commit that referenced this pull request Apr 23, 2024
@falkoschindler
Copy link
Contributor

@CrystalWindSnake Sorry, I merged too early. The PR broke two of our pytests (test_nested_expansion and test_run_method). While trying to fix them, I noticed the following strange behavior:

# Ok, fills horizontal space.
ui.echart({
    "xAxis": {"type": "value"},
    "yAxis": {"type": "value"},
    "series": [{"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "line"}],
})

# Ok, 500px width.
ui.echart({
    "xAxis": {"type": "value"},
    "yAxis": {"type": "value"},
    "series": [{"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "line"}],
}).style('width: 500px')

# Weird, fills horizontal space during animation, then shrinks to 500px.
ui.echart({
    "xAxis": {"type": "value"},
    "yAxis": {"type": "value"},
    "series": [{"data": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "line"}],
}).classes('w-[500px]')

Somehow Tailwind classes cause a resize after the animation finished, while a normal CSS width is applied immediately. Do you have an idea what is going on and how to fix it?

Meanwhile I reverted the squashed merge commit to keep the main branch clean.

@falkoschindler falkoschindler removed this from the 1.4.23 milestone Apr 23, 2024
@CrystalWindSnake
Copy link
Contributor Author

@falkoschindler Apologies for the delayed response; I've been quite busy lately.

I found that Tailwind classes in the mounted hook of a Vue component will not take effect immediately. However, it seems that we can wait for the dom to update by calling await this.$nextTick(); in the mounted hook, and then the classes will take effect.

I will try to modify it and see if it can pass all the tests.

@CrystalWindSnake
Copy link
Contributor Author

@falkoschindler pr has been merged, should I submit a new pr?

@rodja
Copy link
Member

rodja commented May 12, 2024

Yes, please create a new PR @CrystalWindSnake. It's often the easiest way to validate and discuss a concept/idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants