Skip to content

Commit 3f857b0

Browse files
committed
Setting edge label backgound correctly.
1 parent 26a2cb0 commit 3f857b0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/dgmlParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class DgmlParser {
415415
if (setter.property.toLowerCase() === 'fontweight') {
416416
category.fontWeight = setter.value;
417417
}
418-
if (setter.property.toLowerCase() === 'background') {
418+
if (setter.property.toLowerCase() === 'background' && category.background === undefined) { // background color on the category overrides background color on the styling
419419
category.background = setter.value;
420420
}
421421
if (setter.property.toLowerCase() === 'horizontalalignment') {

src/model/Edge.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,16 @@ export class Edge extends BaseElement {
8282
if (this.categoryRef !== undefined) {
8383
titleElements.push(`Category: ${this.categoryRef.id}`);
8484
}
85-
if (this.categoryRef !== undefined && this.categoryRef.background !== undefined) {
86-
jsStringProperties.push(`backgroundColor: '${this.convertColorValue(this.categoryRef.background)}'`);
85+
if (this.background !== undefined) {
86+
jsStringProperties.push(`backgroundColor: '${this.convertColorValue(this.background)}', backgroundOpacity: 1`);
8787
}
8888
else {
89-
jsStringProperties.push(`backgroundColor: 'rgba(63, 124, 227, 1)'`);
89+
if (this.categoryRef !== undefined && this.categoryRef.background !== undefined) {
90+
jsStringProperties.push(`backgroundColor: '${this.convertColorValue(this.categoryRef.background)}', backgroundOpacity: 1`);
91+
}
92+
else {
93+
jsStringProperties.push(`backgroundColor: '', backgroundOpacity: 0`);
94+
}
9095
}
9196
if (this.categoryRef !== undefined && this.categoryRef.stroke !== undefined) {
9297
jsStringProperties.push(`color: '${this.convertColorValue(this.categoryRef.stroke)}'`);

templates/dgmlViewer_Template.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@
245245
'target-arrow-shape': edgeArrowType,
246246
'target-arrow-color': 'data(color)',
247247
'line-style': 'data(lineStyle)',
248+
'text-background-color': 'data(backgroundColor)',
249+
'text-background-opacity': 'data(backgroundOpacity)',
248250
}
249251
}
250252
],

0 commit comments

Comments
 (0)