quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 5.8 kB
JavaScript
import MSCartesian from'../../../../fc-charts/src/chart/_internal/mscartesian';import{TESTSTR,BLANKSTRING,preDefStr,pluck,pluckNumber,convertColor}from'../../../../fc-core/src/lib';import RealtimeColumnDataset from'../../dataset/realtimecolumn';import ColumnMultiseriesGroup from'../../../../fc-charts/src/dataset/groups/column-multiseries';import MessageLogger from'../../../../fc-features/src/messagelogger';import AlertManager from'../../../../fc-features/src/alertmanager';import FusionCharts from'../../../../fc-core/src/constructor';import{addDep}from'../../../../fc-core/src/dependency-manager';import realtimeColumnChartAnimation from'./index.animation';import{_realTimeConfigure,eiMethods,_stopUpdate,_restartUpdate,_isUpdateActive,realTimeUpdate,_RTmanageSpace,realTimeDraw,feedData,_linearDataParser,_clearChart,_setRTmenu as __setRTmenu}from'../_internal/realtime';import _getData from'../../../../fc-core/src/_internal/misc/fetch-data';import{priorityList}from'../../../../fc-core/src/schedular';import DataStreamer from'../_internal/datastreamer';let UNDEF,visibleStr=preDefStr.visibleStr;function _setData(a,b){var c=BLANKSTRING;(a&&a.toString||a===BLANKSTRING||0===a)&&(c='value='+a.toString()),(b&&b.toString||b===BLANKSTRING)&&(c=c+'&label='+b.toString()),c&&this.feedData(c)}addDep({name:'realtimeColumnChartAnimation',type:'animationRule',extension:realtimeColumnChartAnimation}),FusionCharts.addDep(DataStreamer);class RealtimeColumn extends MSCartesian{static getName(){return'RealtimeColumn'}constructor(){super();let a=this;FusionCharts.addDep(MessageLogger),FusionCharts.addDep(AlertManager),this.showRTvalue=!0,this.canvasPadding=!0,this.isRealTime=!0,this.rtManageSpace=!0,this.transposeAxis=!0,this._setData=_setData,this.eiMethods=eiMethods,this._drawRTValue=function(){a._drawRealTimeValue()}}getName(){return'RealtimeColumn'}__setDefaultConfig(){super.__setDefaultConfig();let a=this.config;a.defaultDatasetType='realtimecolumn',a.enablemousetracking=!0}asyncRealTimeValueDraw(){this.addJob('realtimevaluedraw',this._drawRTValue,priorityList&&priorityList.draw)}parseChartAttr(a){super.parseChartAttr(a),this.config.drawTrendRegion=0}_setCategories(){var a,b=this,c=b.getChildren('xAxis')[0],d=[],e=b.config.realTimeConfig,f=e&&e.clear,g=f?UNDEF:b.getFromEnv('dataSource').categories&&b.getFromEnv('dataSource').categories[0]&&b.getFromEnv('dataSource').categories[0].category,h=g&&Array.isArray(g)&&g.filter(a=>!a.vline).length||0,i=e.numDisplaySets;h<i?(d.length=i-h,a=g?d.concat(g):d):h>i&&0<=i?a=i?g.slice(-i):[]:a=g.slice(0),c.setTickValues(a)}_realTimeValuePositioning(a){var b,c,d=this,e=d.getChildren(),f=d.getFromEnv('smartLabel'),g=d.config,h=g.realTimeConfig||(g.realTimeConfig={}),i=h.realTimeValuePadding,j=e.xAxis[0].config,k=j.trend.trendStyle,l=h.style={color:convertColor(pluck(h.realtimeValueFontColor,k.color),pluck(j.trendlineAlpha,99)),fontFamily:pluck(h.realtimeValueFont,k.fontFamily),fontSize:pluck(h.realtimeValueFontSize,k.fontSize),fontWeight:pluck(h.fontWeight,k.fontWeight),lineHeight:pluckNumber(k.lineHeight)};return f.useEllipsesOnOverflow(g.useEllipsesWhenOverflow),f.setStyle(l),h.height=b=f.getOriSize(TESTSTR).height,h.canvasBottom=g.canvasBottom,c=b+i,c>a&&(c=a),{bottom:c}}draw(){super.draw(),this.showRTvalue&&this.config.realTimeConfig.showRTValue&&this._drawRealTimeValue()}_drawRealTimeValue(){var a,b,c,d,e,f,g,h,j,k=this,l=k.getFromEnv('chart'),m=k.config,n=l.getDatasets(),o=l.getFromEnv('animationManager'),p=k.getFromEnv('smartLabel'),q=m.realTimeConfig,r=q.realtimeValueSeparator,s=n.length,t=BLANKSTRING,u=q.canvasBottom,v=q.height,w=m.canvasLeft,x=m.canvasRight,y=q.style||{},z=k.getGraphicalElement('realTimeValue'),A=k.getChildContainer(),B=l.getContainer().parentGroup,C=A.realTimeValueGroup;if(k.removeJob('realtimevaluedraw'),q.clear&&c&&o.setAnimation({el:c,attr:{text:BLANKSTRING},component:k,label:'label'}),!C)C=l.addChildContainer('realTimeValueGroup',o.setAnimation({el:'group',attr:{name:'realTimeValue'},container:B,label:'group',component:l}).insertBefore(A.datalabelsGroup));else{for(j=0;j<s;j++)e=n[j].components.data,g=e[e.length-1],h=g&&g.config.displayValue,t+=h?h===UNDEF?BLANKSTRING:h+r:BLANKSTRING;t=t.substring(0,t.length-r.length),p.useEllipsesOnOverflow(m.useEllipsesWhenOverflow),p.setStyle(y),a=(w+x)/2,b=u-v/2,d={x:a||0,y:b||0,"font-size":y.fontSize,"font-weight":y.fontWeight,"font-family":y.fontFamily,"line-height":y.lineHeight,text:t,fill:y.color,visibility:visibleStr},c=o.setAnimation({el:z||'text',attr:d,container:C,label:'rtValue',component:l}),f=!0,z||k.addGraphicalElement('realTimeValue',c),c&&!f&&c.show()}}_hideRealTimeValue(){var a=this,b=a.getGraphicalElement('realTimeValue');b&&b.hide()}_setRTmenu(a,b){__setRTmenu.call(this,a,b)}_getDataJSON(){return this.config.realTimeConfig.legacyUpdateObj||{values:[]}}_checkInvalidSpecificData(){let a=this.getFromEnv('dataSource'),b=a.dataset,c=this.getChildren('dataStreamer')&&this.getChildren('dataStreamer')[0];if(!b)return c&&c._stopUpdate(),!0}_checkInvalidData(){var a=this,b=a.getFromEnv('dataSource'),c=a.getChildren('dataStreamer')&&this.getChildren('dataStreamer')[0];if({}===b)return c&&c._stopUpdate(),!0}getDSGroupdef(){return ColumnMultiseriesGroup}getDSdef(){return RealtimeColumnDataset}_realTimeConfigure(){_realTimeConfigure.call(this)}_stopUpdate(a){_stopUpdate.call(this,a)}_restartUpdate(){_restartUpdate.call(this)}_isUpdateActive(){return _isUpdateActive.call(this)}_getData(){return _getData.call(this)}realTimeUpdate(a){realTimeUpdate.call(this,a)}_RTmanageSpace(){_RTmanageSpace.call(this)}realTimeDraw(a={}){realTimeDraw.call(this,a)}feedData(a){return feedData.call(this,a)}_linearDataParser(a){return _linearDataParser.call(this,a)}_clearChart(a){_clearChart.call(this,a)}}export default RealtimeColumn;