erikbrinkman / d3-dag

Layout algorithms for visualizing directed acyclic graphs
https://erikbrinkman.github.io/d3-dag/
MIT License
1.45k stars 87 forks source link

example code not runable #111

Closed seahurt closed 1 year ago

seahurt commented 1 year ago
<!DOCTYPE html>

<head>
</head>

<body>
    <script src="https://unpkg.com/d3-dag@0.11.1"></script>
    <script>
        const dag = d3.graphStratify(); 
        const layout = d3.sugiyama();
        layout(dag);

        // ... actually render here ...
        for (const node of dag.nodes()) {
            console.log(node.x, node.y);
        }
        for (const { points } of dag.links()) {
            console.log(points);
        }

    </script>
</body>

I got error: Uncaught TypeError: d3.graphStratify is not a function

seahurt commented 1 year ago

It's the version misleading me. I should use 1.0.0-1 not 0.11.1

here is the passing example

<!DOCTYPE html>

<head>
</head>

<body>
    <script src="https://unpkg.com/d3-dag@1.0.0-1"></script>
    <script>
        var data =[
            {
                "id": "0",
                "parentIds": []
            },
            {
                "id": "1",
                "parentIds": ["0"]
            },
            {
                "id": "2",
                "parentIds": ["0"]
            },
            {
                "id": "3",
                "parentIds": ["1", "2"]
            },
            {
                "id": "4",
                "parentIds": ["0"]
            },
            {
                "id": "5",
                "parentIds": ["4"]
            }
        ]
        const dag = d3.graphStratify()(data); 
        const layout = d3.sugiyama();
        layout(dag);

        // ... actually render here ...
        for (const node of dag.nodes()) {
            console.log(node.x, node.y);
        }
        for (const { points } of dag.links()) {
            console.log(points);
        }

    </script>
</body>
erikbrinkman commented 1 year ago

Ideally you should be using the fully released 1.0.0. I updated the example code in the README where I forgot to update it. Is there anywhere else you saw a reference to 0.11? A grep didn't turn up anything meaningful.

seahurt commented 1 year ago

https://erikbrinkman.github.io/d3-dag/index.html

this page still using 0.11.1

erikbrinkman commented 1 year ago

Thanks! It should be fixed now. Had to rebuild the docs. It will still say the wrong thing on npm, but I don't want to release a patch version just to update it.