process-analytics / bpmn-visualization-js

A TypeScript library for visualizing process execution data on BPMN diagrams
https://process-analytics.github.io/bpmn-visualization-js/
Apache License 2.0
224 stars 31 forks source link

[FEAT] Add fill and stroke attributes in xml to draw colors per bpmn element #2588

Closed Andrii-Deiak closed 1 year ago

Andrii-Deiak commented 1 year ago

Is your feature request related to a problem? Please describe.

XML file is parsed without consideration of stroke/fill attributes for elements. The goal to have for example two circles with different colors defined in the xml file to be rendered with different colors.

Describe the solution you'd like

Allow in xml attributes: bioc:stroke="#000000" bioc:fill="#ffd726" So they can be parsed and drawn on UI.

tbouffard commented 1 year ago

Hi @Andrii-Deiak

The bioc:stroke="#000000" bioc:fill="#ffd726" attributes seem to use the bpmn.io specific BPMN extensions for handling colors. Can you confirm this please, by providing an example of BPMN diagram? We mainly need to have the namespace declarations at the top of the file, and a file to reproduce what you describe. Fill free to provide an anonymized file and attach it to a comment in this issue.

We have no plan to support the bpmn.io color extension. We may support the BPMN in Color Specification in the future, but we do not plan to do so in the short term.

However, bpmn-visualization already provides several ways to add colors to a BPMN diagram. You can use CSS classes and/or use the new "Update Style" API starting from v0.33.0. They let you customize the colors at runtime, and change the colors depending on the use case, without having to hard code them at modeling time.

If you need some pointers to get some examples about how to add colors, please let us know.

Andrii-Deiak commented 1 year ago

HI @tbouffard , thank you for the response! The goal is to have some predefined colors in the xml file per each bpmn element and then render it with colors. It that possible to achieve?

Attaching the example of bpmn with colors:

bpmn-with-colors.txt

If I upload this bpmn example to https://cdn.statically.io/gh/process-analytics/bpmn-visualization-examples/master/examples/misc/compare-with-kie-editors-standalone/index.html the result is without colors:

image

Note: in the bpmn example we use bioc:fill="#da1217" bioc:stroke="#8abff7", but it does not render these colors.

image

This is what we expect to be rendered (predefined colors in xml and render with those colors):

image

Thanks!

tbouffard commented 1 year ago

Hi @Andrii-Deiak and thanks for providing the BPMN file.

Reproduction

I have been able to reproduce what you mentioned with https://cdn.statically.io/gh/process-analytics/bpmn-visualization-examples/v0.33.0/examples/misc/compare-with-bpmn-js/index.html. This is the example that let us compare the BPMN rendering of bpmn-visualization and bpmn-js.

Here is the comparison between bpmn-visualization@0.33.0 and bpmn-js@11.1.1 👇🏿

bpmn-with-colors txt_comparison_bpmn-visualization@0 33 0_bpmn-js@11 1 1

Diagram analysis

The BPMN diagram content confirms what I suggested in https://github.com/process-analytics/bpmn-visualization-js/issues/2588#issuecomment-1475808306. It uses both

The diagram uses a mixture of the two types of color definitions. For example:

Questions

Like I said in https://github.com/process-analytics/bpmn-visualization-js/issues/2588#issuecomment-1475808306, we don't support the colors defined in the BPMN diagram, and don't plan to support that in the short term. However, we may change our plan based on user feedback.

So, could you help us by answering these questions:

Thanks

tbouffard commented 1 year ago

@Andrii-Deiak I have recently opened a Pull Request to support what is described in this issue: #2614.

You can open your diagram with (this environment will be available as far as the PR is opened) https://process-analytics-bpmn-visualization-js-demo_preview-pr-2614.surge.sh/dev/public/.

Here is what I get when I display a diagram based on the one you provided.

xml-parsing_test_issue-2588-both-bpmn-in-color-and-bpmnio_infor-modeler bpmn

Andrii-Deiak commented 1 year ago

@tbouffard thank you for quick response. I imported xml with colors to this environment https://process-analytics-bpmn-visualization-js-demo_preview-pr-2614.surge.sh/dev/public/. Works fine! Looking forward to see these changes in main branch ❤️

tbouffard commented 1 year ago

@Andrii-Deiak thanks for the feedback. We will try to make it available in the next version (or the next one). There are some remaining tasks, in particular to make the support configurable (it will be disable by default).

tbouffard commented 1 year ago

ℹ️ The implementation is almost complete, in particular, the color support is now disable by default. This feature should be included in version 0.35.0 scheduled for the end of May.

tbouffard commented 1 year ago

We have just merged the new implementation that will be included in the next release.

tbouffard commented 1 year ago

The implementation has just been released with https://github.com/process-analytics/bpmn-visualization-js/releases/tag/v0.35.0.