Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b785bc57
authored
Jan 12, 2025
by
Netfan
Committed by
GitHub
Jan 12, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: useEcharts return invalid instance (#5360)
1 parent
6719e267
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
packages/effects/plugins/src/echarts/use-echarts.ts
packages/effects/plugins/src/echarts/use-echarts.ts
View file @
b785bc5
...
@@ -2,6 +2,8 @@ import type { EChartsOption } from 'echarts';
...
@@ -2,6 +2,8 @@ import type { EChartsOption } from 'echarts';
import
type
{
Ref
}
from
'vue'
;
import
type
{
Ref
}
from
'vue'
;
import
type
{
Nullable
}
from
'@vben/types'
;
import
type
EchartsUI
from
'./echarts-ui.vue'
;
import
type
EchartsUI
from
'./echarts-ui.vue'
;
import
{
computed
,
nextTick
,
watch
}
from
'vue'
;
import
{
computed
,
nextTick
,
watch
}
from
'vue'
;
...
@@ -50,7 +52,10 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
...
@@ -50,7 +52,10 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
return
chartInstance
;
return
chartInstance
;
};
};
const
renderEcharts
=
(
options
:
EChartsOption
,
clear
=
true
)
=>
{
const
renderEcharts
=
(
options
:
EChartsOption
,
clear
=
true
,
):
Promise
<
Nullable
<
echarts
.
ECharts
>>
=>
{
cacheOptions
=
options
;
cacheOptions
=
options
;
const
currentOptions
=
{
const
currentOptions
=
{
...
options
,
...
options
,
...
@@ -58,9 +63,8 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
...
@@ -58,9 +63,8 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
};
};
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
if
(
chartRef
.
value
?.
offsetHeight
===
0
)
{
if
(
chartRef
.
value
?.
offsetHeight
===
0
)
{
useTimeoutFn
(()
=>
{
useTimeoutFn
(
async
()
=>
{
renderEcharts
(
currentOptions
);
resolve
(
await
renderEcharts
(
currentOptions
));
resolve
(
null
);
},
30
);
},
30
);
return
;
return
;
}
}
...
@@ -72,7 +76,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
...
@@ -72,7 +76,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
}
}
clear
&&
chartInstance
?.
clear
();
clear
&&
chartInstance
?.
clear
();
chartInstance
?.
setOption
(
currentOptions
);
chartInstance
?.
setOption
(
currentOptions
);
resolve
(
null
);
resolve
(
chartInstance
);
},
30
);
},
30
);
});
});
});
});
...
@@ -109,7 +113,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
...
@@ -109,7 +113,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
return
{
return
{
renderEcharts
,
renderEcharts
,
resize
,
resize
,
chartInstance
,
getChartInstance
:
()
=>
chartInstance
,
};
};
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment