Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
5cbfb2a1
Commit
5cbfb2a1
authored
Dec 23, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(charts): fix echarts does not display after refresh #140
parent
f69aaeab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
35 deletions
+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
No files found.
src/components/Container/index.ts
View file @
5cbfb2a1
import
{
withInstall
}
from
'
../util
'
;
import
{
withInstall
}
from
'
../util
'
;
import
CollapseContainer
from
'
./src/collapse/CollapseContainer.vue
'
;
import
{
createAsyncComponent
}
from
'
/@/utils/factory/createAsyncComponent
'
;
import
{
createAsyncComponent
}
from
'
/@/utils/factory/createAsyncComponent
'
;
export
const
ScrollContainer
=
createAsyncComponent
(()
=>
import
(
'
./src/ScrollContainer.vue
'
));
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
'
));
export
const
LazyContainer
=
createAsyncComponent
(()
=>
import
(
'
./src/LazyContainer.vue
'
));
withInstall
(
ScrollContainer
,
CollapseContainer
,
LazyContainer
);
withInstall
(
ScrollContainer
,
CollapseContainer
,
LazyContainer
);
export
{
CollapseContainer
};
export
*
from
'
./src/types
'
;
export
*
from
'
./src/types
'
;
src/hooks/web/useApexCharts.ts
View file @
5cbfb2a1
...
@@ -4,10 +4,14 @@ import { unref, Ref, nextTick } from 'vue';
...
@@ -4,10 +4,14 @@ import { unref, Ref, nextTick } from 'vue';
import
ApexCharts
from
'
apexcharts
'
;
import
ApexCharts
from
'
apexcharts
'
;
interface
CallBackFn
{
(
instance
:
Nullable
<
ApexCharts
>
):
void
;
}
export
function
useApexCharts
(
elRef
:
Ref
<
HTMLDivElement
>
)
{
export
function
useApexCharts
(
elRef
:
Ref
<
HTMLDivElement
>
)
{
let
chartInstance
:
Nullable
<
ApexCharts
>
=
null
;
let
chartInstance
:
Nullable
<
ApexCharts
>
=
null
;
function
setOptions
(
options
:
any
,
callback
)
{
function
setOptions
(
options
:
any
,
callback
?:
CallBackFn
)
{
nextTick
(()
=>
{
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
useTimeoutFn
(()
=>
{
const
el
=
unref
(
elRef
);
const
el
=
unref
(
elRef
);
...
@@ -16,37 +20,29 @@ export function useApexCharts(elRef: Ref<HTMLDivElement>) {
...
@@ -16,37 +20,29 @@ export function useApexCharts(elRef: Ref<HTMLDivElement>) {
chartInstance
=
new
ApexCharts
(
el
,
options
);
chartInstance
=
new
ApexCharts
(
el
,
options
);
chartInstance
&&
chartInstance
.
render
();
chartInstance
&&
chartInstance
.
render
();
// setOptions增加callback方法,返回chartInstance,以便于对图表进行再操作,例如调用updateOptions方法更新图表
// setOptions增加callback方法,返回chartInstance,以便于对图表进行再操作,例如调用updateOptions方法更新图表
callback
&&
callback
(
chartInstance
);
callback
&&
callback
(
chartInstance
);
},
30
);
},
30
);
});
});
}
}
// 新增调用ApexCharts的updateOptions方法更新图表
// 新增调用ApexCharts的updateOptions方法更新图表
function
updateOptions
(
function
updateOptions
(
chartInstance
:
Nullable
<
ApexCharts
>
,
chartInstance
:
Nullable
<
ApexCharts
>
,
options
,
options
:
any
,
redraw
=
false
,
redraw
=
false
,
animate
=
true
,
animate
=
true
,
updateSyncedCharts
=
true
,
updateSyncedCharts
=
true
,
overwriteInitialConfig
=
true
,
callback
:
CallBackFn
callback
)
{
)
{
nextTick
(()
=>
{
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
useTimeoutFn
(()
=>
{
chartInstance
&&
chartInstance
.
updateOptions
(
options
,
redraw
,
animate
,
updateSyncedCharts
);
chartInstance
&&
chartInstance
.
updateOptions
(
options
,
redraw
,
animate
,
updateSyncedCharts
,
overwriteInitialConfig
);
callback
&&
callback
(
chartInstance
);
callback
&&
callback
(
chartInstance
);
},
30
);
},
30
);
});
});
}
}
tryOnUnmounted
(()
=>
{
tryOnUnmounted
(()
=>
{
...
...
src/hooks/web/useECharts.ts
View file @
5cbfb2a1
...
@@ -21,10 +21,10 @@ export function useECharts(
...
@@ -21,10 +21,10 @@ export function useECharts(
function
init
()
{
function
init
()
{
const
el
=
unref
(
elRef
);
const
el
=
unref
(
elRef
);
if
(
!
el
||
!
unref
(
el
))
{
if
(
!
el
||
!
unref
(
el
))
{
return
;
return
;
}
}
chartInstance
=
echarts
.
init
(
el
,
theme
);
chartInstance
=
echarts
.
init
(
el
,
theme
);
const
{
removeEvent
}
=
useEventListener
({
const
{
removeEvent
}
=
useEventListener
({
el
:
window
,
el
:
window
,
...
@@ -33,7 +33,7 @@ export function useECharts(
...
@@ -33,7 +33,7 @@ export function useECharts(
});
});
removeResizeFn
=
removeEvent
;
removeResizeFn
=
removeEvent
;
const
{
widthRef
,
screenEnum
}
=
useBreakpoint
();
const
{
widthRef
,
screenEnum
}
=
useBreakpoint
();
if
(
unref
(
widthRef
)
<=
screenEnum
.
MD
)
{
if
(
unref
(
widthRef
)
<=
screenEnum
.
MD
||
el
.
offsetHeight
===
0
)
{
useTimeoutFn
(()
=>
{
useTimeoutFn
(()
=>
{
resizeFn
();
resizeFn
();
},
30
);
},
30
);
...
@@ -41,6 +41,12 @@ export function useECharts(
...
@@ -41,6 +41,12 @@ export function useECharts(
}
}
function
setOptions
(
options
:
any
,
clear
=
true
)
{
function
setOptions
(
options
:
any
,
clear
=
true
)
{
if
(
unref
(
elRef
)?.
offsetHeight
===
0
)
{
useTimeoutFn
(()
=>
{
setOptions
(
options
);
},
30
);
return
;
}
nextTick
(()
=>
{
nextTick
(()
=>
{
useTimeoutFn
(()
=>
{
useTimeoutFn
(()
=>
{
if
(
!
chartInstance
)
{
if
(
!
chartInstance
)
{
...
@@ -48,16 +54,15 @@ export function useECharts(
...
@@ -48,16 +54,15 @@ export function useECharts(
if
(
!
chartInstance
)
return
;
if
(
!
chartInstance
)
return
;
}
}
clear
&&
chartInstance
.
clear
();
clear
&&
chartInstance
?
.
clear
();
chartInstance
&&
chartInstance
.
setOption
(
options
);
chartInstance
?
.
setOption
(
options
);
},
30
);
},
30
);
});
});
}
}
function
resize
()
{
function
resize
()
{
if
(
!
chartInstance
)
return
;
chartInstance
?.
resize
();
chartInstance
.
resize
();
}
}
tryOnUnmounted
(()
=>
{
tryOnUnmounted
(()
=>
{
...
...
src/layouts/default/sider/MixSider.vue
View file @
5cbfb2a1
...
@@ -110,7 +110,6 @@
...
@@ -110,7 +110,6 @@
getCanDrag
,
getCanDrag
,
getCloseMixSidebarOnChange
,
getCloseMixSidebarOnChange
,
getMenuTheme
,
getMenuTheme
,
getMixSidebarTheme
,
}
=
useMenuSetting
();
}
=
useMenuSetting
();
const
{
title
}
=
useGlobSetting
();
const
{
title
}
=
useGlobSetting
();
...
@@ -193,7 +192,6 @@
...
@@ -193,7 +192,6 @@
title
,
title
,
openMenu
,
openMenu
,
getMenuTheme
,
getMenuTheme
,
getMixSidebarTheme
,
};
};
},
},
});
});
...
@@ -290,9 +288,12 @@
...
@@ -290,9 +288,12 @@
}
}
}
}
> .scrollbar {
height: calc(100% - @header-height) !important;
}
&-module {
&-module {
position: relative;
position: relative;
height: calc(100% - @header-height) !important;
padding-top: 1px;
padding-top: 1px;
&__item {
&__item {
...
...
src/views/dashboard/analysis/components/AnalysisPie.vue
View file @
5cbfb2a1
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
{
value
:
234
,
name
:
'
其他
'
,
itemStyle
:
{
color
:
'
#7dd9b9
'
}
},
{
value
:
234
,
name
:
'
其他
'
,
itemStyle
:
{
color
:
'
#7dd9b9
'
}
},
];
];
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
AnalysisLine
'
,
props
:
basicProps
,
props
:
basicProps
,
setup
()
{
setup
()
{
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
...
...
src/views/dashboard/analysis/components/TrendLine.vue
View file @
5cbfb2a1
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
import
{
basicProps
}
from
'
./props
'
;
import
{
basicProps
}
from
'
./props
'
;
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
AnalysisLine
'
,
props
:
basicProps
,
props
:
basicProps
,
setup
()
{
setup
()
{
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
const
chartRef
=
ref
<
HTMLDivElement
|
null
>
(
null
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment