-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rendering): render external node labels above arrows (#932)
- Loading branch information
Showing
13 changed files
with
227 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,118 @@ | ||
const EXTERNAL_LABEL_SHAPES = new Set<string>([ | ||
"diamond", | ||
"dot", | ||
"hexagon", | ||
"square", | ||
"star", | ||
"triangle", | ||
"triangleDown", | ||
]); | ||
const INTERNAL_LABEL_SHAPES = new Set<string>([ | ||
"box", | ||
"circle", | ||
"database", | ||
"ellipse", | ||
"text", | ||
]); | ||
|
||
const EXTERNAL_LABEL = new Array(15) | ||
.fill(null) | ||
.map((): string => "This label should be above edge labels and arrows.") | ||
.join("\n"); | ||
const INTERNAL_LABEL = [ | ||
"This", | ||
"label", | ||
"should", | ||
"be", | ||
"above", | ||
"edge", | ||
"labels", | ||
"but", | ||
"bellow", | ||
"arrows.", | ||
].join("\n"); | ||
|
||
context("Z-index", (): void => { | ||
it("node labels > nodes > edge labels > edge arrows > edges", (): void => { | ||
cy.visSimpleCanvasSnapshot( | ||
"node-labels_nodes_edge-labels_edge-arrows_edges", | ||
{ | ||
nodes: [ | ||
describe("external node labels > edge arrows > internal node labels > nodes > edge labels > edges", (): void => { | ||
for (const shape of [...EXTERNAL_LABEL_SHAPES, ...INTERNAL_LABEL_SHAPES]) { | ||
it(shape, function (): void { | ||
cy.visSimpleCanvasSnapshot( | ||
`z-index_${shape}`, | ||
{ | ||
id: 1, | ||
fixed: true, | ||
x: 0, | ||
y: -300, | ||
shape: "dot", | ||
label: new Array(15) | ||
.fill(null) | ||
.map( | ||
(): string => | ||
"This label should be above edge labels and arrows." | ||
) | ||
.join("\n"), | ||
font: { | ||
color: "green", | ||
size: 40, | ||
}, | ||
}, | ||
{ | ||
id: 3, | ||
fixed: true, | ||
x: 100, | ||
y: 300, | ||
shape: "box", | ||
label: new Array(5) | ||
.fill(null) | ||
.map( | ||
(): string => | ||
"This label should be above edge labels but bellow arrows." | ||
) | ||
.join("\n"), | ||
font: { | ||
color: "black", | ||
size: 20, | ||
}, | ||
}, | ||
], | ||
edges: [ | ||
{ | ||
id: 2, | ||
from: 1, | ||
to: 3, | ||
label: new Array(80) | ||
.fill(null) | ||
.map( | ||
(): string => | ||
"This label should be bellow nodes and their labels but above edge arrows." | ||
) | ||
.join("\n"), | ||
font: { | ||
color: "red", | ||
size: 10, | ||
}, | ||
arrows: { | ||
from: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
nodes: [ | ||
{ | ||
id: 1, | ||
fixed: true, | ||
x: 0, | ||
y: -300, | ||
shape, | ||
label: EXTERNAL_LABEL_SHAPES.has(shape) | ||
? EXTERNAL_LABEL | ||
: INTERNAL_LABEL, | ||
font: { | ||
color: "green", | ||
size: 40, | ||
}, | ||
}, | ||
middle: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
{ | ||
id: 3, | ||
fixed: true, | ||
x: 100, | ||
y: 300, | ||
shape: "box", | ||
label: new Array(5) | ||
.fill(null) | ||
.map( | ||
(): string => | ||
"This label should be above edge labels but bellow arrows." | ||
) | ||
.join("\n"), | ||
font: { | ||
color: "black", | ||
size: 20, | ||
}, | ||
}, | ||
to: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
], | ||
edges: [ | ||
{ | ||
id: 2, | ||
from: 1, | ||
to: 3, | ||
label: new Array(80) | ||
.fill(null) | ||
.map( | ||
(): string => | ||
"This label should be bellow nodes and their labels but above edge arrows." | ||
) | ||
.join("\n"), | ||
font: { | ||
color: "red", | ||
size: 10, | ||
}, | ||
arrows: { | ||
from: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
}, | ||
middle: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
}, | ||
to: { | ||
enabled: true, | ||
scaleFactor: 6, | ||
}, | ||
}, | ||
endPointOffset: { | ||
from: -50, | ||
to: -50, | ||
}, | ||
}, | ||
}, | ||
endPointOffset: { | ||
from: -50, | ||
to: -50, | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
); | ||
{ requireNewerVersionThan: "8.0.1" } | ||
); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.