UNPKG

@dfsj/echarts

Version:

专业的水文曲线组件或构造函数以及通用的echart二次封装图表

104 lines (100 loc) 2.9 kB
/** * * @dfsj/echarts: 专业的水文曲线组件或构造函数以及通用的echart二次封装图表 * 版本: v3.7.0-alpha.5 * 作者:yangbo <1747837358@qq.com> * 日期:2025-11-21 13:30:34 * * */ import { defineComponent, ref, toRefs, watch, onUnmounted, openBlock, createElementBlock, createElementVNode, toRaw, unref } from 'vue'; import { statistics } from '../utils/statistics.js'; var _hoisted_1 = { "class": "assistant statistics" }; var _hoisted_2 = ["innerHTML"]; var script = defineComponent({ __name: 'Statistic', props: { value: { type: Object, required: true, "default": null }, chart: { type: null, required: true, "default": null }, visible: { type: Boolean, required: true, "default": false }, statistical: { type: Number, required: true, "default": 0 }, collect: { type: Function, required: true, "default": statistics } }, setup: function setup(__props) { var props = __props; var timer; var content = ref(null); var _toRefs = toRefs(props), chart = _toRefs.chart, visible = _toRefs.visible, value = _toRefs.value; var statistics = function statistics() { console.log('统计'); timer = clearTimeout(timer); timer = setTimeout(function () { content.value = props.collect(toRaw(unref(chart)), toRaw(unref(value))); }, props.statistical); }; watch(function () { return visible.value; }, function (value) { statistics(); if (value) bindEvent(); }); watch(function () { return chart.value; }, function () { bindEvent(); }); onUnmounted(function () { bindEvent(); }); onUnmounted(function () { unBindEvent(); }); function bindEvent() { unBindEvent(); if (chart.value) { var _chart$value, _chart$value2; (_chart$value = chart.value) === null || _chart$value === void 0 || _chart$value.on('datazoom', statistics); (_chart$value2 = chart.value) === null || _chart$value2 === void 0 || _chart$value2.on('legendselectchanged', statistics); } } function unBindEvent() { console.log(' props?.chart', chart.value); if (chart.value) { var _chart$value3, _chart$value4; (_chart$value3 = chart.value) === null || _chart$value3 === void 0 || _chart$value3.off('datazoom', statistics); (_chart$value4 = chart.value) === null || _chart$value4 === void 0 || _chart$value4.off('legendselectchanged', statistics); } } return function (_ctx, _cache) { return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", { innerHTML: content.value }, null, 8, _hoisted_2)]); }; } }); export { script as default };