@fusioncharts/charts
Version:
JavaScript Data Visualisation Library
1 lines • 65.5 kB
JavaScript
"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 _componentInterface=require("@fusioncharts/core/src/component-interface");var UNDEF,compositionKeys={},TRACKER_FILL="rgba(192,192,192,"+(_lib.isIE?.002:1e-6)+")",legendManager,FORMER_SLIDER_INDEX=false,LATER_SLIDER_INDEX=true,PERCENT_STR="%",COMMA_STR=",",DEF_COLOR="#000000",CANVAS_WIDTH="canvasWidth",CANVAS_LEFT="canvasLeft",CANVAS_HEIGHT="canvasHeight",CANVAS_TOP="canvasTop",VERTICAL="vertical",ABSOLUTE="absolute",TOP="top",BOTTOM="bottom",LEFT="left",RIGHT="right",GL_CARPET="GL_CARPET",GL_CAPTION="GL_CAPTION",GL_BODY="GL_BODY",GL_LABELS="GL_LABELS",FL_AXIS="FL_AXIS",GL_SG1="GL_SG1",GL_VALUES="GL_VALUES",FC_GRADIENT_LEGEND="fc-gradient-legend",hasOwnProp={}.hasOwnProperty,M="M",L="L",gLegendRef;function merge(src,snk){(function rec(source,sink){var sourceVal,prop;for(prop in source){if(!hasOwnProp.call(source,prop)){continue}sourceVal=source[prop];if(sink[prop]===UNDEF){sink[prop]=sourceVal}else if(typeof sourceVal==="object"&&sourceVal!==null){rec(sourceVal,sink[prop])}}})(src,snk);return snk}function getValidHexColor(code){var color=code||DEF_COLOR;return(0,_lib.getValidColor)(color)||DEF_COLOR}function getOppositeColor(code){return(0,_lib.getLightColor)(code,1)}function normalizeFontSizeAppend(obj){var fontSize=obj.fontSize+"",normalizeFontSize;if(!fontSize){return obj}normalizeFontSize=fontSize.replace(/(\d+)(px)*/,"$1px");obj.fontSize=normalizeFontSize;return obj}function isInvalid(arg){if(arg===UNDEF||typeof arg==="undefined"||arg===null||isNaN(arg)){return true}return false}compositionKeys.CAPTION="CAPTION";compositionKeys.LEGEND_BODY="LEGEND_BODY";compositionKeys.AXIS_LABEL="LEGEND_LABEL";compositionKeys.LEGEND_AXIS="LEGEND_AXIS";compositionKeys.RANGE="RANGE";compositionKeys.AXIS_VALUE="AXIS_VALUE";legendManager=function(){var chart,defaultConf={};defaultConf.legendCarpetConf={spreadFactor:.85,allowDrag:false,captionAlignment:"center",padding:{v:3,h:3},style:{fill:"#e4d9c1",stroke:"#c4b89d"}};defaultConf.legendCaptionConf={spreadFactor:.2,padding:{v:2,h:2},style:{fill:"#786B50",fontFamily:"sans-serif",fontSize:"12px",fontWeight:"bold",fontStyle:"normal"},bound:{style:{stroke:"none"}}};defaultConf.legendBodyConf={spreadFactor:.8,padding:{v:2,h:2},bound:{style:{stroke:"none"}}};defaultConf.legendAxisConf={legendAxisHeight:11,spreadFactor:.4,padding:{v:1,h:1},style:{stroke:"none","stroke-opacity":0,"stroke-width":1},line:{grooveLength:3,offset:8,style:{stroke:"rgba(255, 255, 255, 0.65)","stroke-width":1.5}},shadow:{style:{stroke:"none",fill:(0,_lib.toRaphaelColor)({FCcolor:{alpha:"25,0,0",angle:360,color:"000000,FFFFFF,FFFFFF",ratio:"0,30,40"}})}},bound:{style:{stroke:"none"}}};defaultConf.sliderGroupConf={showTooltip:1,outerCircle:{rFactor:1.4,style:{fill:TRACKER_FILL,stroke:"#757575","stroke-width":3}},innerCircle:{rFactor:.65,style:{fill:TRACKER_FILL,stroke:"#FFFFFF"}}};defaultConf.axisTextItemConf={spreadFactor:.3,padding:{v:1,h:1},style:{fill:"#786B50",fontFamily:"sans-serif",fontSize:"12px",fontWeight:"normal",fontStyle:"normal"}};function normalizePreprocessedData(confArr){var numberFormatter=chart.getFromEnv("number-formatter"),index,length,rawVal;for(index=0,length=confArr.length;index<length;index++){rawVal=confArr[index].maxvalue;if(!rawVal){continue}confArr[index].maxvalue=numberFormatter.getCleanValue(rawVal)}}return{init:function init(options){chart=options.chart},legacyDataParser:function legacyDataParser(data,extremes){var colormanagerConf={},numberFormatter=chart.getFromEnv("number-formatter"),colorConfArr,colorConf,startColor,endColor,index,validColor,length,colorRange,value,dispValue,mapByPercent,isMaxValPresent;if(!data){return false}colormanagerConf.mapByPercent=mapByPercent=!!(0,_lib.pluckNumber)(data.mapbypercent,0);colorConfArr=data.color||[];if(data.minvalue===UNDEF){data.minvalue=extremes.min!==UNDEF?mapByPercent?0:extremes.min:0}if(data.maxvalue===UNDEF){data.maxvalue=extremes.max!==UNDEF?mapByPercent?100:extremes.max:100}isMaxValPresent=false;for(index=0,length=colorConfArr.length;index<length;index++){if(colorConfArr[index].maxvalue){isMaxValPresent=true;break}}if(!isMaxValPresent){colorConfArr=[]}startColor=data.code;colorRange=colormanagerConf.colorRange=[];colormanagerConf.gradient=!!(0,_lib.pluckNumber)(data.gradient,1);if(!colorConfArr.length){if(startColor){endColor=getValidHexColor(startColor);startColor=getValidHexColor()}else{startColor=getValidHexColor();endColor=getOppositeColor(startColor)}colorConfArr.push({code:endColor,maxvalue:data.maxvalue,label:UNDEF})}else{startColor=getValidHexColor(startColor)}normalizePreprocessedData(colorConfArr);colorConfArr=colorConfArr.sort((function(m,n){return m.maxvalue-n.maxvalue}));value=dispValue=data.minvalue&&numberFormatter.getCleanValue(data.minvalue);dispValue=(value!==UNDEF||value!==null)&&(mapByPercent?value+PERCENT_STR:numberFormatter.legendValue(value));colorRange.push({code:(0,_lib.dehashify)(startColor),value:value,displayValue:dispValue,label:data.startlabel});for(index=0,length=colorConfArr.length;index<length;index++){colorConf=colorConfArr[index];validColor=getValidHexColor(colorConf.code||colorConf.color);value=dispValue=colorConf.maxvalue;if(isNaN(parseInt(value,10))){continue}dispValue=(value!==UNDEF||value!==null)&&(mapByPercent?value+PERCENT_STR:numberFormatter.legendValue(value));colorRange.push({code:(0,_lib.dehashify)(validColor),value:value,displayValue:dispValue,label:(0,_lib.parseUnsafeString)(colorConf.label||colorConf.displayvalue)})}colorRange[colorRange.length-1].label=(0,_lib.parseUnsafeString)(data.endlabel||colorConf.label);return colormanagerConf},getDefaultConf:function getDefaultConf(key){return defaultConf[key]}}}();var GLegend=function(_ComponentInterface){function GLegend(){var _this;_this=_ComponentInterface.call(this)||this;gLegendRef=_this;_this.enabled=false;_this.drawOptions={};_this.components={};return _this}(0,_inheritsLoose2.default)(GLegend,_ComponentInterface);var _proto=GLegend.prototype;_proto.getType=function getType(){return"gradientLegend"};_proto.getName=function getName(){return"gLegend"};_proto.setColorRange=function setColorRange(colorRange){var cr=this.drawOptions.colorRange=colorRange;cr&&cr._preparationGoneWrong&&(this._dontPlot=true)};_proto.configureAttributes=function configureAttributes(){var componentAPI=this,chart=componentAPI.getFromEnv("chart"),chartAttrs=componentAPI.getFromEnv("dataSource").chart,conf=componentAPI.conf={},outCanvasBaseFont=chartAttrs.outcnvbasefont,outCanvasBaseFontSize=this.computeFontSize(chartAttrs.outcnvbasefontsize),outCanvasBaseFontColor=chartAttrs.outcnvbasefontcolor,labelStyle=chart.config.dataLabelStyle,fColor,fFamily,fSize,fSizeWithUnit,fWeight,cfColor,cfFamily,cfSize,cfSizeWithUnit,cfWeight,axisBorderColor,axisBorderAlpha;legendManager.init({chart:chart});componentAPI.data=componentAPI.getFromEnv("dataSource").colorrange;if(componentAPI._dontPlot){return}componentAPI.drawOptions={smartLabel:componentAPI.getFromEnv("smartLabel"),gLegend:componentAPI};componentAPI._dontPlot=false;componentAPI._recalculateLogicalSpace=true;conf.caption=(0,_lib.parseUnsafeString)((0,_lib.pluck)(chartAttrs.legendcaption));conf.legendPosition=(0,_lib.pluck)(chartAttrs.legendposition,"bottom").toLowerCase();conf.legendXPosition=(0,_lib.pluckNumber)(chartAttrs.legendxposition,0);conf.legendYPosition=(0,_lib.pluckNumber)(chartAttrs.legendyposition,0);conf.legendMaxHeight=(0,_lib.pluckNumber)(chartAttrs.legendmaxheight,0);conf.legendMaxWidth=(0,_lib.pluckNumber)(chartAttrs.legendmaxwidth,0);conf.legendVertical=typeof chartAttrs.legendorientation==="string"&&chartAttrs.legendorientation.toLowerCase()===VERTICAL;conf.showLegend=(0,_lib.pluckNumber)(chartAttrs.showlegend,1);conf.interactiveLegend=(0,_lib.pluckNumber)(chartAttrs.interactivelegend,1);conf.showLegendLabels=(0,_lib.pluckNumber)(chartAttrs.showlegendlabels,1);fColor=chartAttrs.legenditemfontcolor||outCanvasBaseFontColor;fFamily=chartAttrs.legenditemfont||outCanvasBaseFont;fSize=chartAttrs.legenditemfontsize||outCanvasBaseFontSize;fSizeWithUnit=(0,_lib.pluckFontSizeMaintainUnit)(chartAttrs.legenditemfontsize,chartAttrs.outcnvbasefontsize);fWeight=(0,_lib.pluckNumber)(chartAttrs.legenditemfontbold,0);cfColor=chartAttrs.legendcaptionfontcolor||outCanvasBaseFontColor;cfFamily=chartAttrs.legendcaptionfont||outCanvasBaseFont;cfSize=chartAttrs.legendcaptionfontsize||outCanvasBaseFontSize;cfSizeWithUnit=(0,_lib.pluckFontSizeMaintainUnit)(chartAttrs.legendcaptionfontsize,chartAttrs.outcnvbasefontsize);cfWeight=(0,_lib.pluckNumber)(chartAttrs.legendcaptionfontbold,1);axisBorderColor=chartAttrs.legendaxisbordercolor?(0,_lib.hashify)((0,_lib.dehashify)(chartAttrs.legendaxisbordercolor)):UNDEF;axisBorderAlpha=axisBorderColor?(0,_lib.pluckNumber)(chartAttrs.legendaxisborderalpha,100)/100:UNDEF;conf.axisTextItemConf={style:{fill:fColor?(0,_lib.convertColor)((0,_lib.pluck)(fColor)):labelStyle.color,fontFamily:fFamily?(0,_lib.pluck)(fFamily):labelStyle.fontFamily,fontSize:fSize?(0,_lib.pluckNumber)(fSize):labelStyle.fontSize.match(/\d+/)[0],fontSizeWithUnit:(0,_lib.pluckFontSizeMaintainUnit)(fSizeWithUnit,labelStyle.fontSize.match(/\d+/)[0]),fontWeight:fWeight?"bold":labelStyle.fontWeight}};conf.legendCaptionConf={style:{fill:cfColor?(0,_lib.convertColor)((0,_lib.pluck)(cfColor)):labelStyle.color,fontFamily:cfFamily?(0,_lib.pluck)(cfFamily):labelStyle.fontFamily,fontSize:cfSize?(0,_lib.pluckNumber)(cfSize):labelStyle.fontSize.match(/\d+/)[0],fontSizeWithUnit:(0,_lib.pluckFontSizeMaintainUnit)(cfSizeWithUnit,labelStyle.fontSize.match(/\d+/)[0]),fontWeight:cfWeight?"bold":labelStyle.fontWeight,fontStyle:"normal"}};conf.legendAxisConf={legendAxisHeight:11,style:{stroke:axisBorderColor,"stroke-opacity":axisBorderAlpha},line:{style:{stroke:(0,_lib.convertColor)((0,_lib.pluck)(chartAttrs.legendscalelinecolor,"FFF8E9"),(0,_lib.pluckNumber)(chartAttrs.legendscalelinealpha,100)),"stroke-width":(0,_lib.pluckNumber)(chartAttrs.legendscalelinethickness)}}};conf.sliderGroupConf={showTooltip:(0,_lib.pluckNumber)(chartAttrs.showtooltip,1),outerCircle:{rFactor:(0,_lib.pluckNumber)(chartAttrs.sliderdiameterfactor),style:{stroke:(0,_lib.convertColor)((0,_lib.pluck)(chartAttrs.legendpointerbordercolor,"757575"),(0,_lib.pluckNumber)(chartAttrs.legendpointerborderalpha,100))}},innerCircle:{rFactor:(0,_lib.pluckNumber)(chartAttrs.sliderholediameterfactor),style:{stroke:(0,_lib.convertColor)((0,_lib.pluck)(chartAttrs.legendpointercolor,"FFFFFF"),(0,_lib.pluckNumber)(chartAttrs.legendpointeralpha,100))}}};conf.legendCarpetConf={spreadFactor:(0,_lib.pluckNumber)(chartAttrs.legendspreadfactor),allowDrag:!!(0,_lib.pluckNumber)(chartAttrs.legendallowdrag,0),captionAlignment:(0,_lib.pluck)(chartAttrs.legendcaptionalignment,"center"),style:{fill:(0,_lib.convertColor)((0,_lib.pluck)(chartAttrs.legendbgcolor,"e4d9c1"),(0,_lib.pluckNumber)(chartAttrs.legendbgalpha,100)),stroke:(0,_lib.convertColor)((0,_lib.pluck)(chartAttrs.legendbordercolor,"c4b89d"),(0,_lib.pluckNumber)(chartAttrs.legendborderalpha,100)),"stroke-width":(0,_lib.pluckNumber)(chartAttrs.legendborderthickness,1)}}};_proto.postConfigureInit=function postConfigureInit(){var componentAPI=this,conf=componentAPI.conf,caption,carpet,axis,sGroup,ovrdConf,ovrdTextConf,body,labels,values,captionConfig,axisConfig,legendPosition=conf.legendPosition?conf.legendPosition.split("-"):[],bodyConfig;componentAPI.elem={};if(conf.interactiveLegend){ovrdConf=merge(legendManager.getDefaultConf("sliderGroupConf"),conf.sliderGroupConf);if(this.sGroup){sGroup=componentAPI.elem.sGroup=this.sGroup;sGroup.configure(ovrdConf);componentAPI.elem.sGroup.gLegend=componentAPI}else{this.sGroup=componentAPI.elem.sGroup=sGroup=new SliderGroup(ovrdConf);sGroup.configure(ovrdConf);componentAPI.elem.sGroup.gLegend=componentAPI}}else{this.sGroup&&this.sGroup.dispose();this.sGroup&&delete this.sGroup}ovrdConf=merge(legendManager.getDefaultConf("legendCarpetConf"),conf.legendCarpetConf);ovrdConf.legendPosition=legendPosition[0]===ABSOLUTE&&!conf.legendVertical||legendPosition[0]===TOP||legendPosition[0]===BOTTOM?BOTTOM:RIGHT;bodyConfig=legendManager.getDefaultConf("legendBodyConf");if(legendPosition[0]===ABSOLUTE&&!conf.legendVertical||legendPosition[0]===TOP||legendPosition[0]===BOTTOM){componentAPI.drawOptions.refSideKey=CANVAS_WIDTH;componentAPI.drawOptions.refOffsetKey=CANVAS_LEFT;ovrdTextConf=merge(legendManager.getDefaultConf("axisTextItemConf"),conf.axisTextItemConf);bodyConfig.legendPosition=BOTTOM;axisConfig=merge(legendManager.getDefaultConf("legendAxisConf"),conf.legendAxisConf);axisConfig.legendPosition=BOTTOM;ovrdTextConf.legendPosition=BOTTOM}else{componentAPI.drawOptions.refSideKey=CANVAS_HEIGHT;componentAPI.drawOptions.refOffsetKey=CANVAS_TOP;ovrdTextConf=merge(legendManager.getDefaultConf("axisTextItemConf"),conf.axisTextItemConf);bodyConfig.legendPosition=RIGHT;axisConfig=merge(legendManager.getDefaultConf("legendAxisConf"),conf.legendAxisConf);axisConfig.legendPosition=RIGHT;ovrdTextConf.legendPosition=RIGHT}if(!Object.keys(this.components).length){this.components.LegendCarpet=new LegendCarpet;this.components.LegendBody=new LegendBody;this.components.LegendAxis=new LegendAxis;this.components.LegendValues=new LegendValues;conf.showLegendLabels&&(this.components.LegendLabels=new LegendLabels)}axis=this.components.LegendAxis;values=this.components.LegendValues;carpet=this.components.LegendCarpet;body=this.components.LegendBody;conf.showLegendLabels&&(labels=this.components.LegendLabels);this.components.LegendCarpet.configure(ovrdConf);this.components.LegendValues.configure(ovrdTextConf);this.components.LegendAxis.configure(axisConfig);this.components.LegendBody.configure(componentAPI.drawOptions.colorRange,bodyConfig,ovrdTextConf);conf.showLegendLabels&&labels.configure(ovrdTextConf);if(conf.caption){captionConfig=merge(legendManager.getDefaultConf("legendCaptionConf"),conf.legendCaptionConf);if(this.componentCaption&&Object.keys(this.componentCaption).length){this.componentCaption.configure(conf.caption,captionConfig)}else{caption=this.componentCaption=new LegendCaption;caption.configure(conf.caption,captionConfig)}carpet.addCompositions(this.componentCaption,compositionKeys.CAPTION)}else{carpet.removeCompositions(compositionKeys.CAPTION);this.componentCaption&&this.componentCaption.dispose();delete this.componentCaption}sGroup&&axis.addCompositions(sGroup,compositionKeys.RANGE);labels&&body.addCompositions(labels,compositionKeys.AXIS_LABEL);body.addCompositions(axis,compositionKeys.LEGEND_AXIS);body.addCompositions(values,compositionKeys.AXIS_VALUE);carpet.addCompositions(body,compositionKeys.LEGEND_BODY);componentAPI.elem.gl=new LegendBase(carpet)};_proto.getValueRange=function getValueRange(){var componentAPI=this,rGroup=componentAPI.elem&&componentAPI.elem.sGroup,sliders=rGroup.sliders,extremes=rGroup.extremes,minVal,maxVal;minVal=sliders["false"].currPos;maxVal=extremes[1]-extremes[0]+sliders["true"].currPos;return[{min:rGroup.getValueFormPixel(minVal),max:rGroup.getValueFormPixel(maxVal)}]};_proto._dispose=function _dispose(){var componentAPI=this;componentAPI.elem&&componentAPI.elem.gl&&componentAPI.elem.gl.dispose();componentAPI.elem={};_ComponentInterface.prototype._dispose.call(this)};_proto.getCalculatedLogicalSpace=function getCalculatedLogicalSpace(){return this._logicalArea};_proto.setCalculatedLogicalSpace=function setCalculatedLogicalSpace(area){this._logicalArea=area};_proto.getLogicalSpace=function getLogicalSpace(maxOtherSide){var componentAPI=this,conf=componentAPI.conf,zeroArea={height:0,width:0},logicalSpace,drawOptions=componentAPI.drawOptions,refSideKey,chartConfig=componentAPI.getFromEnv("chartConfig"),refOffsetKey,isAbsolute=conf.legendPosition.split("-")[0]===ABSOLUTE,maxHeight,maxWidth;if(!componentAPI._recalculateLogicalSpace){refSideKey=drawOptions.refSideKey;refOffsetKey=drawOptions.refOffsetKey;componentAPI.drawOptions.refSide=chartConfig[refSideKey];if(isAbsolute){if(conf.legendMaxHeight<=0){maxHeight=chartConfig.height*.8}else if(conf.legendMaxHeight<=chartConfig.height){maxHeight=conf.legendMaxHeight}else{maxHeight=chartConfig.height}if(conf.legendMaxWidth<=0){maxWidth=chartConfig.width*.8}else if(conf.legendMaxWidth<=chartConfig.width){maxWidth=conf.legendMaxWidth}else{maxWidth=chartConfig.width}if(conf.legendVertical){componentAPI.drawOptions.refSide=maxHeight;componentAPI.drawOptions.maxOtherSide=maxWidth}else{componentAPI.drawOptions.refSide=maxWidth;componentAPI.drawOptions.maxOtherSide=maxHeight}}else{componentAPI.drawOptions.refOffset=chartConfig[refOffsetKey];componentAPI.drawOptions.maxOtherSide=maxOtherSide||componentAPI.drawOptions.maxOtherSide}logicalSpace=componentAPI.elem.gl.getLogicalSpace(componentAPI.drawOptions,true);componentAPI.setCalculatedLogicalSpace(logicalSpace);return componentAPI.getCalculatedLogicalSpace()||zeroArea}if(componentAPI._dontPlot){return zeroArea}componentAPI._recalculateLogicalSpace=false;componentAPI.postConfigureInit();if(!conf.showLegend){return zeroArea}refSideKey=drawOptions.refSideKey;refOffsetKey=drawOptions.refOffsetKey;componentAPI.drawOptions.refSide=chartConfig[refSideKey];componentAPI.drawOptions.refOffset=chartConfig[refOffsetKey];componentAPI.drawOptions.maxOtherSide=maxOtherSide||componentAPI.drawOptions.maxOtherSide;if(componentAPI.elem.gl){logicalSpace=componentAPI.elem.gl.getLogicalSpace(componentAPI.drawOptions,true);componentAPI.elem.gl&&componentAPI.setCalculatedLogicalSpace(logicalSpace)}return componentAPI.getCalculatedLogicalSpace()};_proto.resetLegend=function resetLegend(){var componentAPI=this,rGroup;rGroup=componentAPI.elem&&componentAPI.elem.sGroup;if(rGroup){rGroup.reset()}};_proto._calculateTopPosition=function _calculateTopPosition(y){var legend=this,chart=legend.getFromEnv("chart"),chartConfig=chart.config,yPos=y,caption=chart.getChildren("caption")&&chart.getChildren("caption")[0],subCaption=chart.getChildren("subCaption")&&chart.getChildren("subCaption")[0],toolbar=chart.getChildren("chartMenuBar")&&chart.getChildren("chartMenuBar")[0],oriCanvasTop=chartConfig.oriTopSpace;if(!chartConfig.toolbarY&&toolbar&&toolbar.props&&toolbar.props.height){if(!(oriCanvasTop>toolbar.props.height+toolbar.props.y)){yPos=toolbar.props.y+toolbar.props.height}}if(caption&&caption.config&&caption.config.text&&caption.config.text!==_lib.BLANKSTRING&&caption.config.height&&caption.config.isOnTop===1){yPos=caption.config.height+caption.config.y+caption.config.captionPadding}if(subCaption&&subCaption.config&&subCaption.config.height&&subCaption.config.isOnTop===1){yPos=subCaption.config.y+subCaption.config.height+(caption&&caption.config&&caption.config.captionPadding||0)}return yPos>y?yPos:y};_proto.allocatePosition=function allocatePosition(){var iapi=this.getFromEnv("chart"),config=iapi.config,gradientLegend=this,conf=gradientLegend.conf||{},legendPosition=conf.legendPosition.split("-"),canvasLeft=config.canvasLeft,canvasTop=config.canvasTop,canvasWidth=config.canvasWidth,canvasHeight=config.canvasHeight,marginTop=config.marginTop,marginBottom=config.marginBottom,marginRight=config.marginRight,marginLeft=config.marginLeft,spaceTakenByGradientLegend,spaceLeft,width,height,xPos,yPos,xLim,yLim;conf.axisTextItemConf.style.fontSize=this.computeFontSize(conf.axisTextItemConf.style.fontSizeWithUnit);conf.legendCaptionConf.style.fontSize=this.computeFontSize(conf.legendCaptionConf.style.fontSizeWithUnit);if(!iapi.config.gLegendEnabled){return}spaceTakenByGradientLegend=this.getCalculatedLogicalSpace();width=conf.width=spaceTakenByGradientLegend.width;height=conf.height=spaceTakenByGradientLegend.height;if(legendPosition[0]===ABSOLUTE){xLim=config.width-width;yLim=config.height-height;xPos=conf.legendXPosition<0?0:conf.legendXPosition>xLim?xLim:conf.legendXPosition;yPos=conf.legendYPosition<0?0:conf.legendYPosition>yLim?yLim:conf.legendYPosition}else if(legendPosition[0]===TOP||legendPosition[0]===BOTTOM){spaceLeft=canvasWidth-width;if(legendPosition[1]===LEFT){xPos=canvasLeft}else if(legendPosition[1]===RIGHT){xPos=canvasLeft+(spaceLeft>0?spaceLeft:0)}else{xPos=canvasLeft+(spaceLeft<0?0:spaceLeft/2)}if(legendPosition[0]===TOP){yPos=this._calculateTopPosition(marginTop)}else{yPos=config.height-spaceTakenByGradientLegend.height-marginBottom-(config.actionBarHeight||0)}}else{spaceLeft=canvasHeight-height;if(legendPosition[1]===TOP){yPos=canvasTop}else if(legendPosition[1]===BOTTOM){yPos=canvasTop+spaceLeft}else{yPos=canvasTop+(spaceLeft<0?0:spaceLeft/2)}if(legendPosition[0]===LEFT){xPos=marginLeft}else{xPos=config.width-spaceTakenByGradientLegend.width-marginRight}}conf.xPos=xPos;conf.yPos=yPos};_proto.draw=function draw(){var iapi=this.getFromEnv("chart"),colorRangeObj=iapi.getFromEnv("dataSource").colorrange,gradientLegend=this,conf=gradientLegend.conf||{},hasGradientLegend=iapi.hasGradientLegend;if(!iapi.config.gLegendEnabled){return}colorRangeObj&&hasGradientLegend&&gradientLegend.drawLegendComponent(conf.xPos,conf.yPos,{parentGroup:iapi.getContainer("parentgroup"),animationManager:iapi.getFromEnv("animationManager")})};_proto.drawLegendComponent=function drawLegendComponent(x,y,options){var componentAPI=this,conf=componentAPI.conf,measurement,node;if(componentAPI._dontPlot){return}if(!conf.showLegend){componentAPI.enabled=false;return}componentAPI.drawOptions.animationManager=options.animationManager;componentAPI.drawOptions.parentGroup=options.parentGroup;componentAPI.drawOptions.x=x;componentAPI.drawOptions.y=y;componentAPI.drawOptions.maxOtherSide=componentAPI.drawOptions.maxOtherSide||options.maxOtherSide;node=componentAPI.elem.gl.draw(componentAPI.drawOptions);measurement=node.getBBox();conf.xPos=measurement.x;conf.yPos=measurement.y;conf.height=measurement.height;conf.width=measurement.width;componentAPI.enabled=true};return GLegend}(_componentInterface.ComponentInterface);var LegendBase=function(){function LegendBase(carpet){this.carpet=carpet}var _proto2=LegendBase.prototype;_proto2.draw=function draw(options){return this.carpet.draw(options)};_proto2.getLogicalSpace=function getLogicalSpace(options,recalculate){return this.carpet.getLogicalSpace(options,recalculate)};_proto2.dispose=function dispose(){this.carpet&&this.carpet.group&&this.carpet.group.remove()};return LegendBase}();var LegendCarpet=function(){function LegendCarpet(conf){this.conf=conf;this._id=GL_CARPET;this.compositionsByCategory={};this.node=UNDEF;this.group=UNDEF;this._lSpace=UNDEF;this.autoRecalculate=false;this.groupName=FC_GRADIENT_LEGEND;this.moveInstructions={}}var _proto3=LegendCarpet.prototype;_proto3.configure=function configure(conf){this.conf=conf};_proto3.getName=function getName(){return"LegendCarpet"};_proto3.getType=function getType(){return"legend"};_proto3.addCompositions=function addCompositions(instance,category){this.compositionsByCategory[category]=instance};_proto3.removeCompositions=function removeCompositions(category){delete this.compositionsByCategory[category]};_proto3.getBoundingBox=function getBoundingBox(options){var conf=this.conf,spreadFactor=conf.spreadFactor,refSide=options.refSide,alignment=options.alignment,refOffset=options.refOffset,x=options.x,y=options.y,lWidth,lHeight;if(this.conf.legendPosition==="bottom"){lWidth=conf.width=refSide*spreadFactor;lHeight=options.maxOtherSide;if(alignment&&(x===UNDEF||x===null)){x=(refOffset+refSide)/2-lWidth/2}}else{lHeight=conf.height=refSide*spreadFactor;lWidth=options.maxOtherSide;if(alignment&&(y===UNDEF||y===null)){y=(refOffset+refSide)/2-lHeight/2}}return{width:lWidth,height:lHeight,x:x,y:y}};_proto3.getPostCalcDecisionsH=function getPostCalcDecisionsH(bBox,componentsArea){var conf=this.conf,padding=conf.padding,cat,totalHeightTaken=0;this.moveInstructions={};for(cat in componentsArea){totalHeightTaken+=componentsArea[cat].height||0}bBox.height=totalHeightTaken+2*padding.v};_proto3.getLogicalSpace=function getLogicalSpace(options,recalculate){var lSpace=this._lSpace,categoryMap=["CAPTION","LEGEND_BODY"],conf=this.conf,padding=conf.padding,compositionsByCategory=this.compositionsByCategory,composition,bBox,effectivePlotArea,compositionLSPace,compositionHeight=0,componentsArea={},compositionPlotArea,heightNotUsed=0;if(lSpace&&!recalculate){lSpace.isImpure=true;return lSpace}lSpace=this._lSpace=bBox=this.getBoundingBox(options);if(isInvalid(lSpace.x)||isInvalid(lSpace.y)||isInvalid(lSpace.height)||isInvalid(lSpace.width)){this.autoRecalculate=true}effectivePlotArea=merge(bBox,{});effectivePlotArea.height-=2*padding.v;effectivePlotArea.width-=2*padding.h;effectivePlotArea.x+=padding.h;effectivePlotArea.y+=padding.v;for(var i=0;i<categoryMap.length;i++){composition=compositionsByCategory[categoryMap[i]];if(composition){compositionPlotArea=merge(effectivePlotArea,{});compositionPlotArea.y+=compositionHeight;compositionHeight=effectivePlotArea.height*composition.conf.spreadFactor;compositionPlotArea.height=compositionHeight+heightNotUsed;compositionLSPace=composition.getLogicalSpace(merge(compositionPlotArea,{}),options,recalculate);heightNotUsed=compositionPlotArea.height-compositionLSPace.height;componentsArea[categoryMap[i]]=compositionLSPace;compositionHeight=compositionLSPace.height}}this.getPostCalcDecisions(bBox,componentsArea);this._lSpace=bBox;return bBox};_proto3.setupDragging=function setupDragging(){var group=this.group,dx=0,dy=0,idx=0,idy=0;group.css({cursor:"move"});group.drag((function(_dx,_dy){dx=_dx;dy=_dy;group.attr({transform:"t"+(idx+dx)+","+(idy+dy)})}),(function(){idx+=dx;idy+=dy}),_lib.stubFN)};_proto3.draw=function draw(options){var conf=this.conf,ref=this,categoryMap=["CAPTION","LEGEND_BODY"],compositionsByCategory=this.compositionsByCategory,animationManager=options.animationManager,parentGroup=options.parentGroup,group,category,composition,lSpace;this.getLogicalSpace(options,this.autoRecalculate);lSpace=this._lSpace;this.group=group=animationManager.setAnimation({el:this.group||"group",attr:{name:ref.groupName},component:gLegendRef,container:parentGroup,label:"carpetGroup"});this.node=animationManager.setAnimation({el:this.node||"rect",attr:lSpace,css:conf.style,component:gLegendRef,container:group,label:"rect"});for(var i=0;i<categoryMap.length;i++){composition=compositionsByCategory[categoryMap[i]];if(composition){composition.draw(conf.captionAlignment,lSpace,{animationManager:animationManager,colorRange:options.colorRange,numberFormatter:options.numberFormatter,parentLayer:group,smartLabel:options.smartLabel,moveInstructions:this.moveInstructions[category],gLegend:options.gLegend})}}conf.allowDrag&&this.setupDragging();return this.node};_proto3.getPostCalcDecisions=function getPostCalcDecisions(bBox,componentsArea){return this.conf.legendPosition==="bottom"?this.getPostCalcDecisionsH(bBox,componentsArea):this.getPostCalcDecisionsV(bBox,componentsArea)};_proto3.getPostCalcDecisionsV=function getPostCalcDecisionsV(bBox,componentsArea){var conf=this.conf,padding=conf.padding,maxWidth=Number.NEGATIVE_INFINITY,width,cat,move=this.moveInstructions,diff;this.getPostCalcDecisionsH(bBox,componentsArea);for(cat in componentsArea){width=componentsArea[cat].width;maxWidth=maxWidth<width?width:maxWidth}bBox.width=maxWidth+2*padding.h;for(cat in componentsArea){width=componentsArea[cat].width;diff=maxWidth-width;if(diff){move[cat]="t"+diff/2+",0"}}};return LegendCarpet}();var LegendCaption=function(){function LegendCaption(text,conf){this.rawText=text;this.conf=conf;this._id=GL_CAPTION;this.node=UNDEF;this.bound=UNDEF;this._lSpace=UNDEF;this.LegendCaption={};this.LegendCaption.LEFT={x:function x(smartText,boundingBox){return boundingBox.x+smartText.width/2+2}};this.LegendCaption.RIGHT={x:function x(smartText,boundingBox){return boundingBox.x+boundingBox.width-smartText.width/2-2}};this.LegendCaption.CENTER={x:function x(){var boundingBox=arguments[1];return boundingBox.x+boundingBox.width/2}}}var _proto4=LegendCaption.prototype;_proto4.configure=function configure(text,conf){this.rawText=text;this.conf=conf};_proto4.getName=function getName(){return"LegendCaption"};_proto4.getType=function getType(){return"caption"};_proto4.getLogicalSpace=function getLogicalSpace(bBox,options,recalculate){var conf=this.conf,padding=conf.padding,lSpace=this._lSpace,text=this.rawText,chartConfig=options.gLegend.getFromEnv("chartConfig"),smartLabel,effectivePlotArea,smartText,copyOfStyle;if(lSpace&&!recalculate){lSpace.isImpure=true;return lSpace}lSpace=this._lSpace={bound:{height:0,width:0},node:{logicArea:UNDEF,smartText:UNDEF}};smartLabel=options.smartLabel;if(!text){return lSpace.bound}effectivePlotArea=merge(bBox,{});effectivePlotArea.height-=2*padding.v;effectivePlotArea.width-=2*padding.h;effectivePlotArea.x+=padding.h;effectivePlotArea.y+=padding.v;smartLabel.useEllipsesOnOverflow(chartConfig.useEllipsesWhenOverflow);copyOfStyle=merge(this.conf.style,{});normalizeFontSizeAppend(copyOfStyle);smartLabel.setStyle(this._metaStyle=copyOfStyle);smartText=smartLabel.getSmartText(text,effectivePlotArea.width,effectivePlotArea.height);effectivePlotArea.height=smartText.height;effectivePlotArea.width=smartText.width;bBox.height=smartText.height+2*padding.v;bBox.width=smartText.width+2*padding.h;lSpace.node.smartText=smartText;lSpace.node.logicArea=effectivePlotArea;lSpace.bound=bBox;return bBox};_proto4.draw=function draw(){var conf=this.conf,layer,boundAttr=conf.bound||{},group,bound,boundingArea,lSpace,normalizedX,x,bBox,options,node,animationManager;if(arguments.length>=3){x=arguments[0];bBox=arguments[1];options=arguments[2]}else if(arguments.length>=2){x=arguments[0];options=arguments[1]}layer=options.parentLayer;animationManager=options.animationManager;this.group=group=animationManager.setAnimation({el:this.group||"group",attr:{name:"legend-caption"},css:conf.style,component:gLegendRef,container:layer});this.getLogicalSpace(bBox,options);lSpace=this._lSpace;node=lSpace.node;boundingArea=lSpace.bound;this.bound=bound=animationManager.setAnimation({el:this.bound||"rect",attr:boundingArea,css:boundAttr.style,container:group,component:gLegendRef});normalizedX=typeof x==="string"?this.LegendCaption[x.toUpperCase()].x(node.smartText,bBox||node.logicArea):x;this.node=animationManager.setAnimation({el:this.node||"text",attr:{text:node.smartText.text,x:normalizedX,y:node.logicArea.y+node.smartText.height/2,lineHeight:this._metaStyle.lineHeight,fill:conf.style.fill},container:group,component:gLegendRef});return{group:group,bound:bound,node:this.node}};_proto4.dispose=function dispose(){this.group.remove();this.bound.remove();this.node.remove()};return LegendCaption}();var LegendBody=function(){function LegendBody(colorRange,conf,childTextConf){this.colorRange=colorRange;this.conf=conf;this.childTextConf=childTextConf;this._id=GL_BODY;this.bound=UNDEF;this.group=UNDEF;this.compositionsByCategory={};this._lSpace=UNDEF;this.SC_STACK=[compositionKeys.AXIS_LABEL,compositionKeys.LEGEND_AXIS,compositionKeys.AXIS_VALUE];this.DARW_STACK=[compositionKeys.AXIS_VALUE,compositionKeys.LEGEND_AXIS,compositionKeys.AXIS_LABEL]}var _proto5=LegendBody.prototype;_proto5.configure=function configure(colorRange,conf,childTextConf){this.colorRange=colorRange;this.conf=conf;this.childTextConf=childTextConf;this.compositionsByCategory={}};_proto5.getName=function getName(){return"LegendBody"};_proto5.getType=function getType(){return"legend"};_proto5.addCompositions=function addCompositions(instance,category){this.compositionsByCategory[category]=instance};_proto5.getSpaceTaken=function getSpaceTaken(spaceObj){return this.conf.legendPosition==="bottom"?spaceObj.height:spaceObj.width};_proto5.getLogicalSpace=function getLogicalSpace(bBox,options,recalculate){var lSpace=this._lSpace,conf=this.conf,padding=conf.padding,compositionsByCategory=this.compositionsByCategory,composition,compositionPlotArea,compositionAreaOffset,effectivePlotArea,getCompositionPlotArea,spaceTaken=0,index,length;if(lSpace&&!recalculate){lSpace.isImpure=true;return lSpace}lSpace=this._lSpace={bound:{height:0,width:0},node:{logicArea:UNDEF}};effectivePlotArea=merge(bBox,{});effectivePlotArea.height-=2*padding.v;effectivePlotArea.width-=2*padding.h;effectivePlotArea.x+=padding.h;effectivePlotArea.y+=padding.v;getCompositionPlotArea=this.getCompositionPlotAreaFor(effectivePlotArea);options.colorRange=this.colorRange;for(index=0,length=this.SC_STACK.length;index<length;index++){if(!(composition=compositionsByCategory[this.SC_STACK[index]])){continue}compositionPlotArea=getCompositionPlotArea(compositionAreaOffset,composition.conf.spreadFactor);compositionAreaOffset=composition.getLogicalSpace(merge(compositionPlotArea,{}),options,recalculate);spaceTaken+=this.getSpaceTaken(compositionAreaOffset)}this.updateEffectivePlotArea(bBox,effectivePlotArea,spaceTaken);lSpace.node.logicArea=effectivePlotArea;lSpace.bound=bBox;return bBox};_proto5.draw=function draw(){var childTextConf=this.childTextConf,conf=this.conf,boundStyle=conf.bound.style||{},compositionsByCategory=this.compositionsByCategory,animationManager,layer,bound,composition,legendBodyGroup,bBox,lSpace,options,index,length;if(arguments.length>=3){bBox=arguments[1];options=arguments[2]}else if(arguments.length>=2){options=arguments[1]}layer=options.parentLayer;animationManager=options.animationManager;this.getLogicalSpace(bBox,options);lSpace=this._lSpace;this.group=legendBodyGroup=animationManager.setAnimation({el:this.group||"group",attr:{name:"legend-body",transform:"t0,0"},css:childTextConf.style,container:layer,component:gLegendRef});this.bound=bound=animationManager.setAnimation({el:this.bound||"rect",attr:lSpace.bound,css:boundStyle,container:legendBodyGroup,component:gLegendRef});options.colorRange=this.colorRange;options.parentLayer=legendBodyGroup;for(index=0,length=this.DARW_STACK.length;index<length;index++){if(!(composition=compositionsByCategory[this.DARW_STACK[index]])){continue}composition.draw(options)}if(options.moveInstructions){legendBodyGroup.attr({transform:options.moveInstructions})}return{bound:bound,group:legendBodyGroup}};_proto5.getCompositionPlotAreaFor=function getCompositionPlotAreaFor(effectivePlotArea){var plotArea,isLPosBottom=this.conf.legendPosition==="bottom";plotArea=merge(effectivePlotArea,{});return function(compAreaOffset,sf){var compositionAreaOffset=compAreaOffset;compositionAreaOffset=compositionAreaOffset||{};if(isLPosBottom){plotArea.y+=compositionAreaOffset.height||0;plotArea.height=effectivePlotArea.height*sf}else{plotArea.x+=compositionAreaOffset.width||0;plotArea.width=effectivePlotArea.width*sf}return plotArea}};_proto5.updateEffectivePlotArea=function updateEffectivePlotArea(bBox,effectivePlotArea,val){var conf=this.conf,padding=conf.padding;if(this.conf.legendPosition==="bottom"){effectivePlotArea.height=val;bBox.height=val+2*padding.v}else{effectivePlotArea.width=val;bBox.width=val+2*padding.h}};return LegendBody}();var LegendLabels=function(){function LegendLabels(conf){this.conf=conf;this.node=[];this._id=GL_LABELS}var _proto6=LegendLabels.prototype;_proto6.configure=function configure(conf){this.conf=conf};_proto6.getType=function getType(){return"label"};_proto6.getName=function getName(){return"LegendLabel"};_proto6.getEffectivePlotArea=function getEffectivePlotArea(area){var conf=this.conf,padding=conf.padding;area.height-=2*padding.v;area.width-=2*padding.h;area.x+=padding.h;area.y+=padding.v;return area};_proto6.getLogicalSpace=function getLogicalSpace(bBox,options,recalculate){var isLegendPosBottom=this.conf.legendPosition==="bottom",lSpace=this._lSpace,conf=this.conf,padding=conf.padding,cRange,smartLabel,crDataObj,index,length,labelHeights=[],leftBound,rightBound,plotArea,label,valueRatio,stop,zerothStop,lsTexts,maxHeight,effectivePlotArea,testSmartLabel,nextRefPoint,currPoint,leftStop,smartText,ni,copyOfStyle,chartConfig=options.gLegend.getFromEnv("chartConfig"),normalizedDataArr=[],effectivePlotAreaWH;if(lSpace&&!recalculate){lSpace.isImpure=true;return lSpace}cRange=options.colorRange;smartLabel=options.smartLabel;valueRatio=cRange.getCumulativeValueRatio();crDataObj=cRange.colorRange;lSpace=this._lSpace={bound:{height:0,width:0},node:{logicArea:UNDEF,smartTexts:[]}};lsTexts=lSpace.node.smartTexts;plotArea=merge(bBox,{});effectivePlotArea=this.getEffectivePlotArea(plotArea);effectivePlotAreaWH=isLegendPosBottom?effectivePlotArea.width:effectivePlotArea.height;smartLabel.useEllipsesOnOverflow(chartConfig.useEllipsesWhenOverflow);copyOfStyle=merge(conf.style,{});normalizeFontSizeAppend(this._metaStyle=copyOfStyle);smartLabel.setStyle(copyOfStyle);testSmartLabel=smartLabel.getSmartText("W");for(index=0,length=crDataObj.length;index<length;index++){label=(0,_lib.parseUnsafeString)(crDataObj[index].label);if(!label){lsTexts[index]=UNDEF;continue}normalizedDataArr.push({oriIndex:index,label:label})}length=normalizedDataArr.length;if(length===0){return{height:0,width:0}}if(length>1){stop=(valueRatio[normalizedDataArr[length-1].oriIndex]-valueRatio[normalizedDataArr[0].oriIndex])/2*effectivePlotAreaWH/100}else{stop=Math.max(valueRatio[normalizedDataArr[0].oriIndex],100-valueRatio[normalizedDataArr[0].oriIndex])/2*effectivePlotAreaWH/100}zerothStop=stop;if(isLegendPosBottom){smartText=smartLabel.getSmartText(normalizedDataArr[0].label,zerothStop,effectivePlotArea.height);smartText.x=valueRatio[normalizedDataArr[0].oriIndex]*effectivePlotArea.width/100;leftBound=smartText.x+smartText.width}else{smartText=smartLabel.getSmartText(normalizedDataArr[0].label,zerothStop,effectivePlotArea.width);smartText.y=valueRatio[normalizedDataArr[0].oriIndex]*effectivePlotArea.height/100;leftBound=smartText.y+smartText.width}labelHeights.push(smartText.height);lsTexts[normalizedDataArr[0].oriIndex]=smartText;if(isLegendPosBottom){smartText=smartLabel.getSmartText(normalizedDataArr[length-1].label,zerothStop,effectivePlotArea.height);smartText.x=valueRatio[normalizedDataArr[length-1].oriIndex]*effectivePlotArea.width/100;rightBound=smartText.x-smartText.width}else{smartText=smartLabel.getSmartText(normalizedDataArr[length-1].label,zerothStop,effectivePlotArea.width);smartText.y=valueRatio[normalizedDataArr[length-1].oriIndex]*effectivePlotArea.height/100;rightBound=smartText.y-smartText.width}labelHeights.push(smartText.height);lsTexts[normalizedDataArr[length-1].oriIndex]=smartText;leftStop=leftBound;for(index=1;index<length-1;index++){label=normalizedDataArr[index].label;ni=normalizedDataArr[index].oriIndex;smartText=UNDEF;nextRefPoint=index+1===length-1?rightBound:valueRatio[normalizedDataArr[index+1].oriIndex]*effectivePlotAreaWH/100;currPoint=valueRatio[normalizedDataArr[index].oriIndex]*effectivePlotAreaWH/100;stop=Math.min(currPoint-leftStop,nextRefPoint-currPoint);if(stop>2*testSmartLabel.width){if(isLegendPosBottom){smartText=smartLabel.getSmartText(label,stop,effectivePlotArea.height);smartText.x=valueRatio[ni]*effectivePlotArea.width/100}else{smartText=smartLabel.getSmartText(label,stop,effectivePlotArea.width);smartText.y=valueRatio[ni]*effectivePlotArea.height/100}leftStop=stop;labelHeights.push(smartText.height)}lsTexts[normalizedDataArr[index].oriIndex]=smartText}maxHeight=Math.max.apply(Math,labelHeights);if(isLegendPosBottom){effectivePlotArea.height=maxHeight;bBox.height=maxHeight+2*padding.v}else{effectivePlotArea.width=maxHeight;bBox.width=maxHeight+2*padding.v}lSpace.node.logicArea=effectivePlotArea;lSpace.bound=bBox;return bBox};_proto6.draw=function draw(){var isLegendPosBottom=this.conf.legendPosition==="bottom",layer,bound,conf=this.conf,boundStyle=conf.bound&&conf.bound.style||{stroke:"none"},legendLabelsGroup,bBox,smartText,lSpace,options,index,logicArea,lsTexts,length,pos={},animationManager;if(arguments.length>=2&&arguments[1]){bBox=arguments[0];options=arguments[1]}else if(arguments.length>=1){options=arguments[0]}animationManager=options.animationManager;layer=options.parentLayer;this.getLogicalSpace(bBox,options);lSpace=this._lSpace;logicArea=lSpace.node.logicArea;lsTexts=lSpace.node.smartTexts;this.group=legendLabelsGroup=animationManager.setAnimation({el:this.group||"group",attr:{name:"legend-labels"},container:layer,component:gLegendRef});this.bound=bound=animationManager.setAnimation({el:this.bound||"rect",attr:lSpace.bound,css:boundStyle,container:legendLabelsGroup,component:gLegendRef});for(var i=0;i<this.node.length;i++){this.node[i].remove()}this.node=[];for(index=0,length=lsTexts.length;index<length;index++){smartText=lsTexts[index];if(!smartText){continue}if(isLegendPosBottom){pos.y=logicArea.y+smartText.height/2;if(index===length-1){pos.x=logicArea.x+smartText.x-smartText.width/2}else if(index){pos.x=logicArea.x+smartText.x}else{pos.x=logicArea.x+smartText.x+smartText.width/2}}else{pos.x=logicArea.x+smartText.height/2;if(index===length-1){pos.y=logicArea.y+smartText.y-smartText.width/2}else if(index){pos.y=logicArea.y+smartText.y}else{pos.y=logicArea.y+smartText.y+smartText.width/2}}this.node.push(animationManager.setAnimation({el:"text",attr:{text:smartText.text,x:pos.x,y:pos.y,lineHeight:this._metaStyle.lineHeight,fill:conf.style.fill,transform:isLegendPosBottom?"R0":"R270,"+pos.x+","+pos.y},container:legendLabelsGroup,component:gLegendRef}))}return{group:legendLabelsGroup,bound:bound,node:this.node}};return LegendLabels}();var LegendAxis=function(){function LegendAxis(conf){this.conf=conf;this._id=FL_AXIS;this.node=UNDEF;this.group=UNDEF;this.shadow=UNDEF;this.markerLine=UNDEF;this.compositionsByCategory={}}var _proto7=LegendAxis.prototype;_proto7.configure=function configure(conf){this.conf=conf};_proto7.getName=function getName(){return"LegendAxis"};_proto7.getType=function getType(){return"axis"};_proto7.addCompositions=function addCompositions(instance,category){this.compositionsByCategory[category]=instance};_proto7.getLogicalSpace=function getLogicalSpace(){var isLegendPosBottom=this.conf.legendPosition==="bottom",bBox=arguments[0],recalculate=arguments[2],lSpace=this._lSpace,conf=this.conf,padding=conf.padding,spaceTakenLower,spaceTakenUpper,spaceTaken,axisThickness=conf.legendAxisHeight,compositionsByCategory=this.compositionsByCategory,sliderG,effectivePlotArea,slider,sliderSpace,sliderExtraDiam=0;if(lSpace&&!recalculate){lSpace.isImpure=true;return lSpace}lSpace=this._lSpace={bound:{height:0,width:0},node:{logicArea:UNDEF}};effectivePlotArea=merge(bBox,{});effectivePlotArea.height-=2*padding.v;effectivePlotArea.width-=2*padding.h;effectivePlotArea.x+=padding.h;effectivePlotArea.y+=padding.v;spaceTakenLower=axisThickness/2+conf.line.offset;spaceTakenUpper=axisThickness/2;sliderG=compositionsByCategory[compositionKeys.RANGE];if(sliderG){slider=sliderG.sliders["false"];sliderSpace=slider.conf.outerCircle.rFactor*axisThickness;spaceTakenUpper+=sliderExtraDiam=Math.max(sliderSpace/2-axisThickness/2,0)}if(isLegendPosBottom){effectivePlotArea.y+=sliderExtraDiam;effectivePlotArea.height=spaceTaken=spaceTakenUpper+spaceTakenLower+sliderExtraDiam;bBox.height=spaceTaken+2*padding.v}else{effectivePlotArea.x+=sliderExtraDiam;effectivePlotArea.width=spaceTaken=spaceTakenUpper+spaceTakenLower+sliderExtraDiam;bBox.width=spaceTaken+2*padding.v}lSpace.node.logicArea=effectivePlotArea;lSpace.bound=bBox;return bBox};_proto7.getDrawableAxisArea=function getDrawableAxisArea(parentBoundingRect){var conf=this.conf,isLegendPosBottom=this.conf.legendPosition==="bottom",x=parentBoundingRect.x,y=parentBoundingRect.y,width=isLegendPosBottom?parentBoundingRect.width:conf.legendAxisHeight,height=isLegendPosBottom?conf.legendAxisHeight:parentBoundingRect.height,r=conf.legendAxisHeight/2;return{x:x,y:y,width:width,height:height,r:r}};_proto7.preDrawingRangeParamV=function preDrawingRangeParamV(drawableArea){var x=drawableArea.x+drawableArea.width/2,calculationBase=drawableArea.width;return{x:x,calculationBase:calculationBase,rangeStart:drawableArea.y,rangeEnd:drawableArea.y+drawableArea.height,prop:"x"}};_proto7.preDrawingRangeParamH=function preDrawingRangeParamH(drawableArea){var y=drawableArea.y+drawableArea.height/2,calculationBase=drawableArea.height;return{y:y,calculationBase:calculationBase,rangeStart:drawableArea.x,rangeEnd:drawableArea.x+drawableArea.width,prop:"y"}};_proto7.preDrawingRangeParam=function preDrawingRangeParam(drawableArea){return this.conf.legendPosition==="bottom"?this.preDrawingRangeParamH(drawableArea):this.preDrawingRangeParamV(drawableArea)};_proto7.getScaleMarkerPathStrH=function getScaleMarkerPathStrH(oriAxisRect,valueRatio){var axisRect=merge(oriAxisRect,{}),conf=this.conf,lineAttr=conf.line,index,length,ratio,covered,markerStartY,tickStr=_lib.BLANKSTRING,lineStr=_lib.BLANKSTRING;axisRect.x+=axisRect.r;axisRect.width-=2*axisRect.r;markerStartY=axisRect.y+axisRect.height;for(index=0,length=valueRatio.length;index<length;index++){ratio=valueRatio[index];covered=axisRect.x+ratio*axisRect.width/100;tickStr+=M+covered+COMMA_STR+(markerStartY-lineAttr.grooveLength)+L+covered+COMMA_STR+(markerStartY+lineAttr.offset)}lineStr+=M+axisRect.x+COMMA_STR+(markerStartY+lineAttr.offset)+L+(axisRect.x+axisRect.width)+COMMA_STR+(markerStartY+lineAttr.offset);return tickStr+lineStr};_proto7.getColorGradientH=function getColorGradientH(colorRange){return{axis:colorRange.getBoxFill(),shadow:(0,_lib.toRaphaelColor)({FCcolor:{alpha:"25,0,0",angle:90,color:"000000,FFFFFF,FFFFFF",ratio:"0,30,40"}})}};_proto7.draw=function draw(){var layer,conf=this.conf,boundAttr=conf.bound||{},lineAttr=conf.line,boundStyle=boundAttr.style||{},bBox,category,compositionsByCategory=this.compositionsByCategory,cRange,valueRatio,composition,legendAxisGroup,rangeParams,grad,oriAxisRect,lSpace,options,animationManager,scaleLine;if(arguments.length>=2){bBox=arguments[0];options=arguments[1]}else if(arguments.length>=1){options=arguments[0]}animationManager=options.animationManager;layer=options.parentLayer;cRange=options.colorRange;valueRatio=cRange.getCumulativeValueRatio();this.getLogicalSpace(bBox,options);lSpace=this._lSpace;this.group=legendAxisGroup=animationManager.setAnimation({el:this.group||"group",attr:{name:"legend-axis"},container:layer,component:gLegendRef});this.bound=animationManager.setAnimation({el:this.bound||"rect",attr:lSpace.bound,css:boundStyle,component:gLegendRef,container:legendAxisGroup});oriAxisRect=this.getDrawableAxisArea(lSpace.node.logicArea);grad=this.getColorGradient(cRange);conf.style.fill=grad.axis;conf.shadow.style.fill=grad.shadow;this.node=animationManager.setAnimation({el:this.node||"rect",attr:oriAxisRect,css:conf.style,container:legendAxisGroup,component:gLegendRef});this.shadow=animationManager.setAnimation({el:this.shadow||"rect",attr:oriAxisRect,css:conf.shadow.style,container:legendAxisGroup,component:gLegendRef});scaleLine=this.getScaleMarkerPathStr(oriAxisRect,valueRatio);this.path=animationManager.setAnimation({el:this.path||"path",attr:{path:scaleLine},css:lineAttr.style,container:legendAxisGroup,component:gLegendRef});for(category in compositionsByCategory){composition=compositionsByCategory[category];switch(category){case compositionKeys.RANGE:rangeParams=this.preDrawingRangeParam(oriAxisRect);options[rangeParams.prop]=rangeParams[rangeParams.prop];options.key=rangeParams.prop;options.rCalcBase=rangeParams.calculationBase;options.parentLayer=legendAxisGroup;composition.draw(rangeParams.rangeStart,rangeParams.rangeEnd,options)}}};_proto7.getScaleMarkerPathStr=function getScaleMarkerPathStr(oriAxisRect,valueRatio){return this.conf.legendPosition==="bottom"?this.getScaleMarkerPathStrH(oriAxisRect,valueRatio):this.getScaleMarkerPathStrV(oriAxisRect,valueRatio)};_proto7.getColorGradient=function getColorGradient(colorRange){return this.conf.legendPosition==="bottom"?this.getColorGradientH(colorRange):this.getColorGradientV(colorRange)};_proto7.getScaleMarkerPathStrV=function getScaleMarkerPathStrV(oriAxisRect,valueRatio){var axisRect=merge(oriAxisRect,{}),conf=this.conf,lineAttr=conf.line,index,ratio,length,markerStartX,covered,tickStr=_lib.BLANKSTRING,lineStr=_lib.BLANKSTRING;axisRect.y+=axisRect.r;axisRect.height-=2*axisRect.r;markerStartX=axisRect.x+axisRect.width;for(index=0,length=valueRatio.length;index<length;index++){ratio=valueRatio[index];covered=axisRect.y+ratio*axisRect.height/100;tickStr+=M+(markerStartX-lineAttr.grooveLength)+COMMA_STR+covered+L+(markerStartX+lineAttr.offset)+COMMA_STR+covered}lineStr+=M+(markerStartX+lineAttr.offset)+COMMA_STR+axisRect.y+L+(markerStartX+lineAttr.offset)+COMMA_STR+(axisRect.y+axisRect.height);return tickStr+lineStr};_proto7.getColorGradientV=function getColorGradientV(colorRange){return{axis:colorRange.getBoxFill(true),shadow:(0,_lib.toRaphaelColor)({FCcolor:{alpha:"25,0,0",angle:360,color:"000000,FFFFFF,FFFFFF",ratio:"0,30,40"}})}};return LegendAxis}();var Slider=function(){function Slider(sliderIndex,options,id){this.conf=options.conf;this.sliderIndex=sliderIndex;this.rangeGroup=options.sliderGroup;this._id=id;this.node=UNDEF;this.tracker=UNDEF;this.currPos=0;this.swing=[]}var _proto8=Slider.prototype;_proto8.configure=function configure(sliderIndex,options,id){this.conf=options.conf;this.sliderIndex=sliderIndex;this.rangeGroup=options.sliderGroup;this._id=id;this.currPos=0;this.swing=[]};_proto8.getType=function getType(){return"slider"};_proto8.getName=function getName(){return"Slider"};_proto8.updateSwingRange=function updateSwingRange(index,value){this.swing[+index]=value};_proto8.draw=function draw(rangeStart,scaleVal,position,options){var layer=options.parentLayer,self=this,animationManager=options.animationManager,conf=this.conf,ocConf=conf.outerCircle,icConf=conf.innerCircle,tooltext,chartConfig=animationManager.getFromEnv("chart").config,ocRadius=Math.ceil(ocConf.rFactor*options.rCalcBase/2),icRadius=Math.ceil(icConf.rFactor*options.rCalcBase/2),icThickness=ocRadius-icRadius,group,toolTipController=options.gLegend.getFromEnv("toolTipController"),sliderIndex=this.sliderInde