"use strict";

exports.__esModule = true;
exports.default = void 0;

var echarts = _interopRequireWildcard(require("echarts"));

require("./index-sfc.css");

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; }

// TODO
var __vue_render__ = function __vue_render__() {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c('div', {
    ref: "CircleProgress"
  });
};

var __vue_staticRenderFns__ = [];
var _default = {
  _scopeId: 'data-v-fdb57b56',
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__,
  name: 'chart-circle-progress',
  props: {
    percentage: {
      type: Number,
      required: false,
      default: 0
    },
    color: {
      type: String,
      default: '#FF974C'
    },
    reverseColor: {
      type: String,
      default: 'rgba(255,255,255,0.2)'
    },
    textColor: {
      type: String,
      required: false
    },
    strokeWidth: {
      type: Number,
      default: 25
    }
  },
  data: function data() {
    return {
      Chart: null
    };
  },
  watch: {
    percentage: {
      handler: function handler() {
        var _this = this;

        this.$nextTick(function () {
          _this.draw();
        });
      },
      immediate: true
    }
  },
  methods: {
    draw: function draw() {
      var data = this.percentage;
      var option = {
        title: {
          text: data + "%",
          //主标题文本
          left: 'center',
          top: 'center',
          textStyle: {
            fontWeight: 'normal',
            fontSize: Math.max(16, 45 - this.strokeWidth),
            fontFamily: 'impact-2',
            color: this.textColor || this.color
          }
        },
        series: [{
          name: 'Access From',
          type: 'pie',
          radius: [95 - this.strokeWidth + "%", '95%'],
          hoverAnimation: false,
          label: {
            show: false
          },
          labelLine: {
            show: false
          },
          tooltip: {
            show: false
          },
          legend: {
            show: false
          },
          data: [{
            value: data,
            name: 'Progress',
            itemStyle: {
              color: this.color
            }
          }, {
            value: 100 - data,
            name: '',
            itemStyle: {
              color: this.reverseColor // 反色

            }
          }]
        }]
      };
      this.Chart && this.Chart.setOption(option);
    }
  },
  mounted: function mounted() {
    // 图表实例化
    this.Chart = echarts.init(this.$refs.CircleProgress);
  }
};
exports.default = _default;