"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
exports.transferLineData = transferLineData;
var _react = _interopRequireDefault(require("react"));
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmCharts = require("../../../vm-charts");
var _api = require("../../api");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function transferLineData() {
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var groupByThrowPoint = (0, _groupBy["default"])(data || [], 'throwPointId');
  var groupByDay = (0, _groupBy["default"])(data || [], 'day');
  var lineData = [];
  for (var key in groupByThrowPoint) {
    var item = groupByThrowPoint[key];
    lineData.push({
      name: item[0].throwPointName || '',
      data: item.map(function (item) {
        return item.throwCount || 0;
      })
    });
  }
  // 去除日期中的年
  var xAxis = Object.keys(groupByDay).map(function (item) {
    return item.substring(5);
  });
  return {
    xAxis: xAxis,
    data: lineData
  };
}
var Trend = function Trend(_ref) {
  var classPrefix = _ref.classPrefix,
    id = _ref.id;
  var sumByPoint = _api.overViewService.throwSumByDayAndPoint({
    housingEstateId: id
  });
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-trend")
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u8FD1\u4E00\u5468\u8D8B\u52BF"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(classPrefix, "-trend-chart")
  }, /*#__PURE__*/_react["default"].createElement(_vmCharts.Line1, Object.assign({}, transferLineData(sumByPoint)))));
};
var _default = Trend;
exports["default"] = _default;
//# sourceMappingURL=Trend.js.map
