Yes, but how to color the sequential flow, how to make ‘yes’-path green, how to fill the square and how to do all of this dinamiclly ?
Thanks in advance
I guess this is difficult to explain without an example so here’s one. Through canRender our custom renderer tells bpmn-js that is will render sequence flows. We then render the sequence flows using the original BPMN renderer and only change the color of the sequence flow based on its name. There are two approaches that I have sketched in the example:
Render the sequence flow using the original BPMN renderer and set the given color afterward. As you can see the arrowheads aren’t affected. The utility for rendering colored arrowheads (cf. https://github.com/bpmn-io/bpmn-js/blob/develop/lib/draw/BpmnRenderer.js#L141) isn’t exposed by bpmn-js so you’d have to copy the entire utility.
Monkey-patch the DI to make the renderer render the sequence flow with a given color. This is an anti-pattern, but for the sake of showing that it can be done, I sketched it anyway. As you can see this will also render the arrowheads in the with the given color.
drawConnection(parentNode, element) {
const { businessObject, di } = element;
const stroke = di.get("color:border-color");
if (businessObject.get("name") === "yes") {
di.set("color:border-color", "green");
} else if (businessObject.get("name") === "no") {
di.set("color:border-color", "red");
}
const connection = this.bpmnRenderer.drawConnection(parentNode, element);
// restore original color and hope no one noticed :clown_face:
di.set("color:border-color", stroke);
return connection;
}
}