"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 _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var Lcfx = function Lcfx(props) {
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var id = props.id;
  var _BaseService$useMileA = _api.BaseService.useMileAnalysis(id, (0, _moment["default"])().startOf('M').format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD')),
    mileAnalysisRes = _BaseService$useMileA.mileAnalysisRes;
  var names = mileAnalysisRes.names,
    values = mileAnalysisRes.values;
  var option = {
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a, _b;
        var str = "".concat((_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.axisValue);
        var color = (_b = params[0].color) === null || _b === void 0 ? void 0 : _b.colorStops; // 获取系列的颜色
        params.map(function (item, index) {
          var _a;
          str += "<div ><span style=\"color:".concat((_a = color[index]) === null || _a === void 0 ? void 0 : _a.color, ";font-size:24px\">\u2022</span> ").concat(item.seriesName, " &nbsp;&nbsp;&nbsp;").concat(item.data, "km</div>");
        });
        return str; // 返回带点的字符串
      }
    },
    grid: {
      top: 36,
      left: '6%',
      right: '5%',
      bottom: 20
    },
    legend: {
      show: false
    },
    xAxis: [{
      type: 'category',
      data: names || [],
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    }],
    yAxis: [{
      type: 'value',
      name: '(km)',
      min: 0,
      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)'
        }
      }
    }],
    series: [{
      name: '里程',
      type: 'bar',
      barWidth: 18,
      data: (values === null || values === void 0 ? void 0 : values.length) > 0 ? values[0] : [],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#1677FF'
        }, {
          offset: 1,
          color: '#62FDF3'
        }])
      }
    }]
  };
  return (names === null || names === void 0 ? void 0 : names.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '100%',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      height: '100%',
      width: '100%'
    }
  }));
};
var _default = exports["default"] = Lcfx;
//# sourceMappingURL=Lcfx.js.map
