"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 = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
var _lodash = _interopRequireDefault(require("lodash"));
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); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var ZyfxCC = function ZyfxCC(props) {
  var id = props.id,
    garbageType = props.garbageType;
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    sDate = _useSettings.startDate,
    eDate = _useSettings.endDate,
    theme = _useSettings.theme;
  var _BaseService$useWorkA = _api.BaseService.useWorkAnaCC(id, sDate ? sDate : (0, _moment["default"])().subtract(1, 'M').format('YYYY-MM-DD'), eDate ? eDate : (0, _moment["default"])().format('YYYY-MM-DD'), true),
    workAnaLjsyRes = _BaseService$useWorkA.workAnaLjsyRes;
  var option = {
    tooltip: {
      // trigger: 'axis',
      valueFormatter: function valueFormatter(value) {
        return "".concat(value, "\u6B21");
      }
    },
    grid: {
      left: '5%',
      right: '5%',
      bottom: 20,
      containLabel: true
    },
    legend: {
      align: 'left',
      itemGap: 8,
      itemWidth: 10,
      itemHeight: 10,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: ['实际收集次数'].concat(_toConsumableArray(garbageType === 'fqyz' ? [] : ['计划收集次数']))
    },
    xAxis: [{
      type: 'category',
      data: _lodash["default"].map(workAnaLjsyRes[0] || [], 'labelName'),
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    }],
    yAxis: [{
      type: 'value',
      name: '(次)',
      min: 0,
      interval: 100,
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      splitNumber: 5,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }, {
      show: false,
      type: 'value',
      name: '%'
    }],
    series: [{
      name: '实际收集次数',
      type: 'bar',
      barWidth: 18,
      data: (workAnaLjsyRes === null || workAnaLjsyRes === void 0 ? void 0 : workAnaLjsyRes.length) > 0 ? (workAnaLjsyRes[0] || []).map(function (item) {
        return {
          name: item.labelName,
          value: item.labelValue
        };
      }) : [],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#F5803C '
        }, {
          offset: 1,
          color: '#FFE290'
        }])
      }
    }].concat(_toConsumableArray(garbageType === 'fqyz' ? [] : [{
      name: '计划收集次数',
      type: 'bar',
      barWidth: 18,
      data: (workAnaLjsyRes === null || workAnaLjsyRes === void 0 ? void 0 : workAnaLjsyRes.length) > 0 ? (workAnaLjsyRes[1] || []).map(function (item) {
        return {
          name: item.labelName,
          value: item.labelValue
        };
      }) : [],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#1677FF'
        }, {
          offset: 1,
          color: '#62FDF3'
        }])
      }
    }]))
  };
  return (workAnaLjsyRes === null || workAnaLjsyRes === void 0 ? void 0 : workAnaLjsyRes.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '250px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null));
};
var _default = exports["default"] = ZyfxCC;
//# sourceMappingURL=ZyfxCC.js.map
