-
Notifications
You must be signed in to change notification settings - Fork 19.8k
feat(core): use current device pixel ratio when resize #21489
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
base: master
Are you sure you want to change the base?
feat(core): use current device pixel ratio when resize #21489
Conversation
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the This PR depends on ZRender changes. Please update the ZRender dependency to the latest nightly version including this change, which takes place everyday at 8:00 UTC (16:00 Beijing Time). |
|
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-21489@a29afe9 |
src/core/echarts.ts
Outdated
| // Default to use window.devicePixelRatio to handle browser zoom changes. | ||
| const zrResizeOpts = opts ? extend({}, opts) : {}; | ||
| if (zrResizeOpts.devicePixelRatio == null && env.hasGlobalWindow) { | ||
| /* eslint-disable-next-line */ | ||
| zrResizeOpts.devicePixelRatio = window.devicePixelRatio; | ||
| } | ||
|
|
||
| this._zr.resize(zrResizeOpts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the devicePixelRatio is now fetched and used by zrender, I think we can move this logic to zrender. Here, we only need to pass the user-defined resize options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. The devicePixelRatio is fetched in zrender now.
Brief Information
This pull request is in the type of:
What does this PR do?
Auto update


devicePixelRatioonresize()to fix blurry chart after browser zoom.Zoom in to 500% and call
resize().Before:
After:
Fixed issues
Details
Before: What was the problem?
When browser zoom changes, calling
chart.resize()does not updatedevicePixelRatio, resulting in blurry charts.After: How does it behave after the fixing?
resize()now defaults to usewindow.devicePixelRatio, so charts automatically become crisp after browser zoom.Document Info
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
Merging options
Other information
N.A.