diff --git a/nezha-fronted/src/components/common/language/en.js b/nezha-fronted/src/components/common/language/en.js index cc6cecc26..f2bdda2df 100644 --- a/nezha-fronted/src/components/common/language/en.js +++ b/nezha-fronted/src/components/common/language/en.js @@ -185,10 +185,11 @@ const en = { asset:{ title:'Asset', assetType:'Asset Type', - modelStat:'Model Stat', - dcStat:'DataCenter Stat', + modelStat:'Model', + dcStat:'DataCenter', num:'Num', alert:'Alert', + alertTotal:'Total', alertLow:'Low', alertMedium:'Medium', alertHigh:'High', @@ -221,8 +222,11 @@ const en = { alertNum:'Alert Num', alertRuleTopN:'According to Alert Rule', assetTopN:'According to Asset', - top:'Top' - } + top:'Top', + chart:{ + chartTitle:'Alert Trend' + } + }, } }, validate: { //校验规则 diff --git a/nezha-fronted/src/components/common/login.vue b/nezha-fronted/src/components/common/login.vue index 3262727d7..38429114e 100644 --- a/nezha-fronted/src/components/common/login.vue +++ b/nezha-fronted/src/components/common/login.vue @@ -57,7 +57,7 @@ export default { this.$i18n.locale = this.lang; bus.$emit('login'); this.$router.push({ - path: "/panel", + path: "/overview", query: { t: +new Date() } diff --git a/nezha-fronted/src/components/page/dashboard/overview/chart.vue b/nezha-fronted/src/components/page/dashboard/overview/chart.vue index 0efbae7ec..d88df07e9 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chart.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chart.vue @@ -1,16 +1,12 @@ @@ -18,26 +14,129 @@ import echarts from 'echarts'; import chartDataFormat from "../../../charts/chartDataFormat"; import loading from "../../../common/loading"; + import uuidv1 from "uuid/v1"; import chartConfig from './chartConfig' export default { name: "chart", - props:[], + components:{ + 'loading':loading, + }, + props:{ + chartTitle:{type:String} + }, data(){ return { - option:chartConfig.getCommonOption + chart:null, + option:{}, + chartId:new uuidv1()+'-'+new Date().getTime(), } }, created() { + chartConfig.setSeries(this.series); + chartConfig.setTooltipFormatter(this.tooltipFormatter); + chartConfig.setTooltipPostion(this.tooltipPosition); + chartConfig.setYAxisLabelFormatter(this.yAxisFormatter); + this.option=chartConfig.getCommonOption(); }, methods:{ + tooltipPosition:function(point,params,dom,rect,size){ + dom.style.transform = "translateZ(0)"; + //提示框位置 + var x=0; + var y=0; + //当前鼠标位置 + var pointX = point[0]; + var pointY = point[1]; + //外层div大小 + var viewWidth = size.viewSize[0]; + var viewHeight = size.viewSize[1]; + //提示框大小 + var boxWidth = size.contentSize[0]; + var boxHeight = size.contentSize[1]; + let chartDom = document.getElementById(this.chartId); + if(chartDom){ + let parTop = chartDom.offsetTop; + let parLeft = chartDom.offsetLeft; + let parent = chartDom.parentElement; + let parClientHeight = parent.clientHeight;//可视高度 + let parClientWidth = parent.clientWidth;//可视宽度 + let parScrollTop = parent.scrollTop; + if((parClientWidth-pointX-parLeft-20)>=boxWidth){//说明鼠标在左边放不下提示框 + x=pointX+10; + }else{ + x = pointX - boxWidth; + } + if((parClientHeight-pointY-(parTop-parScrollTop)-20)>=boxHeight){//说明鼠标上面放不下提示框 + y = pointY+10; + }else { + y = pointY-boxHeight; + } + return [x,y]; + }else { + x = pointX - boxWidth; + y = pointY+10; + return [x,y]; + } + }, + tooltipFormatter:function(params){ + let str = `
`; + params.forEach((item, i) => { + if(i===0){ + let t_date = new Date(item.data[0]); + str += [t_date.getFullYear(), t_date.getMonth() + 1, t_date.getDate()].join('-') + " " + + [t_date.getHours(), t_date.getMinutes(),t_date.getSeconds()].join(':'); + str +=`
`; + } + let val = Number(item.data[1]); + str += `
`; + str += `
${item.seriesName}:
`; + str += `
`; + str += chartDataFormat.getUnit(5).compute(val,null,2); + str += `
`; + str += `
`; + }); + str +=`
`; + return str; + }, + yAxisFormatter:function(value,index){ + let unit=chartDataFormat.getUnit(5); + return unit.compute(value,index); + }, + setSeries:function(series){ + this.option.series=series; + if(!this.chart){ + this.chart=echarts.init(document.getElementById(this.chartId)); + } + this.chart.clear(); + this.chart.setOption(this.option) + }, + startLoading:function(){ + this.$refs.loading.startLoading(); + }, + endLoading:function(){ + this.$refs.loading.endLoading(); + } + }, + mounted() { + this.chart=echarts.init(document.getElementById(this.chartId)); + this.chart.setOption(this.option); }, watch:{ + }, + destroyed() { + if(this.chart){ + this.chart.clear(); + } } } diff --git a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue index 276511270..0ca93bfe4 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/chartConfig.vue @@ -5,6 +5,9 @@ show:false, }, color: this.bgColorList, + legend:{ + show:false, + }, tooltip: { trigger: 'axis', confine:false, diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview.scss b/nezha-fronted/src/components/page/dashboard/overview/overview.scss index 25b68c05b..11f1abaf1 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview.scss +++ b/nezha-fronted/src/components/page/dashboard/overview/overview.scss @@ -1,7 +1,6 @@ .overview{ height: 100%; } - .overview-content-header{ display: flex; padding-top: 10px; @@ -51,6 +50,14 @@ .operation .nz-icon-maxview{ font-size: 1.875rem !important; } +.overview-right{ + //margin: 0; + //padding: 0; + //position: absolute; + //width: 100%; + //height: 100%; + //left:0; right:0; top:0; bottom:0; +} .overview-content{ height: calc(100% - 45px); width: 100%; @@ -79,8 +86,8 @@ .box-height-250{ height: 250px; } -.box-height-300{ - height: 300px; +.box-height-290{ + height: 290px; } .box-height-350{ height: 350px; @@ -112,3 +119,7 @@ align-items: center; justify-content: space-between; } +.sub-title{ + display: inline-block; + padding: 5px; +} diff --git a/nezha-fronted/src/components/page/dashboard/overview/overview.vue b/nezha-fronted/src/components/page/dashboard/overview/overview.vue index b095c0209..b36e9595b 100644 --- a/nezha-fronted/src/components/page/dashboard/overview/overview.vue +++ b/nezha-fronted/src/components/page/dashboard/overview/overview.vue @@ -10,7 +10,7 @@ -
+
{{$t('dashboard.overview.contentTitle')}}
@@ -21,7 +21,7 @@
{{sysWeek}}
{{sysDate}}
-
+
@@ -44,26 +44,41 @@
- +
-
-
- +
+
+ + + {{topNFilter.options.find((item)=>{return item.value==topNFilter.default})['label']}} + + {{item.label}} + + + + + {{topNFilter.tops.find((item)=>{return item.value==topNFilter.defaultTop})['label']}} + + {{item.label}} + +
-
-
+
+ +
+
@@ -75,11 +90,13 @@