diff --git a/mindinsight/ui/src/views/train-manage/scalar.vue b/mindinsight/ui/src/views/train-manage/scalar.vue index 4e3a7b75a7294ad598f11ce1bcc8b4f7aa7a3da2..d05e67f7fd66cb4ea81a1779f4b7b2e3a63355f8 100644 --- a/mindinsight/ui/src/views/train-manage/scalar.vue +++ b/mindinsight/ui/src/views/train-manage/scalar.vue @@ -259,6 +259,7 @@ export default { curBenchX: 'stepData', // Front axle reference curAxisName: this.$t('scalar.step'), // Current chart tip axisBenchChangeTimer: null, // Horizontal axis reference switching timing + yAxisScaleTimer: null, // yAxis scale timer compare: false, // Comparison Page scalarCompare: this.$t('scalar')['comparison'], abort: false, // charts that have not been drawn. @@ -370,6 +371,10 @@ export default { clearTimeout(this.axisBenchChangeTimer); this.axisBenchChangeTimer = null; } + if (this.yAxisScaleTimer) { + clearTimeout(this.yAxisScaleTimer); + this.yAxisScaleTimer = null; + } }, mounted() { if (!this.$route.query || !this.$route.query.train_id) { @@ -576,6 +581,7 @@ export default { if (!res || !res.data || !res.data.metadatas) { if (sampleObject.charObj) { sampleObject.charObj.clear(); + sampleObject.onePoint = false; } return; } @@ -641,6 +647,15 @@ export default { sampleObject.charData.charOption = this.formateCharOption( sampleIndex, ); + const tempOption = sampleObject.charData.charOption; + if ( + tempOption.series[0].data.length === 1 || + sampleObject.onePoint + ) { + tempOption.series[0].showSymbol = true; + } else { + tempOption.series[0].showSymbol = false; + } this.$forceUpdate(); @@ -648,41 +663,9 @@ export default { if (sampleObject.charObj) { sampleObject.charObj.hideLoading(); } - // Draw chart if (!this.compare) { - this.updateOrCreateChar(sampleIndex); - - this.getCache(); - if ( - this.thresholdLocal && - this.thresholdLocal[this.decodeTrainingJobId] && - this.thresholdLocal[this.decodeTrainingJobId][ - sampleObject.tagName - ] - ) { - const tempStorgeArr = JSON.parse( - JSON.stringify( - this.thresholdLocal[this.decodeTrainingJobId][ - sampleObject.tagName - ], - ), - ); - let pieceStr = ''; - pieceStr = this.formatePieceStr(tempStorgeArr); - sampleObject.pieceStr = pieceStr; - - tempStorgeArr.forEach((item) => { - item.color = this.thresholdColor; - }); - - if (sampleObject.charObj) { - this.setVisualMap(sampleObject, tempStorgeArr); - } - } else { - sampleObject.pieceStr = ''; - sampleObject.charData.charOption.series[0].markLine = false; - } + this.updateOrCreateChar(sampleIndex, true); } else { this.abort = true; } @@ -696,6 +679,99 @@ export default { }); }, + /** + * set one point style + * @param {Object} sampleObject + */ + + setOnePoint(sampleObject) { + const that = this; + sampleObject.charObj.on('datazoom', function(params) { + const xAxisObject = params.batch[0]; + const yAxisObject = params.batch[1]; + const charData = sampleObject.charData.charOption.series[0].data; + const tempCharOption = sampleObject.charData.charOption; + // one point + if (charData.length === 1) { + sampleObject.onePoint = true; + tempCharOption.series[0].showSymbol = true; + sampleObject.charObj.setOption(tempCharOption, false); + return; + } + let filtetArr = []; + for (let i = 0; i < charData.length; i++) { + if ( + Math.ceil(charData[i][0] * 10000) / 10000 >= + xAxisObject.startValue && + Math.floor(charData[i][0] * 10000) / 10000 <= + xAxisObject.endValue && + Math.ceil(charData[i][1] * 10000) / 10000 >= + yAxisObject.startValue && + Math.floor(charData[i][1] * 10000) / 10000 <= yAxisObject.endValue + ) { + filtetArr.push(charData[i]); + if (filtetArr.length > 1) { + filtetArr = []; + break; + } + } + } + if (filtetArr.length === 1) { + sampleObject.onePoint = true; + tempCharOption.series[0].showSymbol = true; + } else { + sampleObject.onePoint = false; + tempCharOption.series[0].showSymbol = false; + } + + if ( + tempCharOption.visualMap && + tempCharOption.visualMap['pieces'] && + tempCharOption.visualMap['pieces'].length > 0 + ) { + tempCharOption.visualMap = null; + tempCharOption.series[0].markLine = null; + that.updateVisualMap(sampleObject); + } else { + sampleObject.charObj.setOption(tempCharOption, false); + } + }); + }, + + /** + * set restore + * @param {Object} sampleObject + */ + + setRestore(sampleObject) { + const that = this; + sampleObject.charObj.on('restore', function(params) { + const charData = sampleObject.charData.charOption.series[0].data; + const tempCharOption = sampleObject.charData.charOption; + + // one point + if (charData.length === 1) { + sampleObject.onePoint = true; + tempCharOption.series[0].showSymbol = true; + sampleObject.charObj.setOption(tempCharOption, false); + return; + } + sampleObject.onePoint = false; + tempCharOption.series[0].showSymbol = false; + if ( + tempCharOption.visualMap && + tempCharOption.visualMap['pieces'] && + tempCharOption.visualMap['pieces'].length > 0 + ) { + tempCharOption.visualMap = null; + tempCharOption.series[0].markLine = null; + that.updateVisualMap(sampleObject); + } else { + sampleObject.charObj.setOption(tempCharOption, false); + } + }); + }, + /** * Formatting Chart Data * @param {Number} sampleIndex Chart subscript @@ -822,7 +898,6 @@ export default { width: 2, }, }, - axisLabel: { color: '#9EA4B3', formatter(value) { @@ -968,7 +1043,8 @@ export default { strBody += `