danielcaldas / react-d3-graph

Interactive and configurable graphs with react and d3 effortlessly
https://danielcaldas.github.io/react-d3-graph/sandbox/
MIT License
817 stars 233 forks source link

minimal usage example in doc doesn't work properly #565

Open StephanPraetsch opened 10 months ago

StephanPraetsch commented 10 months ago

Describe the bug The minimal example in docs isn't scaled properly and while zooming there are errors.

To Reproduce

nvm use 19
yarn create react-app my-app
cd my-app
yarn add d3
yarn add react-d3-graph

add minimal example from https://github.com/danielcaldas/react-d3-graph#minimal-usage-example so that src/App.js is

import './App.css';
import { Graph } from "react-d3-graph";

function App() {
// graph payload (with minimalist structure)
    const data = {
        nodes: [{ id: "Harry" }, { id: "Sally" }, { id: "Alice" }],
        links: [
            { source: "Harry", target: "Sally" },
            { source: "Harry", target: "Alice" },
        ],
    };

// the graph configuration, just override the ones you need
    const myConfig = {
        nodeHighlightBehavior: true,
        node: {
            color: "lightgreen",
            size: 120,
            highlightStrokeColor: "blue",
        },
        link: {
            highlightColor: "lightblue",
        },
    };

    const onClickNode = function(nodeId) {
        window.alert(`Clicked node ${nodeId}`);
    };

    const onClickLink = function(source, target) {
        window.alert(`Clicked link between ${source} and ${target}`);
    };

    return <Graph
        id="graph-id" // id is mandatory
        data={data}
        config={myConfig}
        onClickNode={onClickNode}
        onClickLink={onClickLink}
    />;
}

export default App;

Expected behavior A viewable and recognizable graph.

Screenshots there is a very small graph in the corner top left grafik

if I hover the small green icon and scroll with mouse wheel then grafik

Environment:

jjnanthakumar commented 3 months ago

+1

skydtrtzmr commented 3 months ago

yes, it also happens in this: https://danielcaldas.github.io/react-d3-graph/sandbox/index.html?data=marvel

it's an example of collapsible.

sometimes when you click on the parent node, the edges disappeared but the child nodes still exist