Quantcast
Channel: GoJS - Northwoods Software
Viewing all 6924 articles
Browse latest View live

Error in link data

$
0
0

@khiemvutrong wrote:

Excuse me Walter, I got this Error tomorrow afternoon, of course before my code it ran
I used to this code
“myDiagram.model = go.Model.fromJson(
{
“nodeDataArray”: itemsIcon,
“linkDataArray”: itemsLink
}
)”
then it console.log() this Error
[ERROR Error: FromKey value for link data [object Object] is not a number or a string: null
at B (go.js:12)
at vq (go.js:1807)
at dr (go.js:1817)
at ar.set (go.js:1831)
at ar.push…/node_modules/gojs/release/go.js.t.Wv (go.js:1796)
at Function.push…/node_modules/gojs/release/go.js.Z.fromJSON.Z.fromJson (go.js:1778)
at DiagramViewComponent.push…/src/app/main/diagram/diagram-view/diagram-view.component.ts.DiagramViewComponent.loadServicesSuccess (diagram-view.component.ts:328)
at SafeSubscriber._next (diagram-view.component.ts:349)
at SafeSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196)
at SafeSubscriber.push…/node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134)]

I am trying to use
“myDiagram.model.nodeDataArray = itemsIcon,
myDiagram.model.nodeDataArray = itemsLink”
It can show items, but my console.log() show this Error
ERROR Error: FromKey value for link data [object Object] is not a number or a string: null
at B (go.js:12)
at vq (go.js:1807)
at tq (go.js:1684)
at go.js:1683
at Array.forEach ()
at sq (go.js:1683)
at rq.push…/node_modules/gojs/release/go.js.rq.doModelChanged (go.js:1690)
at R.Y (go.js:570)
at ar.push…/node_modules/gojs/release/go.js.t.$s (go.js:1747)
at Wq (go.js:1748)

Although they work, I still want to know how to get rid of this Error
Please explain to me and How can I fix It, thanks, Sir

Posts: 2

Participants: 2

Read full topic


makeImageData: svg elements missing on large diagrams

$
0
0

@Dominic.Lerbs wrote:

Hello,

I have a large diagram where each node has an svg icon. Total diagram size is about 18000x10000.
When creating an png with makeImageData (max size is set to diagram size), a png with the correct dimensions is created, but the svg node icons east of ~16000 pixels are not printed. On the other hand, links are drawn correctly, even east of 16000px. If I move some icons from east to west of 16000px, they are displayed correctly in the png. I am using Electron.

In order to be able to set an appropriate maximum size for the image to be generated, I need to understand what is the cause for the missing icons.

As the png has been created correctly, it doesn’t seem to be a memory issue.
There is a limit to the canvas size, but the whole canvas is displayed, so this also seems to be unrelated.

Could you give me a hint what could be causes these missing icons?

Posts: 1

Participants: 1

Read full topic

How do I create the ruler template

Data Binding Conversion Functions Firing

$
0
0

@agillespie wrote:

I want my diagram to automatically recognize if it contains two or more nodes sharing the same value on a common property. I have an external model with global node IDs (“gid”), and can have multiple instances of any given node from the model represented as nodes within myDiagram (they are using the standard “key” as their identifier).

My plan was to use data bindings & conversion functions to recognize that myDiagram.findNodesByExample({gid: “example”}) returns an iterator of count > 1. I ran into a behavior I didn’t expect, however, when I realized that I couldn’t console.log anything from inside a data binding conversion function.

Here’s the relevant bits of my code:

new go.Binding("strokeWidth", "bold", function (e) { 
      console.log("BOLD BINDING FIRED"); //purely for testing, this never fires...
      return e ? 3 : 1  // ...even though this is working
    }),
    new go.Binding("strokeDashArray", "bold", function (e) { 
      //I'm worried this will hurt performance, but it's currently my best idea
      const gidNodesInView = myDiagram.findNodesByExample({gid: gidIn}); //get all instances of gid in view
      console.log("Updating bindings: " + gidNodesInView.count()); //this also never fires (and doesn't set the strokeDashArray either, but that's not my immediate question)
      return gidNodesInView.count()>1 ? [10, 5] : [5, 0] 
    })),

