quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 1.72 kB
JavaScript
import{Tool}from'../../../../fc-core/src/toolbox/tools';const HOVER='hover',NORMAL='normal',VISIBLE='visible',PRESSED='pressed';class SRSTool extends Tool{constructor(a){super(a),this.addEventListener('fc-mouseover',function(){this.setData({hoveredState:HOVER},!0)}),this.addEventListener('fc-mouseout',function(){this.setData({hoveredState:NORMAL},!0)})}__setDefaultConfig(){super.__setDefaultConfig();let a=this.config;a.containerInfo={id:'group',label:'group',isParent:!0},a.spaceNotHardCoded=!0,a.hoveredState=NORMAL}configureAttributes(a={}){let b,c=this,d=c.config;for(b in a)d[b]=a[b];for(b in d.listener)c.addEventListener(b,d.listener[b]);c.setState(VISIBLE,!0!==d.isHidden),d.symbolName=d.name}getHoveredState(){return this.config.hoveredState}draw(){let a=this,b=a.config,c=b.x+b.width/2,d=b.y+b.height/2,e=b.width,f=b.height,g=b.css,h=a.getCurrentState(),i=a.getHoveredState(),j=g[h].config[i],k=g[h].config[`${i}Background`];a.getState(VISIBLE)&&(a.addGraphicalElement({el:'group',attr:{name:'srs-tool'},container:b.containerInfo,component:a,id:'group',label:'group'}),a.addGraphicalElement({el:'rect',attr:{x:c-e/2-2,y:d-f/2-2,width:e+4,height:f+4,opacity:k.opacity},css:k,container:{id:'group',label:'group'},component:a,id:'rect',label:'rect'},!0),a.addGraphicalElement({el:'text',attr:{x:c,y:d,text:b.text,opacity:j.opacity},container:{id:'group',label:'group'},css:j,component:a,id:'text',label:'text'},!0),h===PRESSED&&a.addGraphicalElement({el:'path',attr:{path:`M${c-e/2-1}, ${d+f/2+1.5} h ${e+1}`,opacity:j.opacity},container:{id:'group',label:'group'},css:{stroke:j.fill,"stroke-linecap":'round',"stroke-opacity":j['fill-opacity']},component:a,id:'path',label:'path'},!0))}}export default SRSTool;