Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
commitLayers: function () {
// optional: add circles in the background
// need to remove any old ones first
let diagram = this.diagram;
let gridlayer = diagram.findLayer('Grid');
let circles = new go.Set(go.Part);
gridlayer.parts.each((circle: any) => {
if (circle.name === 'CIRCLE') { circles.add(circle); }
});
circles.each(function (circle) {
diagram.remove(circle);
});
// add circles centered at the root
// let $ = go.GraphObject.make; // for conciseness in defining templates
for (let lay = 1; lay <= this.maxLayers; lay++) {
let radius = lay * this.layerThickness;
let circle =
$(go.Part,
{ name: 'CIRCLE', layerName: 'Grid' },
{ locationSpot: go.Spot.Center, location: this.root.location },
$(go.Shape, 'Circle',
{ width: radius * 2, height: radius * 2 },
{ stroke: '#333333',
font: 'bold 14px sans-serif',
margin: new go.Margin(0, 10, 0, 0) },
new go.Binding('text', 'name')),
$(go.TextBlock,
{ stroke: '#333333',
font: 'bold 14px sans-serif' },
new go.Binding('text', 'desc'))
)
// define the Node template, representing an entity
this.diagram.nodeTemplate =
$(go.Node, 'Auto', // the whole node panel
{ selectionAdorned: true,
resizable: true,
layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
fromSpot: go.Spot.AllSides,
toSpot: go.Spot.AllSides,
isShadowed: true,
shadowColor: '#C5C1AA' },
new go.Binding('location', 'location').makeTwoWay(),
// whenever the PanelExpanderButton changes the visible property of the 'LIST' panel,
// clear out any desiredSize set by the ResizingTool.
new go.Binding('desiredSize', 'visible', () => new go.Size(NaN, NaN)).ofObject('LIST'),
// define the node's outer shape, which will surround the Table
$(go.Shape, 'Rectangle',
{ fill: this.getBrush('lightgrad'), stroke: '#756875', strokeWidth: 3 }),
$(go.Panel, 'Table',
{ margin: 8, stretch: go.GraphObject.Fill },
$(go.RowColumnDefinition, { row: 0, sizing: go.RowColumnDefinition.None }),
// the table header
$(go.TextBlock,
// need to remove any old ones first
let diagram = this.diagram;
let gridlayer = diagram.findLayer('Grid');
let circles = new go.Set(go.Part);
gridlayer.parts.each((circle: any) => {
if (circle.name === 'CIRCLE') { circles.add(circle); }
});
circles.each(function (circle) {
diagram.remove(circle);
});
// add circles centered at the root
// let $ = go.GraphObject.make; // for conciseness in defining templates
for (let lay = 1; lay <= this.maxLayers; lay++) {
let radius = lay * this.layerThickness;
let circle =
$(go.Part,
{ name: 'CIRCLE', layerName: 'Grid' },
{ locationSpot: go.Spot.Center, location: this.root.location },
$(go.Shape, 'Circle',
{ width: radius * 2, height: radius * 2 },
{ fill: 'rgba(200,200,200,0.2)', stroke: null }));
diagram.add(circle);
}
}
});