-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renders as zero width #17
Comments
For the benefit of others who also have this issue, I solved it by just setting the width and height of Working demo: https://jsbin.com/mowewemaxe/edit?html,output Code of the above demo: <style>
html, body { margin:0px; padding:0px; width:100%; height:100%; }
</style>
<script type="module">
import Graph from 'https://esm.sh/@playcanvas/[email protected]?bundle';
import 'https://esm.sh/@playcanvas/[email protected]/styles?bundle';
import 'https://esm.sh/@playcanvas/[email protected]/styles?bundle';
const names = {
nodes: {
HELLO: 0,
WORLD: 1,
},
edges: {
HELLO_TO_WORLD: 0,
}
};
let graphSchema = {
nodes: {
[names.nodes.HELLO]: {
name: 'Hello',
outPorts: [
{
name: 'output',
type: names.edges.HELLO_TO_WORLD
}
]
},
[names.nodes.WORLD]: {
name: 'World',
inPorts: [
{
name: 'input',
type: names.edges.HELLO_TO_WORLD
}
]
}
},
edges: {
[names.edges.HELLO_TO_WORLD]: {
from: names.nodes.HELLO,
to: names.nodes.WORLD,
}
}
};
let graphData = {
nodes: {
1234: {
id: 1234,
nodeType: names.nodes.HELLO,
name: 'Hello',
posX: 200,
posY: 200
},
1235: {
id: 1235,
nodeType: names.nodes.WORLD,
name: 'World',
posX: 500,
posY: 200
},
},
edges: {
'1234,0-1235,0': {
edgeType: names.edges.HELLO_TO_WORLD,
from: 1234,
to: 1235,
inPort: 0,
outPort: 0,
}
}
};
let graphOptions = {
initialData: graphData,
passiveUIEvents: false,
includeFonts: true,
defaultStyles: {
edge: {
connectionStyle: 'smoothInOut'
},
background: {
color: '#20292B',
gridSize: 10
},
}
};
let graph = new Graph(graphSchema, graphOptions);
// this (or some other change) is needed otherwise the graph has zero width and height
graph.dom.style.width = "100%";
graph.dom.style.height = "100%";
window.addEventListener("resize", function() {
graph.width = window.innerWidth;
graph.height = window.innerHeight;
});
document.body.appendChild(graph.dom);
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I render a graph following the readme, and put the graph in a dom node with a set width and height, the graph is rendered with 0 width and height:
If I manually expand the graph size manually in the chrome inspector, it shows the grid with mouse interactivity, however neither of the two nodes show up in the graph that i can find.
I'm doing this in React, but react isn't doing anything here, I'm following the readme:
The text was updated successfully, but these errors were encountered: