import { reactive } from 'vue';

export default function () {
  const maxNum = reactive({
    oneMin: 0,
    oneMax: 0,
    twoMin: 0,
    twoMax: 0,
    threeMin: 0,
    threeMax: 0,
  });
  const getMaxNum = (list: any, key: string) => {
    const max = Math.max(...list);
    // 这样处理是为了不让最大值刚好到坐标轴最顶部
    if (Math.ceil(max / 9.5) * 10 == 0) {
      maxNum[key] = 1;
    } else {
      maxNum[key] = Math.ceil(max / 9.5) * 10;
    }
  };
  const getMinNum = (list: any, key: string) => {
    const min = Math.min(...list);
    // 这样处理是为了不让最大值刚好到坐标轴最底部
    maxNum[key] = Math.floor(min / 12) * 10;
  };

  return {
    maxNum,
    getMaxNum,
    getMinNum,
  };
}
