Creating a surface and a graph

Create a GFX surface using the GFX API, then create the Graph with the createGraph() function, and add the Surface object using the Diagram component.
The following Dojo models must be loaded:
To create the GFX surface and the graph inside it:
  • Use the following code:
    JavaScript
    dojo.require("dojox.gfx");
            dojo.require("ibm_diagram.Graph");
        
            var graph, surface;
            
            var setup = function() {
               surface = dojox.gfx.createSurface(dojo.byId('surfaceDiv'), 700, 600);
               graph = surface.createGraph();
            };
    
            dojo.addOnLoad(setup);
    Markup
    <div id="surfaceDiv"></div>