/**
 * 
 *     @dfsj/echarts： 专业的水文曲线组件或构造函数以及通用的echart二次封装图表
 *     版本: v3.7.0
 *     作者：yangbo <1747837358@qq.com>
 *     日期：2025-05-27 15:53:33
 *     
 *     
 */

import { shallowReactive, watch } from 'vue';
import { createComponent } from './createComponent.js';
import './Statistic.vue.js';
import script from './Statistic.vue2.js';

function useStatistic() {
  var props = shallowReactive({
    value: null,
    chart: null,
    visible: false,
    statistical: 0
  });
  var _createComponent = createComponent(script, props),
    close = _createComponent.close,
    open = _createComponent.open;
  var toggleStatistic = function toggleStatistic(visible) {
    if (visible !== undefined) {
      props.visible = visible;
    } else {
      props.visible = !props.visible;
    }
  };
  watch(function () {
    return props.visible;
  }, function (value, oldValue, onCleanup) {
    value ? open() : close();
  }, {
    immediate: true
  });
  return {
    close: close,
    open: open,
    props: props,
    toggleStatistic: toggleStatistic
  };
}

export { useStatistic };
