"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _lodash = require("lodash");

var _echart = _interopRequireDefault(require("../echart"));

var _context = _interopRequireDefault(require("../context"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var OPTIONS = {
  tooltip: {
    trigger: 'item',
    formatter: '{a} <br/>{b}: {c} ({d}%)'
  },
  legend: {
    icon: 'circle',
    orient: 'vertical',
    top: 'middle',
    left: 'right',
    align: 'left',
    itemWidth: 6,
    textStyle: {
      fontFamily: 'HelveticaNeue-CondensedBold',
      textBorderColor: '#fff',
      textBorderWidth: 2,
      fontSize: 12
    }
  },
  series: [{
    name: '数据来源',
    type: 'pie',
    radius: [45, 55],
    center: [60, '50%'],
    avoidLabelOverlap: false,
    // label: {
    //   show: false,
    //   position: 'center'
    // },
    emphasis: {
      label: {
        show: true,
        formatter: '{c}',
        fontSize: 20,
        fontWeight: 'bold',
        fontFamily: 'HelveticaNeue-CondensedBold'
      }
    },
    labelLine: {
      show: false
    }
  }]
};

/**
 * 环状堆叠占比图
 * @param props IProps
 */
var RingStackChart = function RingStackChart(props) {
  var _useContext = (0, _react.useContext)(_context["default"]),
      _cssPrefix = _useContext._cssPrefix;

  var className = props.className,
      title = props.title,
      dataSource = props.dataSource,
      options = props.options,
      _props$universalStyle = props.universalStyle,
      universalStyle = _props$universalStyle === void 0 ? {
    height: 190
  } : _props$universalStyle;
  return /*#__PURE__*/_react["default"].createElement(_echart["default"], {
    title: title,
    className: (0, _classnames["default"])(className, _cssPrefix + "ring-stack-chart-wrapper"),
    universalStyle: universalStyle,
    loading: (0, _lodash.isNull)(dataSource) || (0, _lodash.isUndefined)(dataSource),
    options: (0, _lodash.merge)({
      series: [{
        data: dataSource,
        label: {
          show: true,
          position: 'center',
          formatter: "" + (0, _lodash.sumBy)(dataSource, 'value')
        }
      }]
    }, OPTIONS, options)
  });
};

var _default = RingStackChart;
exports["default"] = _default;