Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
躺着数星星
vue-element-admin
提交
13c1ecf2
V
vue-element-admin
项目概览
躺着数星星
/
vue-element-admin
与 Fork 源项目一致
Fork自
m0_73228581 / vue-element-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-element-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
13c1ecf2
编写于
5月 23, 2019
作者:
花
花裤衩
提交者:
GitHub
5月 23, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix[Chart]: fixed chart bug in keep-alive (#2119)
上级
8ce250a4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
68 addition
and
54 deletion
+68
-54
src/views/dashboard/admin/components/BarChart.vue
src/views/dashboard/admin/components/BarChart.vue
+2
-8
src/views/dashboard/admin/components/LineChart.vue
src/views/dashboard/admin/components/LineChart.vue
+6
-30
src/views/dashboard/admin/components/PieChart.vue
src/views/dashboard/admin/components/PieChart.vue
+2
-8
src/views/dashboard/admin/components/RaddarChart.vue
src/views/dashboard/admin/components/RaddarChart.vue
+2
-8
src/views/dashboard/admin/components/mixins/resize.js
src/views/dashboard/admin/components/mixins/resize.js
+56
-0
未找到文件。
src/views/dashboard/admin/components/BarChart.vue
浏览文件 @
13c1ecf2
...
...
@@ -5,11 +5,12 @@
<
script
>
import
echarts
from
'
echarts
'
require
(
'
echarts/theme/macarons
'
)
// echarts theme
import
{
debounce
}
from
'
@/utils
'
import
resize
from
'
./mixins/resize
'
const
animationDuration
=
6000
export
default
{
mixins
:
[
resize
],
props
:
{
className
:
{
type
:
String
,
...
...
@@ -33,18 +34,11 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
initChart
()
})
this
.
__resizeHandler
=
debounce
(()
=>
{
if
(
this
.
chart
)
{
this
.
chart
.
resize
()
}
},
100
)
window
.
addEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
window
.
removeEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
this
.
chart
.
dispose
()
this
.
chart
=
null
},
...
...
src/views/dashboard/admin/components/LineChart.vue
浏览文件 @
13c1ecf2
...
...
@@ -5,9 +5,10 @@
<
script
>
import
echarts
from
'
echarts
'
require
(
'
echarts/theme/macarons
'
)
// echarts theme
import
{
debounce
}
from
'
@/utils
'
import
resize
from
'
./mixins/resize
'
export
default
{
mixins
:
[
resize
],
props
:
{
className
:
{
type
:
String
,
...
...
@@ -32,8 +33,7 @@ export default {
},
data
()
{
return
{
chart
:
null
,
sidebarElm
:
null
chart
:
null
}
},
watch
:
{
...
...
@@ -48,38 +48,18 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
initChart
()
})
if
(
this
.
autoResize
)
{
this
.
__resizeHandler
=
debounce
(()
=>
{
if
(
this
.
chart
)
{
this
.
chart
.
resize
()
}
},
100
)
window
.
addEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
}
// 监听侧边栏的变化
this
.
sidebarElm
=
document
.
getElementsByClassName
(
'
sidebar-container
'
)[
0
]
this
.
sidebarElm
&&
this
.
sidebarElm
.
addEventListener
(
'
transitionend
'
,
this
.
sidebarResizeHandler
)
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
if
(
this
.
autoResize
)
{
window
.
removeEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
}
this
.
sidebarElm
&&
this
.
sidebarElm
.
removeEventListener
(
'
transitionend
'
,
this
.
sidebarResizeHandler
)
this
.
chart
.
dispose
()
this
.
chart
=
null
},
methods
:
{
sidebarResizeHandler
(
e
)
{
if
(
e
.
propertyName
===
'
width
'
)
{
this
.
__resizeHandler
()
}
initChart
()
{
this
.
chart
=
echarts
.
init
(
this
.
$el
,
'
macarons
'
)
this
.
setOptions
(
this
.
chartData
)
},
setOptions
({
expectedData
,
actualData
}
=
{})
{
this
.
chart
.
setOption
({
...
...
@@ -149,10 +129,6 @@ export default {
animationEasing
:
'
quadraticOut
'
}]
})
},
initChart
()
{
this
.
chart
=
echarts
.
init
(
this
.
$el
,
'
macarons
'
)
this
.
setOptions
(
this
.
chartData
)
}
}
}
...
...
src/views/dashboard/admin/components/PieChart.vue
浏览文件 @
13c1ecf2
...
...
@@ -5,9 +5,10 @@
<
script
>
import
echarts
from
'
echarts
'
require
(
'
echarts/theme/macarons
'
)
// echarts theme
import
{
debounce
}
from
'
@/utils
'
import
resize
from
'
./mixins/resize
'
export
default
{
mixins
:
[
resize
],
props
:
{
className
:
{
type
:
String
,
...
...
@@ -31,18 +32,11 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
initChart
()
})
this
.
__resizeHandler
=
debounce
(()
=>
{
if
(
this
.
chart
)
{
this
.
chart
.
resize
()
}
},
100
)
window
.
addEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
window
.
removeEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
this
.
chart
.
dispose
()
this
.
chart
=
null
},
...
...
src/views/dashboard/admin/components/RaddarChart.vue
浏览文件 @
13c1ecf2
...
...
@@ -5,11 +5,12 @@
<
script
>
import
echarts
from
'
echarts
'
require
(
'
echarts/theme/macarons
'
)
// echarts theme
import
{
debounce
}
from
'
@/utils
'
import
resize
from
'
./mixins/resize
'
const
animationDuration
=
3000
export
default
{
mixins
:
[
resize
],
props
:
{
className
:
{
type
:
String
,
...
...
@@ -33,18 +34,11 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
initChart
()
})
this
.
__resizeHandler
=
debounce
(()
=>
{
if
(
this
.
chart
)
{
this
.
chart
.
resize
()
}
},
100
)
window
.
addEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
},
beforeDestroy
()
{
if
(
!
this
.
chart
)
{
return
}
window
.
removeEventListener
(
'
resize
'
,
this
.
__resizeHandler
)
this
.
chart
.
dispose
()
this
.
chart
=
null
},
...
...
src/views/dashboard/admin/components/mixins/resize.js
0 → 100644
浏览文件 @
13c1ecf2
import
{
debounce
}
from
'
@/utils
'
export
default
{
data
()
{
return
{
$_sidebarElm
:
null
}
},
mounted
()
{
this
.
$_initResizeEvent
()
this
.
$_initSidebarResizeEvent
()
},
beforeDestroy
()
{
this
.
$_destroyResizeEvent
()
this
.
$_destroySidebarResizeEvent
()
},
// to fixed bug when cached by keep-alive
// https://github.com/PanJiaChen/vue-element-admin/issues/2116
activated
()
{
this
.
$_initResizeEvent
()
this
.
$_initSidebarResizeEvent
()
},
deactivated
()
{
this
.
$_destroyResizeEvent
()
this
.
$_destroySidebarResizeEvent
()
},
methods
:
{
// use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
$_resizeHandler
()
{
return
debounce
(()
=>
{
if
(
this
.
chart
)
{
this
.
chart
.
resize
()
}
},
100
)()
},
$_initResizeEvent
()
{
window
.
addEventListener
(
'
resize
'
,
this
.
$_resizeHandler
)
},
$_destroyResizeEvent
()
{
window
.
removeEventListener
(
'
resize
'
,
this
.
$_resizeHandler
)
},
$_sidebarResizeHandler
(
e
)
{
if
(
e
.
propertyName
===
'
width
'
)
{
this
.
$_resizeHandler
()
}
},
$_initSidebarResizeEvent
()
{
this
.
$_sidebarElm
=
document
.
getElementsByClassName
(
'
sidebar-container
'
)[
0
]
this
.
$_sidebarElm
&&
this
.
$_sidebarElm
.
addEventListener
(
'
transitionend
'
,
this
.
$_sidebarResizeHandler
)
},
$_destroySidebarResizeEvent
()
{
this
.
$_sidebarElm
&&
this
.
$_sidebarElm
.
removeEventListener
(
'
transitionend
'
,
this
.
$_sidebarResizeHandler
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录