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

Node Position or Location based off of Node part and not Node itself

$
0
0

@RoyL wrote:

Hi, Long time listener, First time caller…lol

My question is, is it possible to position a node via location or position based on the Image part or any sub-part of a Node, or only the node itself? My issue is I have a node with an image in the center, this image has a standard size, but has other attributes such as ports, and annotations. The annotations can be on top, bottom, left, or right based on a users choice. Problem is once a annotation is loaded at the top of a node, the image isn’t lining up with other nodes that have a annotation at the bottom of the node.

Stubbed out code that resembles my current code.

$(go.Panel, “Table”
{},
$(go.Panel, “Auto”,
{ row: 1, column: 1, name: “BODY” },
),

$(go.Picture,
	{name: 'nodeIcon', row: 1, column: 1, width:36, height:36, stretch: go.GraphObject.Fill},
	new go.Binding("source"),
	new go.Binding("position", "position", go.Point.parse).makeTwoWay(go.Point.stringify)
),

//adding left ports
getPort($, "leftnode")
//adding right ports
getPort($, "rightnode")
//adding top ports
getPort($, "topnode")
//adding bottom ports
getPort($, "bottomnode")

//annotation panel

$(go.Panel, 'Auto' {},
	new go.Binding('row', '', getRow),
	new go.Binding('column', '', getColumn),
	$(go.Shape, 'Rectangle', {fill: bgColor, stroke: 'gray'}),
	$(go.TextBlock, textStyle()),
)

)

Posts: 10

Participants: 2

Read full topic


Prevent links looping back from crossing other links

$
0
0

@mlerman wrote:

Hello,

I have a diagram which uses the TreeLayout and some nodes loop back to the top. This has the unfortunate effect of crossing existing links (since I am avoiding nodes) and I was wondering if it would be possible to make loops always avoid crossing existing links.

Here is a snapshot of what I am getting:

Thanks,
Marc.

Posts: 2

Participants: 2

Read full topic

Binding to 'data' (.ofObject())

$
0
0

@Luddy wrote:

I have a node template that looks like this:

   $(go.Node,
        ...,
        $(go.Picture,
            { name : "PIC" },
            new go.Binding("element", "data", data => { return this.createCanvasForData(data); }).ofObject()));

It uses a bit of a kludge to get ahold of the entire node data object for the node under construction: a binding on ‘data’ together w/ ofObject. The createCanvasForData() call needs several properties from data; it’s for this reason that binding to a single property w/in data doesn’t suffice.

So, this works, but it results in createCanvasForData() being called twice for every node that is created using the template, when a model is loaded. It’s not hard to imagine ‘data’ being set at the end of the bottom-up copy / construction of a new node, or something of that kind.

So, a few questions:

Is it possible to refer to ‘data’ during construction of a node via a template, other than through a binding on ‘data’ itself? I don’t really need or want a binding here, in the sense of monitoring changes to ‘data’; this is exclusively for creation of the element in the first place.

Is it possible to get the effect of a binding that refers to several properties in tandem? I’m not at liberty, I think, to aggregate the properties of interest into a single property, because the most important one is the category of the node.

Any other suggestions for how I might get this effect?

Thanks,

-Luddy

Posts: 3

Participants: 2

Read full topic

Multiple LinkingBaseTools in a diagram?

$
0
0

@Dave wrote:

Hi,

I’d like to have 2 different link behaviors in a single diagram - mostly the same except isUnconnectedLinkValid true on one and false on the other. I don’t have all the details sorted but think I’d probably have the default for the diagram be the =false version and have the =true version be dragged from a palette or maybe created via a context menu.

Is it possible to do this? I keep coming back to thinking I’ll need multiple extensions to do this but don’t understand how I would do that in a single diagram.

Any tips or pointers to examples would be much appreciated!
-Dave

Posts: 2

Participants: 2

Read full topic

Adding Link in Model ChangedEvent

$
0
0

@estesbubba wrote:

