I’m moving along nicely with GoJS but have a few hurdles right now.
I have it creating the correct Node when double-clicking by setting the archetypeLinkData.category property. I have a PartCreated listener which needs to set additional properties on the node like text and key. I’ve tried using both e.subject.data.text and e.subject.text in the listener and neither works. I need to set some properties dynamically on the Node on creation using data from our app. How can I do this?
I’m trying to make my grid lines 1px but they are 2px. Here is my code:
You’re setting “archetypeLinkData” to customize the creation of the correct Node? I would hope you meant setting myDiagram.toolManager.clickCreatingTool.archetypeNodeData.
Yes, in the “PartCreated” DiagramEvent the e.subject.data ought to be the newly copied JavaScript object to which the new Node is bound. So setting properties on the data should be OK for what you want to do. Remember to call Model.setDataProperty in order for GoJS to know that you have modified the property, since there’s no reliable way for GoJS to be notified automatically. But you don’t need to conduct a transaction, since this DiagramEvent occurs within a transaction performed by ClickCreatingTool.insertPart.
Yes, setting Shape.strokeWidth = 1 should result in one-pixel wide line. But due to anti-aliasing, two adjacent pixels could be drawn, depending on the actual position of the grid line, which in the case of Diagram.grid also depends on the Diagram.position and Diagram.scale.
Yes, you need to set TextBlock.font on each of the TextBlocks that you make. Some day we will support CSS styling in order to control such things, but we haven’t designed that yet.