Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
east-nanjing-new
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
郭铭瑶
east-nanjing-new
Commits
85a4712c
Commit
85a4712c
authored
Apr 17, 2021
by
郭铭瑶
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使my-pie返回实例
parent
65494cdb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
my-pie.vue
src/components/MyComponent/MyChart/my-pie.vue
+10
-3
useChartGenerate.ts
src/components/MyComponent/MyChart/useChartGenerate.ts
+5
-1
No files found.
src/components/MyComponent/MyChart/my-pie.vue
View file @
85a4712c
...
...
@@ -23,7 +23,8 @@ export default defineComponent({
default
:
null
,
},
},
setup
(
props
)
{
emits
:
[
'init'
],
setup
(
props
,
ctx
)
{
const
defaultOption
:
PieOption
=
{
backgroundColor
:
'transparent'
,
tooltip
:
{
...
...
@@ -54,8 +55,14 @@ export default defineComponent({
defaultOption
,
defaultSeriesItem
)
onMounted
(()
=>
initChart
(
props
.
dataset
,
props
.
option
))
watchEffect
(()
=>
initChart
(
props
.
dataset
,
props
.
option
))
onMounted
(()
=>
{
const
instance
:
any
=
initChart
(
props
.
dataset
,
props
.
option
)
instance
&&
ctx
.
emit
(
'init'
,
instance
)
})
watchEffect
(()
=>
{
const
instance
:
any
=
initChart
(
props
.
dataset
,
props
.
option
)
instance
&&
ctx
.
emit
(
'init'
,
instance
)
})
return
{
chartRef
,
}
...
...
src/components/MyComponent/MyChart/useChartGenerate.ts
View file @
85a4712c
...
...
@@ -202,7 +202,10 @@ const useChartGenerate = <T>(
* @param dataset 数据集
* @param option 自定义图表配置
*/
const
initChart
=
(
dataset
:
DatasetComponentOption
,
option
?:
ECOption
)
=>
{
const
initChart
=
(
dataset
:
DatasetComponentOption
,
option
?:
ECOption
):
any
=>
{
if
(
!
myChart
.
value
)
return
const
config
=
(
defaultSeriesItem
as
any
).
type
===
'radar'
...
...
@@ -214,6 +217,7 @@ const useChartGenerate = <T>(
:
defaultConfig
(
defaultOption
,
defaultSeriesItem
,
dataset
)
mergeOptions
(
config
,
option
)
myChart
.
value
.
setOption
(
transLinearColorOption
(
config
),
true
)
return
myChart
.
value
}
return
{
chartRef
,
initChart
}
...
...
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