jwytd
February 17, 2020, 9:41am
1
import BpmnViewer from 'bpmn-js/lib/Viewer'
var elementRegistry = this.bpmnViewer.get('elementRegistry'),
**modeling = this.bpmnViewer.get('modeling');**
var elementToColor = elementRegistry.get('usertask1');
modeling.setColor([ elementToColor ], {
stroke: 'green',
fill: 'rgba(0, 80, 0, 0.4)'
});
Error:
I really need help. thank you.
First, please make sure your Code is readable .
Modeling
is not available in the Viewer, so you can’t use the functionality there. You would have to use the Modeler instead.
jwytd
February 17, 2020, 1:28pm
3
I just want to show my process diagrams,Don’t want to edit id, so i use Viewer,but i want to change the node color.
You don’t need to create a custom renderer. The bpmn-js default renderer can render colors. You can use low-level APIs to set the color without using Modeling
:
const businessObject = element.businessObject;
businessObject.di.set('stroke', stroke);
businessObject.di.set('fill', fill);
const gfx = elementRegistry.getGraphics(element);
const type = element.waypoints ? 'connection' : 'shape';
graphicsFactory.update(type, element, gfx);
jwytd
February 18, 2020, 2:03am
6
philippfromme:
graphicsFactory
I solved the problem by your way. thank you very much. @philippfromme @Niklas_Kiefer
graphicsFactory ?? where did you get it? thank you
graphicsFactory ?? where did you get it? thank you