diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index bd86aabab..0d11ac647 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -145,6 +145,7 @@ import draggable from 'vuedraggable' export default { name: 'chartList', props: { + isModel: {type: Boolean, default: false} }, components: { lineChartBlock, @@ -873,13 +874,17 @@ export default { if (response.data.result) { // 循环处理每个elements下获取的数据列 if(chartItem.type==='singleStat'){ - if(response.data.result.length===1){ - let statistics = chartItem.param.statistics; - if(response.data.result[0].values){ - singleStatRlt = bus.getSingleStatRlt(statistics,response.data.result[0].values); + if (this.isModel) { + singleStatRlt = 999; + } else { + if(response.data.result.length===1){ + let statistics = chartItem.param.statistics; + if(response.data.result[0].values){ + singleStatRlt = bus.getSingleStatRlt(statistics,response.data.result[0].values); + } + }else if(response.data.result.length > 1){ + singleStatRlt = this.$t("dashboard.panel.singleStatErrorTip"); } - }else if(response.data.result.length > 1){ - singleStatRlt = this.$t("dashboard.panel.singleStatErrorTip"); } }else { response.data.result.forEach((queryItem,resIndex) => { @@ -910,7 +915,21 @@ export default { } const tagsArr = Object.keys(queryItem.metric);//["__name__","asset","idc","instance","job","module","project"] // 设置时间-数据格式对 - const dpsArr = Object.entries(queryItem.values);//[ ["0",[1577959830.781,"0"]], ["1",[1577959845.781,"0"]] ] + let tempArr = []; + let dpsArr = []; + if (this.isModel) { + let timeStamp = Math.floor(new Date().getTime()/1000); + for (let i = 0; i < 20; i++) { + tempArr.push([timeStamp - (20-i)*15, Math.floor(Math.random()*10) + ""]); + dpsArr.push([i+"", tempArr[i]]); + } + } else { + tempArr = queryItem.values; + dpsArr = Object.entries(queryItem.values);//[ ["0",[1577959830.781,"0"]], ["1",[1577959845.781,"0"]] ] + dpsArr = dpsArr.map(item => { + return [item[0], [item[1][0], Number(item[1][1])]] + }) + } // 判断是否有数据, && tagsArr.length > 0 if (dpsArr.length > 0 && this.$refs['editChart'+chartItem.id] && this.$refs['editChart'+chartItem.id].length>0) { tagsArr.forEach((tag, i) => { @@ -937,7 +956,7 @@ export default { seriesItem.metric_name = seriesItem.theData.name; // 将秒改为毫秒 //alert('table=='+JSON.stringify(queryItem)) - seriesItem.theData.data = queryItem.values.map((dpsItem, dpsIndex) => { + seriesItem.theData.data = tempArr.map((dpsItem, dpsIndex) => { /*曲线汇总暂不需要 if (sumData.data[dpsIndex]) { const sumNum = sumData.data[dpsIndex][1] || 0; diff --git a/nezha-fronted/src/components/charts/chartDataFormat.js b/nezha-fronted/src/components/charts/chartDataFormat.js index d6305545f..2c48b967a 100644 --- a/nezha-fronted/src/components/charts/chartDataFormat.js +++ b/nezha-fronted/src/components/charts/chartDataFormat.js @@ -255,14 +255,19 @@ function days(value,index,type=1){ * unitIndex:不需要传递,用于递归获取units中的单位 * */ function asciiCompute(num,ascii,units,dot=2,unitIndex=0){ - num = parseFloat(num) + console.info(parseFloat(0.6.toFixed(2))) let quotient=num / ascii; + console.info("aa", parseFloat(0.6.toFixed(0)), parseFloat(0.6.toFixed(1))); + console.info("quotient", quotient); if(unitIndex <= units.length-1){ if(quotient <1 ){ //不足以进位 let toFixed=parseFloat(num.toFixed(dot)); + console.info("toFixed", num, dot, toFixed); if(toFixed == 0){ + console.info("toFixed-r1", `${num} ${units[unitIndex]}`); return `${num} ${units[unitIndex]}` }else{ + console.info("toFixed-r2", `${num.toFixed(dot)} ${units[unitIndex]}`); return `${num.toFixed(dot)} ${units[unitIndex]}`; } }else if(quotient >= 1 && quotient <10){ //可以进位,但是又不足以更进一位 diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index aca7c4316..ba57411c5 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -898,7 +898,8 @@ let chartUnit=chartInfo.unit; chartUnit=chartUnit?chartUnit:2; let unit=chartDataFormat.getUnit(chartUnit); - return unit.compute(value,index); + //console.info(value, chartUnit, unit.compute(value,index)) + return unit.compute(value,index,2); }, }, //boundaryGap:[0,0.2] diff --git a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue index 8f75d6e4b..baaeeb685 100644 --- a/nezha-fronted/src/components/common/bottomBox/bottomBox.vue +++ b/nezha-fronted/src/components/common/bottomBox/bottomBox.vue @@ -103,7 +103,7 @@ if (this.from == 'endpoint' && this.targetTab == 'endpointQuery') { this.$refs.endpointQuery.tableReload(); } - if (this.from == 'model') { + if (this.targetTab == 'panel') { setTimeout(() => {this.$refs.panelTab.$refs.dashboardScrollbar.update();}, 400); } } diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue index b6ebb9702..82af4f985 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/endpointTab.vue @@ -55,13 +55,7 @@ - {{scope.row.module.type}} -
+