"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 _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _api = require("../../api");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
 * 公厕-异常信息-异常信息汇总
 */

var MonthTrend = function MonthTrend(_ref) {
  var id = _ref.id;
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var _ExeceptionService$us = _api.ExeceptionService.useAlarmMonthTrend(id, (0, _moment["default"])().subtract(6, 'M').format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD')),
    alarmMonthTrend = _ExeceptionService$us.alarmMonthTrend;
  var legends = alarmMonthTrend.legends,
    names = alarmMonthTrend.names,
    values = alarmMonthTrend.values;
  var option = {
    color: chartColor,
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a, _b;
        var 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[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, '次', "</div>");
        });
        return str; // 返回带点的字符串
      }
    },
    legend: {
      show: true,
      itemWith: 6,
      itemHeight: 6,
      top: 20,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      },
      data: legends || []
    },
    grid: {
      top: 58,
      left: 18,
      bottom: 12,
      right: 30,
      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[0] || []
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "exeception-trend"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u6708\u5EA6\u8D8B\u52BF\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  }));
};
var _default = exports["default"] = MonthTrend;
//# sourceMappingURL=MonthTrend.js.map
