Hello,
sorry for the delay. I was now able to create an example for this issue.
See demo here (change version in script tag to see difference):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GoJS Spot Panel ItemArray Demo</title>
<!-- Works -->
<!-- <script src="https://unpkg.com/[email protected]/release/go.js"></script> -->
<!-- Does not work -->
<script src="https://unpkg.com/[email protected]/release/go.js"></script>
<style>
html,
body {
height: 100%;
margin: 0;
font-family: Arial, sans-serif;
background: #f5f5f5;
}
#myDiagramDiv {
width: 100%;
height: 100vh;
background: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
header {
padding: 1rem;
background: #2f4f4f;
color: #ffffff;
text-align: center;
}
main {
height: calc(100vh - 70px);
display: flex;
justify-content: center;
align-items: center;
padding: 1rem;
}
</style>
</head>
<body>
<header>
<h1>GoJS Spot Panel with itemArray</h1>
<p>
This demo adds parts directly to the diagram and uses a Spot Panel's
itemTemplate to position TextBlocks.
</p>
</header>
<main>
<div id="myDiagramDiv"></div>
</main>
<script>
(function () {
const $ = go.GraphObject.make;
const diagram = $(go.Diagram, "myDiagramDiv", {
"undoManager.isEnabled": true,
});
const part = $(
go.Part,
"Spot",
{
location: new go.Point(0, 0),
layerName: "Foreground",
},
$(go.Shape, "RoundedRectangle", {
name: "SHAPE",
fill: "#dae4e4",
stroke: "#2f4f4f",
strokeWidth: 2,
width: 260,
height: 180,
spot1: go.Spot.TopLeft,
spot2: go.Spot.BottomRight,
})
);
part.itemTemplate = $(
go.Panel,
"Auto",
new go.Binding("alignment", "alignment", go.Spot.parse),
$(
go.Shape,
"RoundedRectangle",
{
fill: "#ffffff",
stroke: "#2f4f4f",
strokeWidth: 1,
parameter1: 8,
minSize: new go.Size(48, 24),
},
new go.Binding("fill", "fill"),
new go.Binding("stroke", "stroke")
),
$(
go.TextBlock,
{
font: "bold 11pt sans-serif",
margin: new go.Margin(4, 6, 4, 6),
wrap: go.TextBlock.WrapFit,
textAlign: "center",
},
new go.Binding("text", "text")
)
);
part.itemArray = [
{ text: "Top Left", alignment: "0 0", fill: "#f9f9f9" },
{ text: "Top", alignment: "0.5 0", fill: "#fcf2d9" },
{ text: "Top Right", alignment: "1 0", fill: "#f9f9f9" },
{ text: "Left", alignment: "0 0.5", fill: "#d9f2fc" },
{
text: "Center",
alignment: "0.5 0.5",
fill: "#ffffff",
stroke: "#1e88e5",
},
{ text: "Right", alignment: "1 0.5", fill: "#d9f2fc" },
{ text: "Bottom Left", alignment: "0 1", fill: "#f9f9f9" },
{ text: "Bottom", alignment: "0.5 1", fill: "#fcf2d9" },
{ text: "Bottom Right", alignment: "1 1", fill: "#f9f9f9" },
];
diagram.add(part);
})();
</script>
</body>
</html>