Thanks.
One problem solved, now a new one rearing its head.
I have tried binding with the textAlign
and the alignment
properties to each text block, as I would like to give the end user the ability to control the text alignment at this individual level.
https://gojs.net/latest/intro/textblocks.html
However, behavior never works exactly the way I want it too.
For example, in one scenario, when the Heading is “wider” (text-wise) than the Body text, then when I align the Body text, it might move left, right, or center, but only within the original constraints of the Heading. (Heading starts out as “My Heading”, then gets edited to “My Custom Heading Description (whatever…)”, and then when I enter body text that on any single line is less in width than the Heading, and try to align it, the alignment does not reach the edges of the Shape.
Both Heading and Body have the ability to be multi-line.
I have tried various combinations other than the one you see here below. All very frustrating, because in normal html and css, this alignment problem would be dead simple to resolve.
myDiagram.nodeTemplateMap.add("Step",
$(go.Node, "Auto", nodeStyle(),
{
locationSpot: go.Spot.Center
},
new go.Binding("location", "loc", go.Point.parse),
$(go.Shape, "Rectangle",
{
fill: "yellow",
strokeWidth: 2,
minSize: new go.Size(100, NaN)
//maxSize: new go.Size(400, NaN)
},
new go.Binding("fill", "outerShapeFill"),
new go.Binding("stroke", "outerShapeStrokeColor"),
new go.Binding("strokeWidth", "outerShapeStrokeWidth"),
new go.Binding("figure", "figure")
),
$(go.Panel, "Vertical",
$(go.TextBlock,
{
margin: 10,
//editable: false,
font: "bold 12pt Roboto, Arial, sans-serif",
wrap: go.TextBlock.WrapFit,
isMultiline: true,
textAlign: "center"
},
new go.Binding("stroke", "textColor"),
new go.Binding("text", "textHeading"),
new go.Binding("textAlign", "textHeadingAlign")
// if using SINGLE LINE text INPUT instead of TEXTAREA go.Spot.Center
// new go.Binding("alignment", "textHeadingAlign", function (t) { return go.Spot[t]; })
),
$(go.TextBlock,
{
margin: new go.Margin(0, 10, 10, 10),
//textAlign: "start",
font: "12pt Roboto, Arial, sans-serif",
wrap: go.TextBlock.WrapFit,
isMultiline: true,
textAlign: "center",
visible: false
}, // default to not visible, in case there's no data.body property
new go.Binding("stroke", "textColor"),
new go.Binding("text", "textMain"),
new go.Binding("textAlign", "textMainAlign"),
new go.Binding("visible", "textMain", function (t) { return !!t; })
)
),
makePort("T", go.Spot.Top, false, true),
makePort("L", go.Spot.Left, true, true),
makePort("R", go.Spot.Right, true, true),
makePort("B", go.Spot.Bottom, true, false)
)
);