"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _index = require("../../index");
var _api = require("../../api");
require("./index.less");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var getOption = function getOption(data) {
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var total = 0;
  var arr = data.map(function (item) {
    total += item.labelValue;
    return {
      name: item.labelName,
      value: item.labelValue
    };
  });
  return {
    color: chartColor,
    title: {
      text: "{a|\u603B\u6B21\u6570}\n".concat(total, "{a|\u6B21}"),
      left: 'center',
      top: 'center',
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        rich: {
          a: {
            fontSize: 12
          }
        }
      }
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: 'center',
      right: '5%',
      orient: 'vertical',
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    },
    series: [{
      name: '报警次数类型占比',
      type: 'pie',
      center: ['50%', '50%'],
      radius: ['70%', '90%'],
      avoidLabelOverlap: false,
      label: {
        show: false,
        position: 'center'
      },
      labelLine: {
        show: false
      },
      data: arr
    }]
  };
};
var AlarmTypeAnalysis = function AlarmTypeAnalysis(_ref) {
  var startDate = _ref.startDate,
    endDate = _ref.endDate;
  var _useContext = (0, _react.useContext)(_index.RestaurantContext),
    id = _useContext.id;
  var data = _api.AlarmService.typeAnalysis({
    id: id,
    startDate: startDate,
    endDate: endDate
  });
  return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: getOption(data),
    style: {
      width: '100%',
      height: 200
    }
  });
};
var _default = exports["default"] = AlarmTypeAnalysis;
//# sourceMappingURL=AlarmTypeAnalysis.js.map
