@fusioncharts/features
Version:
FusionCharts JavaScript charting framework
1 lines • 2.19 kB
JavaScript
;var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _annotationShape=_interopRequireDefault(require("./annotation-shape"));var _lib=require("@fusioncharts/core/src/lib");var DEFAULT_POLYGON_SIDES=5,DEFAULT_ANGLE_START=0,ELEMENT_TYPE_POLYPATH="polypath";var PolygonAnnotation=function(_AnnotationShape){function PolygonAnnotation(){return _AnnotationShape.apply(this,arguments)||this}(0,_inheritsLoose2.default)(PolygonAnnotation,_AnnotationShape);var _proto=PolygonAnnotation.prototype;_proto.getName=function getName(){return"polygon"};_proto.configureAttributes=function configureAttributes(rawConfig){if(rawConfig===void 0){rawConfig={}}_AnnotationShape.prototype.configureAttributes.call(this,rawConfig);var polygon=this,shapeConfig=polygon.rawConfig;polygon.config.sides=(0,_lib.pluckNumber)((0,_lib.clampNumber)(shapeConfig.sides,3),DEFAULT_POLYGON_SIDES);polygon.config.startAngle=(0,_lib.pluckNumber)(parseFloat(shapeConfig.startAngle),DEFAULT_ANGLE_START);polygon.config.xRadius=(0,_lib.pluckNumber)(parseFloat(shapeConfig.radius),0);polygon.config.elementType=ELEMENT_TYPE_POLYPATH};_proto.updateAttr=function updateAttr(){var polygon=this,config=polygon.config,attr=config.calculatedAttrs;polygon._setConfig("attr",{polypath:[config.sides,(0,_lib.pluckNumber)(attr.x,polygon.getScaledVal(config.x,true)),(0,_lib.pluckNumber)(attr.y,polygon.getScaledVal(config.y,false)),polygon.getScaledVal(config.xRadius),config.startAngle,0]})};_proto._getAnnotationAttrs=function _getAnnotationAttrs(){var polygon=this,config=polygon.config,attr=polygon._getConfig("attr")||{};attr.fill=config.color;attr.stroke=config.borderColor;attr["stroke-width"]=config.borderThickness;attr["stroke-dasharray"]=config.dashArrayStr;attr.polypath=attr.polypath||[config.sides,polygon.getScaledVal(config.x,true),polygon.getScaledVal(config.y,false),polygon.getScaledVal(config.xRadius),config.startAngle,0];return attr};return PolygonAnnotation}(_annotationShape.default);var _default=exports.default=PolygonAnnotation;