External Button click change the shape dynamically

hi ,
Please provide some examples to add new node in the external button click to add Rectangle/Circle shape in the Go Js.

How to add dynamically node data to different shapes in the existing diagram.

myDiagram.startTransaction(“make new node”);
var node = go.GraphObject.make(
{ key:“gamma”, locationSpot: go.Spot.Center, rotatable: true },
go.GraphObject.make(go.Shape, “Circle”, {
fill: “blue”,
stroke: null,
strokeWidth: 0,


myDiagram.commitTransaction(“make new node”);

The problem is that your code assumes that GoJS just has a document architecture, whereas it actually has a model architecture. Adding a node means calling Model.addNodeData with a simple plain JavaScript object, not with an instance of a Node.

Please read https://gojs.net/latest/learn/index.html and https://gojs.net/latest/learn/graphObject.html and https://gojs.net/latest/intro/usingModels.html