goJS is an awesome tools bu I dont understand why it’s so complicated to do a node template… My node template is like :
The corresponding code is :
this.go(go.Node, 'Table',
{
locationSpot: go.Spot.Center,
background: '#00FFF0',
padding: 5,
},
this.go(go.Shape, 'RoundedRectangle', {
spot1: go.Spot.TopLeft,
spot2: go.Spot.BottomRight,
rowSpan: 999,
columnSpan: 999,
margin: new go.Margin(0, 0),
stretch: go.GraphObject.Fill,
strokeWidth: 1,
stroke: scheme.ui.input.normal.border.color,
fill: this.go(go.Brush, 'Linear', {
0: '#F2F2F2',
0.1: '#FFFFFF',
0.9: '#FFFFFF',
1: '#EEEEEE',
}),
}),
this.go(go.Panel, 'Vertical',
{
column: 0,
defaultAlignment: go.Spot.Left,
itemTemplate: this.getPortTemplate(go.Spot.Left, this.properties),
},
),
this.go(go.Panel, 'Vertical',
{
column: 2,
defaultAlignment: go.Spot.Right,
itemTemplate: this.getPortTemplate(go.Spot.Right, this.properties),
},
),
this.go(go.Panel, 'Horizontal',
{
column: 1,
stretch: go.GraphObject.Fill,
background: '#0000FF',
},
this.go(go.TextBlock, 'Un autre',
{
verticalAlignment: go.Spot.Center,
font: '700 12pt "SourceSansPro", sans-serif',
stroke: this.props.scheme.ui.input.normal.forecolor,
textAlign: 'center',
wrap: go.TextBlock.None,
angle: 270,
margin: new go.Margin(10, 0),
stretch: go.GraphObject.Fill,
minSize: new go.Size(30, 50),
},
),
With this item template :
getPortTemplate(alignment, properties, pinColor = this.props.scheme.ui.input.normal.border.color) {
const { portSize, portMargin } = this.props;
let geo;
if (alignment === go.Spot.Left) {
geo = 'F M11.3 0H0v14h11.3c3.8 0 7-3 7-7s-3.2-7-7-7z';
} else {
geo = 'F M7 14h11.3V0H7C3 0 0 3 0 7s3 7 7 7z';
}
const circle = this.go(go.Shape, 'Circle',
{
strokeWidth: 0,
desiredSize: new go.Size(portSize - (portSize / 2), portSize - (portSize / 2)),
cursor: 'pointer',
fromSpot: alignment,
toSpot: alignment,
},
);
const pin = this.go(go.Panel, 'Auto',
{
background: '#FF0000',
},
this.go(go.Shape, {
geometryString: geo,
margin: new go.Margin(0, 0.5),
strokeWidth: 0,
fill: pinColor,
desiredSize: new go.Size(portSize * 1.1, portSize),
}),
circle,
);
const label = properties.display.portDisplayType !== types.PortDisplayType.None ?
this.go(go.TextBlock,
{
background: '#00FF00',
font: '9pt "SourceSansPro", sans-serif',
stroke: '#888888',
margin: new go.Margin(2, 8, 0, 8),
verticalAlignment: go.Spot.MiddleLeft,
},
) : null;
const panel = this.go(go.Panel, 'Horizontal',
{
background: '#FFF000',
alignment,
margin: new go.Margin(portMargin / 2, 0),
},
);
if (alignment === go.Spot.Left) {
panel.add(pin);
if (label !== null) panel.add(label);
} else {
if (label !== null) panel.add(label);
panel.add(pin);
}
return panel;
}
Q1. Without port text, the final width of the node template is lower than 100px but it’s seem the node object as a default width of 100px I cant delete. How to correct this size ? That doesn’t work with minSize = new go.Size(NaN, …)
Q2. I add two new panel (column 0, row 0 and column 0, row 2) on the left colum, how to center the content of the column 0, row 1 ? A stretch fill/vertical doesn’t work.
EDIT : Work with a rowSpan 3 and a margin top/bottom. Is this the only solution ?