"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var React = _interopRequireWildcard(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
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 DonutBaseChart = function DonutBaseChart(props) {
  var propData = props || {};
  var jsonData = props.data;
  var xdata = [];
  var ydata = [];
  jsonData === null || jsonData === void 0 ? void 0 : jsonData.map(function (item) {
    // xdata.push(item[props.xAxis]);
    // ydata.push(item[props.yAxis]);
    xdata.push(item);
    ydata.push(item);
  });
  // console.log(props, '222222222')
  var option = {
    tooltip: {
      trigger: 'item'
    },
    grid: {
      left: '3%',
      //左边空闲3%
      right: '4%',
      //右边空闲4%
      bottom: '3%',
      //底部空闲 3%
      top: '25%',
      //顶部空闲25% 用于展示标题 和图例，这里就是我们本文要调整的数据。
      containLabel: true
    },
    legend: {
      type: 'scroll',
      //可收起
      show: props.legendshow,
      //图例显示
      orient: props.orient,
      //垂直  horizontal 水平
      x: props.x,
      y: props.y,
      padding: [0, 50, 0, 0],
      //可设定图例[距上方距离，距右方距离，距下方距离，距左方距离]
      itemWidth: props.itemWidth,
      //图形宽度。
      itemHeight: props.itemHeight,
      //图形高度
      itemGap: props.itemGap //图例每项之间的间隔
      // 右侧提示框文字样式
    },

    series: [{
      name: props.labelname,
      type: 'pie',
      radius: ['35%', '60%'],
      avoidLabelOverlap: false,
      label: {
        show: propData.labelVisible,
        //控制显示隐藏的
        type: propData.typelabelType || "outer",
        //控制折线线条
        // formatter: ydata,
        // formatter:  '{b}: {c} ({d}%)' ,
        formatter: function formatter(params) {
          if (params.percent) {
            var name = params.data.name + ':' + params.data.value + ' ' + '(' + params.percent + '%' + ')';
            return name;
          } else {
            var percent = params.percent ? params.percent : '0';
            var _name = params.data.name + ':' + params.data.value + ' ' + '(' + percent + '%' + ')';
            return _name;
          }
        },
        position: props.labelType // label 
      },

      emphasis: {
        label: {
          show: true,
          //echarts饼图内部显示百分比设置
          // position: "inside", //outside 外部显示  inside 内部显示
          // formatter: `{d}%`,
          formatter: function formatter(params) {
            if (params.percent) {
              return params.percent + '%';
            } else {
              return '0%';
            }
          },
          color: "#000000",
          //颜色
          fontSize: 12 //字体大小
        }
      },

      labelLine: {
        show: true
      },
      data: props.data,
      color: props.color
    }]
  };
  return (jsonData === null || jsonData === void 0 ? void 0 : jsonData.length) !== 0 ? /*#__PURE__*/React.createElement(_echartsForReact["default"], {
    option: option,
    style: {
      height: props.height,
      width: props.width
    }
  }) : /*#__PURE__*/React.createElement("div", {
    style: {
      height: props.height,
      width: props.width
    }
  }, "\u6682\u65E0\u6570\u636E");
};
var _default = DonutBaseChart;
exports["default"] = _default;