UNPKG

quoslibero

Version:

FusionCharts JavaScript charting framework

1 lines 9.21 kB
import{pluck,pluckNumber,pluckFontSize,parseUnsafeString,BLANK,chartPaletteStr,preDefStr}from'../../../../fc-core/src/lib';import LinearGauge from'../_internal/lineargauge';import{configureAttributes,_getData}from'../_internal/bullet-led-common';import BulletDataset from'../../dataset/bullet';import datasetFactory from'../../factories/vled-dataset';var UNDEF,GUTTER_PADDING=2,BLANKSTRING=BLANK,POSITION_START=preDefStr.POSITION_START,POSITION_END=preDefStr.POSITION_END,POSITION_BOTTOM=preDefStr.POSITION_BOTTOM,POSITION_MIDDLE=preDefStr.POSITION_MIDDLE,math=Math,mathCeil=math.ceil,mathMax=math.max,zeroCommaHundredStr='0,100';class Hbullet extends LinearGauge{static getName(){return'Hbullet'}constructor(){super(),this.defaultSeriesType='hbullet',this.gaugeType=1,this.defaultCaptionPadding=5,this.rendererId='hbullet',this.isHorizontal=!0,this.isAxisOpposite=!0,this.rtManageSpace=!0,this.ticksOnRight=0,this.hasCanvas=!0,this.isAxisReverse=!1,this.defaultPaletteOptions={paletteColors:[['A6A6A6','CCCCCC','E1E1E1','F0F0F0'],['A7AA95','C4C6B7','DEDFD7','F2F2EE'],['04C2E3','66E7FD','9CEFFE','CEF8FF'],['FA9101','FEB654','FED7A0','FFEDD5'],['FF2B60','FF6C92','FFB9CB','FFE8EE']],bgColor:['FFFFFF','CFD4BE,F3F5DD','C5DADD,EDFBFE','A86402,FDC16D','FF7CA0,FFD1DD'],bgAngle:[270,270,270,270,270],bgRatio:[zeroCommaHundredStr,zeroCommaHundredStr,zeroCommaHundredStr,zeroCommaHundredStr,zeroCommaHundredStr],bgAlpha:['100','60,50','40,20','20,10','30,30'],toolTipBgColor:['FFFFFF','FFFFFF','FFFFFF','FFFFFF','FFFFFF'],toolTipBorderColor:['545454','545454','415D6F','845001','68001B'],baseFontColor:['333333','60634E','025B6A','A15E01','68001B'],tickColor:['333333','60634E','025B6A','A15E01','68001B'],trendColor:['545454','60634E','415D6F','845001','68001B'],plotFillColor:['545454','60634E','415D6F','845001','68001B'],borderColor:['767575','545454','415D6F','845001','68001B'],borderAlpha:[50,50,50,50,50]},this.showRTvalue=!1,this.canvasPadding=!1,this.defaultPlotShadow=1,this.realtimeEnabled=!0,this.chartleftmargin=15,this.chartrightmargin=15,this.charttopmargin=10,this.chartbottommargin=10,this.showTooltip=0,this.connectTickMarks=0,this.drawPlotlines=!1,this.drawPlotBands=!1,this.isRealTime=!0,this.colorRange=!0,this.registerFactory('dataset',datasetFactory,['vCanvas'])}getName(){return'Hbullet'}__setDefaultConfig(){super.__setDefaultConfig();let a=this.config;a.friendlyName='Horizontal Bullet Gauge',a.defaultDatasetType='bullet',a.singleseries=!0,a.skipCanvasDrawing=!0}_RTmanageSpace(){var a,b,c=this,d=c.config,e=c.getChildren('scale')[0],f=c.getChildren('dataset')[0];b=f._manageSpaceHorizontal(.7*d.oriCanvasWidth),a=b.right-d.labelSpace.right,c._allocateSpace({right:a}),e.setAxisDimention({axisLength:d.canvasWidth}),d.labelSpace=b}configureAttributes(a){super.configureAttributes(a),configureAttributes.call(this)}_getData(){return _getData.call(this)}_spaceManager(){var a,b,c,d,e,f=this,g=f.config,h=f.getChildren('canvas')[0],i=f.getChildren('dataset')[0],j=f.getChildren('scale')[0],k=f.config.is3D,l=f.getFromEnv('dataSource').chart,m=pluckNumber(l.showborder,k?0:1),n=g.minChartWidth,o=g.minChartHeight,p=g.borderWidth=m?pluckNumber(l.borderthickness,1):0;g.canvasWidth-2*p<n&&(e=(g.canvasWidth-n)/2),g.canvasHeight-2*p<o&&(d=(g.canvasHeight-o)/2),f._allocateSpace({top:d||p,bottom:d||p,left:e||p,right:e||p}),a=.7*g.canvasWidth,f._allocateSpace(j.placeAxis(g.availableHeight)),f._allocateSpace(f._manageActionBarSpace&&f._manageActionBarSpace(.225*g.availableHeight)||{}),g.oriCanvasWidth=g.canvasWidth,b=.225*g.canvasHeight,f._manageChartMenuBar(b),c=mathMax(f.getChildren('subCaption')[0].config.width||0,f.getChildren('caption')[0].config.width||0),g.labelSpace=i._manageSpaceHorizontal(a-.7*c),i._manageSpace&&f._allocateSpace(g.labelSpace),g.oriCanvasWidth-=c,b=.325*g.canvasHeight,h.setDimension({top:g.canvasTop,left:g.canvasLeft,width:g.canvasWidth,height:g.canvasHeight})}_manageCaptionSpacing(){var a,b,c,d,e,f=Math.max,g=this,h=g.config,i=g.getChildren('caption')[0],j=g.getChildren('subCaption')[0],k=i.config,l=j.config,m=g.getFromEnv('dataSource').chart,n=g.getFromEnv('smartLabel'),o=parseUnsafeString(m.caption),p=parseUnsafeString(m.subcaption),q=pluckNumber(m.captionpadding,2),r=h.height,s=h.width,t=0,u=0,v=0,w=.3*s,x={};return 3<.3*r&&(k.captionPadding=l.captionPadding=q,o!==BLANKSTRING&&(d=k.style,t=k.captionLineHeight=mathCeil(parseFloat(pluck(d.fontHeight,d.lineHeight),10),12)),p!==BLANKSTRING&&(e=l.style,u=mathCeil(parseInt(pluck(e.lineHeight,e.fontHeight),10),12)),(0<t||0<u)&&(n.useEllipsesOnOverflow(h.useEllipsesWhenOverflow),n.setStyle(d),b=n.getSmartText(o,w,r),0<b.width&&(b.width+=GUTTER_PADDING,v=b.height),n.setStyle(e),c=n.getSmartText(p,w,r-v),0<c.width&&(c.width+=GUTTER_PADDING),k.captionSubCaptionGap=b.height+0+.2*u,a=f(b.width,c.width),k.text=b.text,k.height=v=b.height,k.width=b.width,k.tooltext&&(k.originalText=b.tooltext),l.text=c.text,l.height=v=c.height,l.width=c.width,l.tooltext&&(k.originalText=c.tooltext),a=f(b.width,c.width),0<a&&(a+=q),k.maxCaptionWidth=l.maxCaptionWidth=a,k.isOnLeft?x.left=a:x.right=a)),k.align=k.isOnLeft?l.align=POSITION_END:l.align=POSITION_START,x}_manageCaptionPosition(){var a=this,b=a.config,c=a.getChildren('caption')[0],d=a.getChildren('subCaption')[0],e=c.config,f=d.config,g=e.captionPosition,h=mathMax(e.width,f.width),i=b.borderWidth||0,j=e.captionSubCaptionGap;switch(g){case POSITION_MIDDLE:e.y=.5*(b.canvasTop+b.canvasHeight);break;case POSITION_BOTTOM:e.y=b.canvasBottom-(e.height+f.height);break;default:e.y=b.canvasTop;}f.y=e.y+j,e.x=e.isOnLeft?f.x=b.marginLeft+h+i:f.x=b.width-b.marginRight-h-i}_feedAxesRawData(){var a,b=this,c=b.getFromEnv('color-manager'),d=b.getFromEnv('number-formatter'),e=b.getFromEnv('dataSource'),f=e.chart,g=chartPaletteStr.chart2D,h=pluckNumber(f.ticksbelowgraph,1),i=pluckNumber(f.ticksonright,f.axisontop,f.axisonleft===UNDEF?UNDEF:!pluckNumber(f.axisonleft),!h,b.isAxisOpposite);return a={isVertical:!b.isHorizontal,isReverse:!1,isOpposit:i,outCanfontFamily:pluck(f.outcnvbasefont,f.basefont,'Verdana,sans'),outCanfontSize:pluckFontSize(f.outcnvbasefontsize,f.basefontsize,10),outCancolor:pluck(f.outcnvbasefontcolor,f.basefontcolor,c.getColor(g.baseFontColor)).replace(/^#?([a-f0-9]+)/ig,'#$1'),useEllipsesWhenOverflow:f.useellipseswhenoverflow,divLineColor:pluck(f.vdivlinecolor,c.getColor(g.divLineColor)),divLineAlpha:pluck(f.vdivlinealpha,c.getColor('divLineAlpha')),divLineThickness:pluckNumber(f.vdivlinethickness,1),divLineIsDashed:!!pluckNumber(f.vdivlinedashed,f.vdivlineisdashed,0),divLineDashLen:pluckNumber(f.vdivlinedashlen,4),divLineDashGap:pluckNumber(f.vdivlinedashgap,2),showAlternateGridColor:pluckNumber(f.showalternatevgridcolor,0),alternateGridColor:pluck(f.alternatevgridcolor,c.getColor('altVGridColor')),alternateGridAlpha:pluck(f.alternatevgridalpha,c.getColor('altVGridAlpha')),numDivLines:f.numvdivlines,labelFont:f.labelfont,labelFontSize:f.labelfontsize,labelFontColor:f.labelfontcolor,labelFontAlpha:f.labelalpha,labelFontBold:f.labelfontbold,labelFontItalic:f.labelfontitalic,axisName:f.xaxisname,axisMinValue:d.getCleanValue(f.lowerlimit),axisMaxValue:d.getCleanValue(f.upperlimit),setAdaptiveMin:f.setadaptivexmin,adjustDiv:f.adjusttm,labelDisplay:f.labeldisplay,showLabels:f.showlabels,rotateLabels:f.rotatelabels,slantLabel:pluckNumber(f.slantlabels,f.slantlabel),labelStep:pluckNumber(f.labelstep,f.xaxisvaluesstep),showAxisValues:pluckNumber(f.showxaxisvalues,f.showxaxisvalue),showDivLineValues:pluckNumber(f.showvdivlinevalues,f.showvdivlinevalues),showZeroPlane:f.showvzeroplane,zeroPlaneColor:f.vzeroplanecolor,zeroPlaneThickness:f.vzeroplanethickness,zeroPlaneAlpha:f.vzeroplanealpha,showZeroPlaneValue:f.showvzeroplanevalue,trendlineColor:f.trendlinecolor,trendlineToolText:f.trendlinetooltext,trendlineThickness:f.trendlinethickness,trendlineAlpha:f.trendlinealpha,showTrendlinesOnTop:f.showtrendlinesontop,showAxisLine:pluckNumber(f.showxaxisline,f.showaxislines,f.drawAxisLines,0),axisLineThickness:pluckNumber(f.xaxislinethickness,f.axislinethickness,1),axisLineAlpha:pluckNumber(f.xaxislinealpha,f.axislinealpha,100),axisLineColor:pluck(f.xaxislinecolor,f.axislinecolor,'#000000'),majorTMNumber:f.majortmnumber,majorTMColor:f.majortmcolor,majorTMAlpha:f.majortmalpha,majorTMHeight:f.majortmheight,tickValueStep:f.tickvaluestep,showTickMarks:f.showtickmarks,connectTickMarks:f.connecttickmarks,showTickValues:f.showtickvalues,majorTMThickness:f.majortmthickness,reverseScale:f.reversescale,showLimits:pluckNumber(f.showlimits,f.showtickmarks),minorTMNumber:pluckNumber(f.minortmnumber,0),minorTMColor:f.minortmcolor,minorTMAlpha:f.minortmalpha,minorTMHeight:pluckNumber(f.minortmheight,f.minortmwidth),minorTMThickness:f.minortmthickness,tickMarkDistance:pluckNumber(f.tickmarkdistance,f.tickmarkgap),tickValueDistance:pluckNumber(f.tickvaluedistance,f.displayvaluedistance),placeTicksInside:f.placeticksinside,placeValuesInside:f.placevaluesinside,upperLimitDisplay:f.upperlimitdisplay,lowerLimitDisplay:f.lowerlimitdisplay},[a]}getDSdef(){return BulletDataset}_fetchCaptionPos(){var a,b=this,c=b.getChildren('caption')[0],d=c.config;return a=d.align===POSITION_END?0:-1,a}}export default Hbullet;