"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 _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
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 }; }
/**
 * 作业信息-有排班-平均完成率
 */

var Zylc = function Zylc(props) {
  var names = props.names,
    values = props.values;
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var option = {
    color: chartColor,
    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 === null || params === void 0 ? void 0 : params[0]) === null || _b === void 0 ? void 0 : _b.color; // 获取系列的颜色
        params.map(function (item) {
          str += "<div ><span style=\"color:".concat(color, " \">\u2022</span> ").concat(item.seriesName, " &nbsp;&nbsp;&nbsp;").concat(item.value, "km</div>");
        });
        return str; // 返回带点的字符串
      }
    },
    legend: {
      itemWith: 6,
      itemHeight: 6,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      },
      data: ['核算作业里程']
    },
    grid: {
      left: '8%',
      right: '6%',
      top: 28,
      bottom: 20
    },
    xAxis: {
      type: 'category',
      boundaryGap: true,
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: names
    },
    yAxis: {
      type: 'value',
      name: '(km)',
      min: 0,
      interval: 100,
      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,
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#45aeff'
        }, {
          offset: 0.9,
          color: '#168fff'
        }])
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (values === null || values === void 0 ? void 0 : values.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '180px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      height: '160px'
    }
  })));
};
var _default = exports["default"] = Zylc;
//# sourceMappingURL=Zylc.js.map
