UNPKG

@fusioncharts/charts

Version:

JavaScript Data Visualisation Library

1 lines 13.4 kB
"use strict";exports.__esModule=true;exports.default=void 0;var _lib=require("@fusioncharts/core/src/lib");var _default=exports.default={"initial.dataset.column":function initialDatasetColumn(){var component=this,chart=component.getFromEnv("chart"),yDepth=chart.config.yDepth||0,yAttrKey="y",hAttrKey="height",xAttrKey="x",wAttrKey="width",plot1SKey="_plot_1Start",plot1EKey="_plot_1End",plot2SKey="_plot_2Start",yAxis=component.getFromEnv("yAxis"),xAxis=component.getFromEnv("xAxis"),_axisSync=function _axisSync(inputJSON,dataObj){var conf=component.config,setElement=dataObj&&dataObj.graphics&&dataObj.graphics.element,finalAttr=inputJSON.attr,oldAttr,oldYVal,oldYPlusH,newZeroPos=yAxis.getPixel(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth),axisEndAttr={},oldZeroAxisPos=conf.oldZeroAxisPos,hasWithAxisAnim,crispingGutter=.7;oldAttr=setElement.attr();axisEndAttr[yAttrKey]=oldYVal=oldAttr[yAttrKey];axisEndAttr[hAttrKey]=oldAttr[hAttrKey];axisEndAttr[xAttrKey]=oldAttr[xAttrKey];axisEndAttr[wAttrKey]=oldAttr[wAttrKey];oldYPlusH=oldAttr[yAttrKey]+oldAttr[hAttrKey];if(newZeroPos!==oldZeroAxisPos){if(oldZeroAxisPos-newZeroPos>=0){if(oldYVal>newZeroPos&&oldYVal<=oldZeroAxisPos+crispingGutter){axisEndAttr[yAttrKey]=newZeroPos;if(oldYPlusH>oldZeroAxisPos){axisEndAttr[hAttrKey]=oldYPlusH-axisEndAttr[yAttrKey]}}if(oldYPlusH>newZeroPos&&oldYPlusH<=oldZeroAxisPos+crispingGutter){axisEndAttr[hAttrKey]=newZeroPos-(axisEndAttr[yAttrKey]||axisEndAttr[yAttrKey]===0?axisEndAttr[yAttrKey]:oldYVal)}}else{if(oldYVal<newZeroPos&&oldYVal>=oldZeroAxisPos-crispingGutter){axisEndAttr[yAttrKey]=newZeroPos;if(oldYPlusH>newZeroPos){axisEndAttr[hAttrKey]=oldYPlusH-axisEndAttr[yAttrKey]}}if(oldYPlusH<newZeroPos&&oldYPlusH>=oldZeroAxisPos-crispingGutter){axisEndAttr[hAttrKey]=newZeroPos-(axisEndAttr[yAttrKey]||axisEndAttr[yAttrKey]===0?axisEndAttr[yAttrKey]:oldYVal)}}hasWithAxisAnim=true}if(component.config.catDiff){axisEndAttr[xAttrKey]=finalAttr[xAttrKey];axisEndAttr[wAttrKey]=finalAttr[wAttrKey];hasWithAxisAnim=true}dataObj[plot1SKey]=axisEndAttr;if(hasWithAxisAnim){return{finalAttr:axisEndAttr,slot:"axis"}}},UNDEF;return{"rect.appearing":function rectAppearing(inputJSON){var zeroPos=yAxis.getPixel(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth),index=inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index,dataObj=component.components.data[index],actualFinalAttr=inputJSON.attr,yAttrVal,hAttrVal,yBasePos,endPosWRT0;if(xAxis.config.isVertical){yAttrKey="x";hAttrKey="width";xAttrKey="y";wAttrKey="height"}yAttrVal=actualFinalAttr[yAttrKey];hAttrVal=actualFinalAttr[hAttrKey];endPosWRT0=Math.sign(yAttrVal+hAttrVal/2-zeroPos);if(endPosWRT0===1){yBasePos=yAttrVal}else{yBasePos=yAttrVal+hAttrVal}dataObj._posWRT0=endPosWRT0;return[{initialAttr:function initialAttr(){var initialAttr={};initialAttr[yAttrKey]=yBasePos;initialAttr.opacity=0;initialAttr[hAttrKey]=0;return initialAttr},finalAttr:{opacity:1},startEnd:function startEnd(){var length=inputJSON.length;return _lib.animHelperFN.getTimeByValue(_lib.animHelperFN.animByWeight(inputJSON.index,length,.6),{startPx:zeroPos,endPx:endPosWRT0===1?component.config.yAxisMaxPixel:component.config.yAxisMinPixel},{startPx:yBasePos,endPx:endPosWRT0===1?actualFinalAttr[yAttrKey]+actualFinalAttr[hAttrKey]:actualFinalAttr[yAttrKey]})},hookFn:function hookFn(){this.attr({opacity:1})},effect:"linear",slot:"plot"}]},"rect.updating":function rectUpdating(inputJSON){var returnArr=[],dataObj=component.components.data[inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index],finalAttr=inputJSON.attr,setElement=dataObj&&dataObj.graphics&&dataObj.graphics.element,startY,startH,startYPlusH,startPlotCenter,endY,endH,endYPlusH,endPlotCenter,zeroPos=yAxis.getPixel(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth),start=0,numColDiff=component.getFromEnv("numColDiff"),step1Start={},hasPlot1Anim,step1End,step2Start,prevDataObj,base1StartAttr,base2StartAttr,oldPrevDataObj,oldBase1EndAttr,middleYplusH,hasTransitionDiff,base1EndAttr,startPosWRT0,endPosWRT0,step1EndBase,effectiveBasePos,step2HookFn,step1HookFn,preHookAttr,nonDimensionAttr,val;if(xAxis.config.isVertical){yAttrKey="x";hAttrKey="width";xAttrKey="y";wAttrKey="height"}if(val=_axisSync(inputJSON,dataObj)){returnArr.push(val)}prevDataObj=dataObj.prevDataObj;base1StartAttr=prevDataObj&&prevDataObj[plot1SKey];base1EndAttr=prevDataObj&&prevDataObj[plot1EKey];base2StartAttr=prevDataObj&&prevDataObj[plot2SKey];oldPrevDataObj=dataObj.oldPrevDataObj;oldBase1EndAttr=dataObj.oldPrevDataObj&&dataObj.oldPrevDataObj[plot1EKey];step1Start=dataObj[plot1SKey];startY=step1Start[yAttrKey];startH=step1Start[hAttrKey];startYPlusH=startY+startH;startPlotCenter=startY+startH/2;endY=finalAttr[yAttrKey];endH=finalAttr[hAttrKey];endYPlusH=endY+endH;endPlotCenter=endY+endH/2;middleYplusH=(startYPlusH+endYPlusH)/2;startPosWRT0=Math.sign(startPlotCenter-zeroPos);endPosWRT0=Math.sign(endPlotCenter-zeroPos);step1End={};step2Start={};step2Start[yAttrKey]=step1End[yAttrKey]=(startY+endY)/2;step2Start[hAttrKey]=step1End[hAttrKey]=(startH+endH)/2;if(startH){if(startPosWRT0!==endPosWRT0){step2Start[hAttrKey]=step1End[hAttrKey]=0;step1End[yAttrKey]=oldPrevDataObj&&oldPrevDataObj._oldPosWRT0===startPosWRT0?oldBase1EndAttr[yAttrKey]+(startPosWRT0===1?oldBase1EndAttr[hAttrKey]:0):zeroPos;step2Start[yAttrKey]=base2StartAttr?base2StartAttr[yAttrKey]+(endPosWRT0===1?base2StartAttr[hAttrKey]:0):zeroPos;hasTransitionDiff=hasPlot1Anim=true}else if(prevDataObj!==oldPrevDataObj){step1EndBase=oldBase1EndAttr||(base1EndAttr&&Math.sign(base1EndAttr[yAttrKey]+base1EndAttr[hAttrKey]/2-zeroPos)===startPosWRT0?base1EndAttr:false);effectiveBasePos=step1EndBase?step1EndBase[yAttrKey]+(startPosWRT0===1?step1EndBase[hAttrKey]:0):zeroPos;if(startPosWRT0===1){step2Start[yAttrKey]=step1End[yAttrKey]=effectiveBasePos;step2Start[hAttrKey]=step1End[hAttrKey]=middleYplusH-step1End[yAttrKey]}else{step2Start[hAttrKey]=step1End[hAttrKey]=effectiveBasePos-step1End[yAttrKey]}hasPlot1Anim=true}}else{if(prevDataObj&&prevDataObj._oldPosWRT0===endPosWRT0||component.stackIndex===0){preHookAttr={};preHookAttr[hAttrKey]=0;preHookAttr[yAttrKey]=base1StartAttr?base1StartAttr[yAttrKey]+(prevDataObj._posWRT0>0?base1StartAttr[hAttrKey]:0):zeroPos;dataObj._posWRT0=endPosWRT0;dataObj[plot1SKey]=preHookAttr;step2Start[yAttrKey]=step1End[yAttrKey]=(preHookAttr[yAttrKey]+endY)/2;step2Start[hAttrKey]=step1End[hAttrKey]=endH/2}else if(startPlotCenter===zeroPos){if(endPosWRT0!==dataObj._posWRT0){start=.5}else{hasPlot1Anim=true;step1End[yAttrKey]=endPosWRT0===1?zeroPos:zeroPos-step1End[hAttrKey]}}}if(numColDiff<0){step1End[xAttrKey]=finalAttr[xAttrKey];step1End[wAttrKey]=finalAttr[wAttrKey];hasPlot1Anim=true}else if(numColDiff>0){start=.5}else if(step1Start[xAttrKey]!==finalAttr[xAttrKey]||step1Start[wAttrKey]!==finalAttr[wAttrKey]){if(start===.5){preHookAttr={};preHookAttr[xAttrKey]=finalAttr[xAttrKey];preHookAttr[wAttrKey]=finalAttr[wAttrKey];step2HookFn=function step2HookFn(){if(hasTransitionDiff){setElement.attr(step2Start)}setElement.attr(preHookAttr)}}else{step1End[xAttrKey]=finalAttr[xAttrKey];step1End[wAttrKey]=finalAttr[wAttrKey];hasPlot1Anim=true;if(step2HookFn){step1HookFn=function step1HookFn(){setElement.attr(preHookAttr)};step2HookFn=UNDEF}}}if(hasPlot1Anim){returnArr.push({finalAttr:step1End,startEnd:{start:0,end:.5},hookFn:step1HookFn,slot:"plot"});start=.5}!step2HookFn&&(step2HookFn=function step2HookFn(){if(hasTransitionDiff){setElement.attr(step2Start)}});returnArr.push({effect:"linear",startEnd:{start:start,end:1},finalAttr:{x:finalAttr.x,y:finalAttr.y,width:finalAttr.width,height:finalAttr.height},callback:function callback(){if(dataObj.config.setValue===null||dataObj.config.setValue===UNDEF){this.hide()}},hookFn:step2HookFn,slot:"plot"});nonDimensionAttr=Object.assign({},finalAttr);delete nonDimensionAttr.x;delete nonDimensionAttr.y;delete nonDimensionAttr.width;delete nonDimensionAttr.height;returnArr.push({finalAttr:nonDimensionAttr,effect:"linear",slot:"plot"});dataObj[plot1EKey]=step1End;dataObj[plot2SKey]=step2Start;dataObj._oldPosWRT0=dataObj._posWRT0;dataObj._posWRT0=endPosWRT0;return returnArr},"rect._disappearing":function rect_disappearing(inputJSON){var zeroPos=yAxis.getPixel(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth),removeDataArr=component.components.removeDataArr,dataObj=removeDataArr&&removeDataArr[inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index]||component.components.data[inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index],setElement=dataObj&&dataObj.graphics&&dataObj.graphics.element,oldBase1EndAttr=dataObj.oldPrevDataObj&&dataObj.oldPrevDataObj[plot1EKey],yBasePos,yAttrVal,attr,val,plot1StartAtt,returnArr=[];if(!setElement){return}if(val=_axisSync(inputJSON,dataObj)){returnArr.push(val)}if(!yAxis.config.isVertical){yAttrKey="x";hAttrKey="width"}plot1StartAtt=dataObj[plot1SKey];yAttrVal=plot1StartAtt[yAttrKey];if(yAttrVal+plot1StartAtt[hAttrKey]/2>zeroPos){yBasePos=oldBase1EndAttr?oldBase1EndAttr[yAttrKey]+oldBase1EndAttr[hAttrKey]:yAttrVal}else{yBasePos=oldBase1EndAttr?oldBase1EndAttr[yAttrKey]:zeroPos}attr={};attr[yAttrKey]=yBasePos;attr[hAttrKey]=0;attr.width=dataObj._width;attr.x=dataObj._xPos;returnArr.push({startEnd:{start:0,end:component.getFromEnv("numOfColumns")<1?1:.5},finalAttr:attr,slot:"plot"});dataObj[plot1EKey]=inputJSON.finalAttr;return returnArr},"plotLabel.appearing":[{initialAttr:{opacity:0},slot:"final"}],"plotLabel._disappearing":[{hookFn:function hookFn(){this.hide()},slot:"initial"}],"plotLabel.updating":[{hookFn:function hookFn(){this.hide()},slot:"initial"},{hookFn:function hookFn(){this.show()},initialAttr:{opacity:0},finalAttr:{opacity:1},slot:"final"}],"group.appearing":function groupAppearing(inputJSON){if(inputJSON.attr.name==="label-group"){return[{initialAttr:{opacity:0},finalAttr:{opacity:1},slot:"final"}]}return[{initialAttr:{opacity:1},finalAttr:{opacity:1},slot:"final"}]},"*":null}},"legendInteraction.dataset.column":function legendInteractionDatasetColumn(){var isNull=function isNull(z){return z==null};var component=this,chart=component.getFromEnv("chart"),yDepth=chart.config.yDepth||0,yAxis=component.getFromEnv("yAxis"),xAxis=component.getFromEnv("xAxis"),yAttrKey="y",hAttrKey="height",xAttrKey="x",wAttrKey="width";return{"rect.disappearing":function rectDisappearing(inputJSON){var _finalAttr;var index=inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index,data=component.components.data[index],updatedIndex=component.getFromEnv("updatedIndex"),stackIndex=component.getFromEnv("stackIndex"),totalMSColumns,stackColumns,prevScale=yAxis.getFromEnv("prevScale"),x,width,y,height;if(xAxis.config.isVertical){yAttrKey="x";hAttrKey="width";xAttrKey="y";wAttrKey="height"}if(isNull(stackIndex)){totalMSColumns=component.getFromEnv("numOfColumns")}else{stackColumns=component.getFromEnv("numOfColumns");if(isNull(updatedIndex)){totalMSColumns=stackColumns}else{totalMSColumns=component.getLinkedParent().getLinkedParent().getFromEnv("numOfColumns")}}if(!isNull(stackIndex)&&stackColumns){height=0;y=yAxis.getPixel(data.config._b)+(chart.isBar?-yDepth:yDepth)}else if(totalMSColumns===0){height=0;y=prevScale.getRangeValue(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth)}else{var groupStart=xAxis.getPixel(index)-component.getFromEnv("groupNetWidth")/2;x=groupStart+updatedIndex*(component.getFromEnv("plotWidth")+component.getFromEnv("plotPadding")+component.getFromEnv("plotPadding")/2);width=0}return[{finalAttr:(_finalAttr={},_finalAttr[wAttrKey]=width,_finalAttr[yAttrKey]=y,_finalAttr[hAttrKey]=height,_finalAttr[xAttrKey]=x,_finalAttr)}]},"rect.updating":function rectUpdating(inputJSON){var index=inputJSON.props&&inputJSON.props.originalIndex||inputJSON.index,data=component.components.data[index],updatedIndex=component.getFromEnv("updatedIndex"),totalMSColumns,stackIndex=component.getFromEnv("stackIndex"),stackColumns,x,y,prevScale=yAxis.getFromEnv("prevScale"),width,height,initialAttr={};if(!component.config.appearing){return[{}]}if(xAxis.config.isVertical){yAttrKey="x";hAttrKey="width";xAttrKey="y";wAttrKey="height"}if(isNull(stackIndex)){totalMSColumns=component.getFromEnv("numOfColumns")}else{stackColumns=component.getFromEnv("numOfColumns");if(isNull(updatedIndex)){totalMSColumns=stackColumns}else{totalMSColumns=component.getLinkedParent().getLinkedParent().getFromEnv("numOfColumns")}}if(!isNull(stackIndex)&&!isNull(stackColumns)&&stackColumns!==1){height=0;y=prevScale.getRangeValue(data.config._b)+(chart.isBar?-yDepth:yDepth)}else if(totalMSColumns===1){height=0;y=prevScale.getRangeValue(yAxis.getAxisBase())+(chart.isBar?-yDepth:yDepth)}else{var groupStart=xAxis.getPixel(index)-component.getFromEnv("oldGroupNetWidth")/2;x=groupStart+updatedIndex*(component.getFromEnv("oldPlotWidth")+component.getFromEnv("oldPlotPadding")+component.getFromEnv("oldPlotPadding")/2);width=0}initialAttr[xAttrKey]=isNull(x)?inputJSON.attr[xAttrKey]:x;initialAttr[yAttrKey]=isNull(y)?inputJSON.attr[yAttrKey]:y;initialAttr[hAttrKey]=isNull(height)?inputJSON.attr[hAttrKey]:height;initialAttr[wAttrKey]=isNull(width)?inputJSON.attr[wAttrKey]:width;return[{initialAttr:initialAttr}]},"plotLabel.updating":function plotLabelUpdating(){if(!component.config.appearing&&component.getState("visible")){return[{}]}return[{initialAttr:{opacity:0},finalAttr:{opacity:0}}]},"*":null}}};