This is another in my string of probably very obvious quesitons - but why am I getting no console logs, even though the data binding is properly toggling my strokeWidth?

Posts: 4

Participants: 2

Read full topic

Picture node does not work

$
0
0

@nachoxxhh wrote:

Hello, I am trying to load an image, but I did nothing.

my code:

var model =  GO(go.GraphLinksModel,  {       
        nodeDataArray,
        linkDataArray 
});

myDiagram = GO(go.Diagram, 'myDiagramDiv', {
	"undoManager.isEnabled": true,
	 layout: GO(go.TreeLayout,  { angle: 0, nodeSpacing: 10, layerSpacing: 40 })
});

myDiagram.nodeTemplateMap.add("nodo_normal",GO(go.Node, 'Vertical', 
	 	GO(go.Picture, { 
	 		name: "SHAPE",
	 		desiredSize: new go.Size(40, 30),
	 		fromSpot: new go.Spot(0.5, 0.75, 0, 0), toSpot: new go.Spot(0.5, 0.25, 0, 0),
            fromLinkable: true, toLinkable: true,
            fromLinkableDuplicates: true, fromLinkableSelfNode: true,
            toLinkableDuplicates: true, toLinkableSelfNode: true,
            cursor: "pointer",
            portId: ""
	 	},
	        new go.Binding("source", "sourse")
	 	),
		GO(go.TextBlock, "text", { name: "TEXTBLOCK", font: '8pt Segoe UI, sans-serif', margin: new go.Margin(3, 0, 5, 0), cursor: "all-scroll" ,fromLinkable: false, toLinkable: false , editable: false}, 
				new go.Binding('text', 'text')
		)
	));

myDiagram.model =  model;
myDiagram.groupTemplate.ungroupable = false;

myDiagram.undoManager.isEnabled = true;

Link Data Array:

  nodeDataArray": [ 
 {"category":"nodo_normal", "key":"OLT-ZOFRI-1:0/1/4", "description":"", "type":"olt_puerta",           
"group":"", "isGroup":"false", "text":"OLT-ZOFRI-1:0/1/4", "sourse":"images/topologia/olt.png"},
{"category":"nodo_normal", "key":"Splitter", "description":"", "type":"splitter", "group":"", 
"isGroup":"false", "text":"Splitter", "sourse":"images/topologia/splitter.png"},
{"category":"nodo_normal", "key":"0", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000511381", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"1", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000310067", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"2", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000316405", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"3", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000310318", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"4", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000515607", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"5", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000479020", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"6", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000453787", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"7", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000317181", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"8", "description":"", "type":"ont", "group":"Grupo1", 
"isGroup":"false", "text":"10000431666", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"Caja1", "description":"", "type":"caja", "group":"Grupo1", 
"isGroup":"false", "text":"Caja 1", "sourse":"images/topologia/switch2.png"},   
{"category":"grupo_principal", "key":"Grupo1", "description":"", "type":"caja", "group":"", 
"isGroup":"true", "text":"Grupo 1", "sourse":""},
{"category":"nodo_normal", "key":"9", "description":"", "type":"ont", "group":"Grupo2", 
"isGroup":"false", "text":"10000310563", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"10", "description":"", "type":"ont", "group":"Grupo2", 
"isGroup":"false", "text":"10000310530", "sourse":"images/topologia/ont.png"},
{"category":"nodo_normal", "key":"11", "description":"", "type":"ont", "group":"Grupo2", 
"isGroup":"false", "text":"10000310909", "sourse":"images/topologia/ont.png"}] 

Posts: 4

Participants: 2

Read full topic

Changing some nodes to another shape

$
0
0

@Enniob wrote:

I’m trying to change on node to have the cloud shape, but when I add the property to change the it, it never changes and it always gives a “Rectangle”

