Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 0e8325b

Browse files
committed
handle font colors black/white
1 parent 0b420f8 commit 0e8325b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

frontend/src/discovery.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function visualizeFrequency(data) {
5050
//set the frequency color scale
5151
const values = Object.values(data);
5252
const max = Math.max(...values);
53+
const avg = max/2;
5354
const myFrequencyScale = frequencyScale(0, max)
5455

5556
//change activity style through mxGraph
@@ -67,9 +68,16 @@ function visualizeFrequency(data) {
6768
activityCell = mxGraph.getModel().getCell(activityElement.bpmnSemantic.id)
6869
activityCurrentStyle = mxGraph.getModel().getStyle(activityCell)
6970
mxGraph.getModel().beginUpdate()
70-
try {
71-
let style = mxgraph.mxUtils.setStyle(activityCurrentStyle, "fillColor", myFrequencyScale(freqValue))
71+
try {
72+
let style = mxgraph.mxUtils.setStyle(activityCurrentStyle, 'fillColor', myFrequencyScale(freqValue))
7273
mxGraph.getModel().setStyle(activityCell, style);
74+
activityCurrentStyle = mxGraph.getModel().getStyle(activityCell)
75+
76+
//set label to white when the activity fillColor is above the scale average
77+
if (freqValue > avg){
78+
style = mxgraph.mxUtils.setStyle(activityCurrentStyle, 'fontColor', 'white')
79+
mxGraph.getModel().setStyle(activityCell, style);
80+
}
7381
} finally {
7482
mxGraph.getModel().endUpdate();
7583
}

0 commit comments

Comments
 (0)