quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 20.3 kB
JavaScript
import{pluck,pluckNumber,parseUnsafeString,POSITION_START,POSITION_END,POSITION_TOP,POSITION_BOTTOM,POSITION_MIDDLE,POSITION_RIGHT,preDefStr,BLANKSTRING,setLineHeight,getFirstValue,pluckFontSize,chartPaletteStr,TESTSTR,crispBound,extend2,convertColor,getFirstColor}from'../../../../../../fc-core/src/lib';import{ComponentInterface}from'../../../../../../fc-core/src/component-interface';import LegendItem from'./legend-item';import{addDep}from'../../../../../../fc-core/src/dependency-manager';import{ScrollBar}from'../../../../../../fc-core/src/toolbox';import legendAnimation from'./index.animation';import{priorityList}from'../../../../../../fc-core/src/schedular';let UNDEF,TEXT_ANCHOR_MAP={left:POSITION_START,right:POSITION_END,center:POSITION_MIDDLE},math=Math,mathMin=math.min,mathMax=math.max,mathFloor=math.floor,mathCeil=math.ceil,COMMA=',',NONE='none',NORMAL=preDefStr.NORMAL,BOLD=preDefStr.BOLD,noneStr=preDefStr.noneStr,styleValueMap={fontWeight:{1:BOLD,0:NORMAL},fontStyle:{1:'italic',0:NORMAL},textDecoration:{1:'underline',0:noneStr}},handlers=function(a){let b,c;return{dragstart:()=>{b=a.config.xL||a.config.xPos,c=a.config.yL||a.config.yPos},dragmove:d=>{let e,f,g=d.originalEvent.data[0],h=d.originalEvent.data[1],i=a.config,j=a.getFromEnv('chartConfig'),k=(i.borderWidth||0)+2;e=mathMin(mathMax(b+g,k),j.width-i.width-k),f=mathMin(mathMax(c+h,k),j.height-i.height-k),i.xPos=i.xL=e,i.yPos=i.yL=f,a.addJob('draw',a.dragDraw,priorityList&&priorityList.draw)}}};addDep({name:'legendAnimation',type:'animationRule',extension:legendAnimation});class Legend extends ComponentInterface{constructor(){super();let a=this;a._stateCosmetics={},a._legendState=[],a.dragDraw=function(){a.draw()},a.drawScroll=function(){a.createItemGroup()},a.config.handlers=handlers(a)}createItem(a){var b,c=this;return b=new LegendItem,c.attachChild(b,'legendItem'),b.setLinkedItem('owner',a),b.addEventListener('mouseover',function(){b.setLegendState('hover',!0)}),b.addEventListener('mouseout',function(){b.removeLegendState('hover')}),b.getId()}getItem(a){var b=this,c=b.getChildren().legendItem;if(!(a!==UNDEF))return!1;else if(c)for(let b=0;b<c.length;b++)if(c[b].getId()===a)return c[b]}getSortedLegendItems(){let a,b,c=this,d=c.getChildren('legendItem')||[],e=c.config.reverselegend,f={},g=[];for(a=0,b=d.length;a<b;a++)d[a].config.index===UNDEF?f[b+a]=d[a]:f[d[a].config.index]=d[a];return Object.keys(f).sort(function(a,b){return e?b-a:a-b}).forEach(a=>{g.push(f[a])}),g}disposeItem(a){var b=this,c=b.getItem(a);c&&c.remove()}getName(){return'legend'}getType(){return'legend'}__setDefaultConfig(){super.__setDefaultConfig();let a=this.config;a.enabled=!0,a.symbolWidth=12,a.borderRadius=1,a.lastScrollPos=0,a.oriSymbolPadding=3,a.textPadding=4,a.scrollY=0,a.backgroundColor='#FFFFFF',a.initialItemX=0,a.title={text:BLANKSTRING,x:0,y:0,padding:2},a.scroll={},a.itemStyle={}}createLegendGroup(){let a,b=this,c=b.config,d=b.getFromEnv('chart'),e=d.config,f=b.getFromEnv('animationManager'),g=.5*(c.borderWidth||0)+2,h=b.getContainer('legendGroup');c.xL&&(c.xL=mathMin(mathMax(c.xL,g),e.width-c.width-g)),c.yL&&(c.yL=mathMin(mathMax(c.yL,g),e.height-c.height-g)),a=f.setAnimation({el:h||'group',attr:{name:'legendGroup',transform:['T',c.xL||c.xPos,c.yL||c.yPos]},container:d.getChildContainer('legendGroup'),component:b}),h||b.addContainer('legendGroup',a)}draw(){this.createLegendGroup(),this.drawLegendBox(),this.createItemGroup(),this.drawCaption(),this.createScrollGroup(),this.decideScroll()}decideScroll(){let a=this,b=a.config,c=b.scroll.enabled;c?this.createScrollBar():b.hasScroll&&(a.getChildren('legendScrollBar')[0].remove(),b.hasScroll=!1)}createItemGroup(){var a,b=this,c=b.getFromEnv('animationManager'),d=b.getContainer('legendGroup'),e=b.getChildContainer('itemGroup'),f=pluckNumber(b.config.padding,4),g=Math.max(b.config.height-f,0),h=COMMA+b.config.width+COMMA+g;return a=c.setAnimation({el:e||'group',attr:{name:'item',transform:['T',0,b.config.scrollY||0]},container:d,component:b}),e||b.addChildContainer('itemGroup',a),b.config.scroll.enabled?a.attr({"clip-rect":'0,'+.5*f+h}):a.attr({"clip-rect":null}),a}createScrollGroup(){let a=this,b=a.getFromEnv('animationManager'),c=a.getChildContainer('scrollGroup'),d=a.getContainer('legendGroup');a.config.scroll.enabled&&!a.getGraphicalElement('scrollbarContainer')&&a.addGraphicalElement('scrollbarContainer',b.setAnimation({el:c||'group',attr:{name:'scrollGroup'},container:d,component:a,label:'scrollbar'}))}createScrollBar(){var a,b,c,d,e,f,g=Math.max,i=this,j=i.config,k=i.getFromEnv('chart-attrib'),l=i.getChildren('legendScrollBar')&&i.getChildren('legendScrollBar')[0],m=j.borderWidth||0,n=pluckNumber(j.padding,4),o=j.width,p=j.height;a={conf:{isHorizontal:!1},handler:{scroll:function(a){j.lastScrollPos=a,j.scrollY=(c-j.totalHeight)*a,i.addJob('scrollDraw',i.drawScroll,priorityList&&priorityList.draw)},mousedown:function(a){a.preventDefault(),a.stopPropagation()}}},k.legendscrollbgcolor&&(a.conf.color=convertColor(k.legendscrollbgcolor)),l||(l=i.attachChild(new ScrollBar,'legendScrollBar'),this.config.hasScroll=!0),l.configure(a.conf),l.attachEventHandlers(a.handler),b=l.config,c=g(p-n,0),d=o-10+.5*n-m,e=.5*m,f=g(p-m,0),b.scrollRatio=(c+n)/j.totalHeight,b.startPercent=0,b.scrollPosition=j.lastScrollPos,b.parentLayer=i.getChildContainer('scrollGroup'),l.setDimension({x:d,y:e,height:f})}drawCaption(){var a,b,c,d,e=this,f=e.getChildContainer('itemGroup'),g=e.getGraphicalElement('caption'),h=this.getFromEnv('animationManager'),i=this.config,j=pluckNumber(i.padding,4),k=i.scroll.enabled,l=i.width;if(i.title&&i.title.text!==BLANKSTRING&&i.validLegendItem){switch(i.title.align){case POSITION_START:c=j;break;case POSITION_END:c=l-j-(k?10:0);break;default:c=.5*l;}b=i.title.style,a={text:i.title.text,title:i.title.originalText||BLANKSTRING,x:c,y:j,fill:i.title.style.color,direction:i.textDirection,"line-height":b.lineHeight,"vertical-align":POSITION_TOP,"text-anchor":i.title.align,opacity:1},d={"font-weight":b.fontWeight,"font-style":b.fontStyle,"font-family":b.fontFamily,"font-size":b.fontSize},g&&g.show(),g?h.setAnimation({el:g,attr:a,component:e}):(g=h.setAnimation({el:'text',attr:a,component:e,container:f}),g=this.addGraphicalElement('caption',g),g.css(d)),e.getFromEnv('toolTipController').enableToolTip(g,i.title.originalText)}else g&&h.setAnimation({el:g,component:e,doNotRemove:!0,callback:function(){g.hide()}})}drawLegendBox(){var a,b=this,c=this.getFromEnv('animationManager'),d=b.config,e=b.getContainer('legendGroup'),f=d.width,g=b.getGraphicalElement('box'),h=d.height,i=d.borderRadius,j=d.backgroundColor,k=d.borderColor,l=d.borderAlpha,m=d.backgroundAlpha,n=d.borderWidth||0;return a=c.setAnimation({el:g||'rect',attr:{x:0,y:0,width:f,height:h,r:i,stroke:k,"stroke-width":n,fill:j||NONE,"stroke-opacity":l/100,"fill-opacity":m/100,cursor:d.legendAllowDrag?'move':'default'},container:e,component:b,label:'legendGroup'}),g||(b.addGraphicalElement('box',a),a.shadow(d.shadow)),a}getPosition(){var a,b,c,d,e,f,g=this,h=g.getFromEnv('chart'),i=h.config,j=g.config,k=i.height-i.canvasBottom,l=i.canvasLeft,m=i.canvasWidth,n=j.chartMarginLeft||0,o=j.chartMarginRight||0,p=j.chartMarginBottom||0,q=i.actionBarHeight||0,r=j.actualCanvasMarginLeft||0,s=i.actualCanvasMarginBottom||0,t=i.actualCanvasMarginRight||0,u=j.alignLegendWithCanvas,v=i.height,w=i.canvasTop,x=j.width||0,y=j.height||0,z=i.borderWidth,A=i.oriCanvasLeft,B=i.oriTopSpace,C=i.oriBottomSpace,D=0,E=0,F=j.borderWidth||0,G=j.legendPos;return G===POSITION_RIGHT&&(j.align=POSITION_RIGHT,j.verticalAlign=POSITION_MIDDLE,f=j.layout='vertical'),f?(a=i.width-o-t-x-z,D=pluckNumber(B,w),E=pluckNumber(C,k),b=D+.5*(v-E-D-y)+(j.y||0)):(d=i.width-(n+r+(o+t)),e=u?m-x:d-x,c=u?pluckNumber(A,l):n+r,a=c+e/2,b=v-y-s-p-q),crispBound(a,b,x,y,F)}setTranslation(a,b){var c=this,d=c.config;d._translateX=a,d._translateY=b,d.translate='t'+a+','+b}allocatePosition(){var a,b=this,c=b.config;a=c.translate?crispBound(c._translateX,c._translateY,c.width,c.height,c.borderWidth):b.getPosition(),c.xPos=a.x,c.yPos=a.y,c.width=a.width,c.height=a.height}_manageLegendPosition(a){var b,c=this,d=c.config,e=d.legendPos;return d.padding=4,d.textPadding=4,b=e===POSITION_RIGHT?c._placeLegendBlockRight(a):c._placeLegendBlockBottom(a),b}setDimension(a){var b=Math.max;let c,d,e,f,g,h,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C=this,D=this.config,E=C.getSortedLegendItems(),F=E.length,G=a.width,H=a.height,I=2*H,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=[],S=!1,T=D.padding,U=D.textPadding,V=C.getFromEnv('smartLabel'),W=C.getStateCosmetics('default'),X=parseInt(W.text['font-size'],10)||10,Y=0,Z=0,$=D.title,_=$.padding,aa=D.minimiseWrappingInLegend,ba=D.legendPadding,ca=D.legendScale,da=D.alignLegendWithCanvas,ea=D.numColumns,fa=D.oriSymbolPadding,ga=G;for(r={width:2*T,height:2*T},q=X+1,0>=q&&(q=1),G=b(G-2*T,0),q*=ca,fa*=ca,q=mathMin(q,G),0>=q&&(fa=q=0),D.symbolWidth=q,D.textPadding=4,D.legendHeight=p=q+2*fa,D.rowHeight=h=mathMax(parseInt(W.text['line-height'],10)||12,p),g=U+fa+T,V.setStyle(extend2({},W.text)),s=V.getOriSize(TESTSTR).height,k=ba+D.borderWidth/2+1,k=mathMin(k,H-s-8),ba=.05*h,D.initialItemY=0,D.initialItemX=0,t=0;t<F;t+=1){if(f=E[t],c=f.config||(f.config={}),d=c,e=c.name=parseUnsafeString(d.label),e===BLANKSTRING||0===d.enabled||!1===d.enabled||f.getState('removed')){c.enabled=0;continue}else c.enabled=1;L+=1,y=!0,z=V.getOriSize(e),J=mathMax(J,z.width),O=mathMax(O,mathMin(z.height,I)),K+=z.width}if(D.validLegendItem=y,M=K/L,B=p+ba+U+fa+2*T,K+=B*L,D.x=!da&&K>ga?0:D.x,y){for(M+=B,J+=B,0<ea&&L<ea&&(ea=L),K<=G&&(0>=ea||ea===L)?(ea=L,N=M=K/L,S=!0,O>h&&(Q=(O-h)/2,h=O)):0<ea&&(N=G/ea)>M?N>J&&(N=J):G>J&&(aa||1.5*M>J)?(ea=mathFloor(G/J),L<ea&&(ea=L),N=J):G>=2*M?(ea=mathFloor(G/M),L<ea&&(ea=L),N=mathFloor(G/ea),N>J&&(N=J)):(ea=1,N=G),D.itemWidth=N,l=mathCeil(N-B),0>l&&(fa=l=U=0),D.symbolPadding=fa,D.textPadding=U,D.width=b(N*ea-ba,0),$.oriText!==BLANKSTRING&&(V.setStyle($.style),z=V.getSmartText($.oriText,G,I),$.text=z.text,z.tooltext&&($.originalText=z.tooltext),o=z.width+2*T,D.width<o&&(D.initialItemX=(o-D.width)/2,D.width=o),D.initialItemY=P=z.height+_),V.setStyle(extend2({},W.text)),t=0;t<F;t+=1)if(f=E[t],c=f.config,0!==c.enabled){if(0===l&&(R[Z]=!0,c.name=BLANKSTRING,u=1,w=parseInt(Z/ea,10),v=Z%ea,c._legendX=v*N,c._legendY=w*h+2*T,c._legendH=u*h,c._totalWidth=q+fa),S)z=V.getOriSize(c.name),z.height<h&&(c._legendTestY=(h-z.height)/2),c._markerYGutter=Q,c._legendX=Y,c._legendY=2*T,c._legendH=h,c._totalWidth=q+g+z.width,Y+=z.width+B;else{for(z=V.getSmartText(c.name,l,I),c.name=z.text,z.tooltext&&(c.originalText=z.tooltext);!0===R[Z];)Z+=1;for(m=z.height/h,n=Z,u=0;u<m;u+=1,n+=ea)R[n]=!0;z.height<h&&(c._legendTestY=(h-z.height)/2),w=parseInt(Z/ea,10),v=Z%ea,c._legendX=v*N,c._legendY=w*h+2*T,c._legendH=u*h,c._totalWidth=q+g+z.width}Z++}x=S?1:mathCeil(R.length/ea),r.height+=x*h+P,D.height=D.totalHeight=r.height,D.rowHeight=h,D.legendNumColumns=ea,D.height-2*fa>H?(D.height=H,A=D.scroll||(D.scroll={}),A.enabled=!0,A.flatScrollBars=D.flatScrollBars,A.scrollBar3DLighting=D.scrollBar3DLighting,D.width=D.width+12>G?D.width:D.width+12):D.scroll.enabled=!1,k+=D.height,D.isActive=!0,D.enabled=!0}else D.enabled=!1,D.width=0,k=0;return{width:G,height:k}}_placeLegendBlockBottom(a){var b,c,d,e,f,g=this,h=g.getFromEnv('chart'),i=h.config,j=h.getFromEnv('chartWidth'),k=h.getFromEnv('chartHeight'),l=i.canvasLeft,m=i.width-(i.canvasRight||0),n=h.getFromEnv('smartLabel'),o=g.config,p=o.chartMarginLeft,q=o.chartMarginRight,r=o.chartMarginTop,s=o.alignLegendWithCanvas,t=g.getSortedLegendItems(),u=t.length,v=o.legendPadding,w=i.canvasMarginRight,x=i.canvasMarginLeft,y=h.getChildren('yAxis'),z=y&&y[0].config.isVertical?y:h.getChildren('xAxis'),A=z&&z[0],B=z&&z[1],C=A&&A.config||{},D=B&&B.config||{},E=C.nameMaxW,F=D.nameMaxW,G=C.name&&C.name.style||{},H=D.name&&D.name.style||{},I=C.axisName||BLANKSTRING,J=D.axisName||BLANKSTRING,K=i.canvasWidth-i.canvasMarginLeft-i.canvasMarginRight;return o.paddingBottom=i.height-i.canvasBottom,n.useEllipsesOnOverflow(i.useEllipsesWhenOverflow),n.setStyle(G),e=n.getOriSize(I),n.setStyle(H),f=n.getOriSize(J),K<v&&(o.padding=v=K=0),(e||f)&&(c=pluckNumber(e.height,0)>pluckNumber(f.height,0)?(d=E)&&e.width:(d=F)&&f.width),K=s?K:j-(c+r>k-a?2*d+q+p+w+x:q+p+x+w),o.showLegend&&0!==u?(o.x=(l-p-m+q)/2,b=g.setDimension({width:K,height:a}).height):(b=0,o.height=0,o.width=0),{bottom:b,right:0}}_placeLegendBlockRight(a){var b,c,d,e,f,g,h,j,k,l,m=this,n=m.config,o=m.getFromEnv('chart'),p=o.config,q=o.getFromEnv('smartLabel'),r=o.getChildren('canvas')[0].config.canvasBorderThickness||0,s=n.textPadding,t=n.title.padding,u=n.oriSymbolPadding,v=n.legendPadding,w=n.legendScale,x=m.getStateCosmetics('default'),y=parseInt(x.text['font-size'],10),z=p.canvasHeight,A=2*z,B=0,C=n.padding,D=2*C,E={width:D,height:D},F={},G=!1,H=m.getSortedLegendItems(),I=H.length,J=0;if(n.initialItemY=0,n.initialItemX=0,a-=D+v,a<v&&(n.padding=v=a=0),e=y+1,0>=e&&(e=1),e*=w,u*=w,e=mathMin(e,a),0>=e&&(u=e=0),n.symbolPadding=u,n.symbolWidth=e,n.legendHeight=f=e+2*u,n.rowHeight=mathMax(parseInt(x.text['line-height'],10)||12,f),b=v+n.borderWidth/2+r,d=a-f-v-s,0>d&&(d=0),q.useEllipsesOnOverflow(p.useEllipsesWhenOverflow),q.setStyle(extend2({},x.text)),!n.showLegend||0===I)F.right=0,n.height=0,n.width=0;else{for(J=0;J<I;J+=1){if(l=H[J],g=l.config||(l.config={}),k=g,h=g.name=parseUnsafeString(k.label),g._legendX=0,g._legendY=E.height,0===k.enabled||!1===k.enabled||h===BLANKSTRING){g.enabled=0;continue}else g.enabled=1;G=!0,0===d?(E.height+=g._legendH=f,g.name=BLANKSTRING,g._totalWidth=e+u):(c=q.getSmartText(h,d,A),g.name=c.text,c.tooltext&&(g.originalText=c.tooltext),c.height<f&&(g._legendTestY=(f-c.height)/2),g._totalWidth=e+u+s+c.width+v,E.height+=g._legendH=mathMax(c.height,f),B=mathMax(c.width,B))}n.validLegendItem=G,G?(n.itemWidth=B+f+v+s,n.width=n.itemWidth+D,n.title.oriText!==BLANKSTRING&&(q.setStyle(n.title.style),c=q.getSmartText(n.title.oriText,a,A),n.title.text=c.text,c.tooltext&&(n.title.originalText=c.tooltext),j=c.width+D,n.width<j&&(n.initialItemX=(j-n.width)/2,n.width=j),n.initialItemY=c.height+t,E.height+=n.initialItemY),n.height=n.totalHeight=E.height,b=mathMin(n.width+b,a),F.right=b+v,n.isActive=!0,n.enabled=!0):(n.enabled=!1,n.width=0,F.right=0)}return F}postSpaceManager(){var a=this,b=a.config,c=b.legendPos,d=a.getFromEnv('chart'),e=d.config.canvasHeight;c===POSITION_RIGHT&&(b.height>e?(b.height=e,b.scroll.enabled=!0,b.scroll.flatScrollBars=b.flatScrollBars,b.scroll.scrollBar3DLighting=b.scrollBar3DLighting,b.width+=(b.scroll.scrollBarWidth=10)+(b.scroll.scrollBarPadding=2)):b.scroll.enabled=!1)}configureAttributes(a={}){super.configureAttributes(a);var b,c,d,e,f,g=this,h=g.config,i=g.getFromEnv('chart'),j=i.config,k=g.getFromEnv('style'),l=i.getFromEnv('chart-attrib'),m=i.config.is3D,n=g.getFromEnv('color-manager'),o=m?chartPaletteStr.chart3D:chartPaletteStr.chart2D,p=h.interactiveLegend=!1!==i.hasInteractiveLegend&&!!pluckNumber(l.interactivelegend,1),q=pluckNumber(l.useroundedges,0),r=k.outCancolor,s=a.style&&a.style.text,t=pluck(l.legenditemfont,s&&s['font-family'],k.outCanfontFamily),u=pluckNumber(l.legendiconscale,1),v=pluckFontSize(l.legenditemfontsize,s&&s['font-size'],k.fontSize)+'px',w=pluck(l.legenditemfontcolor,s&&s.color,r).replace(/^#?([a-f0-9]+)/ig,'#$1'),x=getFirstColor(pluck(l.legenditemhoverfontcolor,w));h.isActive=!1,h.chartMarginTop=j.origMarginTop,h.chartMarginRight=j.origMarginRight,h.chartMarginBottom=j.origMarginBottom,h.chartMarginLeft=j.origMarginLeft,h.reverselegend=pluckNumber(l.reverselegend,0),h.showLegend=pluckNumber(l.showlegend,!i.dontShowLegendByDefault,1),b=setLineHeight({fontSize:v}),h.legendPos=pluck(l.legendposition,i.legendposition,a.legendPosition,POSITION_BOTTOM).toLowerCase(),h.numColumns=pluckNumber(l.legendnumcolumns,0),h.xL=h.yL=0,(0>=u||5<u)&&(u=1),h.drawCustomLegendIcon=pluckNumber(l.drawcustomlegendicon,a.drawcustomlegendicon,0),h.legendScale=u,h.legendPadding=pluckNumber(l.legendpadding,7),h.alignLegendWithCanvas=pluckNumber(a.alignlegendwithcanvas,j.alignLegendWithCanvas),h.title.style={fontFamily:pluck(l.legendcaptionfont,t),fontSize:pluckFontSize(l.legendcaptionfontsize,k.fontSize)+'px',color:pluck(l.legendcaptionfontcolor,r).replace(/^#?([a-f0-9]+)/ig,'#$1'),fontWeight:styleValueMap.fontWeight[pluckNumber(l.legendcaptionfontbold,1)]||BLANKSTRING},f=l.legendcaptionalignment?l.legendcaptionalignment.toLowerCase():TEXT_ANCHOR_MAP.center,h.title.align=TEXT_ANCHOR_MAP[f]||TEXT_ANCHOR_MAP.center,h.title.style['text-anchor']=h.title.align,h.padding=4,c=pluck(l.legendbordercolor,n.getColor(o.legendBorderColor)),d=h.borderAlpha=pluckNumber(l.legendborderalpha,100),h.borderColor=convertColor(c,d),h.borderWidth=pluckNumber(l.legendborderthickness,a.legendborderthickness,!q||l.legendbordercolor?1:0),h.borderRadius=pluckNumber(q,0),h.backgroundAlpha=e=pluckNumber(l.legendbgalpha,a.legendbgalpha,100),h.backgroundColor=convertColor(pluck(l.legendbgcolor,n.getColor(o.legendBgColor)),e),h.symbol3DLighting=!!pluckNumber(l.use3dlighting,l.useplotgradientcolor,1),h.shadow=!!pluckNumber(l.legendshadow,1),h.shadow&&(h.shadow={enabled:h.shadow,opacity:mathMax(d,e)/100}),h.prevReversed=!!pluckNumber(h.reversed,0),h.reversed=!!pluckNumber(l.reverselegend,0),h.lineWidth=pluckNumber(l.linethickness,2),h.borderRadius=pluckNumber(l.legendborderradius,q?3:0),h.legendAllowDrag=!!pluckNumber(l.legendallowdrag,0),h.title.oriText=parseUnsafeString(getFirstValue(l.legendcaption,BLANKSTRING)),h.legendScrollBgColor=getFirstColor(pluck(l.legendscrollbgcolor,l.scrollcolor,n.getColor('altHGridColor'))),h.legendScrollBarColor=pluck(l.legendscrollbarcolor,c),h.legendScrollBtnColor=pluck(l.legendscrollbtncolor,c),h.minimiseWrappingInLegend=pluckNumber(l.minimisewrappinginlegend,0),h.flatScrollBars=pluckNumber(l.flatscrollbars,0),h.scrollBar3DLighting=pluckNumber(l.scrollbar3dlighting,1),h.orderReversed=!1,g.setStateCosmetics('hidden',{symbol:{fill:convertColor(pluck(l.legenditemhiddencolor,'cccccc').replace(/^#?([a-f0-9]+)/ig,'#$1')),stroke:convertColor(pluck(l.legenditemhiddencolor,'cccccc').replace(/^#?([a-f0-9]+)/ig,'#$1'))},text:{fill:convertColor(pluck(l.legenditemhiddencolor,'cccccc').replace(/^#?([a-f0-9]+)/ig,'#$1'))}}),g.setStateCosmetics('default',{text:{fill:convertColor(w),"font-family":t,cursor:p?preDefStr.POINTER:'default',"font-size":v,"line-height":b,"vertical-align":POSITION_TOP,"text-anchor":POSITION_START,direction:'rtl'===j.textDirection?'rtl':'initial',"font-weight":styleValueMap.fontWeight[pluckNumber(l.legenditemfontbold,0)]||BLANKSTRING},symbol:{bgColor:pluck(l.legendiconbgcolor),cursor:p?preDefStr.POINTER:'default',borderColor:pluck(l.legendiconbordercolor),bgAlpha:pluck(l.legendiconbgalpha,l.legendiconalpha,100),borderAlpha:pluck(l.legendiconborderalpha,l.legendiconalpha,100),borderThickness:pluckNumber(l.legendiconborderthickness),startAngle:pluckNumber(l.legendiconstartangle,45),sides:pluckNumber(l.legendiconsides,a.legendiconsides,4)}}),g.setStateCosmetics('hover',function(a,b){return b.hasState('hidden')||(!a.text&&(a.text={}),a.text.fill=convertColor(x.replace(/^#?([a-f0-9]+)/ig,'#$1')),a.text.cursor='inherit'),a}),h.legendAllowDrag&&!h._dragEvtListenerBinded?(g.addEventListener('fc-dragstart',h.handlers.dragstart),g.addEventListener('fc-dragmove',h.handlers.dragmove),h._dragEvtListenerBinded=!0):!h.legendAllowDrag&&h._dragEvtListenerBinded&&(g.removeEventListener('fc-dragstart',h.handlers.dragstart),g.removeEventListener('fc-dragmove',h.handlers.dragmove),h._dragEvtListenerBinded=!1)}getLegendState(){return this._legendState}hasState(a){var b,c,d=this.getLegendState();for(b=0,c=d.length;b<c;b++)if(d[b]===a)return!0;return!1}setLegendState(a,b){this.hasState(a)||(b?this._legendState.push(a):this._legendState.unshift(a)),this.asyncDraw()}removeLegendState(a){var b,c,d=1;if(a)for(b=0,c=this._legendState.length;b<c&&d;b++)a===this._legendState[b]&&(this._legendState.splice(b,1),d=0);else this._legendState.length=0;this.asyncDraw()}setStateCosmetics(a,b){this._stateCosmetics[a]=b}removeStateCosmetics(a){delete this._stateCosmetics[a]}getStateCosmetics(a){return this._stateCosmetics[a]}hide(){var a=this,b=a.getFromEnv('chart'),c=b.getChildContainer('legendGroup');c&&c.hide()}}export default Legend;