From 31de467c646df43fb1fd78efca43d0969a263264 Mon Sep 17 00:00:00 2001 From: wwx691809 Date: Tue, 1 Dec 2020 17:38:21 +0800 Subject: [PATCH] Optimized switching pair logic --- mindinsight/ui/src/locales/en-us.json | 3 +- mindinsight/ui/src/locales/zh-cn.json | 3 +- .../ui/src/views/train-manage/scalar.vue | 47 ++++++++++++++----- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/mindinsight/ui/src/locales/en-us.json b/mindinsight/ui/src/locales/en-us.json index ed5c32f4..0235ad03 100644 --- a/mindinsight/ui/src/locales/en-us.json +++ b/mindinsight/ui/src/locales/en-us.json @@ -185,7 +185,8 @@ "sameCompare": "The comparison operator must be unique.", "unreasonable": "The logic is improper.", "info": "Information", - "isDelete": "Are you sure you want to delete the current threshold?" + "isDelete": "Are you sure you want to delete the current threshold?", + "noLog":"There is no logarithm of 0 and negative numbers" }, "images": { "titleText": "Image", diff --git a/mindinsight/ui/src/locales/zh-cn.json b/mindinsight/ui/src/locales/zh-cn.json index 15ea9b52..f47b589c 100644 --- a/mindinsight/ui/src/locales/zh-cn.json +++ b/mindinsight/ui/src/locales/zh-cn.json @@ -184,7 +184,8 @@ "sameCompare": "不能有相同的比较运算符", "unreasonable": "逻辑不合理", "info": "提示", - "isDelete": "是否删除当前阈值" + "isDelete": "是否删除当前阈值?", + "noLog":"不存在0和负数的对数" }, "images": { "titleText": "图像", diff --git a/mindinsight/ui/src/views/train-manage/scalar.vue b/mindinsight/ui/src/views/train-manage/scalar.vue index e17e1d29..89ea470e 100644 --- a/mindinsight/ui/src/views/train-manage/scalar.vue +++ b/mindinsight/ui/src/views/train-manage/scalar.vue @@ -343,20 +343,22 @@ export default { )}-${this.$t('scalar.titleText')}-MindInsight`; // Adding a Listener window.addEventListener('resize', this.resizeCallback, false); + // Dom ready + this.$nextTick(() => { + // Initializing Data + this.getScalarsList(); - // Initializing Data - this.getScalarsList(); + this.firstNum = 1; - this.firstNum = 1; + this.decodeTrainingJobId = decodeURIComponent(this.trainingJobId); - this.decodeTrainingJobId = decodeURIComponent(this.trainingJobId); + this.getCache(); - this.getCache(); - - // Auto refresh - if (this.isTimeReload) { - this.autoUpdateSamples(); - } + // Auto refresh + if (this.isTimeReload) { + this.autoUpdateSamples(); + } + }); }, methods: { /** @@ -528,11 +530,16 @@ export default { if (resData.metadatas.length) { relativeTimeBench = resData.metadatas[0].wall_time; } + + const mathData = []; // Initializing chart data resData.metadatas.forEach((metaData) => { if (metaData.value === null && !hasInvalidData) { hasInvalidData = true; } + if (!isNaN(metaData.value) && metaData.value !== null) { + mathData.push(metaData.value); + } tempObject.valueData.stepData.push([ metaData.step, metaData.value, @@ -556,6 +563,16 @@ export default { ]); }); + // Numerical range + const maxData = Math.max(...mathData); + const minData = Math.min(...mathData); + sampleObject.max = maxData; + if (maxData === minData) { + sampleObject.isEqual = true; + } else { + sampleObject.isEqual = false; + } + sampleObject.charData.oriData[0] = tempObject; if (hasInvalidData) { @@ -715,7 +732,9 @@ export default { yAxis: { type: sampleObject.log ? 'log' : 'value', scale: true, - logBase: 10, + // Logbase for very small values,default 10 + logBase: sampleObject.max < 1 && sampleObject.isEqual ? 0.1 : 10, + inverse: sampleObject.max < 1 && sampleObject.isEqual ? true : false, axisLine: { lineStyle: { color: '#E6EBF5', @@ -921,7 +940,7 @@ export default { }, myTool2: { show: true, - title: this.$t('scalar.toggleYaxisScale'), + title: sampleObject.max<=0 ? this.$t('scalar.noLog') : this.$t('scalar.toggleYaxisScale'), iconStyle: { borderColor: sampleObject.log ? '#00A5A7' : '#6D7278', }, @@ -1527,6 +1546,10 @@ export default { if (!sampleObject) { return; } + // There is no logarithm of 0 and negative numbers + if (sampleObject.max<=0) { + return; + } this.yAxisScaleTimer = setTimeout(() => { const tempOption = sampleObject.charData.charOption; const tempOriData = sampleObject.charData.oriData;