"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _api = require("../../api");
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
 * 监测-报警信息-报警信息汇总
 */

var MonthTrend = function MonthTrend(_ref) {
  var id = _ref.id;
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    chartColor = _useSettings.chartColor,
    theme = _useSettings.theme;
  var _AlarmService$useAlar = _api.AlarmService.useAlarmTrend(id, (0, _moment["default"])().subtract(6, 'M').format('YYYY-MM-DD 00:00:00'), (0, _moment["default"])().format('YYYY-MM-DD 23:59:59')),
    alarmTrend = _AlarmService$useAlar.alarmTrend;
  var legends = alarmTrend.legends,
    names = alarmTrend.names,
    values = alarmTrend.values;
  var option = {
    color: chartColor,
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      show: true,
      itemWith: 6,
      itemHeight: 6,
      top: 20,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      },
      data: legends || []
    },
    grid: {
      top: 58,
      left: 24,
      bottom: 12,
      right: 24,
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: names || []
    },
    yAxis: [{
      name: '单位（次）',
      type: 'value',
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisLine: {
        show: true
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }],
    series: [{
      name: '次数',
      type: 'line',
      data: (values === null || values === void 0 ? void 0 : values.length) > 0 ? values[0] : []
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "alarm-trend"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u6708\u5EA6\u8D8B\u52BF\u5206\u6790"
  }), (values === null || values === void 0 ? void 0 : values.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      height: '300px',
      width: '100%'
    }
  })));
};
var _default = exports["default"] = MonthTrend;
//# sourceMappingURL=MonthTrend.js.map
