Hi Everyone,
I worked out how to implement this.
I added a transform script on the 'props.scheduledEvents' of the Equipment Schedule component binding itself.
Process:
- Loop over each event.
- Copy it (
dict(e)
). - If
.label == "TEST"
, set["color"] = "#6ECEB2"
; otherwise, set a default. - Append the copy to a new list.
- Output: Return the new list. Each event now has its own
"color"
. - Outcome: The component (e.g. the Schedule) automatically consumes that
"color"
field to render events with the correct hex code.
def transform(self, value, quality, timestamp):
# Transform script for property binding. Assume "value" is the incoming array of event‐objects.
events = value # e.g. [{ "itemId":1, "eventId":16, "label":"TEST", ... }, {...}, ...]
# We'll produce a new list, so that each event gets a "color" attribute based on its label.
out = []
for e in events:
# Make a shallow copy so we do not overwrite the original
newEvent = dict(e)
if newEvent.get('label') == "TEST":
newEvent['backgroundColor'] = "#6ECEB2"
else:
# either leave it blank or give it a default color
newEvent['backgroundColor'] = "#FFBE9F"
out.append(newEvent)
return out
Hope this help's anyone else.