import { cloneDeep as f, isArray as n } from "lodash";
class g {
  /**
   * 支持多系列`series` 仅支持单series描述单图形的图表，类似基础柱状图
   * @param data
   * @param series
   * @returns
   */
  static cloneSeries(s, e) {
    if (s !== void 0) {
      const t = s.length - e.length;
      for (let a = 0; a < t; a++)
        e.push(f(e[0]));
    }
    return e;
  }
  /**
   * 解析Dataset数据
   * @param keyData
   * @param dimensionsData
   * @returns
   */
  static parseDataset(s, e) {
    const t = {};
    n(s) ? s.forEach((o) => {
      const i = o.key;
      n(o.data) && o.data.forEach((l) => {
        const r = l.category, u = l.value;
        t[r] || (t[r] = { category: r }), t[r][i] ? t[r][i] += u : t[r][i] = u;
      });
    }) : t.key = {};
    const a = Object.values(t), c = Object.keys(a[0]), h = c.findIndex((o) => o === "category");
    return c.splice(h, 1), c.unshift("category"), {
      dimensions: e || c,
      source: Object.values(f(t))
    };
  }
  /**
   * 解析其他数据
   * @param keyData
   * @param basicOption
   * @returns
   */
  static parseOtherData(s, e) {
    const t = f(e);
    return s && n(s) && s.forEach((a, c) => {
      s[c] ? t.series[c].data = s[c].data : t.series[c].data = [];
    }), t;
  }
  /**
   * 解析散点图数据
   * @param keyData
   * @returns
   */
  static parseScatterData(s) {
    const e = [];
    return n(s) && s.forEach((t) => {
      n(t.data) && t.data.forEach((a) => {
        e.push([a.x, a.y, a.value]);
      });
    }), {
      source: e
    };
  }
}
export {
  g as EchartsUtils
};
