diff --git a/src/core/echarts.ts b/src/core/echarts.ts index 89f810088b..de828717d9 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -238,6 +238,7 @@ export interface SetOptionOpts { export interface ResizeOpts { width?: number | 'auto', // Can be 'auto' (the same as null/undefined) height?: number | 'auto', // Can be 'auto' (the same as null/undefined) + devicePixelRatio?: number, animation?: AnimationOption silent?: boolean // by default false. }; @@ -1364,7 +1365,14 @@ class ECharts extends Eventful { return; } - this._zr.resize(opts); + // 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); const ecModel = this._model;