var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/CyPie/CyPie2d.tsx
var CyPie2d_exports = {};
__export(CyPie2d_exports, {
  default: () => CyPie2d_default
});
module.exports = __toCommonJS(CyPie2d_exports);
var import_echarts_for_react = __toESM(require("echarts-for-react"));
var import_react = require("react");
var Index = class extends import_react.Component {
  constructor() {
    super();
    this.resizeObserver = null;
  }
  componentDidMount() {
    const div = this.divRef;
    let main = this.mainRef;
    const resizeObserver = new ResizeObserver((entries) => {
      for (const entry of entries) {
        const { width, height } = entry.contentRect;
        main.style.transform = `scale(1.1)`;
        console.log(main, 19);
      }
    });
    resizeObserver.observe(div);
    this.resizeObserver = resizeObserver;
    const myChart = this.echartRef.getEchartsInstance();
    let index = 0;
    myChart.dispatchAction({
      type: "highlight",
      seriesIndex: index,
      dataIndex: index
    });
    myChart.on("mouseover", function(e) {
      if (e.dataIndex != index) {
        myChart.dispatchAction({
          type: "downplay",
          seriesIndex: 0,
          dataIndex: index
        });
      }
    });
    myChart.on("mouseout", function(e) {
      index = e.dataIndex;
      myChart.dispatchAction({
        type: "highlight",
        seriesIndex: 0,
        dataIndex: e.dataIndex
      });
    });
  }
  componentWillUnmount() {
    this.resizeObserver.disconnect();
  }
  getOption() {
    let colorList = ["#00F9FF", "#1978E5", "#FFF67C", "#60B45E", "#BECDD0"];
    let colorListShadow = [
      "rgba(25,63,87,1)",
      "rgba(14,39,86,1)",
      "rgba(56,64,63,1)",
      "rgba(94, 225, 204,.3)",
      "rgba(212,224,227,.1)"
    ];
    let data = this.props.optionsData;
    let outData = data.map((item, index) => {
      return {
        value: item.value,
        name: "",
        //因为不展示label，可不填
        itemStyle: {
          normal: {
            color: item.color || colorListShadow[index]
          }
        }
      };
    });
    var center = ["30%", "50%"];
    var radius = {
      内: ["55%", "60%"],
      pie: ["60%", "75%"],
      外: ["75%", "80%"]
    };
    let option = {
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b}: {c} ({d}%)"
      },
      legend: {
        itemGap: 30,
        selectedMode: false,
        orient: "vertical",
        right: 100,
        top: "center",
        align: "left",
        itemHeight: 16,
        itemWidth: 16,
        textStyle: {
          color: "white",
          rich: {
            name: {
              color: "#fff",
              fontSize: 20,
              lineHeight: 24
            },
            value: {
              color: "#fff",
              fontSize: 20,
              lineHeight: 24
            }
          }
        },
        data,
        formatter: function(name) {
          let nameSpace = (name == null ? void 0 : name.length) < 3 ? name + "   " : name;
          let value = data == null ? void 0 : data.find((item) => (item == null ? void 0 : item.name) == name).value;
          let html = `  {name|${nameSpace}}   {value|${value}}`;
          var arr = [html];
          return arr.join("\n");
        }
      },
      series: [
        {
          name: "项目",
          type: "pie",
          radius: radius["pie"],
          center,
          avoidLabelOverlap: false,
          color: colorList,
          label: {
            normal: {
              show: false,
              position: "center",
              formatter: "{b}\n\n{c}"
            },
            emphasis: {
              show: true,
              textStyle: {
                fontSize: "30",
                fontWeight: "bold",
                color: colorList
              }
            }
          },
          labelLine: {
            normal: {
              show: false
            }
          },
          data
        },
        {
          name: "内边框",
          type: "pie",
          tooltip: {
            show: false
          },
          clockWise: true,
          //顺时加载
          hoverAnimation: false,
          //鼠标移入变大
          center,
          //这里跟上面那组一样即可
          radius: radius["内"],
          //这里根据自己的需要自行调整
          label: {
            normal: {
              show: false
              //重点：此处主要是为了不展示data中的value和name
            }
          },
          data: outData
        },
        {
          name: "外边框",
          type: "pie",
          tooltip: {
            show: false
          },
          clockWise: true,
          //顺时加载
          hoverAnimation: false,
          //鼠标移入变大
          center,
          //这里跟上面那组一样即可
          radius: radius["外"],
          //这里根据自己的需要自行调整
          label: {
            normal: {
              show: false
              //重点：此处主要是为了不展示data中的value和name
            }
          },
          data: outData
        }
      ]
    };
    return option;
  }
  onChartClick() {
  }
  onChartLegendselectchanged() {
  }
  render() {
    const onEvents = {
      click: this.onChartClick,
      legendselectchanged: this.onChartLegendselectchanged
    };
    return /* @__PURE__ */ React.createElement(
      "div",
      {
        ref: (e) => {
          this.divRef = e;
        }
      },
      /* @__PURE__ */ React.createElement(
        "div",
        {
          ref: (e) => {
            this.mainRef = e;
          },
          ...this.props
        },
        /* @__PURE__ */ React.createElement(
          import_echarts_for_react.default,
          {
            onEvents,
            ref: (e) => {
              this.echartRef = e;
            },
            option: this.getOption(),
            theme: "Imooc",
            ...this.props
          }
        )
      )
    );
  }
};
var CyPie2d_default = Index;
