chore: 构建重命名

This commit is contained in:
陈淳
2023-12-14 10:05:32 +08:00
parent 99b1deea3c
commit d4c3756f75
90 changed files with 13475 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import * as echarts from "echarts";
import { onMounted, onUnmounted, watch } from "vue";
import { debounce } from "@/utils/index";
import _ from "lodash";
// containerRef echarts实例 props 传入的值 baseOptions 图表初始化渲染
export default function useEcharts(containerRef, emits, props, baseOptions) {
let chart = null;
onMounted(() => {
chart = echarts.init(containerRef.value);
init();
chart.on("click", function (param) {
emits("chart-click", param);
});
//自适应不同屏幕时改变图表尺寸
window.addEventListener("resize", cancalDebounce);
});
// 用于将echarts实例暴露出去使用
const getChart = () => chart;
onUnmounted(() => {
chart && chart.dispose();
window.removeEventListener("resize", cancalDebounce);
});
function init() {
let option = _.cloneDeep(baseOptions);
chart.setOption(option);
chart.setOption(props.option);
}
function resize() {
chart && chart.resize();
}
watch(
() => props.option,
(val) => {
chart && chart.setOption(val);
},
{ deep: true }
);
const cancalDebounce = debounce(resize, 500);
return {
getChart,
resize,
};
}