UNPKG

quoslibero

Version:

FusionCharts JavaScript charting framework

1 lines 2.15 kB
import{SmartRenderer}from'../../../../../fc-core/src/component-interface';import{getTouchEvent,toRaphaelColor}from'./../../../../../fc-core/src/lib';const COLOR_FDFDFD='#fdfdfd',COLOR_F7FFFE='#f7fffe',COLOR_E3E3E3='#e3e3e3',M='M',v='v',h='h',STROKE_ATTR_LIST=['stroke','stroke-width','stroke-dasharray','stroke-dashoffset','stroke-linecap','stroke-linejoin','stroke-miterlimit','stroke-opacity','stroke-color'];class Selection extends SmartRenderer{constructor(){super(),this._dimensions={}}__setDefaultConfig(){super.__setDefaultConfig(),this.config.defaultStyle={fill:toRaphaelColor({FCcolor:{color:'#fdfdfd,#f7fffe',ratio:'0,100',angle:90,alpha:'50,50'}}),stroke:COLOR_E3E3E3,"stroke-width":1,opacity:1,"fill-opacity":.5,cursor:'move'}}configureAttributes(a={}){super.configureAttributes(a);let b=this,c=b.config,d=c.defaultStyle;c.style=Object.assign({},d,a.style.mask),c.orientation=a.orientation}setDimension(a){this._dimensions=a}getDimension(){return this._dimensions}attachHandlers(){let a,b,c,d,f,e=this,g=e.getFromEnv('animationManager'),h=e.getLinkedParent(),i=h.getFromEnv('timeNavigator');e.addEventListener('fc-dragstart',e.dragstartHandler||(e.dragstartHandler=function(c){b=getTouchEvent(c).clientX,a=h.getCurrentBrushDimensions()})),e.addEventListener('fc-dragmove',e.dragmoveHandler||(e.dragmoveHandler=function(h){g.setAnimationState('timenavScroll'),c=getTouchEvent(h).clientX-b,d=a.x+c,f=a.x+c+a.width,i.validateDomain([d,f])}))}draw(){var a=Math.max;let b,c=this,d=c.config,e=Object.assign({},d.style),f=Object.assign({},d.style),g=STROKE_ATTR_LIST.length,j=c.getDimension();for(b=0;b<g;b++)delete e[STROKE_ATTR_LIST[b]];c.addGraphicalElement({el:'rect',attr:{x:j.x,y:j.y,width:a(j.width,0),height:a(j.height,0),opacity:e.opacity},css:e,id:'selectionBox',label:'selectionBox',component:c,container:{id:'brushGroup',label:'brushGroup',isParent:!0}}),f.fill='none',c.addGraphicalElement({el:'path',attr:{path:[M,j.x,j.y,v,j.height,h,j.width,v,-j.height],opacity:f.opacity},id:'selectionBoxBorder',label:'selectionBoxBorder',css:f,component:c,container:{id:'brushGroup',label:'brushGroup',isParent:!0}})}}export default Selection;