"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 _lodash = _interopRequireDefault(require("lodash"));
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;
  return {
    color: chartColor,
    grid: {
      top: '15%',
      left: 40,
      bottom: 20,
      right: '8%',
      containLabel: true
    },
    tooltip: {
      trigger: 'axis',
      valueFormatter: function valueFormatter(value) {
        return "".concat(value, "\u6B21");
      }
    },
    xAxis: {
      type: 'category',
      data: _lodash["default"].map(data, 'labelName'),
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      name: '日期'
    },
    yAxis: {
      minInterval: 1,
      name: '报警次数：次',
      type: 'value',
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    },
    series: [{
      data: _lodash["default"].map(data, 'labelValue'),
      type: 'line'
    }]
  };
};
var AlarmTrend = function AlarmTrend(_ref) {
  var startDate = _ref.startDate,
    endDate = _ref.endDate;
  var _useContext = (0, _react.useContext)(_index.RestaurantContext),
    id = _useContext.id;
  var data = _api.AlarmService.alarmTrend({
    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"] = AlarmTrend;
//# sourceMappingURL=AlarmTrend.js.map
