"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 echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
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 Zylc(props) {
  var data = props.data;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    chartFontColor = _useSettings.chartFontColor;
  var planData = [],
    workMileage = [],
    xData = [];
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
    xData = data.map(function (ele) {
      return ele.workDate;
    });
    planData = data.map(function (ele) {
      return ele.planMileage;
    });
    workMileage = data.map(function (ele) {
      return ele.workMileage;
    });
  }
  var option = {
    tooltip: {
      trigger: 'axis',
      // formatter: '{b0}:<br/>{a} {c0}km',
      formatter: function formatter(params) {
        var _a;
        var str = "".concat((_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.axisValue);
        params.map(function (item, index) {
          var _a, _b, _c;
          var color = typeof params[0].color == 'string' ? params[0].color : (_c = (_b = (_a = params[0].color) === null || _a === void 0 ? void 0 : _a.colorStops) === null || _b === void 0 ? void 0 : _b[index]) === null || _c === void 0 ? void 0 : _c.color; // 获取系列的颜色
          str += "<div ><span style=\"color:".concat(color, " \">\u2022</span> ").concat(item.seriesName, " &nbsp;&nbsp;&nbsp;").concat(item.data, "km</div>");
        });
        return str; // 返回带点的字符串
      }
    },
    grid: {
      left: '8%',
      right: '6%',
      bottom: 20
    },
    legend: {
      align: 'left',
      itemGap: 8,
      itemWidth: 10,
      itemHeight: 10,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: ['计划里程', '核算作业里程']
    },
    xAxis: [{
      type: 'category',
      data: xData,
      boundaryGap: true,
      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: 8,
      data: planData,
      itemStyle: {
        color: theme === 'dark' ? new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#1B89FF'
        }, {
          offset: 1,
          color: '#51D0FF'
        }]) : '#1890FF'
      }
    }, {
      name: '核算作业里程',
      type: 'bar',
      barWidth: 8,
      data: workMileage,
      itemStyle: {
        color: theme === 'dark' ? new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#00A983'
        }, {
          offset: 1,
          color: '#44FFD1'
        }]) : theme === 'blue' ? '#fff' : '#73DEB3'
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-charts-lcfx"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F5C\u4E1A\u91CC\u7A0B\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-charts-lcfx-contain"
  }, (data === null || data === void 0 ? void 0 : data.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"], null))));
}
var _default = exports["default"] = Zylc;
//# sourceMappingURL=Zylc.js.map