Here is the code I have

    myDiagram.nodeTemplate = $(go.Node, "Auto", {
      locationSpot: go.Spot.Center,
      locationObjectName: "SHAPE"
    }, $(go.Shape, {
      name: "SHAPE",
      fill: "white",
      portId: "",
      cursor: "pointer",
      fromLinkable: true, fromLinkableSelfNode: true, fromLinkableDuplicates: true,
      toLinkable: true, toLinkableSelfNode: true, toLinkableDuplicates: true
    },
    new go.Binding("figure", "figure"),
    new go.Binding("fill", "color")),
    $(go.TextBlock, {
      font: "bold 14px sans-serif",
      stroke: "#333",
      margin: 6,
      isMultiline: true,
      editable: false,
      textAlign: "center"
    },
    new go.Binding("text", "text")));

      var nodeDataArray = [
        { key: 1, text: "Alpha", color: "lightblue" , figure: "Cloud"},
        { key: 2, text: "Beta", color: "orange", figure: "Cloud" },
        { key: 3, text: "Gamma", color: "lightgreen", group: 5, figure: "RoundedRectangle" },
        { key: 4, text: "Delta", color: "pink", group: 5, figure: "RoundedRectangle" },
        { key: 5, text: "Epsilon", color: "green", isGroup: true }
      ];

thanks for the help

Posts: 2

Participants: 2

Read full topic

Root Node has location of x: NaN, y: NaN

$
0
0

@peterma wrote:

Hi Walter, I got this issue: firstly, when a diagram showing an empty canvas with a rootNode which has location of { x: NaN, y: NaN }; but after adding some new nodes and connect the added nodes together, the rootNode could be shown and with a location of { x: 0, y: 0}.
There is no default location set to rootNode.
Do you have any idea what cause this issue?

Posts: 4

Participants: 2

Read full topic

Previous item in search results

$
0
0

@ameyvgupte wrote:

As per the sample we can search for nodes and get back the results in the form of an iterator. As a result it is possible to navigate to the next item in the results but do we have anything which allows to go to the previous element in the search results once iterated to the next one?

Posts: 2

Participants: 2

Read full topic


goJS floorPlanner print

GraphLinksModel.linkKeyProperty must not be an empty string for .toIncrementalData() to succeed

$
0
0

@vishnu4 wrote:

I’m having an issue with code that works fine on 2.1.14, but breaks when i upgrade to 2.1.15 or higher. The error i get is in the title, and i’m just trying to find out what changed and how to fix the issue. See my code below

import { scaleLinear } from "d3";
import go from "gojs";

const noop = (event: any) => {};

function initializeDiagram({ diagramMount, paletteMount, onChange = noop, data = {}, translations }) {
  const {
    StartTitle = "Start",
    StepText = "Step",
    ConditionalText = "???",
    EndTitle = "End",
    CommentText = "Comment",
    YesTitle = "Yes",
  } = translations;

  function init() {
    const $ = go.GraphObject.make; // for conciseness in defining templates

    go.Diagram.licenseKey =
      "XXX";
    const diagram = $(
      go.Diagram,
      diagramMount, // must name or refer to the DIV HTML element
      {
        LinkDrawn: showLinkLabel, // this DiagramEvent listener is defined below
        LinkRelinked: showLinkLabel,
        "undoManager.isEnabled": true, // enable undo & redo
        initialAutoScale: go.Diagram.Uniform,
      },
    );
    // helper definitions for node templates

    function nodeStyle() {
      return [
        // The Node.location comes from the "loc" property of the node data,
        // converted by the Point.parse static method.
        // If the Node.location is changed, it updates the "loc" property of the node data,
        // converting back using the Point.stringify static method.
        new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
        {
          // the Node.location is at the center of each node
          locationSpot: go.Spot.Center,
        },
      ];
    }

    // Define a function for creating a "port" that is normally transparent.
    // The "name" is used as the GraphObject.portId,
    // the "align" is used to determine where to position the port relative to the body of the node,
    // the "spot" is used to control how links connect with the port and whether the port
    // stretches along the side of the node,
    // and the boolean "output" and "input" arguments control whether the user can draw links from or to the port.
    function makePort(name, align, spot, output, input) {
      const horizontal = align.equals(go.Spot.Top) || align.equals(go.Spot.Bottom);
      // the port is basically just a transparent rectangle that stretches along the side of the node,
      // and becomes colored when the mouse passes over it
      return $(go.Shape, {
        fill: "transparent", // changed to a color in the mouseEnter event handler
        strokeWidth: 0, // no stroke
        width: horizontal ? NaN : 8, // if not stretching horizontally, just 8 wide
        height: !horizontal ? NaN : 8, // if not stretching vertically, just 8 tall
        alignment: align, // align the port on the main Shape
        stretch: horizontal ? go.GraphObject.Horizontal : go.GraphObject.Vertical,
        portId: name, // declare this object to be a "port"
        fromSpot: spot, // declare where links may connect at this port
        fromLinkable: output, // declare whether the user may draw links from here
        toSpot: spot, // declare where links may connect at this port
        toLinkable: input, // declare whether the user may draw links to here
        cursor: "pointer", // show a different cursor to indicate potential link point
        mouseEnter: function (e, port) {
          // the PORT argument will be this Shape
          if (!e.diagram.isReadOnly) port.fill = "rgba(255,0,255,0.5)";
        },
        mouseLeave: function (e, port) {
          port.fill = "transparent";
        },
      });
    }

    function textStyle() {
      return {
        font: "bold 11pt Lato, Helvetica, Arial, sans-serif",
        stroke: "#2f2f2f",
      };
    }

    // define the Node templates for regular nodes

    diagram.nodeTemplateMap.add(
      "", // the default category
      $(
        go.Node,
        "Table",
        nodeStyle(),
        // the main object is a Panel that surrounds a TextBlock with a rectangular Shape
        $(
          go.Panel,
          "Auto",
          $(
            go.Shape,
            "Rectangle",
            { fill: "#ccc", stroke: "#00A9C9", strokeWidth: 3.5 },
            new go.Binding("figure", "figure"),
          ),
          $(
            go.TextBlock,
            textStyle(),
            {
              margin: 8,
              maxSize: new go.Size(160, NaN),
              wrap: go.TextBlock.WrapFit,
              editable: true,
            },
            new go.Binding("text").makeTwoWay(),
          ),
        ),
        // four named ports, one on each side:
        makePort("T", go.Spot.Top, go.Spot.TopSide, false, true),
        makePort("L", go.Spot.Left, go.Spot.LeftSide, true, true),
        makePort("R", go.Spot.Right, go.Spot.RightSide, true, true),
        makePort("B", go.Spot.Bottom, go.Spot.BottomSide, true, false),
      ),
    );

    diagram.nodeTemplateMap.add(
      "Conditional",
      $(
        go.Node,
        "Table",
        nodeStyle(),
        // the main object is a Panel that surrounds a TextBlock with a rectangular Shape
        $(
          go.Panel,
          "Auto",
          $(
            go.Shape,
            "Diamond",
            { fill: "#ccc", stroke: "#00A9C9", strokeWidth: 3.5 },
            new go.Binding("figure", "figure"),
          ),
          $(
            go.TextBlock,
            textStyle(),
            {
              margin: 8,
              maxSize: new go.Size(160, NaN),
              wrap: go.TextBlock.WrapFit,
              editable: true,
            },
            new go.Binding("text").makeTwoWay(),
          ),
        ),
        // four named ports, one on each side:
        makePort("T", go.Spot.Top, go.Spot.Top, false, true),
        makePort("L", go.Spot.Left, go.Spot.Left, true, true),
        makePort("R", go.Spot.Right, go.Spot.Right, true, true),
        makePort("B", go.Spot.Bottom, go.Spot.Bottom, true, false),
      ),
    );

    diagram.nodeTemplateMap.add(
      "Start",
      $(
        go.Node,
        "Table",
        nodeStyle(),
        $(
          go.Panel,
          "Spot",
          $(go.Shape, "Circle", {
            desiredSize: new go.Size(70, 70),
            fill: "#ccc",
            stroke: "#22b530",
            strokeWidth: 3.5,
          }),
          $(go.TextBlock, "Start", textStyle(), { editable: true }, new go.Binding("text")),
        ),
        // three named ports, one on each side except the top, all output only:
        makePort("L", go.Spot.Left, go.Spot.Left, true, false),
        makePort("R", go.Spot.Right, go.Spot.Right, true, false),
        makePort("B", go.Spot.Bottom, go.Spot.Bottom, true, false),
      ),
    );

    diagram.nodeTemplateMap.add(
      "End",
      $(
        go.Node,
        "Table",
        nodeStyle(),
        $(
          go.Panel,
          "Spot",
          $(go.Shape, "Circle", {
            desiredSize: new go.Size(60, 60),
            fill: "#ccc",
            stroke: "#DC3C00",
            strokeWidth: 3.5,
          }),
          $(go.TextBlock, "End", textStyle(), { editable: true }, new go.Binding("text")),
        ),
        // three named ports, one on each side except the bottom, all input only:
        makePort("T", go.Spot.Top, go.Spot.Top, false, true),
        makePort("L", go.Spot.Left, go.Spot.Left, false, true),
        makePort("R", go.Spot.Right, go.Spot.Right, false, true),
      ),
    );

    // taken from ../extensions/Figures.js:
    go.Shape.defineFigureGenerator("File", function (shape, w, h) {
      const geo = new go.Geometry();
      const fig = new go.PathFigure(0, 0, true); // starting point
      geo.add(fig);
      fig.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0));
      fig.add(new go.PathSegment(go.PathSegment.Line, w, 0.25 * h));
      fig.add(new go.PathSegment(go.PathSegment.Line, w, h));
      fig.add(new go.PathSegment(go.PathSegment.Line, 0, h).close());
      const fig2 = new go.PathFigure(0.75 * w, 0, false);
      geo.add(fig2);
      // The Fold
      fig2.add(new go.PathSegment(go.PathSegment.Line, 0.75 * w, 0.25 * h));
      fig2.add(new go.PathSegment(go.PathSegment.Line, w, 0.25 * h));
      geo.spot1 = new go.Spot(0, 0.25);
      geo.spot2 = go.Spot.BottomRight;
      return geo;
    });

    diagram.nodeTemplateMap.add(
      "Comment",
      $(
        go.Node,
        "Auto",
        nodeStyle(),
        $(go.Shape, "File", { fill: "#ccc", stroke: "#DEE0A3", strokeWidth: 3 }),
        $(
          go.TextBlock,
          textStyle(),
          {
            margin: 8,
            maxSize: new go.Size(200, NaN),
            wrap: go.TextBlock.WrapFit,
            textAlign: "center",
            editable: true,
          },
          new go.Binding("text").makeTwoWay(),
        ),
        // no ports, because no links are allowed to connect with a comment
      ),
    );

    // replace the default Link template in the linkTemplateMap
    diagram.linkTemplate = $(
      go.Link, // the whole link panel
      {
        routing: go.Link.AvoidsNodes,
        curve: go.Link.JumpOver,
        corner: 5,
        toShortLength: 4,
        relinkableFrom: true,
        relinkableTo: true,
        reshapable: true,
        resegmentable: true,
        // mouse-overs subtly highlight links:
        mouseEnter: function (e, link: any) {
          link.findObject("HIGHLIGHT").stroke = "rgba(30,144,255,0.2)";
        },
        mouseLeave: function (e, link: any) {
          link.findObject("HIGHLIGHT").stroke = "transparent";
        },
        selectionAdorned: false,
      },
      new go.Binding("points").makeTwoWay(),
      $(
        go.Shape, // the highlight shape, normally transparent
        { isPanelMain: true, strokeWidth: 8, stroke: "transparent", name: "HIGHLIGHT" },
      ),
      $(
        go.Shape, // the link path shape
        { isPanelMain: true, stroke: "gray", strokeWidth: 2 },
        new go.Binding("stroke", "isSelected", function (sel) {
          return sel ? "dodgerblue" : "gray";
        }).ofObject(),
      ),
      $(
        go.Shape, // the arrowhead
        { toArrow: "standard", strokeWidth: 0, fill: "gray" },
      ),
      $(
        go.Panel,
        "Auto", // the link label, normally not visible
        { visible: false, name: "LABEL", segmentIndex: 2, segmentFraction: 0.5 },
        new go.Binding("visible", "visible").makeTwoWay(),
        $(
          go.Shape,
          "RoundedRectangle", // the label shape
          { fill: "#ccc", strokeWidth: 0 },
        ),
        $(
          go.TextBlock,
          YesTitle, // the label
          {
            textAlign: "center",
            font: "10pt helvetica, arial, sans-serif",
            stroke: "#333333",
            editable: true,
          },
          new go.Binding("text").makeTwoWay(),
        ),
      ),
    );

    // Make link labels visible if coming out of a "conditional" node.
    // This listener is called by the "LinkDrawn" and "LinkRelinked" DiagramEvents.
    function showLinkLabel(e) {
      const label = e.subject.findObject("LABEL");
      if (label !== null) label.visible = e.subject.fromNode.data.category === "Conditional";
    }

    // temporary links used by LinkingTool and RelinkingTool are also orthogonal:
    diagram.toolManager.linkingTool.temporaryLink.routing = go.Link.Orthogonal;
    diagram.toolManager.relinkingTool.temporaryLink.routing = go.Link.Orthogonal;

    diagram.model = load(); // load an initial diagram from some JSON text

    // initialize the Palette that is on the left side of the page
    const myPalette = $(
      go.Palette,
      paletteMount, // must name or refer to the DIV HTML element
      {
        // Instead of the default animation, use a custom fade-down
        "animationManager.initialAnimationStyle": go.AnimationManager.None,
        InitialAnimationStarting: animateFadeDown, // Instead, animate with this function

        nodeTemplateMap: diagram.nodeTemplateMap, // share the templates used by diagram
        model: new go.GraphLinksModel([
          // specify the contents of the Palette
          { category: "Start", text: StartTitle },
          { text: StepText },
          { category: "Conditional", text: ConditionalText },
          { category: "End", text: EndTitle },
          { category: "Comment", text: CommentText },
        ]),
      },
    );

    // This is a re-implementation of the default animation, except it fades in from downwards, instead of upwards.
    function animateFadeDown(e) {
      const diagram = e.diagram;
      const animation = new go.Animation();
      animation.isViewportUnconstrained = true; // So Diagram positioning rules let the animation start off-screen
      animation.easing = go.Animation.EaseOutExpo;
      animation.duration = 900;
      // Fade "down", in other words, fade in from above
      animation.add(diagram, "position", diagram.position.copy().offset(0, 200), diagram.position);
      animation.add(diagram, "opacity", 0, 1);
      animation.start();
    }

    const scale = scaleLinear().domain([0, 100]).range([diagram.minScale, diagram.maxScale]).clamp(true);

    // @ts-ignore
    diagram.zoomIn = zoomIn.bind(diagram);

    function zoomIn() {
      this.scale = scale(scale.invert(this.scale) + 0.25);
    }

    // @ts-ignore
    diagram.zoomOut = zoomOut.bind(diagram);

    function zoomOut() {
      this.scale = scale(scale.invert(this.scale) - 0.25);
    }

    diagram.zoomToFit = diagram.zoomToFit.bind(diagram);

    diagram.addModelChangedListener((e) => {
      if (e.isTransactionFinished) {
        //getting the below error when i upgrade gojs to 2.1.15 or higher
        //GraphLinksModel.linkKeyProperty must not be an empty string for .toIncrementalData() to succeed
        const dataChanges = e.model.toIncrementalData(e);
        if (dataChanges !== null) {
          onChange(dataChanges);
        }
      }
    });

    return diagram;
  } // end init

  // Show the diagram's model in JSON format that the user may edit
  // function save() {
  //   savedModel = diagram.model.toJson();
  //   diagram.isModified = false;
  // }
  function load() {
    return go.Model.fromJson(data);
  }

  // print the diagram by opening a new window holding SVG images of the diagram contents for each page
  return init();
}
export default initializeDiagram;

Posts: 2

Participants: 2

Read full topic

Avoid groups overlapping

$
0
0

@useche_dev wrote:

Hi, I have a question, how can I avoid overlapping groups? I’m generating several groups, but when I generate them, they overlap the previous one. Is there a property to avoid that and not generate over the previous one? Thanks.

Posts: 2

Participants: 2

Read full topic

onModelChange is called after the first time ReactDiagram rendered

$
0
0

@peterma wrote:

Hi Walter, I’m using ReactDiagram in this way:
<ReactDiagram
ref={refDiagram}
divClassName=‘diagram-waterfall’
initDiagram={initDiagram(onNodeClick, language, makeUniqueKeyFunction, makeUniqueLinkKeyFunction)}
nodeDataArray={toJS(nodeDataArray)}
linkDataArray={toJS(linkDataArray)}
onModelChange={onModelChange}
skipsDiagramUpdate={false}
/>

I’m having a loop of rendering this ReactDiagram and the update on diagramModel caused by
onModelChange.
I am wondering why the onModelChange callback will be called at the first time. Shouldn’t it be called when a user make any changes to the diagram but not the first time?

Posts: 1

Participants: 1

Read full topic

Onmouseover on textblock not working

$
0
0

@aragon wrote:

Hi,
I’m trying to start a link from a panel title but when the mouse is over the textblock the event is not fired. In few words…Is possible to put the textblock in a different layer than the shape with ports, leaving the text visible? Or making the panel start linking when then mouse is clicking over textblock ?
Here’s my code:

        myDiagram.nodeTemplateMap.add("Drivers",
          $(go.Node, "Auto",
            {
            	isTreeExpanded: true,
                minLocation: new go.Point(NaN, NaN),  // not allow movement
                maxLocation: new go.Point(NaN, NaN),
                deletable: false
                
    		},
            new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
            // this rectangular shape surrounds the content of the node
 			{ 
    			contextMenu: myContextMenu
 			},
            $(go.Shape,
              { fill: "#EEEEEE" }),
            // the content consists of a header and a list of items
            $(go.Panel, "Vertical",
              // this is the header for the whole node
              $(go.Panel, "Auto",
                { stretch: go.GraphObject.Horizontal },  // as wide as the whole node
                $(go.Shape,
              	{ 
                  	fill: "#AF5555", 
                  	stroke: null, 
                  	minSize: new go.Size(150, 10),
        		  	portId: "totale",
        		    background: "transparent",
         		 // allows links to/from all sides
        		    fromSpot: go.Spot.Right,
        		    toSpot: go.Spot.Left,
        		 // allows drawing links from or to this port
        		    fromLinkable: true,
        		    toLinkable: true,
        		    cursor:"pointer",
    	            mouseEnter: function(e, port) {  // the PORT argument will be this Shape
    	                if (!e.diagram.isReadOnly) port.fill = "#FF0000";
    	            },
    	            mouseLeave: function(e, port) {
    	                port.fill = "#AF5555";
    	            }    		   
    	         }        		    
    		   ),
   			    $(go.Picture, 
      			  { source: imgpth+"enter_class.png",
      				column: 0,
      				background: "transparent", 
      				width: 20, 
      				height: 20,
      				alignment: go.Spot.TopLeft
      			  }),        			    
                $(go.TextBlock,
                  {
                    alignment: go.Spot.Center,
                	column: 1, 
                    margin: new go.Margin(3, 5, 3, 10),
                    stroke: "white",
                    textAlign: "center",
                    font: "bold 10pt sans-serif"
                  },
                  new go.Binding("text", "cname")                  
                ),
                $("PanelExpanderButton", "TABLE",  
   			      { 
                	column: 2, 
   			        alignment: go.Spot.TopRight 
   			      })
              ),
              /*
              { // handle mouse enter/leave events to show/hide the ports
                mouseEnter: function(e: go.InputEvent, node: go.GraphObject) { showSmallPorts(node: go.GraphObject, true); },
                mouseLeave: function(e: go.InputEvent, node: go.GraphObject) { showSmallPorts(node: go.GraphObject, false); }
              },
              */
              // this Panel holds a Panel for each item object in the itemArray;
              // each item Panel is defined by the itemTemplate to be a TableRow in this Table
             $(go.Panel, "Table",
                {
                  name: "TABLE",
                  padding: 2,
                  minSize: new go.Size(140, 10),
                  defaultStretch: go.GraphObject.Horizontal,
                  itemTemplate: fieldTemplate,
                  visible: false,
       		      cursor:"pointer"

                },
                new go.Binding("itemArray", "fields")
              ) // end Table Panel of items
            )  // end Vertical Panel
          ));  // end Node
>>> 
here's the image:
![immagine|690x288](upload://cQl2cLXKBtTGU017FLpVSS38aEe.png) 

Thx

Posts: 8

Participants: 2

Read full topic

Gojs自动布局下,连线重合的问题。

$
0
0

@Meizhizhi wrote:

gojs自动布局下,连线重合的问题:


如上图,自动布局下,我的连线应该是 {from 1 to 1, {from 1 to 2 }, {from 2 to 2}
现在布局容易让人搞混,请问怎么不让连线重合。

Posts: 2

Participants: 2

Read full topic

Printing to PDF file

$
0
0

@Viswanatha wrote:

Hi Walter

I need your help in printing chart to pdf. I used below code to open chart for print but coming as blank window. any other reference JS i am missing, i have added goJs already. getting error at newDocument.body.appendChild(svg); please help.

myDiagram.model = new go.GraphLinksModel($scope.Employees, $scope.EmployeesRelations);
var button = document.getElementById(‘openSVG’);
button.addEventListener(‘click’, function() {
var newWindow = window.open("",“newWindow”);
if (!newWindow) return;
var newDocument = newWindow.document;
var svg = myDiagram.makeSvg();
newDocument.body.appendChild(svg);
}, false);

Posts: 2

Participants: 2

Read full topic


Placeholder with backgroud

$
0
0

@useche_dev wrote:

Hi. I have a question, and that is if it is possible to backgroud a placeholder in a group and fill the entire top as follows:

image

Thanks in advance.

Posts: 1

Participants: 1

Read full topic

Angular - undo manager not works

$
0
0

@james1 wrote:

Hi Walter and friends, I have two problems that I would like to get your help with.

  1. I moved my project to work with gojs-angular instead gojs library, and I have a problem with the undo manager that wasn’t there before.
    In the initDiagram function, I configured the diagram with ‘undoManager.isEnabled’ to be true.
    Then I made Context-menu with buttons of ‘undo’ and ‘redo’, but nothing happened when I click it after making a few changes at the diagram. (no errors also).

  2. another thing, before the moving to gojs-angular library, I was saved the diagram at my db in that way:
    data = JSON.parse(myDiagram.model.toJson());

but now, I am getting error of ‘maximum call stack size exceeded’.
what is the way to extract to necessary data from the diagram obj for saving at db?

thank you!

Posts: 1

Participants: 1

Read full topic

Debug Creating a link on Console

Question about DOM Tree Customisation

$
0
0

@jasoncooper wrote:


Hello - I am wondering if it’s possible to have the DOM Tree example connect to multiple nodes (similar to how a Sankey flow works) - but also be able to expand the node to reveal more information about that node - e.g. images and a table. See diagram for a general concept - many thanks!

Posts: 1

Participants: 1

Read full topic

Lock nodes in position

$
0
0

@julzelements wrote:

I’m attempting to create a diagram with hyperlinks on each node that can be clicked. However I need all the nodes to be fixed in place with no user interaction, or repositioning.

I’ve tried using diagram.isEnabled = false. This locks the diagram in place with no scrolling, but then the hyperlink does not work.

I’ve tried using diagram.isModelReadOnly = true and diagram.isReadOnly = true. This allows the hyperlink to be clicked, but now, the diagram can be scrolled.

Posts: 3

Participants: 2

Read full topic

Viewing all 6924 articles
Browse latest View live