UNPKG

graphdb-workbench

Version:
2 lines 5.61 kB
export const __webpack_id__=85261;export const __webpack_ids__=[8642,85261];export const __webpack_modules__={8642:(t,e,a)=>{a.r(e),a.d(e,{ChartData:()=>s});var r=a(18301);class s{static get DEFAULT_MULTIPLIER(){return 1.2}static get MAXIMUM_DIVISIONS(){return 10}static get COLORS(){return[s.cssVar("--gw-secondary-base"),s.cssVar("--gw-primary-base"),s.cssVar("--gw-tertiary-base"),s.cssVar("--gw-neutral-base")]}static get AREA_BAR_OPACITY(){return.5}static cssVar(t){return getComputedStyle(document.documentElement).getPropertyValue(t)}constructor(t,e,a,r){this.filter=r,this.disableRangeUpdate=e,this.disableOldDataRemoval=a,this.translateService=t,this.refreshHandlers=[],this.initialChartSetup()}registerRefreshHandler(t){this.refreshHandlers.push(t)}unregisterRefreshHandler(t){const e=this.refreshHandlers.indexOf(t);e>-1&&this.refreshHandlers.splice(e,1)}initialChartSetup(t=!0){this.range=150,this.chartOptions=this.getDefaultChartOptions(this.translateService),t&&(this.dataHolder=this.createDataHolder(),this.chartOptions.series=this.dataHolder,this.firstLoad=!0),this.chartSetup(this.chartOptions)}refresh(t=!1){t||(this.chartSetup(this.chartOptions),this.updateRange(this.dataHolder)),this.refreshHandlers.forEach(t=>t(this.chartOptions))}setSubTitle(t,e=0){this.chartOptions.title.show=!0;let a="";t.forEach((r,s)=>{if(Array.isArray(r.value)&&!r.value.length)return;const i=Array.isArray(r.value)?r.value.join("/"):r.value;a+=`{a|${r.label}}`,void 0!==i&&(a+=`{b|${i}}`),s+1<t.length&&(a+=e>0&&(s+1)%e===0?"\n":"{a| · }")}),this.chartOptions.title.text=a}chartSetup(t){}createDataHolder(){throw new Error("Must implement data holder creation")}addData(t,e){this.removeOldData(this.dataHolder,this.range),this.addNewData(this.dataHolder,t,e,this.isFirstLoad()),this.hasSelectedSeries()&&(this.updateRange(this.dataHolder),this.firstLoad&&(this.firstLoad=!1),this.refresh(!0))}hasSelectedSeries(){return!this.selectedSeries||Object.values(this.selectedSeries).some(t=>!0===t)}removeOldData(t,e){this.disableOldDataRemoval||t[0].data.length>e&&t.forEach(t=>t.data.shift())}addNewData(t,e,a,r){}setSelectedSeries(t){this.selectedSeries=t}updateRange(t,e){if(this.disableRangeUpdate)return;const[a]=s.calculateMaxChartValueAndDivisions(t,e,this.selectedSeries);this.chartOptions.yAxis.max=a}isFirstLoad(){return this.firstLoad}getDefaultChartOptions(){return{title:{show:!1,text:"",left:"center",textStyle:{overflow:"breakAll",rich:{a:{fontWeight:400,fontSize:14},b:{color:s.cssVar("--gw-secondary-base"),fontWeight:400,fontSize:14}}}},animation:!1,color:s.COLORS,legend:{right:"15%",top:"6%",textStyle:{overflow:"truncate"},icon:"circle"},tooltip:{trigger:"axis",axisPointer:{animation:!1,label:{formatter:function(t){return r.kB.format(t.value,"{HH}:{mm}:{ss}",!1)}}}},grid:{containLabel:!0,left:40},xAxis:{type:"time",splitLine:{show:!0},axisLabel:{hideOverlap:!0,padding:8,formatter:{hour:"{bold|{HH}:{mm}}",minute:"{bold|{HH}:{mm}}",second:"{HH}:{mm}:{ss}"},color:s.cssVar("--gw-neutral-dark"),rich:{bold:{fontWeight:500}}}},yAxis:{type:"value",splitLine:{show:!0},axisLabel:{color:s.cssVar("--gw-neutral-dark")},axisTick:{lineStyle:{type:"solid"}}},textStyle:{fontFamily:s.cssVar("--main-font"),fontWeight:400}}}static getMaxValueFromDataHolder(t,e){const a=t.filter(t=>!e||angular.isUndefined(e[t.name])||!0===e[t.name]).map(t=>s.getMaxValueForDataSeries(t));return Math.max(1,...a)}static getMaxValueForDataSeries(t){return Math.max(...t.data.map(t=>t.value[1]))}static calculateMaxChartValueAndDivisions(t,e,a){let r;r=Array.isArray(t)?s.getMaxValueFromDataHolder(t,a):s.getMaxValueForDataSeries(t);const i=Math.ceil(r*(e||s.DEFAULT_MULTIPLIER))||1;return[i,Math.ceil(i/s.MAXIMUM_DIVISIONS)]}static getIntegerRangeForValues(t,e,a){const[r,i]=s.calculateMaxChartValueAndDivisions(t,e,a);return[r,i]}static formatBytesValue(t,e,a){let r=t;e&&(r=s.getMaxValueFromDataHolder(e,a));const i=Math.floor(Math.log(r)/Math.log(1024));return`${(parseFloat(t)/Math.pow(1024,i)).toFixed(2)} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i]}`}formatNumber(t){if(!angular.isUndefined(t)&&this.filter)return this.filter("currency")(t,"",0)}}},85261:(t,e,a)=>{a.r(e),a.d(e,{HeapMemoryChart:()=>s});var r=a(8642);class s extends r.ChartData{constructor(t){super(t,!1,!1)}chartSetup(t){const e={yAxis:{axisLabel:{formatter:t=>this.hasSelectedSeries()?s.formatBytesValue(t,this.dataHolder,this.selectedSeries):s.formatBytesValue(t,this.dataHolder)},min:0},tooltip:{valueFormatter:t=>s.formatBytesValue(t,null,this.selectedSeries)}};_.merge(t,e)}createDataHolder(){return[{name:this.translateService.instant("resource.memory.committed"),type:"line",showSymbol:!1,smooth:!0,data:[]},{name:this.translateService.instant("resource.memory.used"),type:"line",areaStyle:{opacity:r.ChartData.AREA_BAR_OPACITY},showSymbol:!1,smooth:!0,data:[]}]}translateLabels(){const[t,e]=this.dataHolder;t.name=this.translateService.instant("resource.memory.committed"),e.name=this.translateService.instant("resource.memory.used"),this.configureSubtitle()}addNewData(t,e,a){const[r,s]=t,i=this.parseData(a);this.latestData={committed:i.committed,used:i.used,max:i.max},r.data.push({value:[e,i.committed]}),s.data.push({value:[e,i.used]}),this.configureSubtitle()}configureSubtitle(){if(this.latestData.max>0){const t=[{label:this.translateService.instant("resource.memory.heap.max"),value:s.formatBytesValue(this.latestData.max,null,this.selectedSeries)}];this.setSubTitle(t)}}parseData(t){return t.heapMemoryUsage}updateRange(t,e,a){super.updateRange(t,e,a)}}}}; //# sourceMappingURL=85261.940a46929c9c867a9e39.bundle.js.map