"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(e) { return e && e.__esModule ? e : { "default": e }; }
function transferLineData() {
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var groupByThrowPoint = (0, _groupBy["default"])(data || [], 'name');
  var groupByDay = (0, _groupBy["default"])(data || [], 'day');
  var lineData = [];
  for (var key in groupByThrowPoint) {
    var item = groupByThrowPoint[key];
    lineData.push({
      name: item[0].name || '',
      data: item.map(function (item) {
        return item.count || 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({
    throwPointId: id
  });
  var lineData = (sumByPoint || []).map(function (item) {
    return {
      name: item.throwPointName || '',
      count: item.throwCount || 0,
      day: item.day || ''
    };
  });
  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(lineData)))));
};
var _default = exports["default"] = Trend;
//# sourceMappingURL=Trend.js.map
