Skip to content

Commit e18cf18

Browse files
authored
Merge pull request #253 from neo4j/tooltip-truncated
Truncate long property values in tooltip
2 parents a83cf60 + 52ff651 commit e18cf18

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313

1414
## Improvements
1515

16+
- Truncate large property values in the rendered output.
17+
1618
## Other changes

js-applet/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ class PyNVL {
3838
if (tooltip !== null) {
3939
this.hoverInteraction = new HoverInteraction(this.nvl)
4040

41+
const truncateValue = (value: any, maxLength: number = 100): string => {
42+
const strValue = String(value);
43+
if (strValue.length <= maxLength) {
44+
return strValue;
45+
}
46+
return `<span class="tooltip-value">${strValue}</span>`;
47+
};
48+
4149
this.hoverInteraction.updateCallback('onHover', (element: PyNode | PyRel) => {
4250
if (element === undefined) {
4351
tooltip.textContent = "";
@@ -49,7 +57,7 @@ class PyNVL {
4957

5058
let hoverInfo: string = (`<b>Source ID:</b> ${rel.from} </br><b>Target ID:</b> ${rel.to}`)
5159
for (const [key, value] of Object.entries(element.properties)) {
52-
hoverInfo += `</br><b>${key}:</b> ${value}`
60+
hoverInfo += `</br><b>${key}:</b> ${truncateValue(value)}`
5361
}
5462
tooltip.setHTMLUnsafe(hoverInfo)
5563

@@ -59,7 +67,7 @@ class PyNVL {
5967
} else if ("id" in element) {
6068
let hoverInfo: string = `<b>ID:</b> ${element.id}`
6169
for (const [key, value] of Object.entries(element.properties)) {
62-
hoverInfo += `</br><b>${key}:</b> ${value}`
70+
hoverInfo += `</br><b>${key}:</b> ${truncateValue(value)}`
6371
}
6472
tooltip.setHTMLUnsafe(hoverInfo)
6573

python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/base.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python-wrapper/src/neo4j_viz/resources/nvl_entrypoint/styles.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,17 @@ button.icon:active {
4949
filter: drop-shadow(0 4px 8px rgba(26,27,29,0.12));
5050
font-family: 'Public Sans', sans-serif;
5151
color: var(--neutral-text-default);
52-
font-size: 14px
52+
font-size: 14px;
53+
overflow-y: auto;
54+
overflow-x: hidden;
55+
word-wrap: break-word;
56+
overflow-wrap: break-word;
57+
}
58+
59+
.tooltip-value {
60+
display: inline-block;
61+
max-width: 100%;
62+
overflow: hidden;
63+
text-overflow: ellipsis;
64+
white-space: nowrap;
5365
}

0 commit comments

Comments
 (0)