UNPKG

quoslibero

Version:

FusionCharts JavaScript charting framework

1 lines 3.3 kB
import CommonAPI from'./commonchartapi';import{POSITION_BOTTOM}from'../../../../fc-core/src/lib';class CommonSpaceManager extends CommonAPI{_spaceManager(){var a,b,c,d,e,f,g,h,j,k,l,m,n,o,p,q,r,s,t,u,v=this,w=v.config,x=v.getChildren('xAxis')&&v.getChildren('xAxis')[0],y=v.getChildren('yAxis')&&v.getChildren('yAxis')||[],z=w.legendposition,A=w.xDepth,B=w.yDepth,C=w.canvasBgDepth,D=w.canvasBaseDepth,E=w.canvasBasePadding,F=v.getChildren('canvas')[0],G=F.config.canvasBorderWidth,H=w.realTimeConfig&&w.realTimeConfig.showRTValue,I=w.borderWidth,J=w.canvasMarginTop,K=w.canvasMarginBottom,L=w.canvasMarginLeft,M=w.canvasMarginRight,N=w.minCanvasHeight,O=w.minCanvasWidth,P=w.minChartWidth,Q=w.minChartHeight,R=w.height,S=w.width,T=!1,U=!1,V=w.origCanvasTopMargin,W=w.origCanvasBottomMargin,X=w.origCanvasLeftMargin,Y=w.origCanvasRightMargin,Z=[];for(w.canvasWidth-2*I<P&&(p=(w.canvasWidth-P)/2),w.canvasHeight-2*I<Q&&(o=(w.canvasHeight-Q)/2),v._allocateSpace({top:o||I,bottom:o||I,left:p||I,right:p||I}),(l=0,d=y.length);l<d;l++)c=y[l],a=.7*w.availableWidth,t=c&&c.placeAxis(a)||{},Z.push({axisIndex:l,spaceTaken:t}),c&&v._allocateSpace(t);w.yAxisSpaceAllocation=Z,v._allocateSpace(v._manageActionBarSpace&&v._manageActionBarSpace(.225*w.availableHeight)||{}),v._manageLegendSpace&&w.showLegend&&v._manageLegendSpace(e),b=z===POSITION_BOTTOM?.6*w.availableHeight:.6*w.availableWidth,B&&(v._allocateSpace({bottom:B}),w.shift=A+E+D),C&&v._allocateSpace({right:C}),w.canvasWidth-2*G<O&&(r=(w.canvasWidth-O)/2),v._allocateSpace({left:r||G,right:r||G}),O>S-L-M&&(U=!0,f=w.canvasWidth-O,u=L+M,L=w.canvasMarginLeft=f*L/u,M=w.canvasMarginRight=f*M/u),j=L>w.canvasLeft?L-w.canvasLeft:0,k=M>S-w.canvasRight?M+w.canvasRight-S:0,v._allocateSpace({left:j,right:k}),U&&(u=X+Y,n=w.canvasWidth,n>O&&(f=n-O,j=f*X/u,k=f*Y/u),v._allocateSpace({left:j,right:k})),w.actualCanvasMarginRight=k,w.actualCanvasMarginBottom=h,v._manageChartMenuBar(b),b=.2*w.availableHeight,v._getSumValueSpace&&v._allocateSpace(v._getSumValueSpace(b)),b=.3*w.availableHeight,w.realtimeEnabled&&(H?v._allocateSpace(v._realTimeValuePositioning(b)):v._hideRealTimeValue()),v._resetViewPortConfig&&v._resetViewPortConfig(),v._setAxisScale&&v._setAxisScale(),b=.6*w.availableHeight,w.xAxisSpaceAllocation=s=x&&x.placeAxis(b),x&&v._allocateSpace(s),w.canvasHeight-2*G<N&&(q=(w.canvasHeight-N)/2),v._allocateSpace({top:q||G,bottom:q||G}),v._allocateSpace({bottom:D}),N>R-J-K&&(T=!0,f=w.canvasHeight-N,u=J+K,J=w.canvasMarginTop=f*J/u,K=w.canvasMarginBottom=f*K/u),g=J>w.canvasTop?J-w.canvasTop:0,h=K>R-w.canvasBottom?K+w.canvasBottom-R:0,v._allocateSpace({top:g,bottom:h}),T&&(u=V+W,m=w.canvasHeight,m>N&&(f=m-N,g=f*V/u,h=f*W/u),v._allocateSpace({top:g,bottom:h})),w.actualCanvasMarginTop=g,w.actualCanvasMarginLeft=j,F.setDimension({top:w.canvasTop,left:w.canvasLeft,width:w.canvasWidth,height:w.canvasHeight})}_postSpaceManagement(){var a,b,c=this,d=c.config,e=c.getChildren(),f=e.xAxis&&e.xAxis[0],g=e.legend&&e.legend[0],h=d.xDepth,j=c.getChildren('canvas');for(c.setAxisDimention&&c.setAxisDimention(),f&&c._allocateXAxisLabelSpace(f),f&&f.shiftLabels(-h,0),g&&g.postSpaceManager(),a=0;a<(j&&j.length);a++)b=j[a],b.setCanvasPadding();c.setAxisDimention&&c.setAxisDimention(),c.allocateDimensionOfChartMenuBar()}}export default CommonSpaceManager;