process-analytics/bpmn-visualization-pm4py

[REFACTOR] Use the bpmn-visualization API to set element styles

tbouffard opened this issue · 0 comments

Currently, the demo uses custom mxGraph code to style elements.
process-analytics/bpmn-visualization-js#1030 will provide a new way to style the BPMN Elements. So, we should use it here when it is available.

This is currently done at least in:

  • let style = mxgraph.mxUtils.setStyle(activityCurrentStyle, 'fillColor', myFrequencyScale(freqValue))
    mxGraph.getModel().setStyle(activityCell, style);
    activityCurrentStyle = mxGraph.getModel().getStyle(activityCell)
    //different ways of setting the style
    //mxGraph.setCellStyles("fillColor", myFrequencyScale(freqValue), [activityCell]);
    //or
    //mxGraph.setCellStyles(mxgraph.mxConstants.STYLE_FILLCOLOR, 'red', [activityCell]);
    //set label to white when the activity fillColor is above the scale average
    if (freqValue > avg){
    style = mxgraph.mxUtils.setStyle(activityCurrentStyle, 'fontColor', 'white')
    mxGraph.getModel().setStyle(activityCell, style);
    //different way of setting the style
    //mxGraph.setCellStyles("fontColor", "white", [activityCell]);
    }
  • mxGraph.getModel().beginUpdate()
    try {
    mxgraph.mxUtils.setCellStyles(mxGraph.getModel(), activityCells, "fillColor", "none")
    mxgraph.mxUtils.setCellStyles(mxGraph.getModel(), activityCells, "fontColor", "none")
    } finally {
    mxGraph.getModel().endUpdate();
    }