"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var AlarmType = function AlarmType(props) {
  var data = props.data,
    total = props.total;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    chartFontColor = _useSettings.chartFontColor,
    chartColor = _useSettings.chartColor;
  var option = {
    color: chartColor,
    backgroundColor: 'transparent',
    tooltip: {
      trigger: 'item',
      formatter: function formatter(params) {
        var _a, _b;
        var unit = '次';
        var str = '';
        if (Array.isArray(params)) {
          str = "<div  style=\"text-align:left\">".concat((_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.axisValue, "<?div>");
          var color = (_b = params === null || params === void 0 ? void 0 : params[0].color) === null || _b === void 0 ? void 0 : _b.colorStops; // 获取系列的颜色
          params.map(function (item, index) {
            var _a;
            str += "<div  style=\"text-align:left\"><span style=\"color:".concat(item.color && typeof item.color == 'string' ? item.color : (_a = color === null || color === void 0 ? void 0 : color[index]) === null || _a === void 0 ? void 0 : _a.color, "\">\u2022</span> ").concat(item.seriesName, " &nbsp;&nbsp;&nbsp;").concat(item.value).concat(unit, "</div>");
          });
        } else {
          var _color = params === null || params === void 0 ? void 0 : params.color; // 获取系列的颜色
          str += "<div style=\"display:flex;align-items:center\"><span style=\"color:".concat(_color, ";font-size:24px \">\u2022</span>&nbsp;").concat(params === null || params === void 0 ? void 0 : params.name, "&nbsp;&nbsp;").concat(params.value).concat(unit, "</div>");
        }
        return str; // 返回带点的字符串
      }
    },
    title: {
      zlevel: 0,
      text: '总数',
      top: '30%',
      left: '26.5%',
      textAlign: 'center',
      textStyle: {
        color: theme === 'dark' ? '#D4D4D4' : theme === 'blue' ? '#fff' : '#000',
        fontSize: 14
      },
      subtext: "".concat(total),
      subtextStyle: {
        color: theme === 'dark' ? '#fafafa' : theme === 'blue' ? '#fff' : '#000',
        fontSize: 28
      }
    },
    legend: {
      orient: 'vertical',
      type: 'scroll',
      left: '50%',
      top: 'center',
      align: 'left',
      itemGap: 8,
      itemWidth: 10,
      itemHeight: 10,
      formatter: function formatter(name) {
        var value = data.find(function (item) {
          return item.name === name;
        });
        if (value) {
          return "\t\t".concat(name, "\t\t").concat(value.value, "\u6B21");
        } else {
          return '';
        }
      },
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      pageIconcolor: theme === 'blue' ? '#fff' : chartFontColor,
      pageIconInactivecolor: theme === 'blue' ? '#fff' : chartFontColor,
      pageTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    },
    series: [{
      type: 'pie',
      radius: ['70%', '90%'],
      center: ['28%', '50%'],
      hoverAnimation: true,
      z: 10,
      itemStyle: {
        normal: {
          borderWidth: 2,
          borderColor: theme === 'dark' ? '#003359' : '#fff'
        }
      },
      label: {
        show: false
      },
      data: data,
      labelLine: {
        show: false
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-top--right"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u672C\u6708\u62A5\u8B66\u7C7B\u578B\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-top--chart"
  }, /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '100%',
      width: '100%',
      zIndex: 9
    }
  })));
};
var _default = exports["default"] = AlarmType;
//# sourceMappingURL=AlarmType.js.map
