"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 _vmWrapper = _interopRequireDefault(require("../../../vm-wrapper"));
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 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: ['#1670ff'],
    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: 'rgba(22, 119, 255, 0)'
        }, {
          offset: 0.5,
          color: 'rgba(22, 119, 255, 0.5)'
        }, {
          offset: 1,
          color: 'rgba(22, 119, 255, 1)'
        }])
      },
      markLine: {
        data: [{
          yAxis: (props === null || props === void 0 ? void 0 : props.values) ? props.values[1][0] : 0,
          lineStyle: {
            normal: {
              color: '#F5222D'
            }
          },
          name: '设计能力(吨/日)'
        }],
        lineStyle: {
          color: '#F5222D'
        },
        label: {
          show: true,
          position: 'insideEndTop',
          formatter: '{b}: {c}',
          color: '#F5222D',
          fontWeight: 'normal'
        }
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_vmWrapper["default"], {
    title: "\u8FDB\u573A\u8D8B\u52BF\u5206\u6790",
    needChange: false
  }, /*#__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: '100%',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null))));
};
var _default = exports["default"] = ChartJcqs;
//# sourceMappingURL=ChartJcqs.js.map
