@walter I am still struggling
There is extra space between rows and columns that come up when I add color bar as new part
here is the code
scope.init = function () {
if (window.goSamples) goSamples(); // init for these samples -- you don't need to call this
var = go.GraphObject.make;
$scope.myDiagram =
$(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center,
layout: $(TableLayout
//$(go.RowColumnDefinition, {row: 1, height: 22}), // fixed size column headers
//$(go.RowColumnDefinition, {column: 1, width: 22}) // fixed size row headers
),
"SelectionMoved": function (e) {
e.diagram.layoutDiagram(true);
},
"undoManager.isEnabled": true
});
$scope.myDiagram.allowHorizontalScroll = false;
$scope.myDiagram.allowVerticalScroll = false;
$scope.myDiagram.allowMove = false;
$scope.myDiagram.allowSelect = false;
$scope.myDiagram.allowZoom = false;
$scope.myDiagram.padding = 0;
$scope.myDiagram.resizingTool = true;
$scope.myDiagram.nodeTemplate = // for regular nodes within cells (groups); you'll want to extend this
$(go.Node, "Auto",
// {size:new go.Size(20, 20)}, // assume uniform Margin, all around
new go.Binding("row"),
new go.Binding("column", "col"),
$(go.Shape, {fill: "white"},
new go.Binding("fill", "color"),
new go.Binding("desiredSize", "size")
),
$(go.Picture,
// stretch the image to occupy all the space
{imageStretch: go.GraphObject.Fill},
new go.Binding("source", "img"),
new go.Binding("angle", "setAngle"),
new go.Binding("desiredSize", "size")
),
$(go.TextBlock,
new go.Binding("text", "key"))
);
$scope.addColorBar = function () {
$scope.myDiagram.nodeTemplateMap.add("Header", // an overall table header, at the top
$(go.Part, "Auto",
{
row: 0, column: 0,columnSpan: 9999,
stretch: go.GraphObject.Horizontal,
selectable: false, pickable: false,
padding:10
},
$(go.Picture, {
source: "colorBar.jpg",
//angle: 90,
desiredSize: new go.Size(400, 20),
imageStretch: go.GraphObject.Fill
})
));
$scope.myDiagram.nodeTemplateMap.add("Sider", // an overall table header, on the left side
$(go.Part, "Auto",
{
row: 0, column: 0,rowSpan: 9999,
stretch: go.GraphObject.Vertical,
selectable: false, pickable: false,
padding:10
},
$(go.Picture, {
source: "colorBar.jpg",
angle: 90,
desiredSize: new go.Size(400, 20),
imageStretch: go.GraphObject.Fill
})
));
$scope.allNodes.push( { key: "Sider", text: "Personnel", category: "Sider" });
$scope.allNodes.push( { key: "Header", text: "Vacation Procedures", category: "Header" });
$scope.myDiagram.model = new go.GraphLinksModel($scope.allNodes);
$scope.myDiagram.requestUpdate();
};
$scope.allNodes = [
{key: "Delta", row: 1, col: 1, size: new go.Size(100, 50), color: "orange", img: "IMG_4938.JPG"},
{key: "Epsilon", row: 1, col: 2, color: "coral", size: new go.Size(100, 50)},
{key: "Zeta", row: 2, col: 1, color: "tomato", size: new go.Size(100, 50)},
{key: "Eta", row: 2, col: 2, color: "coral", size: new go.Size(100, 50)},
{key: "Theta", row: 3, col: 1, color: "tomato", size: new go.Size(100, 50)},
];
$scope.myDiagram.model = new go.GraphLinksModel($scope.allNodes);
};
$scope.updateDiagram = function () {
setTimeout(function () {
$scope.myDiagram.startTransaction("change Layout");
$scope.myDiagram.contentAlignment = go.Spot["TopCenter"];
$scope.myDiagram.commitTransaction("change Layout");
$scope.myDiagram.requestUpdate();
//$scope.myPalette.requestUpdate();
}, 1000);
};
ScreenShot
When there is no color bar then there is no space.
Horizontal space comes with horizontal color bar
respectively vertical.