import { defaultSingleDataWithName } from "../assets/common";
import { getSingleDataWithName, val } from "../methods/methods";

/** 仪表盘 */
export class Gauge {
  /**
   * 获取仪表盘数据
   * @param name 名称
   * @param range 数据范围
   * @returns arr
   */
  static getGaugeData(name: string[], range?: number[]) {
    return getSingleDataWithName(name, range);
  }

  /**
   * 仪表盘0
   * @param data 数据
   * @param colorArr 颜色组
   * @returns option
   */
  static gauge0(data?: any, colorArr?: any[]) {
    const d = data ? data : defaultSingleDataWithName[0];
    const _colorArr = colorArr ? colorArr : val("colorData");
    const option = {
      backgroundColor: val("backgroundColor"),
      color: _colorArr,
      tooltip: {
        trigger: "item",
      },
      series: [
        {
          name: "Pressure",
          type: "gauge",
          progress: {
            show: true,
          },
          detail: {
            formatter: "{value}",
          },
          data: [d],
        },
      ],
    };
    console.log(option, "xxx");

    return option;
  }
}
