diff --git a/mindinsight/ui/src/views/train-manage/compare-plate.vue b/mindinsight/ui/src/views/train-manage/compare-plate.vue index 3bcf8ef6c749d99b61d80f5f36580a7c1cbe048f..22f7a2e129298e1a314dc2c3c910b2713f30de17 100644 --- a/mindinsight/ui/src/views/train-manage/compare-plate.vue +++ b/mindinsight/ui/src/views/train-manage/compare-plate.vue @@ -292,116 +292,116 @@ export default { params.limit = 999; RequestService.querySummaryList(params) - .then((res) => { + .then((res) => { // error; - if ( - !res || + if ( + !res || !res.data || !res.data.train_jobs || !res.data.train_jobs.length - ) { - this.initOver = true; - return; - } - const tempSummaryList = []; - const tempTagList = []; - const dataList = []; - const data = res.data.train_jobs; - data.forEach((summaryObj, summaryIndex) => { - const colorIndex = this.curAvlColorIndexArr.length + ) { + this.initOver = true; + return; + } + const tempSummaryList = []; + const tempTagList = []; + const dataList = []; + const data = res.data.train_jobs; + data.forEach((summaryObj, summaryIndex) => { + const colorIndex = this.curAvlColorIndexArr.length ? this.curAvlColorIndexArr.shift() : this.defColorCount - 1; - const summaryNmeColor = CommonProperty.commonColorArr[colorIndex]; - - tempSummaryList.push({ - label: summaryObj.train_id, - checked: true, - show: true, - color: summaryNmeColor, - colorIndex: colorIndex, - }); + const summaryNmeColor = CommonProperty.commonColorArr[colorIndex]; - if (summaryObj.cache_status === this.cacheStatus) { - tempSummaryList.forEach((item) => { - if (item.label === summaryObj.train_id) { - item.loading = true; - } - }); - } + tempSummaryList.push({ + label: summaryObj.train_id, + checked: true, + show: true, + color: summaryNmeColor, + colorIndex: colorIndex, + }); - summaryObj.plugins.scalar.forEach((tagObj) => { + if (summaryObj.cache_status === this.cacheStatus) { + tempSummaryList.forEach((item) => { + if (item.label === summaryObj.train_id) { + item.loading = true; + } + }); + } + + summaryObj.plugins.scalar.forEach((tagObj) => { // tag with the same name exists - let sameTagIndex = -1; - dataList.some((tagItem, curIndex) => { - if (tagItem.tagName === tagObj) { - sameTagIndex = curIndex; - return true; - } - }); + let sameTagIndex = -1; + dataList.some((tagItem, curIndex) => { + if (tagItem.tagName === tagObj) { + sameTagIndex = curIndex; + return true; + } + }); - if (!this.oriDataDictionaries[tagObj]) { + if (!this.oriDataDictionaries[tagObj]) { // Add the tag list - this.oriDataDictionaries[tagObj] = true; - tempTagList.push({ - label: tagObj, - checked: true, - show: true, - }); + this.oriDataDictionaries[tagObj] = true; + tempTagList.push({ + label: tagObj, + checked: true, + show: true, + }); - const sampleIndex = dataList.length; - - // Adding Chart Data - dataList.push({ - tagName: tagObj, - summaryNames: [summaryObj.train_id], - colors: [summaryNmeColor], - show: false, - updateFlag: false, - dataRemove: false, - fullScreen: false, - sampleIndex: sampleIndex, - domId: 'prDom' + this.DomIdIndex, - charData: { - oriData: [], - charOption: {}, - }, - zoomData: [null, null], - zoomDataTimer: null, - charObj: null, - }); + const sampleIndex = dataList.length; + + // Adding Chart Data + dataList.push({ + tagName: tagObj, + summaryNames: [summaryObj.train_id], + colors: [summaryNmeColor], + show: false, + updateFlag: false, + dataRemove: false, + fullScreen: false, + sampleIndex: sampleIndex, + domId: 'prDom' + this.DomIdIndex, + charData: { + oriData: [], + charOption: {}, + }, + zoomData: [null, null], + zoomDataTimer: null, + charObj: null, + }); - this.DomIdIndex++; - } else { - const sameTagObj = dataList[sameTagIndex]; - sameTagObj.summaryNames.push(summaryObj.train_id); - sameTagObj.colors.push(summaryNmeColor); - } - }); + this.DomIdIndex++; + } else { + const sameTagObj = dataList[sameTagIndex]; + sameTagObj.summaryNames.push(summaryObj.train_id); + sameTagObj.colors.push(summaryNmeColor); + } }); - this.summaryOperateList = tempSummaryList; + }); + this.summaryOperateList = tempSummaryList; - this.tagOperateList = tempTagList; - if (dataList.length === 1) { - dataList[0].fullScreen = true; + this.tagOperateList = tempTagList; + if (dataList.length === 1) { + dataList[0].fullScreen = true; + } + this.originDataArr = dataList; + this.initOver = true; + + this.$nextTick(() => { + this.multiSelectedTagNames = this.$refs.tagsGroup.updateSelectedDic(); + this.multiSelectedSummaryNames = this.$refs.summaryGroup.updateSelectedDic(); + this.updateTagInPage(); + this.resizeCallback(); + if (Object.keys(this.multiSelectedSummaryNames).length > 0) { + this.trainJobsCaches(); } - this.originDataArr = dataList; - this.initOver = true; - - this.$nextTick(() => { - this.multiSelectedTagNames = this.$refs.tagsGroup.updateSelectedDic(); - this.multiSelectedSummaryNames = this.$refs.summaryGroup.updateSelectedDic(); - this.updateTagInPage(); - this.resizeCallback(); - if (Object.keys(this.multiSelectedSummaryNames).length > 0) { - this.trainJobsCaches(); - } - }); - }, this.requestErrorCallback) - .catch((e) => { - this.initOver = true; - this.$message.error(this.$t('public.dataError')); }); + }, this.requestErrorCallback) + .catch((e) => { + this.initOver = true; + this.$message.error(this.$t('public.dataError')); + }); }, trainJobsCaches() { @@ -468,81 +468,81 @@ export default { } RequestService.getSummarySample(params) - .then((res) => { - if (sampleObject.charObj) { - sampleObject.charObj.showLoading(); - } - let scalarIndex = 0; - let hasInvalidData = false; - if (!res || !res.data || !res.data.scalars) { - return; + .then((res) => { + if (sampleObject.charObj) { + sampleObject.charObj.showLoading(); + } + let scalarIndex = 0; + let hasInvalidData = false; + if (!res || !res.data || !res.data.scalars) { + return; + } + const resData = res.data.scalars; + resData.forEach((scalarItem) => { + const tempObject = { + valueData: { + stepData: [], + absData: [], + relativeData: [], + }, + logData: { + stepData: [], + absData: [], + relativeData: [], + }, + }; + let relativeTimeBench = 0; + if (scalarItem.values.length) { + relativeTimeBench = scalarItem.values[0].wall_time; } - const resData = res.data.scalars; - resData.forEach((scalarItem) => { - const tempObject = { - valueData: { - stepData: [], - absData: [], - relativeData: [], - }, - logData: { - stepData: [], - absData: [], - relativeData: [], - }, - }; - let relativeTimeBench = 0; - if (scalarItem.values.length) { - relativeTimeBench = scalarItem.values[0].wall_time; + // Initializing Chart Data + scalarItem.values.forEach((metaData) => { + if (metaData.value === null && !hasInvalidData) { + hasInvalidData = true; } - // Initializing Chart Data - scalarItem.values.forEach((metaData) => { - if (metaData.value === null && !hasInvalidData) { - hasInvalidData = true; - } - tempObject.valueData.stepData.push([ - metaData.step, - metaData.value, - ]); - tempObject.valueData.absData.push([ - metaData.wall_time, - metaData.value, - ]); - tempObject.valueData.relativeData.push([ - metaData.wall_time - relativeTimeBench, - metaData.value, - ]); - const logValue = metaData.value >= 0 ? metaData.value : ''; - tempObject.logData.stepData.push([metaData.step, logValue]); - tempObject.logData.absData.push([metaData.wall_time, logValue]); - tempObject.logData.relativeData.push([ - metaData.wall_time - relativeTimeBench, - logValue, - ]); - }); - - sampleObject.charData.oriData[scalarIndex] = tempObject; - scalarIndex++; + tempObject.valueData.stepData.push([ + metaData.step, + metaData.value, + ]); + tempObject.valueData.absData.push([ + metaData.wall_time, + metaData.value, + ]); + tempObject.valueData.relativeData.push([ + metaData.wall_time - relativeTimeBench, + metaData.value, + ]); + const logValue = metaData.value >= 0 ? metaData.value : ''; + tempObject.logData.stepData.push([metaData.step, logValue]); + tempObject.logData.absData.push([metaData.wall_time, logValue]); + tempObject.logData.relativeData.push([ + metaData.wall_time - relativeTimeBench, + logValue, + ]); }); - if (hasInvalidData) { - this.$set(this.originDataArr[sampleIndex], 'invalidData', true); - } - sampleObject.charData.charOption = this.formateCharOption( - sampleIndex, - ); + sampleObject.charData.oriData[scalarIndex] = tempObject; + scalarIndex++; + }); - this.$nextTick(() => { - if (sampleObject.charObj) { - sampleObject.charObj.hideLoading(); - } + if (hasInvalidData) { + this.$set(this.originDataArr[sampleIndex], 'invalidData', true); + } + sampleObject.charData.charOption = this.formateCharOption( + sampleIndex + ); - // Draw chart - this.updateOrCreateChar(sampleIndex); - }); - }) - .catch((error) => {}); + this.$nextTick(() => { + if (sampleObject.charObj) { + sampleObject.charObj.hideLoading(); + } + + // Draw chart + this.updateOrCreateChar(sampleIndex); + }); + }) + .catch((error) => {}); }); }, @@ -591,12 +591,12 @@ export default { if (curOriData) { if (sampleObject.log) { dataObj.data = this.formateSmoothData( - curOriData.logData[this.curBenchX], + curOriData.logData[this.curBenchX] ); dataObjBackend.data = curOriData.logData[this.curBenchX]; } else { dataObj.data = this.formateSmoothData( - curOriData.valueData[this.curBenchX], + curOriData.valueData[this.curBenchX] ); dataObjBackend.data = curOriData.valueData[this.curBenchX]; } @@ -738,23 +738,23 @@ export default { position: (point, params, dom, rect, size) => { const curDom = document.getElementById(sampleObject.domId); if (!curDom) { - return {left: 0, bottom: '100%'}; + return { left: 0, bottom: '100%' }; } if (sampleObject.fullScreen) { if (point[0] + size.contentSize[0] <= size.viewSize[0]) { - return {left: point[0], bottom: '10%'}; + return { left: point[0], bottom: '10%' }; } else { - return {right: size.viewSize[0] - point[0], bottom: '10%'}; + return { right: size.viewSize[0] - point[0], bottom: '10%' }; } } else { const parentNode = curDom.parentNode; if (!parentNode) { - return {left: 0, bottom: '100%'}; + return { left: 0, bottom: '100%' }; } if (parentNode.offsetLeft > size.contentSize[0]) { - return {right: '100%', bottom: 0}; + return { right: '100%', bottom: 0 }; } else { - return {left: '100%', bottom: 0}; + return { left: '100%', bottom: 0 }; } } }, @@ -833,16 +833,16 @@ export default { `display:inline-block;">