playcanvas / pcui-graph

A PCUI extension for creating node-based graphs
https://playcanvas.github.io/pcui-graph
MIT License
122 stars 15 forks source link

Renders as zero width #17

Open AndrewRayCode opened 3 years ago

AndrewRayCode commented 3 years ago

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:

<div style="width: 600px; height: 600px;">
<div class="pcui-element font-regular pcui-graph joint-paper joint-theme-default" style="background-color: rgb(32, 41, 43); width: 0px; height: 0px;">
...
</div>
</div>

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:

useEffect(() => {
    const schema = {
      nodes: {
        0: {
          name: 'Hello',
          fill: 'red',
        },
        1: {
          name: 'World',
          fill: 'green',
        },
      },
      edges: {
        0: {
          from: [0], // this edge can connect nodes of type 0
          to: [1], // to nodes of type 1,
          stroke: 'blue',
        },
      },
    };

    const graph = new PcGraph(schema);
    if (graphRef.current) {
      graphRef.current.appendChild(graph.dom);
    }
  }, [graphRef]);