A BPMN process diagram is a formidable place to visualize information around your process. We recommend to use JavaScript libraries to display process diagrams and enrich them with additional information.
In our web applications Cockpit and Tasklist, we use bpmn.io, a toolkit for rendering BPMN 2.0 process models directly in the browser. It allows adding additional information to the diagram and includes ways for user interaction. Although bpmn.io is still under development, its API is rather stable.
The previous JavaScript BPMN renderer can still be found at camunda-bpmn.js, but it is not actively developed anymore.
bpmn.io Diagram Renderer
To render a process diagram, you need to retrieve the diagram XML via the Java- or REST API. The following example shows how to render the process XML using bpmn.io. For more documentation regarding the annotation of the diagram and user interaction, please refer to the bpmn.io page.
var BpmnViewer = require('bpmn-js');
var xml = getBpmnXml(); // get the process xml via REST
var viewer = new BpmnViewer({ container: 'body' });
viewer.importXML(xml, function(err) {
if (err) {
console.log('error rendering', err);
} else {
console.log('rendered');
}
});
Alternatively, you can use the bpmn-viewer widget from the Camunda commons UI.
原文: https://docs.camunda.org/manual/7.9/user-guide/process-engine/process-diagram-api/