@fecp/mobile
Version:
75 lines (74 loc) • 1.79 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
require("../../utils/echartsUtil.js");
const core = require("../../../../../node_modules/.pnpm/echarts@5.6.0/node_modules/echarts/core.js");
const _sfc_main = {
__name: "BaseChart",
props: {
width: {
type: String,
default: "100%"
},
height: {
type: String,
default: "100%"
},
options: {
type: Object,
default: {}
}
},
setup(__props) {
const props = __props;
let myCharts = null;
const chartRef = vue.ref();
vue.onMounted(() => {
initChart();
});
vue.onBeforeUnmount(() => {
if (myCharts) {
myCharts.dispose();
}
});
function initChart() {
if (!myCharts) {
myCharts = core.init(chartRef.value);
myCharts.setOption(props.options);
myCharts.on("click", function(params) {
console.log("click", params);
});
myCharts.on("dblClick", function(params) {
console.log("dblClick", params);
});
} else {
updateChart();
}
}
vue.watch(
() => props.options,
() => {
updateChart();
},
{ deep: true }
);
function updateChart() {
if (myCharts) {
myCharts.setOption(props.options);
}
}
vue.onUpdated(() => {
if (myCharts) {
myCharts.resize();
}
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
ref_key: "chartRef",
ref: chartRef,
style: vue.normalizeStyle({ width: __props.width, height: __props.height })
}, null, 4);
};
}
};
exports.default = _sfc_main;