You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
532 B
Vue
32 lines
532 B
Vue
<template>
|
|
<div style="width: 100%;height: 100%" ref="chartRef" />
|
|
</template>
|
|
|
|
<script setup>
|
|
import * as echarts from 'echarts';
|
|
|
|
const props = defineProps({
|
|
defaultOption: Object
|
|
});
|
|
|
|
|
|
const chart = ref(null);
|
|
const option = ref(null);
|
|
const chartRef = ref();
|
|
|
|
const setData = (e) => {
|
|
option.value = e;
|
|
initChart(e);
|
|
};
|
|
const initChart = (option) => {
|
|
if (!chart.value) {
|
|
chart.value = echarts.init(chartRef.value, 'macarons');
|
|
}
|
|
chart.value.setOption(option, true);
|
|
};
|
|
|
|
defineExpose({
|
|
setData
|
|
});
|
|
</script>
|