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

Render multiple jgraph views on single page #10

Open
fredhohman opened this issue Mar 15, 2017 · 2 comments
Open

Render multiple jgraph views on single page #10

fredhohman opened this issue Mar 15, 2017 · 2 comments

Comments

@fredhohman
Copy link

fredhohman commented Mar 15, 2017

Is it possible to render multiple jgraph views on one page? For example:

jgraph.create('.graph-left');
$.getJSON('graphs/lesmis.json', function (graph) {
    jgraph.draw(graph);
});

jgraph.create('.graph-right');
$.getJSON('graphs/lesmis.json', function (graph) {
    jgraph.draw(graph);
});

When I run this, the .graph-right div shows a jgraph, but .graph-left does not.

Thanks!

@patrickfuller
Copy link
Owner

patrickfuller commented Mar 15, 2017

You can deep copy the jgraph object to run independent canvases. Something like this should work:

var left, right;
left = $.extend({}, jgraph);
right = $.extend({}, jgraph);

left.create('.graph-left');
$.getJSON('graphs/lesmis.json', function (graph) {
    left.draw(graph);
});
right.create('.graph-right');
$.getJSON('graphs/lesmis.json', function (graph) {
    right.draw(graph);
});

Longer term, jgraph should be reorganized to make this easier.

@fredhohman
Copy link
Author

Great, thanks!

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