"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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
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
