diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index c8605c335a..bcc02afa36 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -361,12 +361,7 @@ export class VChart implements IVChart { this._currentThemeName = ThemeManager.getCurrentThemeName(); this._setNewSpec(spec); this._updateCurrentTheme(); - this._currentSize = calculateChartSize(this._spec, { - container: this._container, - canvas: this._canvas, - mode: this._option.mode || RenderModeEnum['desktop-browser'], - modeParams: this._option.modeParams - }); + this._currentSize = this.getCurrentSize(); this._compiler = new Compiler( { dom: this._container ?? 'none', @@ -545,12 +540,12 @@ export class VChart implements IVChart { } getCurrentSize() { - const { width: containerWidth, height: containerHeight } = getContainerSize( - this._container!, - DEFAULT_CHART_WIDTH, - DEFAULT_CHART_HEIGHT - ); - return { width: this._spec.width ?? containerWidth, height: this._spec.height ?? containerHeight }; + return calculateChartSize(this._spec, { + container: this._container, + canvas: this._canvas, + mode: this._option.mode || RenderModeEnum['desktop-browser'], + modeParams: this._option.modeParams + }); } private _doResize() {