Skip to content

Commit

Permalink
display short version queuename name, show tooltip if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
SP12893678 committed Oct 8, 2024
1 parent e7820ab commit 37ac73f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/app/components/queue-v2/queues-v2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ function queueVisualization(rawData : QueueInfo , componentInstance: QueueV2Comp

nodeEnter.each(function(d) {
const group = select(this);
const queueName = d.data.queueName.split(".").at(-1) ?? d.data.queueName;

group.append("rect")
.attr("width", 300)
Expand Down Expand Up @@ -242,9 +243,9 @@ function queueVisualization(rawData : QueueInfo , componentInstance: QueueV2Comp
.attr("y", 22.5)
.attr("font-size", "25px")
.attr("fill", "black")
.text(d.data.queueName)
.text(queueName)
.call(ellipsis, 270)
.call(tooltip, group, d.data.queueName);
.call(tooltip, group, queueName);

const plusCircle = group.append("circle")
.attr("cx", 150)
Expand Down Expand Up @@ -425,8 +426,7 @@ function ellipsis(

let count = 1;
while (textNode && maxWidth < textNode.getBBox().width) {
const lines = text.split(".").slice(count);
selection.text(`...${lines.join(".")}`);
selection.text(`${text.slice(0, text.length - count)}...`);
count++;
}
}
Expand All @@ -435,7 +435,10 @@ function tooltip(
selection: Selection<SVGTextElement, unknown, null, undefined>,
container: Selection<SVGGElement, unknown, null, undefined>,
text: string,
): Selection<SVGGElement, unknown, null, undefined> {
): Selection<SVGGElement, unknown, null, undefined> | null {
// if current text same as tooltip text, unnecessary render tooltip
if(selection.text() === text) return null;

const textNode = selection.node();
const bbox = textNode?.getBBox();
const textWidth = bbox?.width || 100;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"target": "ES2022",
"module": "es2020",
"lib": [
"es2020",
"es2022",
"dom"
],
"paths": {
Expand Down

0 comments on commit 37ac73f

Please sign in to comment.