UNPKG

@fusioncharts/features

Version:

FusionCharts JavaScript charting framework

1 lines 2.36 kB
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _lib=require("@fusioncharts/core/src/lib");var _annotationShape=_interopRequireDefault(require("./annotation-shape"));var DEFAULT_RADIUS=0,ELEMENT_TYPE_RECT="rect";var RectAnnotation=function(_AnnotationShape){function RectAnnotation(){return _AnnotationShape.apply(this,arguments)||this}(0,_inheritsLoose2.default)(RectAnnotation,_AnnotationShape);var _proto=RectAnnotation.prototype;_proto.getName=function getName(){return"rect"};_proto.configureAttributes=function configureAttributes(rawConfig){if(rawConfig===void 0){rawConfig={}}_AnnotationShape.prototype.configureAttributes.call(this,rawConfig);var rect=this;rect.config.xRadius=(0,_lib.pluckNumber)(parseFloat(rect.rawConfig.radius),DEFAULT_RADIUS);rect.config.elementType=ELEMENT_TYPE_RECT};_proto.updateAttr=function updateAttr(){var _ref,_ref2;var rect=this,config=this.config,x,y,tox,toy,attr=config.calculatedAttrs;x=(0,_lib.pluckNumber)(attr.x,rect.getScaledVal(config.x,true));y=(0,_lib.pluckNumber)(attr.y,rect.getScaledVal(config.y,false));tox=(0,_lib.pluckNumber)(attr.toX,rect.getScaledVal(config.tox,true));toy=(0,_lib.pluckNumber)(attr.toY,rect.getScaledVal(config.toy,false));toy>=0&&y>=0&&toy<y&&(_ref=[toy,y],y=_ref[0],toy=_ref[1],_ref);tox>=0&&x>=0&&tox<x&&(_ref2=[tox,x],x=_ref2[0],tox=_ref2[1],_ref2);rect._setConfig("attr",{x:x,y:y,width:Math.abs(tox-x),height:Math.abs(toy-y)})};_proto._getAnnotationAttrs=function _getAnnotationAttrs(){var rect=this,config=rect.config,attr=rect._getConfig("attr")||{},x=rect.getScaledVal(config.x),y=rect.getScaledVal(config.y);attr.x=typeof attr.x==="undefined"?x:attr.x;attr.y=typeof attr.y==="undefined"?y:attr.y;attr.width=typeof attr.width==="undefined"?Math.abs(rect.getScaledVal(config.tox)-x):attr.width;attr.height=typeof attr.height==="undefined"?Math.abs(rect.getScaledVal(config.toy)-y):attr.height;attr.r=rect.getScaledVal(config.xRadius);attr.fill=config.color;attr.stroke=config.borderColor;attr["stroke-width"]=config.borderThickness;attr["stroke-dasharray"]=config.dashArrayStr;return attr};return RectAnnotation}(_annotationShape.default);var _default=exports.default=RectAnnotation;