"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _react = _interopRequireDefault(require("react"));
var _spin = _interopRequireDefault(require("antd/lib/spin"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var LineCharts = function LineCharts(_ref) {
  var _ref$height = _ref.height,
    height = _ref$height === void 0 ? 280 : _ref$height,
    _ref$theme = _ref.theme,
    theme = _ref$theme === void 0 ? 'light' : _ref$theme,
    legendData = _ref.legendData,
    _ref$yAxisList = _ref.yAxisList,
    yAxisList = _ref$yAxisList === void 0 ? [] : _ref$yAxisList,
    xAxisData = _ref.xAxisData,
    _ref$series = _ref.series,
    series = _ref$series === void 0 ? [] : _ref$series,
    _ref$grid = _ref.grid,
    grid = _ref$grid === void 0 ? {} : _ref$grid,
    _ref$loading = _ref.loading,
    loading = _ref$loading === void 0 ? false : _ref$loading;
  var axisTextColor = theme === 'light' ? 'rgba(0, 0, 0, 0.6)' : '#fff';
  var option = {
    grid: _objectSpread({
      top: '20%',
      left: '5%',
      right: '10%',
      bottom: '20%',
      containLabel: true
    }, grid),
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      left: 'center',
      top: 30,
      itemWidth: 18,
      itemHeight: 6,
      itemGap: 32,
      textStyle: {
        color: theme === 'light' ? '#222' : '#fff',
        fontSize: 14
      },
      data: legendData
    },
    xAxis: {
      data: xAxisData,
      type: 'category',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: true,
        textStyle: {
          fontSize: 12,
          color: axisTextColor //X轴文字颜色
        },
        formatter: function formatter(value) {
          return value.replace(' ', '\n');
        }
      }
    },
    yAxis: yAxisList.map(function (item) {
      return _objectSpread({
        type: 'value',
        nameTextStyle: {
          color: axisTextColor,
          fontSize: 12
        },
        axisLine: {
          show: false
        },
        axisTick: {
          show: false
        },
        axisLabel: {
          color: axisTextColor,
          fontSize: 14
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: theme === 'light' ? 'rgba(0, 0, 0, 0.2)' : 'rgba(255, 255, 255, 0.20)',
            type: 'dashed'
          }
        }
      }, item);
    }),
    dataZoom: [{}],
    series: series
  };
  return loading ? /*#__PURE__*/_react["default"].createElement(_spin["default"], null) : /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    style: {
      width: '100%',
      height: height
    },
    option: option,
    lazyUpdate: true,
    notMerge: true
  });
};
var _default = exports["default"] = LineCharts;
//# sourceMappingURL=index.js.map
