echarts: [Bug] [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.

Version

5.4.1

Link to Minimal Reproduction

No response

Steps to Reproduce

import * as echarts from "echarts";

echarts.init(container);

Current Behavior

[Violation] Added non-passive event listener to a scroll-blocking ‘mousewheel’ event. Consider marking event handler as ‘passive’ to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

image

Expected Behavior

This violation warning should not display.

Environment

- OS: Windows 11
- Browser: 110.0.5481.77
- Framework: Vue 3

Any additional comments?

No response

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 31
  • Comments: 36 (1 by maintainers)

Most upvoted comments

I found the method of installing default-passive-events on the internet and the warning disappeared. But when I use the scrolling chart of echarts, I will report an error: Unable to preventDefault inside passive event listener invocation

Hello everyone, I added this package to my react project with echarts, did the import and it solved the warnings problem apparently.

Step 1: npm install default-passive-events --save-dev

Step 2: import ‘default-passive-events’

https://www.prestashop.com/forums/topic/901204-solved-uses-passive-event-listeners-to-improve-scrolling-performance-ps1742/

Package: https://www.npmjs.com/package/default-passive-events

1. Solution to errors during scroll zoomArea:

In node_modles, find the file: zrender/lib/core/event.js

Find the function: Export Function Addeventlistener (...

Comment or delete the current and insert {passive: false} instead of opt

Image

⚠️ Important: Clear Your Cache!

Your bundler (like Vite) creates a cache of your packages. After editing the file, you must clear this cache for your change to take effect.

Run the following command in your terminal to clear Vite’s cache:

rm -rf node_modules/.vite

2. Solution to warnings passive events

install npm install default-passive-events --save-dev

add into your main.js or mains.ts: import 'default-passive-events'

My package version is like below. and it is still make warning in console. “echarts”: “^5.5.1”, “echarts-for-react”: “^3.0.2”,

is there any way to optimize performance in echarts-for-react like “add passive property in echarts-for-react” ?

Some components like DataZoom will need to stop the scroll behavior, so it can’t be simply set as passive.