quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 3.2 kB
JavaScript
import{SmartRenderer}from'../../../../../fc-core/src/component-interface';import Handle from'./handle';import Label from'./label';import Selection from'./selection';class Brush extends SmartRenderer{constructor(){super(),this._maxDimensions={},this._currDimensions={}}__setDefaultConfig(a={}){super.__setDefaultConfig(a);let b=this.config;b.handleWidth=12,b.handleHeight=20}configureAttributes(a={}){super.configureAttributes(a);let b=this,c=b.config;c.values=a.values,c.style=a.style,b.createChildComponents()}setChildDimension(){let a=this,b=a.config,c=a.getChildren('selection')[0],d=a.getChildren('leftHandle')[0],e=a.getChildren('rightHandle')[0],f=a.getChildren('leftLabel')[0],g=a.getChildren('rightLabel')[0],h=a.getFromEnv('timeNavigatorConfig').contextScale,i=a.getFromEnv('timeNavigatorConfig').values||[],j=h.getRangeValue(i[0]),k=h.getRangeValue(i[1]);c.setDimension({x:j,y:a._maxDimensions.y,width:k-j,height:a._maxDimensions.height}),d.setDimension({x:j-b.handleWidth,y:a._maxDimensions.y+a._maxDimensions.height/2-b.handleHeight/2,width:b.handleWidth,height:b.handleHeight}),e.setDimension({x:k,y:a._maxDimensions.y+a._maxDimensions.height/2-b.handleHeight/2,width:b.handleWidth,height:b.handleHeight}),f.setDimension({x:j,y:a._maxDimensions.y}),g.setDimension({x:k,y:a._maxDimensions.y}),a.setCurrentBrushDimensions({x:j,y:a._maxDimensions.y,width:k-j,height:a._maxDimensions.height-a._maxDimensions.y})}getLabelSpace(){let a=this,b=a.getChildren('leftLabel')[0],c=a.getChildren('rightLabel')[0];return Math.max(b.getLabelDimension().height,c.getLabelDimension().height)}draw(){let a=this;a.addGraphicalElement({el:'group',attr:{name:'brush-group'},id:'brushGroup',label:'brushGroup',component:a,container:{id:'exo',label:'group',isParent:!0}})}hideAllLabels(){let a=this,b=a.getChildren('leftLabel')[0],c=a.getChildren('rightLabel')[0];a.config.pointerReleasedOnParent||(b.config.showLabel=c.config.showLabel=!1,b.asyncDraw(),c.asyncDraw())}createChildComponents(){let a,b,c,d,e,f=this,g=f.config,h=f.getFromEnv('getStyleDef');e=f.attachChild(Selection,'selection'),e.attachHandlers(),e.configure({orientation:'horizontal',style:{mask:h(g.style.mask)}}),a=f.attachChild(Handle,'leftHandle'),a.attachHandlers(),a.configure({orientation:'horizontal',type:'leftHandle',style:{handle:h(g.style.handle),"handle-grip":h(g.style['handle-grip'])}}),b=f.attachChild(Handle,'rightHandle'),b.attachHandlers(),b.configure({orientation:'horizontal',type:'rightHandle',style:{handle:h(g.style.handle),"handle-grip":h(g.style['handle-grip'])}}),c=f.attachChild(Label,'leftLabel'),c.attachHandlers(),c.configure({orientation:'horizontal',type:'leftLabel',value:g.values[0],style:{label:h(g.style.label),labelBg:h(g.style['label-background'])}}),d=f.attachChild(Label,'rightLabel'),d.attachHandlers(),d.configure({orientation:'horizontal',type:'rightLabel',value:g.values[1],style:{label:h(g.style.label),labelBg:h(g.style['label-background'])}})}setMaxBrushDimensions(a){this._maxDimensions=a,this.setChildDimension()}getMaxBrushDimensions(){return this._maxDimensions}setCurrentBrushDimensions(a){this._currDimensions=a}getCurrentBrushDimensions(){return this._currDimensions}}export default Brush;