From 1647882a3b955bf4f65c4dd5525daa7eb899e7c9 Mon Sep 17 00:00:00 2001 From: WeiFeng-mindinsight Date: Fri, 10 Jul 2020 13:58:08 +0800 Subject: [PATCH] UI fix step trace bug that text covers others --- .../ui/src/components/autocomplete.vue | 1 - .../train-manage/profiling-dashboard.vue | 17 ++++++++++---- .../ui/src/views/train-manage/step-trace.vue | 23 ++++++++++++------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/mindinsight/ui/src/components/autocomplete.vue b/mindinsight/ui/src/components/autocomplete.vue index 3a8fb53..e1ad6ae 100644 --- a/mindinsight/ui/src/components/autocomplete.vue +++ b/mindinsight/ui/src/components/autocomplete.vue @@ -22,7 +22,6 @@ limitations under the License. :aria-expanded="suggestionVisible" :aria-owns="id"> { if (i.duration) { if (i.name) { + if (i.duration < minTime) { + textOffsets++; + } else { + textOffsets = 0; + } + i.textOffsets = textOffsets; + const tempDom = this.createRect(i, index); const tempStr = `g${ i.duration > minTime ? '' : '.arrow' @@ -732,7 +740,6 @@ export default { const height = 40; const width = (data.duration / this.svg.totalTime) * this.svg.totalWidth; const fontSize = 12; - const normalRect = data.duration > this.svg.minRate * this.svg.totalTime; const x1 = (data.start / this.svg.totalTime) * this.svg.totalWidth + @@ -775,7 +782,7 @@ export default { foreignObject.setAttribute( 'x', - normalRect + !data.textOffsets ? x1 : Math.min( this.svg.svgPadding * 2 + this.svg.totalWidth - textWidth, @@ -785,14 +792,14 @@ export default { foreignObject.setAttribute( 'y', - y1 + (height - fontSize) / 2 + (normalRect ? 0 : fontSize), + y1 + (height - fontSize) / 2 + data.textOffsets * fontSize, ); foreignObject.setAttribute('height', fontSize); foreignObject.setAttribute('width', width); foreignObject.setAttribute('style', `color:${color[0]}`); foreignObject.setAttribute( 'class', - `content${normalRect ? '' : ' content-mini'}`, + `content${!data.textOffsets ? '' : ' content-mini'}`, ); const title = document.createElementNS(this.svg.namespaceURI, 'title'); diff --git a/mindinsight/ui/src/views/train-manage/step-trace.vue b/mindinsight/ui/src/views/train-manage/step-trace.vue index 9c67f6d..1a96738 100644 --- a/mindinsight/ui/src/views/train-manage/step-trace.vue +++ b/mindinsight/ui/src/views/train-manage/step-trace.vue @@ -164,7 +164,7 @@ export default { totalTime: 0, rowHeight: 60, markerPadding: 4, - minRate: 0.05, + minRate: 0.01, namespaceURI: 'http://www.w3.org/2000/svg', resizeTimer: null, colorList: [ @@ -483,9 +483,17 @@ export default { const dashedLine = this.addDashedLine(index); svg.insertBefore(dashedLine, svg.querySelector('g')); + let textOffsets = 0; row.forEach((i) => { if (i.duration) { if (i.name) { + if (i.duration < minTime) { + textOffsets++; + } else { + textOffsets = 0; + } + i.textOffsets = textOffsets; + const tempDom = this.createRect(i, index); const tempStr = `g${ i.duration > minTime ? '' : '.arrow' @@ -528,7 +536,6 @@ export default { const height = 40; const width = (data.duration / this.svg.totalTime) * this.svg.totalWidth; const fontSize = 12; - const normalRect = data.duration > this.svg.minRate * this.svg.totalTime; const x1 = (data.start / this.svg.totalTime) * this.svg.totalWidth + @@ -571,7 +578,7 @@ export default { foreignObject.setAttribute( 'x', - normalRect + !data.textOffsets ? x1 : Math.min( this.svg.svgPadding * 2 + this.svg.totalWidth - textWidth, @@ -581,14 +588,14 @@ export default { foreignObject.setAttribute( 'y', - y1 + (height - fontSize) / 2 + (normalRect ? 0 : fontSize), + y1 + (height - fontSize) / 2 + data.textOffsets * fontSize, ); foreignObject.setAttribute('height', fontSize); foreignObject.setAttribute('width', width); foreignObject.setAttribute('style', `color:${color[0]}`); foreignObject.setAttribute( 'class', - `content${normalRect ? '' : ' content-mini'}`, + `content${!data.textOffsets ? '' : ' content-mini'}`, ); const title = document.createElementNS(this.svg.namespaceURI, 'title'); @@ -747,8 +754,8 @@ export default { } } .step-message { - height: 24px; - line-height: 24px; + height: 32px; + line-height: 16px; margin-top: 6px; margin-left: 14px; overflow-y: auto; @@ -765,7 +772,7 @@ export default { font-weight: bold; } .pf-content-middle { - padding: 15px 15px 0; + padding: 10px 15px 0; height: calc(100% - 62px); #trace-container { width: 100%; -- GitLab