"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 _moment = _interopRequireDefault(require("moment"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _api = require("../../api");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _index = require("../../index");
var _lodash = _interopRequireDefault(require("lodash"));
var _vmCard = _interopRequireDefault(require("../../../vm-card"));
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 MonthTrend = function MonthTrend() {
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var _useContext = (0, _react.useContext)(_index.CcCpContext),
    id = _useContext.id;
  var alarmMonthTrend = _api.ExceptionService.getSyPointErrorReportMonthNums(id, (0, _moment["default"])().startOf('y').format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD'));
  var option = {
    color: chartColor,
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a, _b;
        //tongjia
        var unit = '次';
        var str = '';
        if (Array.isArray(params)) {
          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 === null || params === void 0 ? void 0 : 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).concat(unit, "</div>");
          });
        } else {
          var _color = params === null || params === void 0 ? void 0 : params.color; // 获取系列的颜色
          str += "<div style=\"display:flex;align-items:center\"><span style=\"color:".concat(_color, ";font-size:24px \">\u2022</span>&nbsp;").concat(params === null || params === void 0 ? void 0 : params.name, "&nbsp;&nbsp;").concat(params.value).concat(unit, "</div>");
        }
        return str; // 返回带点的字符串
      }
    },
    legend: {
      show: true,
      itemWith: 6,
      itemHeight: 6,
      top: 20,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      }
    },
    grid: {
      top: 58,
      left: '5%',
      bottom: 12,
      right: 24,
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: _lodash["default"].map(alarmMonthTrend, 'labelName') || []
    },
    yAxis: [{
      name: '异常次数（次）',
      type: 'value',
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisLine: {
        show: true
      },
      minInterval: 1,
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }],
    series: [{
      name: '次数',
      type: 'line',
      data: _lodash["default"].map(alarmMonthTrend, 'labelValue') || []
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_vmCard["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
