anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.75k stars 425 forks source link

Graph Inside Div #6

Closed sherlholmes closed 12 years ago

sherlholmes commented 12 years ago

I am trying to render the Graph inside a div. Not able to figure it out. How to put the graph in the div?

anvaka commented 12 years ago

When you create a renderer instance set the 'container' property to required DOM element, where you want to place a graph. E.g.

   var renderer = Viva.Graph.View.renderer(graph,
        {
            container  : document.getElementById('graphDiv')
            // other settings
        });
Clay-Ferguson commented 8 years ago

@anvaka This is probably going to be a popular question. You may want to therefore address this question right at the beginning of your first example. Specifically in the readme.md would be best imo. That's where I was missing it.

Thanks! looking forward to trying this out. Looks awesome in the demos!

anvaka commented 8 years ago

@Clay-Ferguson thanks! fixed

Clay-Ferguson commented 8 years ago

I tried to run it, and it renders a canvas object that's 1px by 1px. Not sure what i'm doing wrong. I'm sure I have the JS file loading correctly but not working yet.

anvaka commented 8 years ago

check the CSS for the div - does it have width/height?

Clay-Ferguson commented 8 years ago

I tried again, but still can't get it. Here's the code: I am sure the DIV exists, and has size 500x500px, and the vivaGraph.js is definitely getting found and loaded correctly. (So something's gotta be missing? Are there other dependecies? I have jquery and polymer and lots of other javascript, BTW, so maybe I should try on a blank page or something and get it running there first).

I didn't (nor will I) run any command line code. ALL i'm doing is including your JS file, right?

                    var graph = Viva.Graph.graph();
                    graph.addLink(1, 2);

/////////////// //var graphGenerator = Viva.Graph.generator(); //var graph = graphGenerator.grid(3, 3);

// var layout = Viva.Graph.Layout.forceDirected(graph, { // springLength : 10, // springCoeff : 0.0005, // dragCoeff : 0.02, // gravity : -1.2 // });

var graphics = Viva.Graph.View.webglGraphics(); var container = document.getElementById('searchResultsPanelSub'); if (container==null) { console.log("container is null in viva!"); return; } var renderer = Viva.Graph.View.renderer(graph, { container : container, graphics : graphics//, //layout : layout }); renderer.run();

Best regards, Clay Ferguson wclayf@gmail.com

On Wed, Mar 30, 2016 at 11:13 PM, Andrei Kashcha notifications@github.com wrote:

check the CSS for the div - does it have width/height?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/anvaka/VivaGraphJS/issues/6#issuecomment-203744066