text: import{pluckNumber,pluck}from'../../../../fc-core/src/lib';import AnnotationShape from'./annotation-shape';const STRAIGHT_ANGLE_DEGREES=180,FULL_ANGLE_DEGREES=360,DEFAULT_RADIUS_INNER=0,DEFAULT_ANGLE_START=0,DEFAULT_ANGLE_END=360,DEFAULT_PAPER_WIDTH=700,DEFAULT_PAPER_HEIGHT=350,isPerfectCircle=a=>a.startAngle===DEFAULT_ANGLE_START&&a.endAngle===DEFAULT_ANGLE_END,circleHasHole=a=>0<a.innerRadius||0<a.innerYRadius;function toRadian(a){return a*(Math.PI/STRAIGHT_ANGLE_DEGREES)}class CircleAnnotation extends AnnotationShape{getName(){return'circle'}configureAttributes(a={}){super.configureAttributes(a);let b=this,c=b.rawConfig,d=b.getFromEnv('chart'),e=+d.getFromEnv('chartHeight'),f=+d.getFromEnv('chartWidth'),g=Math.max(e||DEFAULT_PAPER_WIDTH,f||DEFAULT_PAPER_HEIGHT),h=Math.sqrt(g);b.config.radius=c.radius,b.config.xRadius=pluckNumber(parseFloat(c.radius),parseFloat(c.xRadius),h),b.config.yRadius=pluckNumber(parseFloat(c.yRadius),b.config.xRadius),b.config.startAngle=pluckNumber(parseFloat(c.startAngle),DEFAULT_ANGLE_START),b.config.endAngle=pluckNumber(parseFloat(c.endAngle),DEFAULT_ANGLE_END),b.config.innerRadius=pluckNumber(parseFloat(c.innerRadius),DEFAULT_RADIUS_INNER),b.config.innerYRadius=pluckNumber(parseFloat(c.innerYRadius),b.config.innerRadius,DEFAULT_RADIUS_INNER),b.config.elementType='arc'===b.config.type?'ringpath':isPerfectCircle(b.config)&&!circleHasHole(b.config)?'ellipse':'ringpath'}updateAttr(){let a,b,c=this,d=this.config,e=d.calculatedAttrs,f=c.getFromEnv('chart'),g=+f.getFromEnv('chartHeight'),h=+f.getFromEnv('chartWidth'),i=c.getScaledVal(d.xRadius),j=c.getScaledVal(d.yRadius),k=c.getScaledVal(d.innerRadius),l=c.getScaledVal(d.innerYRadius);switch(pluck(d.radius)||(d.radius=h<g?c.getScaledVal(h):c.getScaledVal(g),d.radius*=.3,k>d.radius&&(k+=d.radius,d.radius=k-d.radius,k-=d.radius),i=j=d.radius,l=k),d.elementType){case'ringpath':b=[pluckNumber(e.x,c.getScaledVal(d.x,!0)),pluckNumber(e.y,c.getScaledVal(d.y,!1)),i,k,toRadian(FULL_ANGLE_DEGREES-d.endAngle),toRadian(FULL_ANGLE_DEGREES-d.startAngle),j,l],a={ringpath:b};break;default:a={cx:pluckNumber(e.x,c.getScaledVal(d.x,!0)),cy:pluckNumber(e.y,c.getScaledVal(d.y,!1))};}c._setConfig('attr',a)}_getAnnotationAttrs(){let a,b=this,c=b.config,d=b.config.attr||{},e=c.x,f=c.y,g=b.getScaledVal(c.xRadius),h=b.getScaledVal(c.yRadius),i=b.getScaledVal(c.innerRadius),j=b.getScaledVal(c.innerYRadius),k=c.startAngle,l=c.endAngle,m=c.borderColor,n=c.borderThickness,o=c.dashArrayStr,p=c.color;switch(c.xRadius||(g=0),c.yRadius||(h=0),d.fill=p,d.stroke=m,d['stroke-width']=n,d['stroke-dasharray']=o,b.config.elementType){case'ringpath':a=[b.getScaledVal(e,!0),b.getScaledVal(f,!1),g,i,toRadian(FULL_ANGLE_DEGREES-l),toRadian(FULL_ANGLE_DEGREES-k),h,j],d.ringpath=d.ringpath||a;break;default:d.rx=g,d.ry=h,d.cx='undefined'==typeof d.cx?b.getScaledVal(e,!0):d.cx,d.cy='undefined'==typeof d.cy?b.getScaledVal(f,!1):d.cy;}return d}}export default CircleAnnotation;