Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 305ca3e

Browse files
committed
improve rendering of grid for higher number of cells
Fixes #627
1 parent 4e0048a commit 305ca3e

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

app/plugins/modules/activation-visualizations/lib/cell.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,24 @@ exports.renderCell = (returnTo, cell, activation, isFailure=!activation.response
5050
cell.className = `${cell.className} is-failure-${isFailure}`
5151
container.className = `grid-cell-content latency-${latBucket}`
5252

53-
if (!isFailure && (!options || options.zoom > 0)) {
54-
const innerLabel = document.createElement('span')
55-
innerLabel.innerText = prettyPrintDuration(duration)
56-
container.appendChild(innerLabel)
57-
}
58-
59-
//label = document.createElement('div')
60-
// container.appendChild(label)
61-
// label.className = 'cell-label'
62-
// label.innerText = labelText || ''
53+
// any extra info to display in the tooltip?
54+
let extraTooltip = ''
6355

6456
if (isFailure) {
6557
const fdom = document.createElement('div')
6658
fdom.className = 'grid-oops-overlay'
6759
container.appendChild(fdom)
60+
61+
} else if (!options || options.zoom > 0) {
62+
// for larger zoom levels, and only for successful activations,
63+
// render the latency inside the cell
64+
const innerLabel = document.createElement('span')
65+
innerLabel.innerText = prettyPrintDuration(duration)
66+
container.appendChild(innerLabel)
67+
68+
} else {
69+
// for higher zoom levels (zoom < 0), render the latency in the tooltip
70+
extraTooltip += `${newline}${prettyPrintDuration(duration)}`
6871
}
6972

7073
if (activation) {
@@ -88,7 +91,7 @@ exports.renderCell = (returnTo, cell, activation, isFailure=!activation.response
8891
cell.isFailure = isFailure
8992
cell.setAttribute('data-action-name', activation.name)
9093
cell.setAttribute('data-balloon-break', 'data-balloon-break')
91-
cell.setAttribute('data-balloon', `${options && options.nameInTooltip ? activation.name + ' action, invoked ' : ''}${ui.prettyPrintTime(activation.start, 'short')}${msg}`)
94+
cell.setAttribute('data-balloon', `${options && options.nameInTooltip ? activation.name + ' action, invoked ' : ''}${ui.prettyPrintTime(activation.start, 'short')}${msg}${extraTooltip}`)
9295
cell.setAttribute('data-balloon-pos', 'up')
9396
}
9497

app/plugins/modules/activation-visualizations/lib/grid.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ const _drawGrid = (options, {sidecar, leftHeader, rightHeader}, content, groupDa
287287
}
288288

289289
// and try to make the gridDom mostly squarish
290-
gridDom.querySelector('.grid-row').style.maxWidth = `${width * (zoomLevelForDisplay === 0 ? 2.5 : zoomLevelForDisplay === 1 ? 3 : zoomLevelForDisplay === 2 ? 4 : 3)}vw`
290+
gridDom.querySelector('.grid-row').style.maxWidth = `${width * (zoomLevelForDisplay === 0 ? 2.5 : zoomLevelForDisplay === 1 ? 3 : zoomLevelForDisplay === 2 ? 4 : 0.75)}vw`
291291

292292
let idx = 0
293293
group.activations.forEach(activation => {
294-
renderCell(viewName, cells[idx], activation, !isSuccess(activation))
294+
renderCell(viewName, cells[idx], activation, !isSuccess(activation),
295+
undefined, undefined, { zoom: zoomLevelForDisplay })
295296
idx++
296297
})
297298
} else {
@@ -313,7 +314,8 @@ const _drawGrid = (options, {sidecar, leftHeader, rightHeader}, content, groupDa
313314
const cell = makeCellDom()
314315
cellContainer.appendChild(cell)
315316
cell.classList.add('grid-cell-newly-created')
316-
renderCell(viewName, cell, activation, !isSuccess(activation))
317+
renderCell(viewName, cell, activation, !isSuccess(activation), undefined, undefined,
318+
{ zoom: zoomLevelForDisplay })
317319
}
318320
} catch (e) {
319321
console.error(e)

app/plugins/modules/activation-visualizations/web/css/table.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@
395395
/* square aspect ratio */
396396
width: 0.75vw;
397397
height: 0.75vw;
398+
399+
/* for higher zoom levels, use a transparent outline to blur the small cells together better */
400+
border: none;
401+
outline: 1px solid rgba(255,255,255,0.4);
398402
}
399403
.activation-viz-plugin .grid .grid-cell {
400404
display: flex;

0 commit comments

Comments
 (0)