Skip to content
Snippets Groups Projects
Commit 734602c8 authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Fixed node filtering and design. Nodes may still change color during filter...

Fixed node filtering and design. Nodes may still change color during filter operations. This should be resolved when colors are hard-mapped to node types.
parent 09f5d90f
No related branches found
No related tags found
1 merge request!3Master into new editor
Pipeline #56804 failed
.filter-class-label { .filter-class-label {
display: inline-block; display: inline-block;
padding-right: 5px; padding-right: 10px;
color: #fff; color: #fff;
font-size: 13px; font-size: 13px;
line-height: 20px; line-height: 20px;
font-family: CuratorRegular, Helvetica Neue, Helvetica, Arial, sans-serif; font-family: CuratorRegular, Helvetica Neue, Helvetica, Arial, sans-serif;
text-transform: uppercase; text-transform: uppercase;
margin-bottom: 6px; margin-bottom: 8px;
height: 17px; height: 17px;
z-index: 100; z-index: 100;
cursor: pointer; cursor: pointer;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
bottom: 0; bottom: 0;
pointer-events: none; pointer-events: none;
width: 350px; width: 350px;
max-width: 400px; height: 105px;
padding: 10px; padding: 10px;
left: 0; left: 0;
display: block; display: block;
......
...@@ -32,14 +32,17 @@ function FilterMenu({ classes, onVisibilityChange }: FilterMenuProps) { ...@@ -32,14 +32,17 @@ function FilterMenu({ classes, onVisibilityChange }: FilterMenuProps) {
} }
}; };
const labelWidth = 10 * chars;
const width = Math.ceil(classList.length / 3) * (labelWidth + 20);
return ( return (
<div className={"filter-menu"}> <div className={"filter-menu"} style={{ width }}>
{classList.map((cls: string, idx) => ( {classList.map((cls: string, idx) => (
<ClassLabel <ClassLabel
key={cls} key={cls}
type={cls} type={cls}
color={classes.get(cls)} color={classes.get(cls)}
width={10 * chars} width={labelWidth}
visible={visibility[idx]} visible={visibility[idx]}
onClick={() => handleClick(idx)} onClick={() => handleClick(idx)}
/> />
......
...@@ -131,7 +131,7 @@ class Display extends React.Component< ...@@ -131,7 +131,7 @@ class Display extends React.Component<
{this.state.graph && ( {this.state.graph && (
<FilterMenu <FilterMenu
classes={this.state.graph.nodeColors} classes={this.graph.nodeColors}
onVisibilityChange={this.handleNodeFilter} onVisibilityChange={this.handleNodeFilter}
/> />
)} )}
......
...@@ -58,6 +58,7 @@ export default class Graph { ...@@ -58,6 +58,7 @@ export default class Graph {
this.resetNodeData(); this.resetNodeData();
this.updateNodeData(); this.updateNodeData();
this.removeFloatingNodes();
this.mapNodeColors(); this.mapNodeColors();
this.mapLinkColors(); this.mapLinkColors();
} }
...@@ -69,6 +70,10 @@ export default class Graph { ...@@ -69,6 +70,10 @@ export default class Graph {
} }
} }
private removeFloatingNodes() {
this.nodes = this.nodes.filter((node) => node.neighbors.length > 0);
}
/** /**
* Updates the graph data structure to contain additional values. * Updates the graph data structure to contain additional values.
* Creates a 'neighbors' and 'links' array for each node object. * Creates a 'neighbors' and 'links' array for each node object.
...@@ -137,6 +142,10 @@ export default class Graph { ...@@ -137,6 +142,10 @@ export default class Graph {
nodeTypes: Map<string, boolean>, nodeTypes: Map<string, boolean>,
linkTypes?: Map<string, boolean> linkTypes?: Map<string, boolean>
): Graph { ): Graph {
// Filter nodes depending on type
const nodes = this.nodes.filter((l) => nodeTypes.get(l.type));
// Filter links depending on type
let links; let links;
if (linkTypes === undefined) { if (linkTypes === undefined) {
links = this.links; links = this.links;
...@@ -144,8 +153,13 @@ export default class Graph { ...@@ -144,8 +153,13 @@ export default class Graph {
links = this.links.filter((l) => linkTypes.get(l.type)); links = this.links.filter((l) => linkTypes.get(l.type));
} }
// Filter links which are connected to an invisible node
links = links.filter(
(l) => nodeTypes.get(l.source.type) && nodeTypes.get(l.target.type)
);
return new Graph( return new Graph(
this.nodes.filter((l) => nodeTypes.get(l.type)), nodes,
links.map((link) => { links.map((link) => {
return { return {
source: link.source.id, source: link.source.id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment