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

Run function before drag from palette

$
0
0

@agillespie wrote:

Howdy.

I’m working with a palette and a custom HTMLInfo tooltip. The HTML Tooltip Div is obscuring parts of my main Diagram and preventing users from dropping nodes there.

I want to call the function that hides my tooltip div just before a drag event from the palette occurs.
Is there a more simple way of doing this or do I have to learn how do some sort of “customDraggingTool” where I extend the current dragging tool… where the only change is the addition of one function call at the beginning?

Posts: 1

Participants: 1

Read full topic


Upgrading Angular project

Error saving diagram JSON graphql

$
0
0

@BATorres wrote:

I’ve had this problem for a couple days and I don’t know how to solve it. The problem is: I tried to save my diagram data using diagram.model.toJson() and then transform the JSON into a string to store it in a database using a graphql mutation. I only get Error: applyIncrementalJson cannot change Model properties evey single time, I also tried to use toIncrementalJson but thats not what I need, I need the complete diagram information. I apreciate all kind of guidance or help, I’m using gojs for my degree proyect so I need to acomplish this to finish the prototype.

Posts: 2

Participants: 2

Read full topic

Node size don't go back auto stretch

$
0
0

@BATU wrote:

If you don’t set desiredSize explicitly, the node size will auto stretch, e.g. when adding more text, Now I need it reverse, I resize node by mouse to any size, then press the button delete the size property, but it not automatically go back to the auto stretch mode.

https://jsfiddle.net/batobolg/bmypcvjk/33/

press the button try it.

Posts: 3

Participants: 2

Read full topic

Multi-node overlap of fishbone graph data

$
0
0

@scholar wrote:

I use a fishbone diagram layout. When I have too many nodes, there will be the effect of node overlap. How can I avoid this situation? Using layerSpacing cannot solve this problem at all.
1591596282(1)
This is the demo link https://jshare.com.cn/scholar/h9G0zc
Please help me, thanks!

Posts: 1

Participants: 1

Read full topic

Save Selection as json

$
0
0

@ironwill1023 wrote:

Hi, I’d like to save diagram.selection as json template so I can reuse it in the diagram.
Or do you have any other way to save selection data in db except json format?
Thanks.

Posts: 2

Participants: 2

Read full topic

toSpot and fromSpot on ports

$
0
0

@d3chapma wrote:

I have nodes that look like this: image. The dark grey boxes are ports. I currently have code that changes sets the toSpot and fromSpot on the port based on where it is positioned. So, for example, the ‘I/O’ port has a fromSpot and toSpot of go.Spot.Top so that links will only connect at a single point in the center of that port.

However, for the ‘PoE’ port, I want the behaviour to be that links can connect to a single point on the top side, or a single point on the right side chosen based on the shortest path. In this situation I currently set the value to go.Spot.TopRightSides, but that is not to a single point. I could set the value to go.Spot.TopRight, but that would force links out of the corner rather than the top or the right.

Is there are way to get the behaviour I want on these corner ports?

Posts: 1

Participants: 1

Read full topic

Centering an outpu link on a picture within a node

$
0
0

@jcaruso wrote:

I created a node which consists of text blocks and a picture. The text blocks are stacked vertically to the left of the picture. I need for the link come out of the picture centered on the picture. Unfortunately, I haven’t figured how to accomplish this. It seems the link output is centered on the node. Is there a way to have the link centered on the picture.

image

Here’s s snippet of the template:

    myDiagram.nodeTemplate =
      $(go.Node, "Horizontal",
        {
          locationSpot: go.Spot.Center,  // Node.location is the center of the Shape
          locationObjectName: "SHAPE",
          selectionObjectName: "SHAPE"
          //selectionAdorned: false,
        },
        new go.Binding("location", "", toLocation).makeTwoWay(fromLocation),
        $(go.Panel, "Vertical", {},
           $(go.TextBlock, {
                alignment: go.Spot.Center,
                textAlign: "center",
                font: '9px bold sans-serif',
            },
            new go.Binding("text")),
          $(go.TextBlock, {
              alignment: go.Spot.Center,
              textAlign: "center",
              stroke: "#ff8c00",
              font: '9px bold sans-serif',
            },
            new go.Binding("text")),
          $(go.TextBlock, {
              alignment: go.Spot.Center,
              textAlign: "center",
              stroke: "red",
              font: '9px bold sans-serif',
            },
            new go.Binding("text")),
        ),
        $(go.Panel, "Auto",
        $(go.Picture,
          {
            name: "SHAPE",
          },
          new go.Binding("source", "type", nodeTypeImage),
          new go.Binding("desiredSize", "type", nodeTypeSize)
        ),
      ),
    );

Posts: 2

Participants: 2

Read full topic


Unable to download complete diagram as image

$
0
0

@Bharath01 wrote:

Hi Walter,
i am trying to export a huge diagram.
actual diagram:

when i export a diagram ports are missing

fullv

below is the code i am using

  img = this.diagram.makeImageData({
                          background: "white",
                          scale: 0.8,
                          maxSize: new go.Size(Infinity, Infinity)
                        });

and in animation finish event i have been using ‘centerrect’ for a node.
what i observed is, if i zoom out the diagram. i can get the whole diagram.

  1. if i use zoomtofit image is not clear.
    what is the main reason to cause this. and what might be the actual solution.

Posts: 1

Participants: 1

Read full topic

makeImageData with Scrolling Table issue

$
0
0

@Junaid wrote:

Hi, my node template uses scrolling table. When i try to use diagram.makeImageData() with scale:1 and maxSize: new go.Size(Infinity, Infinity) some columns are missing from scrolling table node as shown in attached image. Issue with large image. For small images its working fine.

As you can see for some nodes only the first column is getting exported. For some nodes no columns (only blank table) being displayed after export.

Posts: 2

Participants: 2

Read full topic

Inspector changes do not update data correctly (Angular)

$
0
0

@Hazzed wrote:

Hi!
I’m using Angular and gojs-angular. I have an inspector which in simplified form is similar to the one shown in GoJS Angular basic demo. It’s form has two fields - first changes text of given node, second changes template of a node (node should change it’s apperance). Here is my code that handles inspector changes (it is nearly the same as the code in demo).

handleInspectorChange(data) {
    const key = data.key;

    let index = null;
    for (let i = 0; i < this.graphNodeData.length; i++) {
      const entry = this.graphNodeData[i];
      if (entry.key && entry.key === key) {
        index = i;
      }
    }

    if (index >= 0) {
      this.skipsDiagramUpdate = false;
      this.graphNodeData[index] = { ...data };
    }
  }

When I change the text of a node it works only once - after changing it second time, arrays synchronized by GoJS-Angular DataSyncService (this.graphNodeData present in my component and model.nodeDataArray) are out of sync, as shown below. After I change the category of a node it is synchronized again, however with this approach diagramModelChange() responsible for syncing those arrays is not called at all.

I’ve tried diffrent approaches such as:

    if (index >= 0) {
      const diagram = this.graphComponent.diagram;
      this.skipsDiagramUpdate = false;
      
      diagram.startTransaction();
      diagram.model.assignAllDataProperties(this.graphNodeData[index], data);
      diagram.updateAllTargetBindings();
      diagram.commitTransaction('update');
    }

This calls diagramModelChange() function and updates this.graphNodeData, but does not update model.nodeDataArray at all. Am I doing something wrong? What might be the problem?

Posts: 1

Participants: 1

Read full topic

Styling contextmenu in angular

$
0
0

@james1 wrote:

Hi guys,
Can you please explain how can I style a context-menu in angular? (e.g. change background color)
can I give the context-menu a CSS class?

thank you.

Posts: 2

Participants: 2

Read full topic

How to play video in go.Picture?

$
0
0

@ironwill1023 wrote:

I want to play video in go.Picture.

    var src = editingNode.data['videoUrl'];
    var video = document.createElement('video');
    video.autoplay = true;
    video.setAttribute("width", 120*editingNode.data.size);
    video.setAttribute("height", 67.5*editingNode.data.size);
    video.src = src;
    editingNode.findObject('screenshot').element = video;
    editingNode.findObject('screenshot').redraw();

‘screenshot’ is go.Picture.
editingNode.data[‘videoUrl’] = ‘https://vimeo.com/387193565/49e5599b2d
But above code isn’t working.
just blank screen.
I’m using https://gojs.net/latest/release/go-debug.js.
Thanks

Posts: 2

Participants: 2

Read full topic

Context menu on link release location

$
0
0

@mladenmacanovic wrote:

Hi,

I want’t show context menu on the diagram when I release the link. My scenario is as following:

  • I have a node in the diagram
  • Click on the node to start the line drawing
  • Move the line anywhere on the diagram, still holding the mouse
  • If I release the mouse over the diagram AND NOT over another node, I do:
    • detect mouse location
    • show context menu on that location

So far I was unable to find the right API for this. The closest I come is use of doMouseUp tool

diagram.toolManager.linkingTool.doMouseUp = function () {
                console.log("mouse up");
            };

But that overrides default behavior of line drawing and connecting to other nodes so everything stops working.

Posts: 1

Participants: 1

Read full topic

React and setState

$
0
0

@phlerp wrote:

I am evaluating GoJS as a component of a planned system. I have run into a problem using GoJS with React.

I have created a basic project based on some of the available samples with functionality to add new nodes and edit the text in nodes which works fine. However when I add an eventlistener and set a state inside it, any changes (changed texts and added nodes) revert back to original. Positions are strangely kept but all other user induced changes disappear.

I can read the state with no problems but as soon as I write anything to the state I get this behaviour. There seems to be no problem setting states outside of the eventlisteners. I have tried some different approaches as binding this to the eventlistener as well as using arrow functions with a variable with this in. I have also tried both building my component as a class component and as a functional component with the same result. I have also tried to use the stateful example for React modified to work with JS (as it is TypeScript).

Is this a known problem? Am I doing something wrong or is it a bug?

Posts: 2

Participants: 2

Read full topic


Unable to use node ports when hover adornment is active

$
0
0

@aabi01 wrote:

So I have implemented the node structure where the node has a bunch of elements in it, like Shape, Textblock, picture and buttons etc. The node also has incoming and outgoing ports on it which are linkable to other nodes.
The nodes also shows buttons on mouse hover. I followed the hoverButton example at (https://gojs.net/latest/samples/hoverButtons.html)

The problem is, when i hover over the node it shows the buttons and they are working fine, but the adornment placeholder covers the whole area over the node including ports, which i cannot use anymore.

The code for my node and adornment is as follows.

Node

this.$(
			go.Node,
			'Spot',
			{
				isShadowed: true,
				shadowColor: '#0000001A',
				shadowOffset: new go.Point(0, 5),
				shadowBlur: 15,
				selectionAdorned: false,
			},
			{
				click: (e: go.InputEvent, activeNode: go.Node) => {
					if (
						e.targetObject instanceof go.Shape ||
						e.targetObject instanceof go.TextBlock ||
						e.targetObject instanceof go.Picture
					) {
						nodeClickCallback(e, activeNode);
					}
				},
				mouseHover: (e, activeNode: go.Node) => {
					self.onNodeMouseHover(e, activeNode);
					nodeHoverAdornment.adornedObject = activeNode;
					activeNode.addAdornment('mouseHover', nodeHoverAdornment);
				},
				mouseLeave: (e, activeNode: go.Node) => {
					self.onNodeMouseLeave(e, activeNode);
				},
			},
			new go.Binding('location', 'loc').makeTwoWay(),
			this.$(
				go.Shape,
				'RoundedRectangle',
				{
					width: 160,
					height: 120,
					fill: 'white',
					stroke: null,
					strokeWidth: 3,
					spot1: go.Spot.TopLeft,
					spot2: go.Spot.BottomRight,
				},
				new go.Binding('stroke', 'isHighlighted', (h) => {
					return h ? self.highlightColor : 'white';
				}).ofObject()
			),
			this.$(
				go.Panel,
				'Auto',
				this.$(
					go.Panel,
					'Table',
					{
						defaultAlignment: go.Spot.Left,
					},
					this.$(go.RowColumnDefinition, { column: 0, width: 55 }),
					this.$(go.RowColumnDefinition, { column: 1, width: 80 }),
					this.$(go.RowColumnDefinition, { column: 2, width: 25 }),
					this.$(go.RowColumnDefinition, { row: 0, height: 50 }),
					this.$(go.RowColumnDefinition, { row: 1, height: 70 }),

					// Node Icon - Row 0
					this.$(
						go.Panel,
						'Auto',
						{ row: 0, column: 0, alignment: go.Spot.Left },
						this.$(
							go.Shape,
							'RoundedRectangle',
							{
								width: 42,
								height: 42,
								stroke: null,
								strokeWidth: 0,
								margin: 5,
							},
							new go.Binding(
								'fill',
								'transformationStep',
								(step: TransformationStepModel) =>
									TransformationTypeConstant.findById(
										step.transformationType
									).color
							)
						),
						this.$(
							go.Picture,
							{
								desiredSize: new go.Size(20, 20),
							},
							new go.Binding(
								'source',
								'transformationStep',
								(step: TransformationStepModel) =>
									TransformationTypeConstant.findById(
										step.transformationType
									).icon
							)
						)
					),

					// Node ID - Row 0
					this.$(
						go.Panel,
						'Horizontal',
						{
							row: 0,
							column: 1,
						},
						this.$(
							go.Picture,
							{
								desiredSize: new go.Size(18, 18),
								margin: new go.Margin(0, 5, 0, 0),
							},
							new go.Binding(
								'visible',
								'transformationStep',
								(step: TransformationStepModel) =>
									step.transformationType ===
									TransformationTypesEnum.INPUT
							),
							new go.Binding(
								'source',
								'transformationStep',
								(step: TransformationStepModel) =>
									this.getInputNodeIcon(step)
							)
						),
						this.$(
							go.TextBlock,
							{
								stroke: 'black',
								font: 'normal 10pt sans-serif',
							},
							new go.Binding(
								'text',
								'transformationStep',
								(step: TransformationStepModel) =>
									TransformationTypeConstant.findById(
										step.transformationType
									).title
							)
						)
					),

					// Node Description - Row 1
					this.$(
						go.TextBlock,
						{
							row: 1,
							column: 0,
							columnSpan: 3,
							alignment: go.Spot.LeftCenter,
							margin: new go.Margin(0, 10, 10, 10),
							stroke: '#707070',
							font: 'normal 9pt sans-serif',
							text: '...',
							overflow: go.TextBlock.OverflowEllipsis,
						},
						new go.Binding(
							'stroke',
							'transformationStep',
							(step: TransformationStepModel) => {
								return step.hasError ? '#ff4d4d' : '#707070';
							}
						),
						new go.Binding(
							'text',
							'transformationStep',
							(step: TransformationStepModel) =>
								NodeDescriptionHelper.showNodeDescription(step)
						)
					)
				)
			),
			this.$(
				go.Panel,
				'Vertical',
				{
					alignment: go.Spot.Left,
					alignmentFocus: new go.Spot(0, 0.5, 20, 0),
				},
				inports
			),
			this.$(
				go.Panel,
				'Vertical',
				{
					alignment: go.Spot.Right,
					alignmentFocus: new go.Spot(1, 0.5, -20, 0),
				},
				outports
			),
			this.$(
				go.Panel,
				'Horizontal',
				{
					alignment: go.Spot.Top,
					alignmentFocus: new go.Spot(0, 1, 75, 0),
				},
				// Error Icon
				this.$(
					go.Shape,
					{
						width: 15,
						height: 15,
						fill: '#ff4d4d',
						strokeWidth: 0,
						geometry: go.Geometry.parse(
							this.svgIcons['warning'],
							true
						),
					},
					new go.Binding(
						'visible',
						'transformationStep',
						(step: TransformationStepModel) => step.hasError
					)
				)
			)
		);

Adornment

const nodeHoverAdornment = this.$(
			go.Adornment,
			'Spot',
			{
				background: 'lightgrey',
				click: function (e, obj) {
					console.log('adornment click');
					const activeNode = obj.part.adornedPart;
					nodeClickCallback(e, activeNode);
				},
				mouseHover: (e, obj) => {
					console.log('adornment mouseHover');
					const activeNode = obj.part.adornedPart;
					self.onNodeMouseHover(e, activeNode);
				},
				mouseOver: (e, obj) => {
					console.log('adornment mouseOver');
					const activeNode = obj.part.adornedPart;
					self.onNodeMouseHover(e, activeNode);
				},
				mouseLeave: function (e, obj) {
					console.log('adornment mouseLeave');
					const ad = obj.part;
					// hide the Adornment when the mouse leaves it
					ad.adornedPart.removeAdornment('mouseHover');
					self.onNodeMouseLeave(e, obj.part.adornedPart);
				},
			},
			this.$(go.Placeholder, {
				background: 'transparent',
				isActionable: true,
			}),
			this.$(
				'Button',
				{
					alignment: go.Spot.Top,
					alignmentFocus: new go.Spot(0, 1, -35, 0),
					'ButtonBorder.stroke': null,
					_buttonStrokeOver: null,
					'ButtonBorder.fill': 'transparent',
					click: function (e, obj: go.Node) {
						const activeNode = obj.part;
						// functionality for this button
					},
				},
				this.$(go.Shape, {
					width: 15,
					height: 15,
					fill: '#bbbbbb',
					strokeWidth: 0,
					geometry: go.Geometry.parse(this.svgIcons['cog'], true),
				})
			),
			this.$(
				'Button',
				{
					alignment: go.Spot.Top,
					alignmentFocus: new go.Spot(0, 1, -60, 0),
					'ButtonBorder.stroke': null,
					_buttonStrokeOver: null,
					'ButtonBorder.fill': 'transparent',
					click: function (e, obj: go.Node) {
						// Delete Node
						const activeNode = obj.part;
						console.log('delete node', activeNode);
						nodeDeleteCallback(activeNode);
					},
				},
				this.$(go.Shape, {
					width: 15,
					height: 15,
					fill: '#bbbbbb',
					strokeWidth: 0,
					geometry: go.Geometry.parse(this.svgIcons['remove'], true),
				})
			)
		);

How can i manage the adornment placeholder size so that i does not cover the ports and they are still working?

Posts: 5

Participants: 2

Read full topic

Change port colors when mousehover on node

$
0
0

@kumar1 wrote:

$(go.Panel, "Horizontal",
          new go.Binding("itemArray", "bottomArray"),
          {
            alignment: go.Spot.BottomCenter,
            alignmentFocus:  go.Spot.BottomCenter,
            //  row: 2, column: 1,
            itemTemplate:
              $(go.Panel,
                {
                  _side: "bottom",
                  fromSpot: go.Spot.Bottom, toSpot: go.Spot.Bottom,
                  fromLinkable: true, toLinkable: true, cursor: "pointer",
                },
                new go.Binding("portId", "portId"),
                $(go.Shape, "Circle",
                  {
                    stroke: null, strokeWidth: 2,
                    desiredSize: new go.Size(7, 7),
                    fill: null,
                    margin: new go.Margin(0, 0, -3, 0),
                  })
              )
          }),
          { // handle mouse enter/leave events to show/hide the ports
            mouseEnter: ((e, node) => { showSmallPorts(e, node, true) }),
            mouseLeave: ((e, node) =>  { showSmallPorts(e, node, false)})
          } // end itemTemplate
      );  // end Node

 var  showSmallPorts = ((e,node,show) => {
      node.ports.each((port) => {
        if (port.portId !== "") {  // don't change the default port, which is the big shape
          port.fill = show ? "rgba(0,0,0,.3)" : null;
        }
      });
    })

how to change the fill color in itemTemplete when mouseover

Posts: 4

Participants: 2

Read full topic

Layout positioning problem

$
0
0

@useche_dev wrote:

Hi, I have a question. In the diagram I am working on I am using the GridLayout, but my problem is that when I move a group, and then expand/collapse it, it returns to its original position instead of staying where I moved it to. What could be causing this behavior? Thank you in advance.

Posts: 4

Participants: 3

Read full topic

Basic Swim lane diagram with 3 rows

$
0
0

@Enniob wrote:

Is there a basic example that I can find to make a Swim Lane diagram? I was looking to implement something really basic with 3 rows and some nodes on each row connect to other nodes on next rows.

Here is a image representation for it.

Posts: 6

Participants: 2

Read full topic

Rotating a node re-renders the entire diagram

$
0
0

@jcaruso wrote:

I need to provide the user to rotate an image within a node to line up with the link/edge. For example,

I’m able successfully able to rotate the node and have it line up but, the entire diagram ends up rerendering as follows:

The image is perfect square. How can I prevent the diagram from rerendering. Here’s the nodeTemplate:

   myDiagram.nodeTemplate =
      $(go.Node, "Horizontal",
        {
          locationSpot: go.Spot.Center,  // Node.location is the center of the Shape
          locationObjectName: "SHAPE",
          selectionObjectName: "SHAPE",
          rotatable: true,
          locationSpot: go.Spot.Center,
          rotateObjectName: "SHAPE",
          rotateAdornmentTemplate:  // specify appearance of rotation handle
            $(go.Adornment,
              { locationSpot: go.Spot.Center },
              $(go.Shape, "Circle",
                { width: 12, height: 12, cursor: "pointer",
                  background: "transparent", stroke: "dodgerblue", strokeWidth: 2
                }
                )
            ),
          //selectionAdorned: false,
        },
        new go.Binding("location", "", toLocation).makeTwoWay(fromLocation),
        $(go.Panel, "Vertical", {},
           $(go.TextBlock, {
                alignment: go.Spot.Center,
                textAlign: "center",
                font: '9px bold sans-serif',
            },
            new go.Binding("text")),
        ),
        $(go.Panel, "Auto",
        $(go.Picture,
          {
            name: "SHAPE",
            angle: 180,
            alignment: go.Spot.Center,
            portId: ""
          },
          new go.Binding("source", "type", nodeTypeImage),
          new go.Binding("desiredSize", "type", nodeTypeSize)
        ),
      ),

Finally, sometimes when I rotate the link/edge follows. I want to be able to rotate a shape independent of the link/edge.

Posts: 2

Participants: 2

Read full topic

Viewing all 6924 articles
Browse latest View live