Ok, but what should this “service” be? In the starter example there is a div with the id #canvas to which the dmn is bind. So I thought, that in this case the id of the element was ment.
If I change this to canvas I get this error:
could not import DMN 1.1 diagram Error: "No provider for "canvas"! (Resolving: canvas)"
You told me that there is no documentation. So I have to adapt the examples. In the starter Example there is this block included with the zoom fit viewport. I don’t know if I have to define that. If I remove this codeblock the dmn still works - I think.
For what should this be? Could I remove that?
I don’t have a special expectation why I’m using this - only because the example includes it.
The example shows you how to access components within the DmnJS instance. Due to the nature of the library (it essentially hosts a number of different editors, one for each view) we’d actually need to take the active editor into account when fetching internal components.
The following will only work if we’re currently viewing a DRD, which is the case in the example.
var activeEditor = dmnModeler.getActiveViewer();
// access active editor components
var canvas = activeEditor.get('canvas');
// zoom to fit full viewport
canvas.zoom('fit-viewport');
The better way to approach it would be to check for the active view’s type and act accordingly:
var activeView = dmnModeler.getActiveView();
if (activeView.type === 'drd') {
var activeEditor = dmnModeler.getActiveViewer();
// access active editor components
var canvas = activeEditor.get('canvas');
// zoom to fit full viewport
canvas.zoom('fit-viewport');
}