vangj / jsbayes-viz

Simple Bayesian Belief Network visualization and interactive library for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about redraw

InVinCiblezz opened this issue · comments

Hey, I am trying to make an interactive version to add a new node to the graph.

I noticed you added a function named redraw 3 years ago. I tried this method but it seems does not work well.

 const addNode = function (name, values, parent) {
        let newNode = graph.addNode(name, values);
        newNode.addParent(parent)
        graph.reinit()
        graph.sample(1000);
        let g = jsbayesviz.fromGraph(graph);

        jsbayesviz.redraw({
            id: '#bbn',
            width: 1500,
            height: 800,
            graph: g,
        });
    }

    const handleCLick = function() {
        addNode("new", ["Repair", "Normal"], n5)
    }

image

No edge and wrong place.

I also tried to use draw here. But It is still no edge.
Did I use the wrong method?

Thanks a lot!