"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"] = Chart;
var _react = _interopRequireDefault(require("react"));
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
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 Chart(_ref) {
  var _ref$theme = _ref.theme,
    theme = _ref$theme === void 0 ? 'light' : _ref$theme,
    _ref$chartData = _ref.chartData,
    chartData = _ref$chartData === void 0 ? {} : _ref$chartData;
  var _a, _b;
  var textColor = ['dark', 'blue'].includes(theme) ? '#fff' : '#000';
  var xAxisData = ((chartData === null || chartData === void 0 ? void 0 : chartData.histogramList) || []).map(function (item) {
    return item.date;
  });
  var ylData = ((chartData === null || chartData === void 0 ? void 0 : chartData.histogramList) || []).map(function (item) {
    return item.weight;
  });
  var ccData = ((chartData === null || chartData === void 0 ? void 0 : chartData.histogramList) || []).map(function (item) {
    return item.count;
  });
  var option = {
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a;
        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 >");
        params.map(function (item) {
          str += '<div>';
          str += item.marker;
          str += "".concat(item.seriesName, "\uFF1A").concat(item.data).concat(item.seriesName === '车次' ? '次' : '吨');
          str += '</div>';
        });
        return str;
      }
    },
    grid: {
      left: '6%',
      right: '5%',
      bottom: 20
    },
    legend: [{
      align: 'left',
      itemHeight: 8,
      itemWidth: 8,
      icon: 'rect',
      itemStyle: {
        color: '#1C86F3'
      },
      textStyle: {
        color: textColor
      },
      data: ['运量'],
      left: '40%'
    }, {
      align: 'left',
      itemHeight: 2,
      itemWidth: 16,
      icon: 'rect',
      itemStyle: {
        color: '#1FB64D'
      },
      textStyle: {
        color: textColor
      },
      data: ['车次'],
      left: '60%'
    }],
    xAxis: [{
      type: 'category',
      data: xAxisData,
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: textColor
      }
    }],
    yAxis: [{
      show: true,
      type: 'value',
      name: '车次(次)',
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }, {
      type: 'value',
      name: '运量(吨)',
      nameTextStyle: {
        color: textColor
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: textColor
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }],
    series: [{
      name: '运量',
      type: 'bar',
      barWidth: 18,
      yAxisIndex: 1,
      data: ylData,
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
          offset: 0,
          color: '#1C86F3'
        }, {
          offset: 1,
          color: 'rgba(28, 134, 243, 0)'
        }])
      }
    }, {
      name: '车次',
      type: 'line',
      yAxisIndex: 0,
      data: ccData,
      showSymbol: false,
      itemStyle: {
        color: '#1FB64D'
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "yxfx-top"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "pjryl"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "name"
  }, "\u5E73\u5747\u65E5\u8FD0\u91CF"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "num"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (_a = chartData === null || chartData === void 0 ? void 0 : chartData.avgDayWeight) !== null && _a !== void 0 ? _a : 0), /*#__PURE__*/_react["default"].createElement("span", {
    className: "unit"
  }, "\u5428"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "pjrcc"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "name"
  }, "\u5E73\u5747\u65E5\u8F66\u6B21"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "num",
    style: {
      color: '#20BB70'
    }
  }, /*#__PURE__*/_react["default"].createElement("span", null, (_b = chartData === null || chartData === void 0 ? void 0 : chartData.avgDayCount) !== null && _b !== void 0 ? _b : 0), /*#__PURE__*/_react["default"].createElement("span", {
    className: "unit"
  }, "\u6B21")))), /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  }));
}
//# sourceMappingURL=Chart.js.map
