Skip to content
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

Weird rendering of simple graph in Vue #414

Open
inc0 opened this issue Oct 13, 2020 · 2 comments
Open

Weird rendering of simple graph in Vue #414

inc0 opened this issue Oct 13, 2020 · 2 comments

Comments

@inc0
Copy link

inc0 commented Oct 13, 2020

Hello! Trying to render simple graph, but it doesn't behave like it should.

var nodes = {
        "nodes": [
            "node1",
            "node2",
            "node3",
            "node4",
            "node5",     
        ],
        "edges": [
            ["node1", "node2"],
            ["node2", "node3"],
            ["node2", "node4"],
            ["node4", "node5"]
        ]
    }
function draw_graph() {
    var dagreD3 = require("dagre-d3");
    var d3 = require("d3");

    var g = new dagreD3.graphlib.Graph()
    g.setGraph({}).setDefaultEdgeLabel(function() { return {}; });

    nodes.nodes.map((n) => g.setNode(n, {label: n, width: 100, height: 150}));
    nodes.edges.map((e) => g.setEdge(e[0], e[1]));

    var render = new dagreD3.render();
    render(d3.select("svg"), g);
    console.log(g);
}

And styles:

<style scoped>
.node rect {
  stroke: rgb(214, 48, 48);
  fill: #fff;
}

.edgePath path {
  stroke: rgb(41, 184, 60);
  fill: rgb(187, 78, 78);
  stroke-width: 1.5px;
}
</style>

I run func draw_graph on mount in Vue, this is result:

graph

How to debug this? No errors are shown

@inc0
Copy link
Author

inc0 commented Oct 13, 2020

Made progress on this. Turns out that vues scoped style made it break. If you remove scoped, it works.

@alfredocovaDS
Copy link

thanks for the notice, did you ran into something else while working in Vue? I'm about to start working with this library, any advice would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants