quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 3.58 kB
JavaScript
import Canvas from'../../../fc-charts/src/_internal/components/canvases/canvas';import{pluckNumber,pluck,setLineHeight,toRaphaelColor}from'../../../fc-core/src/lib';const MAX_MITER_LINEJOIN=2;class CanvasGantt extends Canvas{createGroup(){super.createGroup();let a,b=this.getFromEnv('chart'),c=b.config,d=c.style.inCanvasStyle,e=this.getFromEnv('animationManager'),f=this,g=b.getChildContainer('plotGroup');this.getChildContainer('taskGroup')||this.addChildContainer('taskGroup',e.setAnimation({el:'group',attr:{name:'task'},container:g,component:f})),this.getChildContainer('connectorGroup')||this.addChildContainer('connectorGroup',e.setAnimation({el:'group',attr:{name:'connector'},container:g,component:f})),this.getChildContainer('milestoneGroup')||this.addChildContainer('milestoneGroup',e.setAnimation({el:'group',attr:{name:'milestone'},container:g,component:f})),a=c.milestoneLabelStyle={fontSize:pluckNumber(c.milestonefontsize,d.fontSize)+'px',fontFamily:pluck(c.milestonefont,d.fontFamily),fontWeight:pluckNumber(c.milestonefontbold,0)&&'bold'||'normal',fontStyle:pluckNumber(c.milestonefontitalic,0)&&'italic'||'normal'},setLineHeight(a),this.getChildContainer('milestoneGroup').css(a)}draw(){super.draw(),this.setClipping()}setClipping(){var a=this.getFromEnv('chart'),b=a.config,c=this.getChildContainer('taskGroup'),d=this.getChildContainer('connectorGroup'),e=a.getChildContainer(),f=e.plotGroup,g=e.datalabelsGroup,h=e.trackerGroup,i=b.viewPortConfig,j=i.scaleX,k=i.x,l=this.getFromEnv('animationManager'),m=a.getChildren('canvas')[0].config.clip['clip-canvas'].slice(0);l.setAnimation({el:f,attr:{"clip-rect":m},state:a.config.clipSet?'updating':'appearing',component:this}),l.setAnimation({el:g,attr:{"clip-rect":m},state:a.config.clipSet?'updating':'appearing',component:this}),l.setAnimation({el:h,attr:{"clip-rect":m},state:a.config.clipSet?'updating':'appearing',component:this}),b.xOffset=k*j,l.setAnimation({el:f,attr:{transform:'T'+-(k*j)+',0'},component:this}),l.setAnimation({el:c,attr:{transform:'T'+-(k*j)+',0'},component:this}),l.setAnimation({el:d,attr:{transform:'T'+-(k*j)+',0'},component:this}),l.setAnimation({el:g,attr:{transform:'T'+-(k*j)+',0'},component:this}),l.setAnimation({el:h,attr:{transform:'T'+-(k*j)+',0'},component:this}),a.config.clipSet=!0}drawCanvas(){var a=Math.max;let b,c,d,e,f=this,g=f.getFromEnv('chart'),h=g.getFromEnv('dataSource'),i=h.chart,j=g.config,k=f.getFromEnv('animationManager'),l=f.config,m=l.clip={},n=f.getGraphicalElement('canvasBorderElement'),o=f.getGraphicalElement('canvasElement'),p=j.actualCanvasLeft,q=j.actualCanvasTop,r=j.canvasWidth,s=j.canvasHeight,t=j.canvasLeft,u=j.canvasTop,v=j.canvasWidth+j.totalWidth,w=j.canvasHeight+j.totalHeight,x=f.getContainer('canvasGroup'),y=l.canvasBorderRadius,z=l.canvasBorderWidth,A=.5*z,B=l.canvasBorderColor,C=l.canBGColor,D=l.shadow,E=l.showCanvasBG=!!pluckNumber(i.showcanvasbg,1),F=l.shadowOnCanvasFill,G=l.showCanvasBorder;d=C,e={x:p-A,y:q-A,width:v+z,height:w+z,r:y,"stroke-width":z,stroke:B,"stroke-linejoin":z>MAX_MITER_LINEJOIN?'round':'miter'},G?(b=k.setAnimation({el:n||'rect',attr:e,container:x,component:f}),n?b.show():b=f.addGraphicalElement('canvasBorderElement',b),b.shadow(D)):n&&n.hide(),m['clip-canvas']=[a(0,t),a(0,u),a(1,r),a(1,s)],m['clip-canvas-init']=[a(0,t),a(0,u),1,a(1,s)],E?(e={x:p,y:q,width:v,height:w,r:y,"stroke-width":0,stroke:'none',fill:toRaphaelColor(d)},c=k.setAnimation({el:o||'rect',attr:e,component:f,container:x}),o?c.show():c=f.addGraphicalElement('canvasElement',c),c.shadow(F)):o&&o.hide()}}export default CanvasGantt;