mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-08-17 22:19:03 +08:00
fix: make the .chart
getter work with Vue 2
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
* Changed `updateOptions.lazyUpdate` to `true` by default. ([#533](https://github.com/ecomfe/vue-echarts/issues/533#issuecomment-809883909))
|
* Changed `updateOptions.lazyUpdate` to `true` by default. ([#533](https://github.com/ecomfe/vue-echarts/issues/533#issuecomment-809883909))
|
||||||
* Only perform an additional `resize` call after init within a task. ([#533](https://github.com/ecomfe/vue-echarts/issues/533#issuecomment-809883909))
|
* Only perform an additional `resize` call after init within a task. ([#533](https://github.com/ecomfe/vue-echarts/issues/533#issuecomment-809883909))
|
||||||
|
* The `.chart` getter API now works for Vue 2. (#542)
|
||||||
|
|
||||||
## 6.0.0-rc.4
|
## 6.0.0-rc.4
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-echarts",
|
"name": "vue-echarts",
|
||||||
"description": "Vue.js component for Apache ECharts.",
|
"description": "Vue.js component for Apache ECharts.",
|
||||||
"version": "6.0.0-rc.4",
|
"version": "6.0.0-rc.5",
|
||||||
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "GU Yiling <justice360@gmail.com>",
|
"author": "GU Yiling <justice360@gmail.com>",
|
||||||
|
@ -14,8 +14,7 @@ import {
|
|||||||
nextTick,
|
nextTick,
|
||||||
PropType,
|
PropType,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
Vue2,
|
Vue2
|
||||||
getCurrentInstance
|
|
||||||
} from "vue-demi";
|
} from "vue-demi";
|
||||||
import { init as initChart } from "echarts/core";
|
import { init as initChart } from "echarts/core";
|
||||||
import {
|
import {
|
||||||
@ -64,6 +63,9 @@ export default defineComponent({
|
|||||||
...loadingProps
|
...loadingProps
|
||||||
},
|
},
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
created() {
|
||||||
|
console.log(this);
|
||||||
|
},
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
setup(props, { attrs, listeners }) {
|
setup(props, { attrs, listeners }) {
|
||||||
@ -145,7 +147,16 @@ export default defineComponent({
|
|||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
if (instance && !instance.isDisposed()) {
|
if (instance && !instance.isDisposed()) {
|
||||||
|
// temporarily suppress errors caused by https://github.com/apache/echarts/issues/14846
|
||||||
|
try {
|
||||||
instance.resize();
|
instance.resize();
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message === "Cannot read property 'get' of undefined") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,23 +248,13 @@ export default defineComponent({
|
|||||||
|
|
||||||
onUnmounted(cleanup);
|
onUnmounted(cleanup);
|
||||||
|
|
||||||
const chartGetter = {
|
return {
|
||||||
get() {
|
chart,
|
||||||
return unref(chart);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const exposed = {
|
|
||||||
root,
|
root,
|
||||||
setOption,
|
setOption,
|
||||||
nonEventAttrs,
|
nonEventAttrs,
|
||||||
...publicApi
|
...publicApi
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(getCurrentInstance(), "chart", chartGetter);
|
|
||||||
Object.defineProperty(exposed, "chart", chartGetter);
|
|
||||||
|
|
||||||
return exposed;
|
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
const attrs = { ...this.nonEventAttrs };
|
const attrs = { ...this.nonEventAttrs };
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { Ref } from "vue-demi";
|
import { Ref, unref } from "vue-demi";
|
||||||
import { EChartsType, Option } from "../types";
|
import { EChartsType, Option } from "../types";
|
||||||
|
|
||||||
const METHOD_NAMES = [
|
const METHOD_NAMES = [
|
||||||
|
@ -557,8 +557,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.startActions();
|
this.startActions();
|
||||||
|
|
||||||
console.log(this.$refs.pie.chart);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user