UNPKG

graphdb-workbench

Version:
2 lines 7.8 kB
export const __webpack_esm_id__=6425;export const __webpack_esm_ids__=[6425,8642,86670];export const __webpack_esm_modules__={6425(e,t,r){var a=r(18301),o=r(8642),s=r(57154),i=r(86670);angular.module("graphdb.framework.resources.directives",[]).directive("chart",["$rootScope","$translate",function(e,t){return{restrict:"AE",scope:{chart:"="},link:function(r,l){let n;i.R.initThemes();const c=e.$on("$translateChangeSuccess",()=>{r.chart.translateLabels(),n.setOption(r.chart.chartOptions)});function d(){n.setOption(r.chart.chartOptions),r.chart.updateRange(r.chart.dataHolder),n.hideLoading()}function h(e){r.chart.setSelectedSeries(e.selected)}function u(){n.resize()}r.$watch("chart",function(){!function(){const e=(0,s.service)(s.ThemeService).isDarkModeApplied()?i.R.DARK_THEME:i.R.LIGHT_THEME,c=t.instant("common.loading");n=a.Ts(l[0],e,{renderer:"svg"}),n.setOption(r.chart.chartOptions),n.showLoading({text:c,maskColor:`color-mix(in srgb, ${o.h.cssVar("--gw-default-background")}, transparent 20%)`,textColor:o.h.cssVar("--gw-default-color")}),n.on("legendselectchanged",h),r.chart.registerRefreshHandler(d),r.chart.translateLabels(),window.addEventListener("resize",u)}()}),r.$on("$destroy",function(){n.on("legendselectchanged"),n.dispose(),r.chart.unregisterRefreshHandler(d),c(),window.removeEventListener("resize",u)})}}}])},8642(e,t,r){r.d(t,{h:()=>o});var a=r(18301);class o{static get DEFAULT_MULTIPLIER(){return 1.2}static get MAXIMUM_DIVISIONS(){return 10}static get COLORS(){return[o.cssVar("--gw-secondary-base"),o.cssVar("--gw-primary-base"),o.cssVar("--gw-tertiary-base"),o.cssVar("--gw-neutral-base")]}static get AREA_BAR_OPACITY(){return.5}static cssVar(e){return getComputedStyle(document.documentElement).getPropertyValue(e)}constructor(e,t,r,a){this.filter=a,this.disableRangeUpdate=t,this.disableOldDataRemoval=r,this.translateService=e,this.refreshHandlers=[],this.initialChartSetup()}registerRefreshHandler(e){this.refreshHandlers.push(e)}unregisterRefreshHandler(e){const t=this.refreshHandlers.indexOf(e);t>-1&&this.refreshHandlers.splice(t,1)}initialChartSetup(e=!0){this.range=150,this.chartOptions=this.getDefaultChartOptions(this.translateService),e&&(this.dataHolder=this.createDataHolder(),this.chartOptions.series=this.dataHolder,this.firstLoad=!0),this.chartSetup(this.chartOptions)}refresh(e=!1){e||(this.chartSetup(this.chartOptions),this.updateRange(this.dataHolder)),this.refreshHandlers.forEach(e=>e(this.chartOptions))}setSubTitle(e,t=0){this.chartOptions.title.show=!0;let r="";e.forEach((a,o)=>{if(Array.isArray(a.value)&&!a.value.length)return;const s=Array.isArray(a.value)?a.value.join("/"):a.value;r+=`{a|${a.label}}`,void 0!==s&&(r+=`{b|${s}}`),o+1<e.length&&(r+=t>0&&(o+1)%t===0?"\n":"{a| · }")}),this.chartOptions.title.text=r}chartSetup(e){}createDataHolder(){throw new Error("Must implement data holder creation")}addData(e,t){this.removeOldData(this.dataHolder,this.range),this.addNewData(this.dataHolder,e,t,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(e=>!0===e)}removeOldData(e,t){this.disableOldDataRemoval||e[0].data.length>t&&e.forEach(e=>e.data.shift())}addNewData(e,t,r,a){}setSelectedSeries(e){this.selectedSeries=e}updateRange(e,t){if(this.disableRangeUpdate)return;const[r]=o.calculateMaxChartValueAndDivisions(e,t,this.selectedSeries);this.chartOptions.yAxis.max=r}isFirstLoad(){return this.firstLoad}getDefaultChartOptions(){return{title:{show:!1,text:"",left:"center",textStyle:{overflow:"breakAll",rich:{a:{fontWeight:400,fontSize:14},b:{color:o.cssVar("--gw-secondary-base"),fontWeight:400,fontSize:14}}}},animation:!1,color:o.COLORS,legend:{right:"15%",top:"6%",textStyle:{overflow:"truncate"},icon:"circle"},tooltip:{trigger:"axis",axisPointer:{animation:!1,label:{formatter:function(e){return a.kB.format(e.value,"{HH}:{mm}:{ss}",!1)}}}},emphasis:{disabled:!0},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:o.cssVar("--gw-neutral-dark"),rich:{bold:{fontWeight:500}}}},yAxis:{type:"value",splitLine:{show:!0},axisLabel:{color:o.cssVar("--gw-neutral-dark")},axisTick:{lineStyle:{type:"solid"}}},textStyle:{fontFamily:o.cssVar("--main-font"),fontWeight:400},backgroundColor:o.cssVar("--gw-default-background")}}static getMaxValueFromDataHolder(e,t){const r=e.filter(e=>!t||angular.isUndefined(t[e.name])||!0===t[e.name]).map(e=>o.getMaxValueForDataSeries(e));return Math.max(1,...r)}static getMaxValueForDataSeries(e){return Math.max(...e.data.map(e=>e.value[1]))}static calculateMaxChartValueAndDivisions(e,t,r){let a;a=Array.isArray(e)?o.getMaxValueFromDataHolder(e,r):o.getMaxValueForDataSeries(e);const s=Math.ceil(a*(t||o.DEFAULT_MULTIPLIER))||1;return[s,Math.ceil(s/o.MAXIMUM_DIVISIONS)]}static getIntegerRangeForValues(e,t,r){const[a,s]=o.calculateMaxChartValueAndDivisions(e,t,r);return[a,s]}static formatBytesValue(e,t,r){let a=e;t&&(a=o.getMaxValueFromDataHolder(t,r));const s=Math.floor(Math.log(a)/Math.log(1024));return`${(parseFloat(e)/Math.pow(1024,s)).toFixed(2)} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][s]}`}formatNumber(e){if(!angular.isUndefined(e)&&this.filter)return this.filter("currency")(e,"",0)}}},86670(e,t,r){r.d(t,{R:()=>s});var a=r(18301),o=r(8642);class s{static LIGHT_THEME="gwLight";static DARK_THEME="gwDark";static initThemes(){const e=s.getGwDarkTheme(),t=s.getGwLightTheme();a.bf(s.DARK_THEME,e),a.bf(s.LIGHT_THEME,t)}static getGwLightTheme(){return{tooltip:{backgroundColor:`color-mix(in srgb, ${o.h.cssVar("--gw-tooltip-background")}, transparent 10%)`,textStyle:{color:o.h.cssVar("--gw-tooltip-color")},borderWidth:0}}}static getGwDarkTheme(){return{...s.getEchartsDarkTheme(),tooltip:{backgroundColor:`color-mix(in srgb, ${o.h.cssVar("--gw-tooltip-background")}, transparent 10%)`,textStyle:{color:o.h.cssVar("--gw-tooltip-color")},borderWidth:0}}}static getEchartsDarkTheme(){const e="#B9B8CE",t="#100C2A",r=function(){return{axisLine:{lineStyle:{color:e}},splitLine:{lineStyle:{color:"#484753"}},splitArea:{areaStyle:{color:["rgba(255,255,255,0.02)","rgba(255,255,255,0.05)"]}},minorSplitLine:{lineStyle:{color:"#20203B"}}}},a=["#4992ff","#7cffb2","#fddd60","#ff6e76","#58d9f9","#05c091","#ff8a45","#8d48e3","#dd79ff"],o={darkMode:!0,color:a,backgroundColor:t,axisPointer:{lineStyle:{color:"#817f91"},crossStyle:{color:"#817f91"},label:{color:"#fff"}},legend:{textStyle:{color:e}},textStyle:{color:e},title:{textStyle:{color:"#EEF1FA"},subtextStyle:{color:"#B9B8CE"}},toolbox:{iconStyle:{borderColor:e}},dataZoom:{borderColor:"#71708A",textStyle:{color:e},brushStyle:{color:"rgba(135,163,206,0.3)"},handleStyle:{color:"#353450",borderColor:"#C5CBE3"},moveHandleStyle:{color:"#B0B6C3",opacity:.3},fillerColor:"rgba(135,163,206,0.2)",emphasis:{handleStyle:{borderColor:"#91B7F2",color:"#4D587D"},moveHandleStyle:{color:"#636D9A",opacity:.7}},dataBackground:{lineStyle:{color:"#71708A",width:1},areaStyle:{color:"#71708A"}},selectedDataBackground:{lineStyle:{color:"#87A3CE"},areaStyle:{color:"#87A3CE"}}},visualMap:{textStyle:{color:e}},timeline:{lineStyle:{color:e},label:{color:e},controlStyle:{color:e,borderColor:e}},calendar:{itemStyle:{color:t},dayLabel:{color:e},monthLabel:{color:e},yearLabel:{color:e}},timeAxis:r(),logAxis:r(),valueAxis:r(),categoryAxis:r(),line:{symbol:"circle"},graph:{color:a},gauge:{title:{color:e}},candlestick:{itemStyle:{color:"#FD1050",color0:"#0CF49B",borderColor:"#FD1050",borderColor0:"#0CF49B"}}};return o.categoryAxis.splitLine.show=!1,o}}}}; //# sourceMappingURL=6425.28a4c321c134ab15e73f.bundle.js.map