Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
5cbfb2a1
提交
5cbfb2a1
authored
12月 23, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(charts): fix echarts does not display after refresh #140
上级
f69aaeab
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
37 行增加
和
35 行删除
+37
-35
index.ts
src/components/Container/index.ts
+6
-4
useApexCharts.ts
src/hooks/web/useApexCharts.ts
+16
-20
useECharts.ts
src/hooks/web/useECharts.ts
+11
-6
MixSider.vue
src/layouts/default/sider/MixSider.vue
+4
-3
AnalysisPie.vue
src/views/dashboard/analysis/components/AnalysisPie.vue
+0
-1
TrendLine.vue
src/views/dashboard/analysis/components/TrendLine.vue
+0
-1
没有找到文件。
src/components/Container/index.ts
浏览文件 @
5cbfb2a1
import
{
withInstall
}
from
'../util'
;
import
CollapseContainer
from
'./src/collapse/CollapseContainer.vue'
;
import
{
createAsyncComponent
}
from
'/@/utils/factory/createAsyncComponent'
;
export
const
ScrollContainer
=
createAsyncComponent
(()
=>
import
(
'./src/ScrollContainer.vue'
));
export
const
CollapseContainer
=
createAsyncComponent
(
()
=>
import
(
'./src/collapse/CollapseContainer.vue'
)
);
// export const CollapseContainer = createAsyncComponent(
// () => import('./src/collapse/CollapseContainer.vue')
// );
export
const
LazyContainer
=
createAsyncComponent
(()
=>
import
(
'./src/LazyContainer.vue'
));
withInstall
(
ScrollContainer
,
CollapseContainer
,
LazyContainer
);
export
{
CollapseContainer
};
export
*
from
'./src/types'
;
src/hooks/web/useApexCharts.ts
浏览文件 @
5cbfb2a1
...
...
@@ -4,10 +4,14 @@ import { unref, Ref, nextTick } from 'vue';
import
ApexCharts
from
'apexcharts'
;
interface
CallBackFn
{
(
instance
:
Nullable
<
ApexCharts
>
):
void
;
}
export
function
useApexCharts
(
elRef
:
Ref
<
HTMLDivElement
>
)
{
let
chartInstance
:
Nullable
<
ApexCharts
>
=
null
;
function
setOptions
(
options
:
any
,
callback
)
{
function
setOptions
(
options
:
any
,
callback
?:
CallBackFn
)
{
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
const
el
=
unref
(
elRef
);
...
...
@@ -16,37 +20,29 @@ export function useApexCharts(elRef: Ref<HTMLDivElement>) {
chartInstance
=
new
ApexCharts
(
el
,
options
);
chartInstance
&&
chartInstance
.
render
();
// setOptions增加callback方法,返回chartInstance,以便于对图表进行再操作,例如调用updateOptions方法更新图表
callback
&&
callback
(
chartInstance
);
},
30
);
});
}
// 新增调用ApexCharts的updateOptions方法更新图表
function
updateOptions
(
chartInstance
:
Nullable
<
ApexCharts
>
,
options
,
redraw
=
false
,
animate
=
true
,
updateSyncedCharts
=
true
,
overwriteInitialConfig
=
true
,
callback
)
{
chartInstance
:
Nullable
<
ApexCharts
>
,
options
:
any
,
redraw
=
false
,
animate
=
true
,
updateSyncedCharts
=
true
,
callback
:
CallBackFn
)
{
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
chartInstance
&&
chartInstance
.
updateOptions
(
options
,
redraw
,
animate
,
updateSyncedCharts
);
chartInstance
&&
chartInstance
.
updateOptions
(
options
,
redraw
,
animate
,
updateSyncedCharts
,
overwriteInitialConfig
);
callback
&&
callback
(
chartInstance
);
},
30
);
});
});
}
tryOnUnmounted
(()
=>
{
...
...
src/hooks/web/useECharts.ts
浏览文件 @
5cbfb2a1
...
...
@@ -21,10 +21,10 @@ export function useECharts(
function
init
()
{
const
el
=
unref
(
elRef
);
if
(
!
el
||
!
unref
(
el
))
{
return
;
}
chartInstance
=
echarts
.
init
(
el
,
theme
);
const
{
removeEvent
}
=
useEventListener
({
el
:
window
,
...
...
@@ -33,7 +33,7 @@ export function useECharts(
});
removeResizeFn
=
removeEvent
;
const
{
widthRef
,
screenEnum
}
=
useBreakpoint
();
if
(
unref
(
widthRef
)
<=
screenEnum
.
MD
)
{
if
(
unref
(
widthRef
)
<=
screenEnum
.
MD
||
el
.
offsetHeight
===
0
)
{
useTimeoutFn
(()
=>
{
resizeFn
();
},
30
);
...
...
@@ -41,6 +41,12 @@ export function useECharts(
}
function
setOptions
(
options
:
any
,
clear
=
true
)
{
if
(
unref
(
elRef
)?.
offsetHeight
===
0
)
{
useTimeoutFn
(()
=>
{
setOptions
(
options
);
},
30
);
return
;
}
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
if
(
!
chartInstance
)
{
...
...
@@ -48,16 +54,15 @@ export function useECharts(
if
(
!
chartInstance
)
return
;
}
clear
&&
chartInstance
.
clear
();
clear
&&
chartInstance
?
.
clear
();
chartInstance
&&
chartInstance
.
setOption
(
options
);
chartInstance
?
.
setOption
(
options
);
},
30
);
});
}
function
resize
()
{
if
(
!
chartInstance
)
return
;
chartInstance
.
resize
();
chartInstance
?.
resize
();
}
tryOnUnmounted
(()
=>
{
...
...
src/layouts/default/sider/MixSider.vue
浏览文件 @
5cbfb2a1
...
...
@@ -110,7 +110,6 @@
getCanDrag
,
getCloseMixSidebarOnChange
,
getMenuTheme
,
getMixSidebarTheme
,
}
=
useMenuSetting
();
const
{
title
}
=
useGlobSetting
();
...
...
@@ -193,7 +192,6 @@
title
,
openMenu
,
getMenuTheme
,
getMixSidebarTheme
,
};
},
});
...
...
@@ -290,9 +288,12 @@
}
}
>
.scrollbar
{
height
:
calc
(
100%
-
@
header-height
)
!important
;
}
&
-module
{
position
:
relative
;
height
:
calc
(
100%
-
@
header-height
)
!important
;
padding-top
:
1px
;
&__item
{
...
...
src/views/dashboard/analysis/components/AnalysisPie.vue
浏览文件 @
5cbfb2a1
...
...
@@ -15,7 +15,6 @@
{
value
:
234
,
name
:
'其他'
,
itemStyle
:
{
color
:
'#7dd9b9'
}
},
];
export
default
defineComponent
({
name
:
'AnalysisLine'
,
props
:
basicProps
,
setup
()
{
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
...
...
src/views/dashboard/analysis/components/TrendLine.vue
浏览文件 @
5cbfb2a1
...
...
@@ -8,7 +8,6 @@
import
{
basicProps
}
from
'./props'
;
export
default
defineComponent
({
name
:
'AnalysisLine'
,
props
:
basicProps
,
setup
()
{
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论