"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 _lodash = require("lodash");
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
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 ChartJcqs = function ChartJcqs(props) {
  var _a, _b;
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var xData = (props === null || props === void 0 ? void 0 : props.names) || [];
  var values = (props === null || props === void 0 ? void 0 : props.values) ? props.values[0] : [];
  var maxNum = null;
  if (((_a = props === null || props === void 0 ? void 0 : props.values) === null || _a === void 0 ? void 0 : _a.length) > 0) {
    maxNum = (0, _lodash.max)((0, _lodash.flatten)(props.values));
  }
  var option = {
    color: ['#00FFE7'],
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        return params[0].name + '<br/>' + params[0].seriesName + ': ' + params[0].value + '吨';
      }
    },
    legend: {
      itemWith: 6,
      itemHeight: 6,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      },
      props: (props === null || props === void 0 ? void 0 : props.legends) || []
    },
    grid: {
      left: '6%',
      right: '7%',
      bottom: 20,
      top: 84,
      containLabel: true
    },
    xAxis: {
      type: 'category',
      name: '日期',
      boundaryGap: true,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: xData
    },
    yAxis: {
      type: 'value',
      boundaryGap: true,
      name: '吨',
      max: maxNum,
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      // splitNumber: 5,
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    },
    series: [{
      name: '进场量',
      type: 'line',
      data: values,
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#51d0ff6e'
        }, {
          offset: 1,
          color: '#1B89FF'
        }])
      },
      markLine: {
        data: [{
          yAxis: (props === null || props === void 0 ? void 0 : props.values) ? props.values[1][0] : 0,
          lineStyle: {
            normal: {
              color: '#FFE25D'
            }
          },
          name: '设计能力(吨/日)'
        }],
        lineStyle: {
          color: '#FFE25D'
        },
        label: {
          show: true,
          position: 'insideEndTop',
          formatter: '{b}: {c}',
          color: theme === 'blue' ? '#fff' : chartFontColor,
          fontWeight: 'normal'
        }
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u8FDB\u573A\u8D8B\u52BF\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "metering-content-charts-chart"
  }, ((_b = props === null || props === void 0 ? void 0 : props.names) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '107%',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null))));
};
var _default = exports["default"] = ChartJcqs;
//# sourceMappingURL=ChartJcqs.js.map
