Skip to content

Commit 7f02e26

Browse files
committed
fix(custom-chart-web): apply conditional layout config
1 parent 2bae55f commit 7f02e26

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

packages/pluggableWidgets/custom-chart-web/src/controllers/ChartPropsController.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,18 @@ export class ChartPropsController implements ReactiveController {
8484
height: this.sizeProvider.height,
8585
autosize: true,
8686
font: {
87-
family: "Open Sans, sans-serif",
88-
size: Math.max(12 * (this.sizeProvider.width / 1000), 8)
87+
family: this.layout.font?.family ? this.layout.font.family : "Open Sans, sans-serif",
88+
size: this.layout.font?.size
89+
? this.layout.font.size
90+
: Math.max(12 * (this.sizeProvider.width / 1000), 8)
8991
},
9092
legend: {
9193
...this.layout.legend,
9294
font: {
9395
...this.layout.legend?.font,
94-
size: Math.max(10 * (this.sizeProvider.width / 1000), 7)
96+
size: this.layout.legend?.font?.size
97+
? this.layout.legend.font.size
98+
: Math.max(10 * (this.sizeProvider.width / 1000), 7)
9599
},
96100
itemwidth: Math.max(10 * (this.sizeProvider.width / 1000), 3),
97101
itemsizing: "constant"
@@ -100,23 +104,27 @@ export class ChartPropsController implements ReactiveController {
100104
...this.layout.xaxis,
101105
tickfont: {
102106
...this.layout.xaxis?.tickfont,
103-
size: Math.max(10 * (this.sizeProvider.width / 1000), 7)
107+
size: this.layout.xaxis?.tickfont?.size
108+
? this.layout.xaxis.tickfont.size
109+
: Math.max(10 * (this.sizeProvider.width / 1000), 7)
104110
}
105111
},
106112
yaxis: {
107113
...this.layout.yaxis,
108114
tickfont: {
109115
...this.layout.yaxis?.tickfont,
110-
size: Math.max(10 * (this.sizeProvider.width / 1000), 7)
116+
size: this.layout.yaxis?.tickfont?.size
117+
? this.layout.yaxis.tickfont.size
118+
: Math.max(10 * (this.sizeProvider.width / 1000), 7)
111119
}
112120
},
113121
margin: {
114122
...this.layout.margin,
115-
l: 60,
116-
r: 60,
117-
t: 60,
118-
b: 60,
119-
pad: 10
123+
l: this.layout.margin?.l ? this.layout.margin.l : 60,
124+
r: this.layout.margin?.r ? this.layout.margin.r : 60,
125+
t: this.layout.margin?.t ? this.layout.margin.t : 60,
126+
b: this.layout.margin?.b ? this.layout.margin.b : 60,
127+
pad: this.layout.margin?.pad ? this.layout.margin.pad : 10
120128
}
121129
};
122130
}

0 commit comments

Comments
 (0)