From 8d4760104f3e633bcbbb54d55dd8320a30c7b1bf Mon Sep 17 00:00:00 2001
From: chuan_wuhao <443547225@qq.com>
Date: Thu, 1 Dec 2022 17:16:00 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?=E5=93=8D=E5=BA=94=E5=BC=8F=E5=B0=BA=E5=AF=B8=E5=8F=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dist/production-dist/index.html | 2 +-
src/components/RayChart/index.tsx | 13 ++++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dist/production-dist/index.html b/dist/production-dist/index.html
index 69a7163a..16e225ea 100644
--- a/dist/production-dist/index.html
+++ b/dist/production-dist/index.html
@@ -5,7 +5,7 @@
ray template
-
+
diff --git a/src/components/RayChart/index.tsx b/src/components/RayChart/index.tsx
index b7b31836..346a8918 100644
--- a/src/components/RayChart/index.tsx
+++ b/src/components/RayChart/index.tsx
@@ -21,6 +21,7 @@ import { LabelLayout, UniversalTransition } from 'echarts/features' // 标签自
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers' // `echarts` 渲染器
import { useSetting } from '@/store'
import { cloneDeep } from 'lodash-es'
+import { on, off } from '@/utils/element'
import type { PropType } from 'vue'
@@ -245,6 +246,12 @@ const RayChart = defineComponent({
}
}
+ const resizeChart = () => {
+ if (echartInstance) {
+ echartInstance.resize()
+ }
+ }
+
watch(
() => themeValue.value,
(theme) => {
@@ -276,11 +283,16 @@ const RayChart = defineComponent({
} else {
props.theme ? renderChart('dark') : renderChart('')
}
+
+ if (props.autoResize) {
+ on(window, 'resize', resizeChart)
+ }
})
})
onBeforeUnmount(() => {
destroyChart()
+ off(window, 'resize', resizeChart)
})
return {
@@ -313,5 +325,4 @@ export default RayChart
* 该组件会在卸载组件时, 自动释放资源
*
* 注意: 尽量别一次性倒入全部 `chart` 会造成打包体积异常大
- *
*/