"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Pie;
var _react = _interopRequireDefault(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
require("./index.less");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var chartFontColor = '#000';
var getOptions = function getOptions(data, title, isDeepTheme) {
  var _a;
  var detailList = ((data === null || data === void 0 ? void 0 : data.detailList) || []).map(function (item) {
    return Object.assign(Object.assign({}, item), {
      name: item.name,
      value: item.czzCount
    });
  });
  return {
    color: ['#438EF7', '#40AAF3', '#62C4F9', '#20BB70', '#1DD27B', '#49E6A2', '#F2953A', '#FAAB59', '#F9C665', '#8A7FEE'],
    backgroundColor: 'transparent',
    title: {
      textAlign: 'center',
      text: title || '运输起点(个)',
      textStyle: {
        fontSize: 14,
        color: '#595959'
      },
      subtext: (_a = data === null || data === void 0 ? void 0 : data.totalCount) !== null && _a !== void 0 ? _a : 0,
      subtextStyle: {
        fontSize: 36,
        color: '#1F1F1F'
      },
      top: '40%',
      left: '19%'
    },
    tooltip: {
      show: true,
      formatter: "{b}\uFF1A{c}\u4E2A"
    },
    legend: {
      orient: 'vertical',
      left: '45%',
      top: 'middle',
      align: 'left',
      itemGap: 8,
      icon: 'circle',
      itemWidth: 10,
      itemHeight: 10,
      textStyle: {
        fontSize: 14,
        color: isDeepTheme ? '#fff' : '#000'
      },
      pageIconColor: chartFontColor,
      pageIconInactiveColor: chartFontColor,
      pageTextStyle: {
        color: isDeepTheme ? '#fff' : chartFontColor
      },
      formatter: function formatter(name) {
        var value = detailList.find(function (item) {
          return item.name === name;
        });
        var newName = name.length > 10 ? name.slice(0, 10) + '......' : name;
        if (value) {
          return "".concat(newName, "(\u5173\u8054").concat(value === null || value === void 0 ? void 0 : value.czzCount, "\u5904\u7F6E\u8BC1)");
        } else {
          return '';
        }
      }
    },
    series: [{
      type: 'pie',
      radius: ['55%', '75%'],
      center: ['20%', '50%'],
      hoverAnimation: true,
      z: 10,
      label: {
        show: false
      },
      data: detailList,
      labelLine: {
        show: false
      }
    }, {
      type: 'pie',
      radius: ['75%', '85%'],
      center: ['20%', '50%'],
      hoverAnimation: true,
      z: 10,
      label: {
        show: false
      },
      data: detailList,
      labelLine: {
        show: false
      },
      itemStyle: {
        borderWidth: 0,
        opacity: 0.3
      }
    }]
  };
};
function Pie(_ref) {
  var isDeepTheme = _ref.isDeepTheme,
    pieData = _ref.pieData;
  var leftData = pieData.find(function (item) {
    return item.startEndType === 'START';
  });
  var optionsLeft = getOptions(leftData, '运输起点(个)', isDeepTheme);
  var rightData = pieData.find(function (item) {
    return item.startEndType === 'END';
  });
  var optionsRight = getOptions(rightData, '运输终点(个)', isDeepTheme);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-car-dispose-container-pie"
  }, /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: optionsLeft,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  }), /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: optionsRight,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  }));
}
//# sourceMappingURL=Pie.js.map