I have a scenario when adding a node to the diagram where I also need to add a self-looping link to that node. I need to do that when the Model ChangedEvent fires and propertyName is ‘CommittedTransation’. I iterate over the modified nodes and create a link if it’s needed. I’m not sure the best practice to do this?

If I do a setTimeout() it works but seems hokey.
setTimeout(() => model.addLinkData(buildLinkData(transitionData)), 0);

If I use a transaction the Chrome tab locks up maybe in infinite loop?

          model.startTransaction('addLink');
          model.addLinkData(buildLinkData(transitionData));
          model.commitTransaction('addLink');

Here it is in the context of the code

  updateNodes = event => {
    const {
      formArrayPush,
      formArrayRemove,
      formChange,
      form,
      formValues: { nodes }
    } = this.props;
    const { model } = event;
    const changes = JSON.parse(model.toIncrementalJson(event));
    const modified = changes.modifiedNodeData || [];
    const inserted = changes.insertedNodeKeys || [];
    const removed = changes.removedNodeKeys || [];

    modified.forEach(item => {
      if (inserted.includes(item.id)) {
        let data = { ...nodeModel };
        const { transition } = item;
        const idx = Math.abs(item.id);
        const goData = model.findNodeDataForKey(item.id);

        // We are part of an undo/redo
        if (model.modelData._removedNodes[item.id]) {
          data = model.modelData._removedNodes[item.id];
          delete model.modelData._removedNodes[item.id];
        } else {
          data = {
            ...this.setNodeData(item, data, idx),
            id: item.id,
            type: item.category,
            locationX: item.location.x,
            locationY: item.location.y,
            width: item.width,
            height: item.height
          };
        }

        formArrayPush(form, 'nodes', data);
        if (transition) {
          const transitionData = {
            ...transition,
            fromNodeId: data.id,
            toNodeId: data.id
          };

          // Works but maybe bad practice?
          setTimeout(() => model.addLinkData(buildLinkData(transitionData)), 0);

          // Locks up Chrome tab maybe infinite loop?
          model.startTransaction('addLink');
          model.addLinkData(buildLinkData(transitionData));
          model.commitTransaction('addLink');
        }
        Object.assign(goData, buildNodeData(data));
        model.updateTargetBindings(goData);
      }
...

What would be the recommended way to add a link in a Model ChangedEvent?

Posts: 2

Participants: 2

Read full topic

Add new Node between two nodes without arranging whole layout

$
0
0

@opkeydev wrote:

Hi,
i am using LayeredDigraphLayout with following options
layout: $(go.LayeredDigraphLayout,
{
direction: 90,isOngoing: false,isInitial :false,
layerSpacing: 50, columnSpacing: 40,
setsPortSpots: false,
}),
now i just want to drop a node on link and set some spacing when it get added without effecting any other node position in diagram
right now i am able to add new node between two nodes but i am not be able to add spacing between it and when i use these propertyes
myDiagram.layout.isValidLayout = false;
myDiagram.layout.invalidateLayout(true);

my whole diagram get arranged but i only want to arrange that newly added node only without effecting whole layout i have also tried layoutConditions on node-template and set Part.isLayoutPositioned to false but then i my newly added node also get effected. Please provide me some solution for this


i need some spacing between this red marked node and link so that it looks same as all links and node look like

Posts: 4

Participants: 2

Read full topic

_ property in model.addLinkData()

$
0
0

@estesbubba wrote:

I need to add some data to my link model that isn’t used by the diagram link template. This data is needed later and I thought to use _ to mark it as extra data not used by the template. Here is a simple example:

model.addLinkData({
  a: a,
  b: b,
  _c: c
})

Later in a ChangedEvent I want to access _c after doing this:

    const { model } = event;
    const changes = JSON.parse(model.toIncrementalJson(event));
    const modified = changes.modifiedLinkData || [];

In the debugger model.linkDataArray has the _c property in it but changes.modifiedLinkData doesn’t. Doing a model.toIncrementalJson(event) looks to not include any property with a _. If I change my code to ABC: c then it works just fine.

So does model.toIncrementalJson() purposely ignore any properties with an _? If so is there a recommened way to store data into a link model that isn’t used by the template?

Posts: 2

Participants: 2

Read full topic

`measureTemporaryTextBlock` depending `font size`


Treeview expand only next sub level

$
0
0

@Raminaidu wrote:

I am using GoJs tree view. All the nodes in my tree view are expanded by default. My requirement is when i first load the tree view it should expand only to the first level. When i click expand icon against node then only one next level should be expanded.
Can you please modify treeview html file and send me?

Posts: 2

Participants: 2

Read full topic

isSubGraphExpanded doesn't preserved on copy/paste group

$
0
0

@AntonTrinkunas wrote:

Hi

We have a problem that after copy/paste groups collapse/expand state is not copied. Can be reproducible on Grouping sample. I tried to implement it by overriding pasteFromClipboard() method but it is not possible to find a match between copied and pasted artifacts. Do you have any suggestions?

Thanks, Anton.

Posts: 5

Participants: 2

Read full topic

Link graphics are "wrapping around" to original points

$
0
0

@av8orbynight wrote:

I’m placing links over a map. Essentially, a string of lat/long pairs are placed inside the ‘points’ field of the link data. I have a start node(red), and an end node (blue). The yellow/green line represents a railroad. My issue is that, as you can see, after the links are drawn using the points array, the end points are rejoined (as if trying to close a polygon). All of my links are doing this. Is there something that generally causes this behavior that I can check?

I’ve verified that there is no legitimate hop back from the end node to the start node in the coordinates. I’ve also tried having and not having end nodes and the links are specifying the correct node keys.

The template for the link is below the image.

`
let theLink =
$(go.Link,
{
layerName: ‘facilities’,
adjusting: go.Link.Stretch,
selectionAdornmentTemplate:
$(go.Adornment,
$(go.Shape,
{isPanelMain: true, stroke: ‘red’, strokeWidth: 3}
)
), // end Adornment
contextMenu:
$(go.Adornment, ‘Vertical’,
$(‘ContextMenuButton’,
new go.Binding(‘fill’, ‘symbolColor’),
$(go.TextBlock,
new go.Binding(‘text’, ‘contextMenuShowDetailsText’),
{
alignment: go.Spot.Left
}),
{
click: (e, obj) => {
this.showInExplorerClicked.emit({e, obj})
}
},
new go.Binding(‘visible’, ‘’, (d) => {
return !this.isDetailPage && d.contextMenuShowDetailsText;
})
),
$(‘ContextMenuButton’,
this.contextMenuButtonStyle,
$(go.TextBlock,
new go.Binding(‘text’, ‘contextMenuEditText’),
{
alignment: go.Spot.Left
}),
{
click: (e, obj) => {
this.editNodeClicked.emit({e, obj})
}
},
new go.Binding(‘visible’, ‘’, (d) => {
return !this.isDetailPage && !this.isUserRealOnly && d.contextMenuEditText;
})
),
$(‘ContextMenuButton’,
this.contextMenuButtonStyle,
$(go.TextBlock,
new go.Binding(‘text’, ‘contextMenuDeleteText’),
{
alignment: go.Spot.Left
}),
{
click: (e, obj) => {
this.deleteNodeClicked.emit({e, obj})
}
},
new go.Binding(‘visible’, ‘’, (d) => {
return !this.isDetailPage && !this.isUserRealOnly && d.contextMenuDeleteText;
})
),
),
toolTip: $(go.Adornment, ‘Auto’,
$(go.Shape, {
figure: ‘RoundedRectangle’,
parameter1: 3, //rounded rect radius
fill: ‘rgba(174, 20, 0, 0.7)’,
strokeWidth: 1,
stroke: ‘white’
}),
$(go.Panel, ‘Vertical’,
new go.Binding(‘itemArray’, ‘toolTipDataArray’),
{
margin: 8,
itemTemplate:
$(go.Panel, ‘Horizontal’,
{
alignment: go.Spot.Left,
margin: 3
},
$(go.TextBlock, {
stroke: ‘#fff’,
font: ‘12px bold arial, sans-serif’,
stretch: go.GraphObject.Fill,
textAlign: ‘center’,
alignment: go.Spot.BottomCenter
},
new go.Binding(‘text’, ‘’)
)
)

          },

        )
      ),
    },
    new go.Binding('points', 'points', (data) => {
      let ret = [];

      if (!data) return ret;

      data.forEach((latlong) => {
        let point = this.map.latLngToContainerPoint(latlong);
        ret.push(point.x);
        ret.push(point.y);

      });

      return ret;

    }),
    $(go.Shape, {
      strokeWidth: 5,
      isPanelMain: true,
      cursor: 'pointer',
      stroke: 'black'
    }),
    $(go.Shape,
      new go.Binding('stroke', '', (d) => {
        if (d.highlighted) {
          return 'red';
        }
        return d.symbolColor;
      }),
      {
      strokeWidth: 3,
      isPanelMain: true,
      cursor: 'pointer',
      name: 'linkFillShape',
    }),
    $(go.Panel, 'Auto',  // this whole Panel is a label
      $(go.Shape, 'RoundedRectangle',
        new go.Binding('fill', 'symbolColor', (d) => {
          return go.Brush.darkenBy(d, .50);
        }),
        {
        stroke: 'white',
        name: 'theLabel'
      }),
      new go.Binding('visible', '', (d) => {
        return this.map.getZoom() >= d.minVisibleLabelZoom && this.labelsVisible;
      }),
      $(go.TextBlock, {
          margin: 3,
          stroke: '#fff',
          font: '9px normal arial, sans-serif',
        },
        new go.Binding('text', 'linkLabel',))
    )
  );

`

Posts: 2

Participants: 1

Read full topic

Copy Selected Nodes and Links and Add them to new Diagram

$
0
0

@danaia wrote:

Like to ‘export’ a collection of links and nodes from one diagram and ‘import’ this collection into a new diagram.

I currently can save JSON into a DB (using MongoDB) and then retrieve JSON without issue (complete node/link arrays) - but this is for only one diagram at a time.

What I hope to do, however, is too allow users to create ‘templates’ of nodes and links and then import these saved JSON templates into other diagrams (I am using the state chart: https://gojs.net/latest/samples/statechart.html ).

Hope this makes sense. I want the ability to save layouts and then add each of these layouts into one larger layout/diagram. What is the best way to accomplish this?

Posts: 2

Participants: 2

Read full topic

Question about customizing link appearance

$
0
0

@AndreaCensi wrote:

I am evaluating whether I can use GoJS for my application.

I need to draw links like in the picture below.

I can see how to realize the appearance with extra nodes/links, but it would be great if this can be done using a link Geometry customization - because then there will be a 1-to-1 map between the semantics of my application and the GoJS diagram.

Is this possible in GoJS?

thanks,
A.

Posts: 1

Participants: 1

Read full topic

Angular gojs integration

Adding Child Lane (BPMN)


A good way to connect father son nodes?

$
0
0

@zhouhuan0910 wrote:

Hello, I now have a requirement that a node has more than one dependent child node, the parent node has location information, but the number of child nodes is determined by configuration; that is, the current JSON data has the LOC attribute of the parent node and the parent node, but want the child node to automatically generate and follow the parent node, how to implement It is better now

Posts: 2

Participants: 2

Read full topic

Behavior error between "spot" and "Vertical" for panel

How to optimize for SVG transfer

$
0
0

@ahmetgundogdu wrote:

Hello,
I have svg list.
I make new shape using svg paths.
But shapes is not equal.
Example images:
defaultSvgconvertedPaths

I use the node template:

this.diagram.nodeTemplateMap.add(Enums.AbsoluteFormNodeTemplates.UnifiedShapes,
goMake(go.Node, “Auto”, {
minLocation: new go.Point(0, 0),
locationObjectName: “Panel”,
locationSpot: go.Spot.Center,
selectable: true,
selectionAdornmentTemplate: this.nodeSelectionAdornmentTemplate,
selectionObjectName: “Panel”,
resizeObjectName: “Panel”,
resizeAdornmentTemplate: this.nodeResizeAdornmentTemplate,
resizable: true,
},
new go.Binding(“location”, “”, this.bindShapeLocation).makeTwoWay(this.converterShapeLocation),
new go.Binding(“isActionable”, “”, this.bindShapeLock).makeTwoWay(),
new go.Binding(“visible”, “”, this.bindNodeVisible),
goMake(go.Panel, “Auto”, {
name: “Panel”
},
new go.Binding(“desiredSize”, “”, this.bindShapeSize).makeTwoWay(this.converterShapeSize),
new go.Binding(“itemArray”, “”, this.bindPanelItemArray.bind(this)),
{
itemTemplate:
goMake(go.Panel, “Auto”,
new go.Binding(“desiredSize”, “”, this.bindPanelItemSize.bind(this)).makeTwoWay(),
goMake(go.Shape, “RoundedRectangle”,
{
fill: “#91E3E0”,
alignment: go.Spot.Center,
},
new go.Binding(“stroke”, “”, this.bindPanelItemBorderColor.bind(this)).makeTwoWay(),
new go.Binding(“fill”, “”, this.bindPanelItemColor.bind(this)).makeTwoWay(),
new go.Binding(“geometry”, “”, this.bindShapeGeometry.bind(this)),
new go.Binding(“strokeWidth”, “”, this.bindPanelItemBorderThickness.bind(this)),
new go.Binding(“strokeDashArray”, “”, this.bindPanelItemBorderType.bind(this)).makeTwoWay(),
//new go.Binding(“desiredSize”, “”, this.bindPanelItemSize.bind(this)).makeTwoWay(),
))
})
)
);

I have to use a panel to create the shape of a svg. Because i need all paths in svg

Posts: 8

Participants: 2

Read full topic

Treelayout doesnt scrollToRect() if I expandTree() of parent node

$
0
0

@rkaren wrote:

I have a tree based on Tree View sample. I have a search routine that locates a child node, selects it and scrollsToRect. It works fine if the parent is expanded but if I expandTree(parent), it selects the node but fails to scroll to it. Here is how I am doing that part. thanks for your help.

  doSearchTargetsTree: function() { // called from Search button.
var searchStr = $('#searchTerm').val();
var searchStrRegExp = new RegExp(searchStr, 'i');
var obj = new Object();
obj.title = searchStrRegExp ;
var iter = tree.myDiagram.findNodesByExample(obj);
var node = iter.first();
if (node) {
  var parentKey = node.data.parent;
  var parent = tree.myDiagram.findNodeForKey(parentKey);
  if (parent) {
    parent.expandTree();
    // expand root node, if necessary.
    var root = tree.myDiagram.findNodeForKey('0');
    root.expandTree();
    tree.myDiagram.clearSelection();
    tree.myDiagram.select(node);
    // scroll tree to center on bounds of the selected node.
    var rect = node.actualBounds;
    if (rect) {
      console.log('actual bounds of selected node: ' + rect);
      tree.myDiagram.scrollToRect(rect);
      // sometimes scroll doesn't work. using setTimeout() did NOT help.
      ms = '2000';
      window.setTimeout(addressBook.scrollTreeToKey(node.data.key), ms);
    } else {
      alert('There was a problem scrolling to selected target. Please scroll down/up to locate it.');
    }

  scrollTreeToKey: function(key) {
var node = tree.myDiagram.findNodeForKey(key);
if (node) {
  var rect = node.actualBounds;
  tree.myDiagram.scrollToRect(rect);
} else {
  alert('scrollTreeToKey: invalid node');
}

},

Posts: 11

Participants: 2

Read full topic

Where to find json file for a diagram

$
0
0

@sama wrote:

Hi,
I am a GoJS beginner and I want to ask where can I find the JSON file for any diagram
also, if I save a diagram in local storage how can i access all stored files?

thanks in advance

Posts: 4

Participants: 2

Read full topic

Viewing all 6977 articles
Browse latest View live


Latest Images