### Go Debugging with Delve Source: https://gojs.net/latest/release/go-debug.mjs This snippet demonstrates how to start a Go application with the Delve debugger. Ensure Delve is installed (`go install github.com/go-delve/delve/cmd/dlv@latest`). ```bash dlv debug main.go ``` -------------------------------- ### Basic Tree Layout Setup Source: https://gojs.net/latest/intro/layouts.html Implement TreeLayout for hierarchical structures. This example sets up the layout, content alignment, and basic node/link templates with sample tree data. ```javascript diagram.layout = new go.TreeLayout(); diagram.contentAlignment = go.Spot.Center; // define a simple Node template diagram.nodeTemplate = new go.Node("Spot") // the Shape will go around the TextBlock .add( new go.Shape("Ellipse", { fill: 'palegreen', stroke: '#333', strokeWidth: 3, width: 40, height: 40 }), new go.TextBlock({ font: 'bold 12pt sans-serif', stroke: '#333' // some room around the text }) // TextBlock.text is bound to Node.data.key .bind("text", "key") ); diagram.linkTemplate = new go.Link() // Default routing is go.Routing.Normal // Default corner is 0 .add( new go.Shape({ strokeWidth: 3, stroke: "#333" }) ); // create the model data that will be represented by Nodes and Links diagram.model = new go.GraphLinksModel( [ { key: "1" }, { key: "2" }, { key: "3" }, { key: "4" }, { key: "5" }, { key: "6" } ], [ { from: "1", to: "2" }, { from: "1", to: "3" }, { from: "3", to: "4" }, { from: "3", to: "5" }, { from: "3", to: "6" } ]); ``` -------------------------------- ### Basic Force-Directed Layout Setup Source: https://gojs.net/latest/intro/layouts.html Utilize ForceDirectedLayout for simulating physical forces between nodes. This example configures electrical charge and spring length, along with basic diagram and model setup. ```javascript diagram.layout = new go.ForceDirectedLayout({ defaultElectricalCharge: 50, defaultSpringLength: 10 }); diagram.initialAutoScale = go.AutoScale.Uniform; diagram.contentAlignment = go.Spot.Center; // define a simple Node template diagram.nodeTemplate = new go.Node("Spot") // the Shape will go around the TextBlock .add( new go.Shape("Ellipse", { fill: 'palegreen', stroke: '#333', strokeWidth: 3, width: 40, height: 40 }), new go.TextBlock({ font: 'bold 12pt sans-serif', stroke: '#333' // some room around the text }) // TextBlock.text is bound to Node.data.key .bind("text", "key") ); diagram.linkTemplate = new go.Link() .add( new go.Shape({ strokeWidth: 3, stroke: "#333" }) ); // create the model data that will be represented by Nodes and Links diagram.model = new go.GraphLinksModel( [ { key: "1" }, { key: "2" }, { key: "3" }, { key: "4" }, { key: "5" }, { key: "6" }, { key: "7" }, { key: "8" }, { key: "9" }, { key: "10" }, { key: "11" }, ], [ { from: "6", to: "2" }, { from: "3", to: "4" }, { from: "3", to: "5" }, { from: "3", to: "6" }, { from: "6", to: "1" }, { from: "6", to: "7" }, { from: "4", to: "8" }, { from: "4", to: "9" }, { from: "4", to: "10" }, { from: "4", to: "11" }, ]); ``` -------------------------------- ### Setup for Legend Source: https://gojs.net/latest/intro/legends.html Initializes the diagram for adding legends. This is a common setup step. ```javascript setupForLegend(diagram); ``` -------------------------------- ### Typical LinkLabelRouter Setup Source: https://gojs.net/latest/api/symbols/LinkLabelRouter.html Demonstrates the basic setup for initializing a LinkLabelRouter with custom ForceDirectedLayout properties. ```typescript myDiagram.routers.add(new LinkLabelRouter({ layoutProps: { defaultElectricalCharge: 100, ... } })); ``` -------------------------------- ### Go Debugging with Delve Source: https://gojs.net/latest/release/go-debug.mjs This snippet shows how to start a Go application with Delve for debugging. Ensure Delve is installed. ```bash dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient ``` -------------------------------- ### Initialize and Start Simulation Source: https://gojs.net/latest/intro/accessibility.html This code initializes the simulation by calling `queueActions1` and then starting the execution loop with `execute1`. ```javascript queueActions1(); execute1(); ``` -------------------------------- ### Find Links by Example Source: https://gojs.net/latest/release/go.mjs Finds links in the diagram that match a given example data object. ```go findLinksByExample(...t){const e=new GSet,i=this.rn.iterator;for(;i.next();){const s=i.value,n=s.data;if(n!==null)for(let o=0;o{const s=this.observed;if(s===null)return;const n=s.viewportBounds,o=this.lastInput.documentPoint;s.position=new Point(o.x-n.width/2,o.y-n.height/2)},this.J2=s=>{this.invalidateDocumentBounds(),this.E0()},this.$2=s=>{this.observed!==null&&(this.invalidateDocumentBounds(),this.L())},this.kb=s=>{this.updateDelay<1?this.L():this.O0||(this.O0=!0,U.yn(()=>this.redraw(),this.updateDelay))},this.Z2=s=>{this.observed!==null&&this.E0()},this.autoScale=2,this.$t=!1,i&&this.setProperties(i),this}setupRouters(){}computePixelRatio(){return 1}redraw(){this.O0&&this.updateDelay>=1&&(this.O0=!1,this.qO()),super.redraw()}vi(){if(this.Lt===null&&U.n("No div specified"),this.ut===null&&U.n("No canvas specified"),this.ut instanceof SVGSurface||(this.box.UM(),!this.Qe))return;const t=this.observed;if(t===null||t.animationManager.defaultAnimation.isAnimating||!t.oa)return;this.T0();const i=this.ut,e=this._t;if(e.clearContextCache(!0),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,i.width,i.height),this.updateDelay<1)this.GL();else if(this.pc!==null){e.drawImage(this.pc.Nt,0,0);const o=this.E;e.scale(this.te,this.te),e.transform(o.m11,o.m12,o.m21,o.m22,o.dx,o.dy),e.commitTransform()}} ``` -------------------------------- ### alternateNodeIndent Source: https://gojs.net/latest/samples/tLayout.html Gets or sets the alternate indentation of the first child. The default value is zero. The value should be non-negative. This property is only sensible when the alignment is Start or End. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node. This sets the alternateDefaults' property of the same name. ```APIDOC ## alternateNodeIndent ### Description Gets or sets the alternate indentation of the first child. ### Property Type number ### Default Value 0 ### Remarks The value should be non-negative. This property is only sensible when the alignment is Start or End. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node. This sets the alternateDefaults' property of the same name. ``` -------------------------------- ### Stepping Through Go Code Source: https://gojs.net/latest/release/go-debug.mjs This example illustrates how to step through your Go code line by line. Use 'step over' to execute a line and move to the next, or 'step into' to enter function calls. ```Go package main import "fmt" func process(value int) { fmt.Printf("Processing: %d\n", value*2) } func main() { data := 10 // Step through this section to observe function calls fmt.Println("Starting process...") process(data) fmt.Println("Process finished.") } ``` -------------------------------- ### Brush Start Point Getter and Setter Source: https://gojs.net/latest/release/go.mjs Gets or sets the starting Spot for linear or radial brushes. ```typescript get start(){return this.ae}set start(t){this.u&&U.L(this,t),this.ae=t.C(),this.Ln=null} ``` -------------------------------- ### Go Tool Class Example Source: https://gojs.net/latest/release/go-debug.mjs Demonstrates the basic structure and methods of a Go Tool class, including event handling and transaction management. ```go isJustDiscarded(){return this.Em}}class Tool{f;At;Gi;Wk;jk;Vm;aT;constructor(){GSet._i(this),this.f=Diagram.Bm(),this.At="",this.Gi=!0,this.Wk=!1,this.jk=null,this.aT=new InputEvent,this.Vm=-1}get diagram(){return this.f}set diagram(t){t instanceof Diagram&&(this.f=t)}toString(){return this.name!==""?this.name+" Tool":U.Jn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){const t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.U(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.U(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.Jk=t.scale;const n=s.x-e.x,o=s.y-e.y,r=Math.sqrt(n*n+o*o);t.$k=r,i.bubbles=!1}Point.o(e),Point.o(s)}standardPinchZoomMove(){const t=this.diagram,i=t.lastInput,e=i.getMultiTouchViewPoint(0,Point.U(NaN,NaN)),s=i.getMultiTouchViewPoint(1,Point.U(NaN,NaN));if(!e.isReal()||!s.isReal()){Point.o(e),Point.o(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){const n=s.x-e.x,o=s.y-e.y,l=Math.sqrt(n*n+o*o)/t.$k,h=new Point((Math.min(s.x,e.x)+Math.max(s.x,e.x))/2,(Math.min(s.y,e.y)+Math.max(s.y,e.y))/2),a=t.Jk*l,f=t.commandHandler;if(a!==t.scale&&f.canResetZoom(a)){const c=t.zoomPoint;t.zoomPoint=h,f.resetZoom(a),t.zoomPoint=c}i.bubbles=!1}Point.o(e),Point.o(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){const t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){const t=this.diagram;if(!t.allowSelect)return;const i=t.lastInput,e=t.findPartAt(i.documentPoint,!1);if(e!==null){if(U.yr?i.meta:i.control){t.F("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.F("ChangedSelection",t.selection)}else if(i.shift){if(!e.isSelected){t.F("ChangingSelection",t.selection);let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.F("ChangedSelection",t.selection)}}else if(!e.isSelected){let s=e;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else i.left&&!(U.yr?i.meta:i.control)&&!i.shift&&t.clearSelection()}standardMouseClick(t,i){t===void 0&&(t=null),i===void 0&&(i=o=>!o.layer?.isTemporary);const e=this.diagram,s=e.lastInput,n=e.findObjectAt(s.documentPoint,t,i);return s.targetObject=n,this.fT(n,s,e)}fT(t,i,e){if(i.handled=!1,t!==null&&!t.isEnabledObject())return!1;let s=0;i.left?i.clickCount===1?s=1:i.clickCount===2?s=2:s=1:i.right&&i.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&e.F(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&e.F(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(i,t),i.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=e.click;break;case 2:o=e.doubleClick?e.doubleClick:e.click;break;case 3:o=e.contextClick;break}o!==null&&o(i)}return i.handled}standardMouseOver(){const t=this.diagram,i=t.lastInput;if(t.animationManager.Ni===!0)return;const e=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(i.documentPoint)?t.findObjectAt(i.documentPoint,null,null):null;i.event&&(i.event.type==="pointercancel"||i.event.type==="pointerout")&&(s=null),i.targetObject=s;let n=!1;if(s!==t.Vf){let o=t.Vf;const r=o;for(t.Vf=s,this.cT(o,s),i.handled=!1;o!==null;){const l=o.mouseLeave;if(l!==null&&(s===o||s!==null&&s.isContainedBy(o)||(l(i,o,s),n=!0,i.handled)))break;o=o.panel}for(o=r,i.handled=!1;s!==null;){const l=s.mouseEnter;if(l!==null&&(o===s||o!==null&&o.isContainedBy(s)||(l(i,s,o),n=!0,i.handled)))break;s=s.panel}s=t.Vf}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,i.handled=!1,o=s;o!==null;){const l=o.mouseOver;if(l!==null&&(l(i,o),n=!0,i.handled))break;o=o.panel}}else{this.doUpdateCursor(null);const o=t.mouseOver;o!==null&&(o(i),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=e}doUpdateCursor(t){const i=this.diagram;i&&(i.currentCursor="")}cT(t,i){}standardMouseWheel(){const t=this.diagram,i=t.lastInput;let e=i.delta;if(e===0||!t.documentBounds.isR ``` -------------------------------- ### Brush Start Radius Getter and Setter Source: https://gojs.net/latest/release/go.mjs Gets or sets the radius for the starting point of a radial brush. Must be non-negative. ```typescript get startRadius(){return this.y0}set startRadius(t){this.u&&U.L(this,t),t<0&&U.J(t,">= zero",Brush,"startRadius"),this.y0=t,this.Ln=null} ``` -------------------------------- ### TextBlock Graduated Start Property Source: https://gojs.net/latest/release/go.mjs Sets or gets the starting point (0.0 to 1.0) for graduated elements. Changes trigger a layout update. ```javascript get graduatedStart(){return this.K!==null?this.K.Rf:0} set graduatedStart(t){const e=this.graduatedStart;e!==t&&(t<0?t=0:t>1&&(t=1),this.K===null&&(this.K=new GradElementSettings),this.K.Rf=t,this.f(),this.t("graduatedStart",e,t))} ``` -------------------------------- ### Setting a Variable Source: https://gojs.net/latest/release/go-debug.mjs Demonstrates how to set a variable in Go. ```go const path = "C:\\Users\\file"; ``` -------------------------------- ### Brush.startRadius Accessor Source: https://gojs.net/latest/api/symbols/Brush.html Gets or sets the radius of a radial brush at the start location. ```APIDOC ## startRadius ### Description Gets or sets the radius of a radial brush at the start location. The default value is 0. ### Returns number ``` -------------------------------- ### Initializing TextEditingTool with Options Source: https://gojs.net/latest/release/go.mjs Demonstrates how to create a new instance of TextEditingTool and configure its properties using an options object. ```javascript constructor(t){ super(), this.name = "TextEditing", this.vi = new TextBlock, this.gM = null, this.mM = 2, this.Gl = null, this.Gt = 1, this.pM = 1, this.yM = !0, this.wM = null, this.Vx = new HTMLInfo, this.Bx = null, this.SR(this.Vx), t && Object.assign(this, t) } ``` -------------------------------- ### Stepping Through Go Code Source: https://gojs.net/latest/release/go-debug.mjs This example illustrates how to step over, step into, and step out of functions during debugging. ```go package main import "fmt" func helperFunction() { fmt.Println("Inside helper function.") } func main() { fmt.Println("Starting main function.") // Use 'step into' to enter helperFunction helperFunction() fmt.Println("Back in main function.") // Use 'step over' to execute this line without entering any called functions fmt.Println("End of program.") } ``` -------------------------------- ### Install FreehandDrawingTool Source: https://gojs.net/latest/api/symbols/FreehandDrawingTool.html Installs the FreehandDrawingTool as the primary mouse down tool in the diagram's tool manager. This allows users to start drawing shapes immediately upon clicking. ```typescript myDiagram.toolManager.mouseDownTools.insertAt(0, new FreehandDrawingTool()); ``` -------------------------------- ### Arrangement Origin and Initial Position Source: https://gojs.net/latest/release/go-debug.mjs Manages the starting point for arrangements. `arrangementOrigin` gets or sets the origin, and `initialOrigin` calculates the starting point, considering group placeholders or the group's position. ```typescript get arrangementOrigin(){return this.yg}set arrangementOrigin(t){Debug&&U.s(t,Point,Layout,"arrangementOrigin"),this.yg.equals(t)||(this.yg.c(t),this.b())} ``` ```typescript initialOrigin(t){const i=this.group;if(i!==null)if(i.hasPlaceholder()){const e=i.placeholder,s=e.getDocumentPoint(Spot.TopLeft);(isNaN(s.x)||isNaN(s.y))&&s.set(t);const n=e.padding;return s.x+=n.left,s.y+=n.top,s}else{const e=i.position.copy();return(isNaN(e.x)||isNaN(e.y))&&e.set(t),e}return t}} ``` -------------------------------- ### Initialize GoJS GridLayout Source: https://gojs.net/latest/samples/gLayout.html Demonstrates how to create a new instance of the GoJS GridLayout. ```javascript new go.GridLayout() ``` -------------------------------- ### Get Default From Point Source: https://gojs.net/latest/release/go.mjs Retrieves the default starting point of the link, typically the first point in its path. ```javascript get defaultFromPoint ``` -------------------------------- ### Diagram Initialization and DOM Setup Source: https://gojs.net/latest/release/go-debug.mjs This snippet demonstrates the core logic for setting up a GoJS Diagram instance, including attaching it to a DOM element, handling resizing, and initializing essential components like the CanvasSurface and ToolManager. It also covers setting up event listeners for mouse and touch interactions. ```javascript static fromDiv(t){let i=t;if(typeof t=="string"&&(i=root.document.getElementById(t)),i instanceof HTMLDivElement){const e=Diagram._e.get(i);if(e)return e}return null}get div(){return this.Lt}set div(t){if(t!==null&&U.s(t,HTMLDivElement,Diagram,"div"),this.Lt!==t){const i=this.Lt;if(i!==null){if(Diagram._e.delete(i),i.goDiagram=void 0,i.go=void 0,i.innerHTML="",this.ut!==null){const s=this.ut.Nt;this.Ii(s,"pointermove",this.Ma,!1),this.Ii(s,"pointerdown",this.mh,!1),this.Ii(s,"pointerup",this.Na,!1),this.Ii(s,"pointerout",this.Ca,!1),this.Ii(s,"pointercancel",this.Aa,!1),this.ut.dispose()}this.hc&&(this.hc.disconnect(),this.hc=null);const e=this.toolManager;e!==null&&(e.mouseDownTools.each(s=>s.cancelWaitAfter()),e.mouseMoveTools.each(s=>s.cancelWaitAfter()),e.mouseUpTools.each(s=>s.cancelWaitAfter())),e.cancelWaitAfter(),this.currentTool.doCancel(),this.ut=null,this.Ii(root,"resize",this.nb,!1),this.Ii(root,"wheel",this.Pa,!0),Diagram.Bm()===this&&Diagram.iL(null)}else this.mh===null&&(this.ro=!1);if(this.Lt=null,t!==null){const e=Diagram._e.get(t);e&&(e.div=null),this.k2(t),this.Ku(),this.themeManager&&this.themeManager.aO()}else this.themeManager&&this.themeManager.fO()}}setupRouters(){this.cc.push(new AvoidsNodesRouter)}k2(t){const i=this;if(!Diagram.isUsingDOM())return;t==null&&U.n("Diagram setup requires an argument DIV."),i.Lt!==null&&U.n("Diagram has already completed setup."),typeof t=="string"?i.Lt=root.document.getElementById(t):t instanceof HTMLDivElement?i.Lt=t:U.n("No DIV or DIV id supplied: "+t),i.Lt===null&&U.n("Invalid DIV id; could not get element with id: "+t);const e=Diagram._e.get(i.Lt);if(e&&e!==this&&U.n("Invalid div id; div already has a Diagram associated with it."),!i.hc&&root.ResizeObserver){const f=root.ResizeObserver,c=U.Dk(()=>i.requestUpdate(),250,!1);i.hc=new f(()=>c()),i.hc.observe(i.Lt)}root.getComputedStyle(i.Lt,null).position==="static"&&(i.Lt.style.position="relative");let s=5;const n="rgba(2"+s+", 255, 255, 0)";s--,i.Lt.style["-webkit-tap-highlight-color" ``` -------------------------------- ### startPoint Source: https://gojs.net/latest/api/symbols/DraggingTool.html Gets or sets the mouse point from which parts start to move. The value is a Point in document coordinates. ```APIDOC ## startPoint ### Description Gets or sets the mouse point from which parts start to move. The value is a Point in document coordinates. This property is normally set to the diagram's mouse-down point in doActivate, but may be set to a different point if parts are being copied from a different control. Setting this property does not raise any events. ### Type Point ``` -------------------------------- ### Overview Component Setup Source: https://gojs.net/latest/release/go.mjs Configures the Overview component, linking it to a Diagram and managing its visual properties like the bounding box and temporary layer drawing. ```typescript get observed(){return this.a1} set observed(t){const e=this.a1;if(t!==null&&U.se(t,Diagram,Overview,"observed"),t instanceof Overview&&U.o("Overview.observed Diagram may not be an Overview itself: "+t),e!==t){if(e!==null&&this.BO(e),this.a1=t,t!==null&&this.zO(t),this.invalidateDocumentBounds(),t===null){this.ff=null;const i=this.lt,s=this.Wt;i&&s&&(s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,i.width,i.height))}else this.u1(null),this.Dp(),this.N();this.t("observed",e,t)}} ``` ```typescript get box(){return this.Xl} set box(t){const e=this.Xl;e!==t&&(t.It(),this.Xl=t,this.remove(e),this.add(this.Xl),this.Dp(),this.t("box",e,t))} ``` ```typescript get drawsTemporaryLayers(){return this.h1} set drawsTemporaryLayers(t){this.h1!==t&&(this.h1=t,this.redraw())} ``` ```typescript get drawsGrid(){return this.c1} set drawsGrid(t){this.c1!==t&&(this.c1=t,this.redraw())} ``` ```typescript get updateDelay(){return this.f1} set updateDelay(t){t<0&&(t=0),this.f1!==t&&(this.f1=t)} ``` ```typescript zO(t){t!==null&&(t.addDiagramListener("ViewportBoundsChanged",this.Y2),t.addDiagramListener("DocumentBoundsChanged",this.K2),t.addDiagramListener("InvalidateDraw",this.u1),t.addDiagramListener("AnimationFinished",this.H2),this.add(this.box))} ``` ```typescript BO(t){t!==null&&(this.remove(this.box),t.removeDiagramListener("ViewportBoundsChanged",this.Y2),t.removeDiagramListener("DocumentBoundsChanged",this.K2),t.removeDiagramListener("InvalidateDraw",this.u1),t.removeDiagramListener("AnimationFinished",this.H2))} ``` ```typescript Dp(){const t=this.box,e=this.observed;if(e===null)return;this.Wi=!0;const i=e.viewportBounds,s=t.selectionObject,n=Size.l();n.e(i.width,i.height),Size.i(n);const o=2/this.scale;s instanceof Shape&&(s.strokeWidth=o),t.location=new Point(i.x-o/2,i.y-o/2),t.isSelected=!0} ``` ```typescript computeBounds(){const t=this.observed;if(t===null)return Rect.tm;const e=t.documentBounds.copy();return e.unionRect(t.viewportBounds),e} ``` ```typescript invalidateViewport(t,e){this.Wi!==!0&&(this.Wi=!0,this.requestUpdate())} ``` ```typescript onViewportBoundsChanged(t,e,i,s){this.Ht||(this.Qr(),this.N(),this.Mh(),this.invalidateDocumentBounds(),this.Dp(),this.Ye.scale=i,this.Ye.position.x=t.x,this.Ye.position.y=t.y,this.Ye.bounds.h(t),this.Ye.isScroll=s,this.T("ViewportBoundsChanged",this.Ye,t))}} ``` -------------------------------- ### alternateNodeIndent Source: https://gojs.net/latest/api/symbols/TreeLayout.html Gets or sets the alternate indentation of the first child. This property is useful for reserving space at the start of a row of children. ```APIDOC ## alternateNodeIndent ### Description Gets or sets the alternate indentation of the first child. ### Type number ### Default Value zero ### Remarks The value should be non-negative. This property is only sensible when the alignment is Start or End. Having a positive value is useful if you want to reserve space at the start of the row of children for some reason. For example, if you want to pretend the parent node is infinitely deep, you can set this to be the breadth of the parent node. This sets the alternateDefaults' property of the same name. ``` -------------------------------- ### Setup Grid Layers in Go Source: https://gojs.net/latest/release/go-debug.mjs Initializes and adds several layers to the diagram, including Grid, ViewportBackground, Background, Foreground, ViewportForeground, Adornment, and Tool layers. These layers are used for rendering different visual elements. ```go sL(){let t=0,i=new Layer;i.name="Grid",i.allowSelect=!1,i.pickable=!1,i.isTemporary=!0,i.isInDocumentBounds=!1,this.el(i,t++),i=new Layer,i.name="ViewportBackground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.el(i,t++),i=new Layer,i.name="Background",this.el(i,t++),i=new Layer,i.name="",this.el(i,t++),i=new Layer,i.name="Foreground",this.el(i,t++),i=new Layer,i.name="ViewportForeground",i.isViewportAligned=!0,i.isTemporary=!0,i.isInDocumentBounds=!1,this.el(i,t++),i=new Layer,i.name="Adornment",i.isTemporary=!0,i.isInDocumentBounds=!1,this.el(i,t++),i=new Layer,i.name="Tool",i.isTemporary=!0,i.isInDocumentBounds=!0,this.el(i,t++)} ``` -------------------------------- ### TextBlock TextAlign Property Source: https://gojs.net/latest/release/go-debug.mjs Illustrates getting and setting the text alignment for a TextBlock. Accepts 'start', 'end', 'left', 'right', or 'center'. ```javascript get textAlign(){ return this.nt!==null?this.nt.Qp:"start" } set textAlign(t){ const i=this.textAlign; i!==t&& (Debug&&U.i(t,"string",TextBlock,"textAlign"), t==="start"||t==="end"||t==="left"||t==="right"||t==="center"? (this.Bs().Qp=t,this.L(),this.t("textAlign",i,t)) :Debug&&U.G(t,'"start", "end", "left", "right", or "center"',TextBlock,"textAlign")) } ``` -------------------------------- ### Get Roots Property in GoJS TreeLayout Source: https://gojs.net/latest/release/go.mjs Accessor for the root nodes of the tree layout. The roots property is used to define the starting points for the layout. ```typescript get roots(){return this.Ie} ``` -------------------------------- ### Finding Nodes by Example Properties Source: https://gojs.net/latest/intro/usingModels.html Demonstrates how to find nodes that match specific property values using Diagram.findNodesByExample. This returns a collection of matching nodes. ```javascript const nodes = myDiagram.findNodesByExample({ text: "something", count: 17 }); nodes.each(n => console.log(n.key)); ``` -------------------------------- ### Using `log` Package for Debugging Source: https://gojs.net/latest/release/go-debug.mjs Demonstrates how to use the standard `log` package for debugging output. This is useful for logging events and variable states, especially in concurrent programs. ```go package main import ( "fmt" "log" ) func main() { userID := 123 log.Printf("Processing user ID: %d", userID) // Simulate some work result := userID * 2 log.Printf("Result for user %d is %d", userID, result) fmt.Println("Done.") } ``` -------------------------------- ### PathSegment Angle Properties (Arc) Source: https://gojs.net/latest/release/go.mjs Gets or sets the start angle and sweep angle for an arc segment. These define the portion of the ellipse that forms the arc. ```javascript get startAngle() { return this.ni; } set startAngle(t) { this.u && U.L(this, t), t = t % 360, t < 0 && (t += 360), this.ni = t, this.yt = !0; } get sweepAngle() { return this.oi; } set sweepAngle(t) { this.u && U.L(this, t), t > 360 && (t = 360), t < -360 && (t = -360), this.oi = t, this.yt = !0; } ``` -------------------------------- ### Initialize Main Diagram and Overview Source: https://gojs.net/latest/intro/overview.html This snippet shows how to initialize a main GoJS Diagram with a node template and sample data, and then create an Overview component linked to this main diagram. ```javascript // initialize the main Diagram diagram.nodeTemplate = new go.Node("Auto") .add( new go.Shape("Rectangle", { fill: "white" }) .bind("fill", "color"), new go.TextBlock({ margin: 5 }) .bind("text", "color") ); // start off with a lot of nodes const nodeDataArray = []; for (let i = 0; i < 1000; i++) { nodeDataArray.push({ color: go.Brush.randomColor() }); } diagram.model.nodeDataArray = nodeDataArray; // create the Overview and initialize it to show the main Diagram const myOverview = new go.Overview("myOverviewDiv", { observed: diagram }); ``` -------------------------------- ### wasSubGraphExpanded Source: https://gojs.net/latest/api/symbols/Group.html Gets or sets whether the subgraph starting at this group had been collapsed by a call to expandSubGraph on the containing Group. The initial value is false. `see` isSubGraphExpanded ```APIDOC ## wasSubGraphExpanded ### Description Indicates whether the subgraph originating from this group was previously collapsed by a call to `expandSubGraph` on its containing `Group`. This property is primarily for internal tracking and reflects the state before potential expansion. The default value is `false`. ### Property Type boolean ### Default Value false ### Related Properties - `isSubGraphExpanded` ``` -------------------------------- ### Overview Diagram Setup Source: https://gojs.net/latest/samples/addToPalette.html Initializes an Overview diagram by setting its 'observed' property to the main Diagram. This allows the Overview to display the entire diagram and the current viewport. ```javascript var myOverview = G(go.Overview, "myOverviewDiv", { "observed": myDiagram, "contentAlignment": go.Spot.Center }); ``` -------------------------------- ### Brush.start Accessor Source: https://gojs.net/latest/api/symbols/Brush.html Gets or sets the starting location for a linear or radial gradient. The value is a Spot specifying a relative point in the object's GraphObject.naturalBounds. ```APIDOC ## start ### Description Gets or sets the starting location for a linear or radial gradient. A Spot value specifies a relative point in the object's GraphObject.naturalBounds. The default value is Spot.TopCenter for linear gradients and Spot.Center for radial gradients. ### Returns Spot ``` -------------------------------- ### Programmatically Start Linking Tool Source: https://gojs.net/latest/api/symbols/LinkingTool.html This snippet shows how to programmatically initiate the LinkingTool. Set the startObject property to define the starting point for link creation and then activate the tool. ```javascript const tool = myDiagram.toolManager.linkingTool; tool.startObject = ...; myDiagram.currentTool = tool; tool.doActivate(); ``` -------------------------------- ### Animating Multiple Nodes Source: https://gojs.net/latest/intro/animation.html This example animates the 'angle' property of multiple nodes in a diagram. It's more efficient to group properties into a single animation if they start and have the same duration. ```javascript // define a simple Node template diagram.nodeTemplate = new go.Node("Spot", { locationSpot: go.Spot.Center }) .bind("angle") .add( new go.Shape("Diamond", { strokeWidth: 0, width: 75, height: 75 }) .bind("fill", "color"), new go.TextBlock({ margin: 8, font: 'bold 12pt sans-serif' }) .bind("text") ); diagram.model = new go.GraphLinksModel( [ { key: 1, text: "Alpha", color: "lightblue" }, { key: 2, text: "Beta", color: "orange" }, { key: 3, text: "Gamma", group: 'G1', color: "lightgreen" }, { key: 4, text: "Delta", group: 'G1', color: "pink", angle: 45 } ], [ { from: 1, to: 2 }, { from: 3, to: 4 } ]); window.animate1 = () => { const animation = new go.Animation(); diagram.nodes.each(node => { // Animate the clockwise turning of a node from its current angle to a random value animation.add(node, "angle", node.angle, node.angle + Math.random() * 180); }); animation.duration = 1000; // Animate over 1 second, instead of the default 600 milliseconds animation.start(); // starts the animation immediately } ``` -------------------------------- ### Manual Animation Example Source: https://gojs.net/latest/api/symbols/Animation.html Demonstrates how to create and start a manual animation on a Node's position and a Shape's fill. This animation runs simultaneously on both properties. ```javascript const node = myDiagram.nodes.first(); const shape = part.findObject("SHAPE"); // assumes this Node contains a go.Shape with .name = "SHAPE" const animation = new go.Animation(); // Animate this Node from its current position to (400, 500) animation.add(node, "position", node.position, new go.Point(400, 500)); // Animate the fill of the Shape within the Node, from its current color to blue animation.add(shape, "fill", shape.fill, "blue"); // Both of these effects will animate simultaneously when start() is called: animation.start(); ``` -------------------------------- ### allowDragOut Source: https://gojs.net/latest/api/symbols/Diagram.html Gets or sets whether the user may start a drag-and-drop operation in this Diagram, potentially dropping it in a different HTML element. The initial value is false. ```APIDOC ## allowDragOut ### Description Gets or sets whether the user may start a drag-and-drop in this Diagram, possibly dropping in a different element. The initial value is false. ### Type boolean ``` -------------------------------- ### Stepping Through Go Code Source: https://gojs.net/latest/release/go-debug.mjs This example shows how to step over, step into, and step out of functions using Delve commands. Essential for tracing execution flow. ```bash (dlv) next (dlv) step (dlv) continue (dlv) restart ``` -------------------------------- ### wasTreeExpanded Property Source: https://gojs.net/latest/api/symbols/Node.html Gets or sets a boolean indicating whether the subtree graph starting at this node was collapsed by a call to expandTree on its parent. The initial value is false. ```APIDOC ## wasTreeExpanded ### Description Gets or sets whether the subtree graph starting at this node had been collapsed by a call to expandTree on the parent node. The initial value is false. `see` isTreeExpanded ### Method GET/SET ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) boolean #### Response Example None ```