text: import _inheritsLoose from"@babel/runtime/helpers/inheritsLoose";import CommonSpaceManager from"./commonspacemanager";import{chartPaletteStr,pluckNumber,pluck,pluckFontSize,extend2}from"@fusioncharts/core/src/lib";import cartesianAxisFactory from"../../factories/cartesian-axis";import canvasFactory from"../../factories/canvas-axis-ref-cartesian";import virtualCanvasFactory from"../../factories/vcanvas";import mousetrackerFactory from"../../factories/mouse-tracker";import isEqualString from"@fusioncharts/utils/src/string/equal";var mathMax=Math.max,mathMin=Math.min,UNDEF,setDimension=function setDimension(dimension1,dimension2){if(dimension1<dimension2&&dimension2>0){return dimension2-dimension1}return 0};var Cartesian=function(_CommonSpaceManager){_inheritsLoose(Cartesian,_CommonSpaceManager);function Cartesian(){var _this;_this=_CommonSpaceManager.call(this)||this;_this.registerFactory("axis",cartesianAxisFactory,["canvas"]);_this.registerFactory("canvas",canvasFactory);_this.registerFactory("vCanvas",virtualCanvasFactory,["axis"]);_this.registerFactory("mouseTracker",mousetrackerFactory,["canvas"]);return _this}Cartesian.getName=function getName(){return"Cartesian"};var _proto=Cartesian.prototype;_proto.getName=function getName(){return"Cartesian"};_proto.getType=function getType(){return"chartAPI"};_proto._allocateXAxisLabelSpace=function _allocateXAxisLabelSpace(axis){var iapi=this,config=iapi.config,dimensions=axis.getAxisEndLabelDisplaySpace(),left=dimensions.left,right=dimensions.right,top=dimensions.top,sum,bottom=dimensions.bottom,availableWidth=config.availableWidth,availableHeight=config.availableHeight,canvasLeft=config.canvasLeft,canvasRight=config.canvasRight,canvasTop=config.canvasTop,canvasBottom=config.canvasBottom,width=config.width,height=config.height;if(top+bottom>availableHeight){sum=top+bottom;top=availableHeight*top/sum;bottom=availableHeight*bottom/sum}if(left+right>availableWidth){sum=left+right;left=availableWidth*left/sum;right=availableWidth*right/sum}left=setDimension(canvasLeft,left);right=setDimension(width-canvasRight,right);top=setDimension(canvasTop,top);bottom=setDimension(height-canvasBottom,bottom);iapi._allocateSpace({left:left,right:right,top:top,bottom:bottom})};_proto._setCategories=function _setCategories(){var iapi=this,dataObj=iapi.getFromEnv("dataSource"),xAxis=iapi.getChildren("xAxis"),categories=dataObj.categories&&dataObj.categories.length&&dataObj.categories[0].category;xAxis&&xAxis[0].setTickValues(categories)};_proto._feedAxesRawData=function _feedAxesRawData(){var iapi=this,chartConfig=iapi.config,dataObj=iapi.getFromEnv("dataSource"),xAxisConf,yAxisConf;xAxisConf=iapi.getSpecificxAxisConf();yAxisConf=iapi.getSpecificyAxisConf();xAxisConf.vtrendlines=extend2([],dataObj.vtrendlines);yAxisConf.trendlines=extend2([],dataObj.trendlines);if(chartConfig.isstacked){yAxisConf.isPercent=pluckNumber(chartConfig.stack100percent,0)}return{yAxisConf:[yAxisConf],xAxisConf:[xAxisConf]}};_proto.getSpecificxAxisConf=function getSpecificxAxisConf(){var iapi=this,chartAttrs=iapi.getFromEnv("chart-attrib"),chartConfig=iapi.config,is3D=iapi.config.is3D,xAxisConf=iapi.getBasexAxisConf();xAxisConf.isReverse=chartConfig.reverseXAxis;xAxisConf.axisLineColor=pluck(chartAttrs.xaxislinecolor,chartAttrs.axislinecolor,"#000000");xAxisConf.showAlternateGridColor=pluckNumber(chartAttrs.showalternatevgridcolor,0);xAxisConf.numDivLines=pluckNumber(chartAttrs.numvdivlines,chartConfig.numVDivLines);xAxisConf.axisName=chartAttrs.xaxisname;xAxisConf.setAdaptiveMin=pluckNumber(chartAttrs.setadaptivexmin,chartConfig.setadaptivexmin,chartConfig.setadaptivexmin);xAxisConf.showLimits=pluckNumber(chartAttrs.showvlimits,chartConfig.showvlimits);xAxisConf.showDivLineValues=pluckNumber(chartAttrs.showvdivlinevalues,chartAttrs.showvdivlinevalues,chartConfig.showvdivlinevalues);xAxisConf.zeroPlaneThickness=pluckNumber(chartAttrs.vzeroplanethickness,chartAttrs.vdivlinethickness,chartConfig.zeroplanethickness,2);xAxisConf.zeroPlaneAlpha=pluckNumber(chartAttrs.vzeroplanealpha,chartAttrs.vdivlinealpha,chartConfig.zeroplanealpha);xAxisConf.showZeroPlaneValue=pluckNumber(chartAttrs.showvzeroplanevalue,chartConfig.showzeroplanevalue);xAxisConf.showAxisLine=is3D?0:pluckNumber(chartAttrs.showxaxisline,chartAttrs.showaxislines,chartAttrs.drawAxisLines,chartConfig.showxaxisline,0);xAxisConf.maxLabelHeight=chartAttrs.maxlabelheight;xAxisConf.showZeroPlane=pluckNumber(chartAttrs.showvzeroplane,chartConfig.showzeroplane);return xAxisConf};_proto.getSpecificyAxisConf=function getSpecificyAxisConf(){var iapi=this,chartAttrs=iapi.getFromEnv("chart-attrib"),chartConfig=iapi.config,is3D=iapi.config.is3D,palleteString=is3D?chartPaletteStr.chart3D:chartPaletteStr.chart2D,isReverse=chartConfig.isInverse,colorM=iapi.getFromEnv("color-manager"),showYAxisZeroPlane=pluckNumber(chartAttrs.showzeroplane,chartConfig.showzeroplane,1),showYAxisZeroPlaneValue=pluckNumber(chartAttrs.showzeroplanevalue,chartConfig.showzeroplanevalue);if(!showYAxisZeroPlane&&showYAxisZeroPlaneValue===UNDEF){showYAxisZeroPlaneValue=0}return{isVertical:true,isReverse:!isReverse,isOpposit:isEqualString(chartAttrs.yaxisposition,"right"),outCanfontFamily:pluck(chartAttrs.outcnvbasefont,chartAttrs.basefont,"Verdana,sans"),outCanfontSize:pluckFontSize(chartAttrs.outcnvbasefontsize,chartAttrs.basefontsize,10),outCancolor:pluck(chartAttrs.outcnvbasefontcolor,chartAttrs.basefontcolor,colorM.getColor(palleteString.baseFontColor)).replace(/^#? ([a-f0-9]+)/gi,"#$1"),axisBreaks:chartAttrs.yaxisbreaks,axisNamePadding:chartAttrs.yaxisnamepadding,axisValuePadding:chartAttrs.yaxisvaluespadding,axisNameFont:chartAttrs.yaxisnamefont,axisNameFontSize:chartAttrs.yaxisnamefontsize,axisNameFontColor:chartAttrs.yaxisnamefontcolor,axisNameFontBold:chartAttrs.yaxisnamefontbold,axisNameFontItalic:chartAttrs.yaxisnamefontitalic,axisNameBgColor:chartAttrs.yaxisnamebgcolor,axisNameBorderColor:chartAttrs.yaxisnamebordercolor,axisNameAlpha:chartAttrs.yaxisnamealpha,axisNameFontAlpha:chartAttrs.yaxisnamefontalpha,axisNameBgAlpha:chartAttrs.yaxisnamebgalpha,axisNameBorderAlpha:chartAttrs.yaxisnameborderalpha,axisNameBorderPadding:chartAttrs.yaxisnameborderpadding,axisNameBorderRadius:chartAttrs.yaxisnameborderradius,axisNameBorderThickness:chartAttrs.yaxisnameborderthickness,axisNameBorderDashed:chartAttrs.yaxisnameborderdashed,axisNameBorderDashLen:chartAttrs.yaxisnameborderdashlen,axisNameBorderDashGap:chartAttrs.yaxisnameborderdashgap,axisNameWidth:chartAttrs.yaxisnamewidth,useEllipsesWhenOverflow:chartAttrs.useellipseswhenoverflow,rotateAxisName:pluckNumber(chartAttrs.rotateyaxisname,1),axisName:chartAttrs.yaxisname,divLineColor:pluck(chartAttrs.divlinecolor,colorM.getColor(palleteString.divLineColor)),divLineAlpha:pluck(chartAttrs.divlinealpha,is3D?colorM.getColor("divLineAlpha3D"):colorM.getColor("divLineAlpha")),divLineThickness:pluckNumber(chartAttrs.divlinethickness,1),divLineIsDashed:Boolean(pluckNumber(chartAttrs.divlinedashed,chartAttrs.divlineisdashed,0)),divLineDashLen:pluckNumber(chartAttrs.divlinedashlen,4),divLineDashGap:pluckNumber(chartAttrs.divlinedashgap,2),showAlternateGridColor:pluckNumber(chartAttrs.showalternatehgridcolor,1),alternateGridColor:pluck(chartAttrs.alternatehgridcolor,colorM.getColor("altHGridColor")),alternateGridAlpha:pluck(chartAttrs.alternatehgridalpha,colorM.getColor("altHGridAlpha")),numDivLines:pluckNumber(chartAttrs.numdivlines,chartConfig.numDivLines),axisMinValue:chartConfig.yRangeMin||chartAttrs.yaxisminvalue,axisMaxValue:chartConfig.yRangeMax||chartAttrs.yaxismaxvalue,setAdaptiveMin:pluckNumber(chartAttrs.setadaptivesymin,chartAttrs.setadaptiveymin,chartConfig.setAdaptiveMin),adjustDiv:chartAttrs.adjustdiv,labelStep:chartAttrs.yaxisvaluesstep,showAxisValues:pluckNumber(chartAttrs.showyaxisvalues,chartAttrs.showyaxisvalue,chartConfig.showyaxisvalues),showLimits:pluckNumber(chartAttrs.showyaxislimits,chartAttrs.showlimits,iapi.showLimits),showDivLineValues:pluckNumber(chartAttrs.showdivlinevalues,chartAttrs.showdivlinevalue,chartConfig.showdivlinevalues),showZeroPlane:showYAxisZeroPlane,zeroPlaneColor:chartAttrs.zeroplanecolor,zeroPlaneThickness:pluckNumber(chartAttrs.zeroplanethickness,chartAttrs.divlinethickness,chartConfig.zeroplanethickness,2),zeroPlaneAlpha:pluckNumber(chartAttrs.zeroplanealpha,chartAttrs.divlinealpha,chartConfig.zeroplanealpha),showZeroPlaneValue:showYAxisZeroPlaneValue,showZeroPlaneOnTop:chartConfig.showzeroplaneontop,trendlineColor:chartAttrs.trendlinecolor,trendlineToolText:chartAttrs.trendlinetooltext,trendlineThickness:chartAttrs.trendlinethickness,trendlineAlpha:chartAttrs.trendlinealpha,showTrendlinesOnTop:chartAttrs.showtrendlinesontop,showAxisLine:is3D?0:pluckNumber(chartAttrs.showyaxisline,chartAttrs.showaxislines,chartAttrs.drawAxisLines,chartConfig.showyaxisline,0),axisLineThickness:pluckNumber(chartAttrs.yaxislinethickness,chartAttrs.axislinethickness,1),axisLineAlpha:pluckNumber(chartAttrs.yaxislinealpha,chartAttrs.axislinealpha,100),axisLineColor:pluck(chartAttrs.yaxislinecolor,chartAttrs.axislinecolor,"#000000"),forceTrendBelow:!!chartConfig.is3D,labelFont:chartAttrs.yaxisvaluefont,labelFontSize:chartAttrs.yaxisvaluefontsize,labelFontColor:chartAttrs.yaxisvaluefontcolor,labelAlpha:chartAttrs.yaxisvaluealpha,labelFontBold:chartAttrs.yaxisvaluefontbold,labelFontItalic:chartAttrs.yaxisvaluefontitalic,labelBdrColor:chartAttrs.yaxisvaluebordercolor,labelBdrAlpha:chartAttrs.yaxisvalueborderalpha,labelBgAlpha:chartAttrs.yaxisvaluebgalpha,labelLink:chartAttrs.yaxisvaluelink,labelBgColor:chartAttrs.yaxisvaluebgcolor,labelBdrThickness:chartAttrs.yaxisvalueborderthickness,labelBdrPadding:chartAttrs.yaxisvalueborderpadding,labelBdrRadius:chartAttrs.yaxisvalueborderradius,labelBdrDashed:chartAttrs.yaxisvalueborderdashed,labelBdrDashLen:chartAttrs.yaxisvalueborderdashlen,labelBdrDashGap:chartAttrs.yaxisvalueborderdashgap}};_proto.getBasexAxisConf=function getBasexAxisConf(){var iapi=this,chartAttrs=iapi.getFromEnv("chart-attrib"),is3D=iapi.config.is3D,palleteString=is3D?chartPaletteStr.chart3D:chartPaletteStr.chart2D,colorM=iapi.getFromEnv("color-manager");return{isVertical:false,isOpposit:isEqualString(chartAttrs.xaxisposition,"top"),outCanfontFamily:pluck(chartAttrs.outcnvbasefont,chartAttrs.basefont,"Verdana,sans"),outCanfontSize:pluckFontSize(chartAttrs.outcnvbasefontsize,chartAttrs.basefontsize,10),outCancolor:pluck(chartAttrs.outcnvbasefontcolor,chartAttrs.basefontcolor,colorM.getColor(palleteString.baseFontColor)).replace(/^#? ([a-f0-9]+)/gi,"#$1"),axisNamePadding:chartAttrs.xaxisnamepadding,axisValuePadding:chartAttrs.labelpadding,axisNameFont:chartAttrs.xaxisnamefont,axisNameFontSize:chartAttrs.xaxisnamefontsize,axisNameFontColor:chartAttrs.xaxisnamefontcolor,axisNameFontBold:chartAttrs.xaxisnamefontbold,axisNameFontItalic:chartAttrs.xaxisnamefontitalic,axisNameBgColor:chartAttrs.xaxisnamebgcolor,axisNameBorderColor:chartAttrs.xaxisnamebordercolor,axisNameAlpha:chartAttrs.xaxisnamealpha,axisNameFontAlpha:chartAttrs.xaxisnamefontalpha,axisNameBgAlpha:chartAttrs.xaxisnamebgalpha,axisNameBorderAlpha:chartAttrs.xaxisnameborderalpha,axisNameBorderPadding:chartAttrs.xaxisnameborderpadding,axisNameBorderRadius:chartAttrs.xaxisnameborderradius,axisNameBorderThickness:chartAttrs.xaxisnameborderthickness,axisNameBorderDashed:chartAttrs.xaxisnameborderdashed,axisNameBorderDashLen:chartAttrs.xaxisnameborderdashlen,axisNameBorderDashGap:chartAttrs.xaxisnameborderdashgap,useEllipsesWhenOverflow:chartAttrs.useellipseswhenoverflow,divLineColor:pluck(chartAttrs.vdivlinecolor,chartAttrs.divlinecolor,colorM.getColor(palleteString.divLineColor)),divLineAlpha:pluck(chartAttrs.vdivlinealpha,chartAttrs.divlinealpha,is3D?colorM.getColor("divLineAlpha3D"):colorM.getColor("divLineAlpha")),divLineThickness:pluckNumber(chartAttrs.vdivlinethickness,chartAttrs.divlinethickness,1),divLineIsDashed:Boolean(pluckNumber(chartAttrs.vdivlinedashed,chartAttrs.vdivlineisdashed,chartAttrs.divlinedashed,chartAttrs.divlineisdashed,0)),divLineDashLen:pluckNumber(chartAttrs.vdivlinedashlen,chartAttrs.divlinedashlen,4),divLineDashGap:pluckNumber(chartAttrs.vdivlinedashgap,chartAttrs.divlinedashgap,2),alternateGridColor:pluck(chartAttrs.alternatevgridcolor,colorM.getColor("altVGridColor")),alternateGridAlpha:pluck(chartAttrs.alternatevgridalpha,colorM.getColor("altVGridAlpha")),labelFont:chartAttrs.labelfont,labelFontSize:chartAttrs.labelfontsize,labelFontColor:chartAttrs.labelfontcolor,labelAlpha:chartAttrs.labelalpha,labelFontBold:chartAttrs.labelfontbold,labelFontItalic:chartAttrs.labelfontitalic,labelBdrColor:chartAttrs.labelbordercolor,labelBdrAlpha:chartAttrs.labelborderalpha,labelLink:chartAttrs.labellink,labelBgColor:chartAttrs.labelbgcolor,labelBdrThickness:chartAttrs.labelborderthickness,labelBdrPadding:chartAttrs.labelborderpadding,labelBdrRadius:chartAttrs.labelborderradius,labelBdrDashed:chartAttrs.labelborderdashed,labelBgAlpha:chartAttrs.labelbgalpha,labelBdrDashLen:chartAttrs.labelborderdashlen,labelBdrDashGap:chartAttrs.labelborderdashgap,axisMinValue:chartAttrs.xaxisminvalue,axisMaxValue:chartAttrs.xaxismaxvalue,adjustDiv:chartAttrs.adjustvdiv,labelDisplay:chartAttrs.labeldisplay,showLabels:chartAttrs.showlabels,rotateLabels:chartAttrs.rotatelabels,slantLabel:pluckNumber(chartAttrs.slantlabels,chartAttrs.slantlabel),labelStep:pluckNumber(chartAttrs.labelstep,chartAttrs.xaxisvaluesstep),showAxisValues:pluckNumber(chartAttrs.showxaxisvalues,chartAttrs.showxaxisvalue),zeroPlaneColor:chartAttrs.vzeroplanecolor,trendlineColor:chartAttrs.trendlinecolor,trendlineToolText:chartAttrs.trendlinetooltext,trendlineThickness:chartAttrs.trendlinethickness,trendlineAlpha:chartAttrs.trendlinealpha,showTrendlinesOnTop:chartAttrs.showtrendlinesontop,axisLineThickness:pluckNumber(chartAttrs.xaxislinethickness,chartAttrs.axislinethickness,1),axisLineAlpha:pluckNumber(chartAttrs.xaxislinealpha,chartAttrs.axislinealpha,100)}};_proto.getConfig=function getConfig(confName){return confName?this.config[confName]:this.config};_proto._getSumValueSpace=function _getSumValueSpace(maxAvailableSpace){var iapi=this,dim={},isBar=iapi.isBar,chartAttr=iapi.getFromEnv("dataSource").chart,showSum=iapi.showsum!==0?pluckNumber(chartAttr.showsum,iapi.showsum,0):0,stack100Percent=pluckNumber(iapi.config.stack100percent),isStacked=iapi.config.isstacked,width=0,i,stackManagers=[],height=0;iapi.iterateComponents(function(child){if(child.getName()==="cartesianStackGroup"||child.getName()==="marimekkoStackgroup"){stackManagers.push(child)}});if(showSum&&stack100Percent&&isStacked&&stackManagers.length){for(i=stackManagers.length-1;i>=0;i--){dim=stackManagers[i].getMaxSumValueSpace();if(!isBar){height=Math.max(height,dim.maxHeight)}else{width=Math.max(width,dim.maxWidth)}}if(height>maxAvailableSpace){height=maxAvailableSpace}if(width>maxAvailableSpace){width=maxAvailableSpace}}return{top:height,right:width}};_proto.setAxisDimention=function setAxisDimention(){var iapi=this,xAxis=iapi.getChildren("xAxis")&&iapi.getChildren("xAxis")[0],yAxis=iapi.getChildren("yAxis")&&iapi.getChildren("yAxis")[0],config=iapi.config,xDepth=config.xDepth||0,canvasConfig=iapi.getChildren("canvas")&&iapi.getChildren("canvas")[0].config,canvasBorderWidth=canvasConfig&&canvasConfig.canvasBorderWidth,hasScrollBar=xAxis&&xAxis.isScrollEnabled(),shift=(hasScrollBar||config.is3D)&&config.shift||0,canvasPadding=canvasConfig.canvasPadding,canvasLeft=canvasConfig.canvasLeft,canvasRight=canvasLeft+canvasConfig.canvasWidth,canvasPaddingLeft=canvasConfig.canvasPaddingLeft,canvasPaddingRight=canvasConfig.canvasPaddingRight,canvasTop=canvasConfig.canvasTop,sumValueSpaceTop=config.sumValueSpace&&config.sumValueSpace.top||0,canvasPaddingTop=canvasConfig.canvasPaddingTop;xAxis&&xAxis.setAxisConfig({canvasPaddingLeft:Math.max(canvasPaddingLeft,canvasPadding),canvasPaddingRight:Math.max(canvasPaddingRight,canvasPadding)});xAxis&&xAxis.setAxisDimention({x:canvasLeft+xDepth+Math.max(canvasPaddingLeft,canvasPadding),y:xAxis.config.isOpposit?canvasTop-canvasBorderWidth-(hasScrollBar?shift:0)-sumValueSpaceTop:config.canvasBottom+shift+canvasBorderWidth,opposite:xAxis.config.isOpposit?config.canvasBottom+shift+canvasBorderWidth:canvasTop-canvasBorderWidth-shift,axisLength:canvasConfig.canvasWidth-xDepth-Math.max(canvasPaddingLeft,canvasPadding)-Math.max(canvasPaddingRight,canvasPadding)});yAxis&&yAxis.setAxisDimention({x:yAxis.config.isOpposit?canvasRight+canvasBorderWidth:canvasLeft-canvasBorderWidth,y:canvasTop+canvasPaddingTop,opposite:yAxis.config.isOpposit?canvasLeft-canvasBorderWidth:canvasRight+canvasBorderWidth,axisLength:canvasConfig.canvasHeight-canvasPaddingTop-canvasConfig.canvasPaddingBottom})};_proto._getTrendLineMinMax=function _getTrendLineMinMax(type,axsType){var iapi=this,axisType=axsType,trendLines=type==="v"?iapi.getFromEnv("dataSource").vtrendlines:iapi.getFromEnv("dataSource").trendlines,retObj={max:-Infinity,min:Infinity},trendLineObj,i,ii,ln,lnn;axisType=axisType||"p";if(trendLines){for(i=0,ln=trendLines.length;i<ln;i+=1){for(ii=0,lnn=trendLines[i].line?trendLines[i].line.length:0;ii<lnn;ii+=1){trendLineObj=trendLines[i].line[ii];if(axisType==="s"&&trendLineObj.parentyaxis!=="s"||axisType!=="s"&&trendLineObj.parentyaxis==="s"){continue}retObj.max=mathMax(trendLineObj.startvalue||-Infinity,trendLineObj.endvalue||-Infinity,retObj.max);retObj.min=mathMin(trendLineObj.startvalue||Infinity,trendLineObj.endvalue||Infinity,retObj.min)}}}return retObj};return Cartesian}(CommonSpaceManager);export default Cartesian;