Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Trying to reload the diagram

$
0
0

@chan_1di wrote:

Below is my code...
when i click on a button it generates the diagram perfectly but when i click on that button again it says ..Error: Invalid div id; div already has a Diagram associated with it..could you please tell me what am i doing wrong...i tried using Diagram.div = null;
but its not working at all.
Thanks

var $1 = go.GraphObject.make;
myDiagram = $1(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center,
"undoManager.isEnabled": true,
allowDragOut: false
});
myDiagram.nodeTemplate =
$1(go.Node, "Auto",
$1(go.Shape, "Ellipse", { strokeWidth: 5 },
new go.Binding("fill", "color")),
$1(go.TextBlock, { margin: 8 },
new go.Binding("text", "key"))
);
var linkDataArray = [];
var linkerData = [];

  for (var i = 0, j = 0; i < Session.get('gojsname1').length, j < Session.get('gojsname2').length; i++, j++) {
      linkDataArray.push({ key: Session.get('gojsname1')[i], color: "orange" }, { key: Session.get('gojsname2')[j], color: "orange" });
      linkerData.push({ from: Session.get('gojsname1')[i], to: Session.get('gojsname2')[j] });
  }

  for (var iter = 0; iter < linkDataArray.length; iter++) {
      for (var innerIter = 0; innerIter < linkDataArray.length; innerIter++) {

          if (iter != innerIter) {
              if (linkDataArray[iter].key == linkDataArray[innerIter].key) {
                  linkDataArray.splice(innerIter, 1);
              }
          }
      }
  }
  myDiagram.model = new go.GraphLinksModel(
      linkDataArray, linkerData
  );

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles