mirror of
https://github.com/maciejpedzich/six-degs-of-f1.git
synced 2024-11-27 15:55:47 +01:00
Remove redundant options prop from Graph component
This commit is contained in:
parent
0e72f6ce97
commit
b9a2b2e85c
@ -4,16 +4,14 @@ import type { Node, Edge, Options } from 'vis-network/esnext';
|
|||||||
interface Props {
|
interface Props {
|
||||||
nodes: Node[];
|
nodes: Node[];
|
||||||
edges: Edge[];
|
edges: Edge[];
|
||||||
options?: Options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { nodes, edges, options = {} } = Astro.props;
|
const { nodes, edges } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<vis-graph
|
<vis-graph
|
||||||
data-nodes={JSON.stringify(nodes)}
|
data-nodes={JSON.stringify(nodes)}
|
||||||
data-edges={JSON.stringify(edges)}
|
data-edges={JSON.stringify(edges)}
|
||||||
data-options={JSON.stringify(options)}
|
|
||||||
>
|
>
|
||||||
<div></div>
|
<div></div>
|
||||||
</vis-graph>
|
</vis-graph>
|
||||||
@ -59,8 +57,7 @@ const { nodes, edges, options = {} } = Astro.props;
|
|||||||
levelSeparation: 80
|
levelSeparation: 80
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
physics: false,
|
physics: false
|
||||||
...(JSON.parse(this.dataset.options as string) as Options)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
new Network(container, data, options);
|
new Network(container, data, options);
|
||||||
|
@ -100,9 +100,15 @@ if (paramsNotEqual) {
|
|||||||
</p>
|
</p>
|
||||||
{
|
{
|
||||||
nodes.length > 0 && (
|
nodes.length > 0 && (
|
||||||
<div id="graph-container">
|
<>
|
||||||
<Graph nodes={nodes} edges={edges} />
|
<div id="graph-container">
|
||||||
</div>
|
<Graph nodes={nodes} edges={edges} />
|
||||||
|
</div>
|
||||||
|
<small>
|
||||||
|
Drag to pan, scroll to zoom. Click on a node to highlight it and its
|
||||||
|
links.
|
||||||
|
</small>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,5 +116,6 @@ if (paramsNotEqual) {
|
|||||||
#graph-container {
|
#graph-container {
|
||||||
height: 600px;
|
height: 600px;
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user