"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var getGaugeOption = function getGaugeOption(_ref) {
  var _ref$num = _ref.num,
    num = _ref$num === void 0 ? 0 : _ref$num,
    _ref$min = _ref.min,
    min = _ref$min === void 0 ? 0 : _ref$min,
    _ref$average = _ref.average,
    average = _ref$average === void 0 ? 0 : _ref$average,
    _ref$max = _ref.max,
    max = _ref$max === void 0 ? 100 : _ref$max,
    _ref$name = _ref.name,
    name = _ref$name === void 0 ? '' : _ref$name,
    _ref$unit = _ref.unit,
    unit = _ref$unit === void 0 ? '' : _ref$unit;
  var good = Number(num) > Number(average);
  return {
    title: {
      left: 'center',
      top: '60%',
      text: "{a|".concat(name, "}\n{b|").concat(good ? '优于均值' : '差于均值', "}"),
      textStyle: {
        rich: {
          a: {
            color: '#fff',
            fontSize: 14,
            lineHeight: 40
          },
          b: {
            color: good ? '#63FFC6' : '#FFCD36',
            fontSize: 14
          }
        }
      }
    },
    series: [{
      type: 'gauge',
      center: ['50%', '50%'],
      radius: '75%',
      startAngle: 200,
      endAngle: -20,
      min: min,
      max: max,
      splitNumber: 10,
      progress: {
        show: true,
        width: 10,
        itemStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0,
              color: good ? '#50F0FF' : '#FFBE31'
            }, {
              offset: 1,
              color: good ? '#3EA6FF' : '#FF4800'
            }]
          }
        }
      },
      pointer: {
        show: false
      },
      axisLine: {
        lineStyle: {
          width: 10
        }
      },
      axisTick: {
        distance: -20,
        length: 5,
        splitNumber: 5,
        lineStyle: {
          width: 1,
          color: '#999'
        }
      },
      splitLine: {
        distance: -23,
        length: 8,
        lineStyle: {
          width: 2,
          color: '#999'
        }
      },
      axisLabel: {
        show: false,
        distance: -12,
        color: '#999',
        fontSize: 12
      },
      anchor: {
        show: false
      },
      title: {
        show: false
      },
      detail: {
        valueAnimation: true,
        width: '60%',
        borderRadius: 8,
        offsetCenter: [0, 0],
        fontWeight: 'bolder',
        formatter: average === false ? "{a|".concat(num, "}{b|").concat(unit, "}") : "{a|".concat(num, "}{b|").concat(unit, "}\n{c|\u5747\u503C").concat(average).concat(unit, "}"),
        textStyle: {
          rich: {
            a: {
              color: '#fff',
              fontSize: 24
            },
            b: {
              color: '#fff',
              fontSize: 12
            },
            c: {
              color: '#9BA8B0',
              fontSize: 12
            }
          }
        }
      },
      data: [{
        value: num
      }]
    }]
  };
};
var Gauge1 = function Gauge1(props) {
  return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: getGaugeOption(props),
    style: {
      height: '100%'
    }
  });
};
var _default = exports["default"] = Gauge1;
//# sourceMappingURL=Gauge1.js.map
