Custom fill of nodeTemplate

Hi, I have nodeTemplate config below:

(go.Panel, 'Auto', { stretch: go.GraphObject.Horizontal }, (go.Shape,
{ fill: ‘#4dbd74’, stroke: null, height: 35 }),
alignment: go.Spot.Center,
new go.Binding(‘text’, ‘label’))),

In fill property, how can i set color’ code base on key of node, ex:

{ fill: key===‘Alpha’ ? ‘4dbd74’ : ‘black’ , stroke: null, height: 35 }),

  • nodeDataArray: [
    key: ‘Alpha’, label: ‘Alpha’,
    key: ‘Beta’, label: ‘Beta’,

Thanks a lot !

Use a Binding on the Shape targeting the Shape.fill property, with the source being the “key” property, using a conversion function that checks the key value and returns the desired color.
Please read

1 Like

Thank you for a quickly support!