Ich verwende GoJS, um das Diagramm zu erstellen.GoJS: Wie kann ich die Farbe der Knotenfarbe ändern?
Meine Diagramm-Konfiguration (das Beispiel von der offiziellen Dokumentation):
function init() {
//......
// define the Node template
myDiagram.nodeTemplate =
$(go.Node, "Auto",
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
// define the node's outer shape, which will surround the TextBlock
$(go.Shape, "RoundedRectangle",
{
parameter1: 20, // the corner has a large radius
fill: $(go.Brush, "Linear", { 0: "rgb(254, 201, 0)", 1: "rgb(254, 162, 0)" }),
stroke: null,
portId: "", // this Shape is the Node's port, not the whole Node
fromLinkable: true, fromLinkableSelfNode: true, fromLinkableDuplicates: true,
toLinkable: true, toLinkableSelfNode: true, toLinkableDuplicates: true,
cursor: "pointer"
}),
$(go.TextBlock,
{
font: "bold 11pt helvetica, bold arial, sans-serif",
editable: true // editing the text automatically updates the model data
},
new go.Binding("text").makeTwoWay())
);
//......
}
ich die Knoten in der folgenden Art und Weise zu erstellen:
var nodeOperations = new Object();
for (var i = 0; i < countState; i++) {
var json = {'id': i, 'loc': nodesCenters[i].x +' '+nodesCenters[i].y, 'text': markedStateTable['digitStates'][i] + ', ' + markedStateTable['namedStates'][i]};
nodes.push(json);
}
Und jetzt ich ändern müssen programmatisch die Füllfarbe für bestimmten Knoten. Ich versuche diesen Code:
Aber danach wird mein Diagramm nicht angezeigt. Und es gibt keinen Fehler in der Konsole. Sollte ich die neue Form für den Knoten festlegen? Oder wie kann ich das tun? Danke für Ihre Hilfe!
danke @Geethu jose –