@@ -14,7 +14,7 @@ Most of the properties in each of the interfaces are optionals, as users may not
14
14
This function therefore instantiates defaults where user values have not been provided.
15
15
This creates a styles object that is passed to the chart.
16
16
*/
17
- import { AxisStyle , CentileStyle , SDSStyle , ChartStyle , GridlineStyle , MeasurementStyle } from '../interfaces/StyleObjects' ;
17
+ import { AxisStyle , CentileStyle , SDSStyle , ChartStyle , GridlineStyle , MeasurementStyle , ReferenceStyle } from '../interfaces/StyleObjects' ;
18
18
19
19
const black = '#000000' ;
20
20
const white = '#FFFFFF' ;
@@ -35,7 +35,8 @@ function makeAllStyles(
35
35
centileStyle ?: CentileStyle ,
36
36
sdsStyle ?: SDSStyle ,
37
37
measurementStyle ?: MeasurementStyle ,
38
- textMultiplier ?: number // this is used to scale text size based on the aspect ratio of the chart using the height and width. Default is 1
38
+ textMultiplier ?: number , // this is used to scale text size based on the aspect ratio of the chart using the height and width. Default is 1
39
+ referenceStyle ?: ReferenceStyle ,
39
40
) {
40
41
41
42
let newGridlineStyle = {
@@ -70,17 +71,20 @@ function makeAllStyles(
70
71
fontSize : ( chartStyle ?. tooltipTextStyle ?. size ?? 14 ) * ( textMultiplier ?? 1 ) ,
71
72
fill : chartStyle ?. tooltipTextStyle ?. colour ?? black ,
72
73
fontFamily : chartStyle ?. tooltipTextStyle ?. name ?? 'Montserrat' ,
74
+ fontWeight : chartStyle ?. tooltipTextStyle ?. weight ?? 400 ,
73
75
fontStyle : chartStyle ?. tooltipTextStyle ?. style ?? 'normal' ,
74
76
textAnchor : "start"
75
77
} ,
76
78
chartTitle : {
77
- fontFamily : chartStyle ?. titleStyle ?. name ?? 'Arial' ,
79
+ fontFamily : chartStyle ?. titleStyle ?. name ?? 'Arial' ,
80
+ fontWeight : chartStyle ?. subTitleStyle ?. weight ?? 700 ,
78
81
color : chartStyle ?. titleStyle ?. colour ?? black ,
79
82
fontSize : chartStyle ?. titleStyle ?. size ?? 14 ,
80
83
fontStyle : chartStyle ?. titleStyle ?. style === 'italic' ? 'italic' : 'normal' ,
81
84
} ,
82
85
chartSubTitle : {
83
86
fontFamily : chartStyle ?. subTitleStyle ?. name ?? 'Arial' ,
87
+ fontWeight : chartStyle ?. subTitleStyle ?. weight ?? 700 ,
84
88
color : chartStyle ?. subTitleStyle ?. colour ?? black ,
85
89
fontSize : chartStyle ?. subTitleStyle ?. size ?? 14 ,
86
90
fontStyle : chartStyle ?. subTitleStyle ?. style === 'italic' ? 'italic' : 'normal' ,
@@ -96,17 +100,19 @@ function makeAllStyles(
96
100
padding : 20 ,
97
101
fill : axisStyle ?. axisLabelTextStyle ?. colour ?? black ,
98
102
fontFamily : axisStyle ?. axisLabelTextStyle ?. name ?? 'Arial' ,
103
+ fontWeight : axisStyle ?. axisLabelTextStyle ?. weight ?? 400 ,
99
104
fontStyle : axisStyle ?. axisLabelTextStyle ?. style ?? 'normal' ,
100
105
} ,
101
106
ticks : {
102
107
stroke : axisStyle ?. tickLabelTextStyle ?. colour ?? black ,
103
108
} ,
104
109
tickLabels : {
105
110
fontSize : ( axisStyle ?. tickLabelTextStyle ?. size ?? 8 ) * ( textMultiplier ?? 1 ) ,
106
- padding : 5 ,
111
+ padding : axisStyle ?. tickLabelTextStyle ?. padding ?? 5 ,
107
112
fill : axisStyle ?. tickLabelTextStyle ?. colour ?? black ,
108
113
color : axisStyle ?. tickLabelTextStyle ?. colour ?? black ,
109
114
fontFamily : axisStyle ?. axisLabelTextStyle ?. name ?? 'Arial' ,
115
+ fontWeight : axisStyle ?. axisLabelTextStyle ?. weight ?? 400 ,
110
116
fontStyle : axisStyle ?. axisLabelTextStyle ?. style ?? 'normal' ,
111
117
} ,
112
118
grid : {
@@ -117,6 +123,7 @@ function makeAllStyles(
117
123
fill : axisStyle ?. tickLabelTextStyle ?. colour ?? black ,
118
124
fontSize : ( axisStyle ?. tickLabelTextStyle ?. size ?? 8 ) * ( textMultiplier ?? 1 ) ,
119
125
fontFamily : axisStyle ?. tickLabelTextStyle ?. name ?? 'Arial' ,
126
+ fontWeight : axisStyle ?. tickLabelTextStyle ?. weight ?? 400 ,
120
127
fontStyle : axisStyle ?. axisLabelTextStyle ?. style ?? 'normal' ,
121
128
} ,
122
129
yAxis : {
@@ -129,6 +136,7 @@ function makeAllStyles(
129
136
padding : 25 ,
130
137
fill : axisStyle ?. axisLabelTextStyle ?. colour ?? black ,
131
138
fontFamily : axisStyle ?. axisLabelTextStyle ?. name ?? 'Arial' ,
139
+ fontWeight : axisStyle ?. axisLabelTextStyle ?. weight ?? 400 ,
132
140
fontStyle : axisStyle ?. axisLabelTextStyle ?. style ?? 'normal' ,
133
141
} ,
134
142
ticks : {
@@ -139,6 +147,7 @@ function makeAllStyles(
139
147
padding : 5 ,
140
148
fill : axisStyle ?. tickLabelTextStyle ?. colour ?? black ,
141
149
fontFamily : axisStyle ?. axisLabelTextStyle ?. name ?? 'Arial' ,
150
+ fontWeight : axisStyle ?. axisLabelTextStyle ?. weight ?? 400 ,
142
151
fontStyle : axisStyle ?. axisLabelTextStyle ?. style ?? 'normal' ,
143
152
} ,
144
153
grid : {
@@ -154,19 +163,20 @@ function makeAllStyles(
154
163
} ,
155
164
delayedPubertyThresholdLine : {
156
165
data : {
157
- stroke : charcoal ,
166
+ stroke : axisStyle . axisThresholdLineStyle ?. colour ?? charcoal ,
158
167
strokeWidth : 1 ,
159
168
} ,
160
169
} ,
161
170
delayedPubertyThresholdLabel : {
162
- fontSize : ( 9 ) * ( textMultiplier ?? 1 ) ,
163
- fill : axisStyle ?. axisLabelTextStyle ?. colour ?? black ,
164
- fontFamily : axisStyle ?. axisLabelTextStyle ?. name ?? 'Arial' ,
171
+ fontSize : ( axisStyle ?. axisThresholdLabelTextStyle ?. size ?? 9 ) * ( textMultiplier ?? 1 ) ,
172
+ fill : axisStyle ?. axisThresholdLabelTextStyle ?. colour ?? black ,
173
+ fontFamily : axisStyle ?. axisThresholdLabelTextStyle ?. name ?? 'Arial' ,
174
+ fontWeight : axisStyle ?. axisThresholdLabelTextStyle ?. weight ?? 400 ,
165
175
textAlign : 'start' ,
166
176
} ,
167
177
nondisjunctionThresholdLine : {
168
178
data : {
169
- stroke : charcoal ,
179
+ stroke : axisStyle . axisThresholdLineStyle ?. colour ?? charcoal ,
170
180
strokeWidth : 1 ,
171
181
} ,
172
182
} ,
@@ -194,9 +204,10 @@ function makeAllStyles(
194
204
} ,
195
205
} ,
196
206
centileLabel : {
197
- fontSize : ( 6 ) * ( textMultiplier ?? 1 ) ,
198
- fontFamily : 'Montserrat' ,
199
- fill : centileStyle ?. centileStroke ?? black
207
+ fontSize : ( centileStyle . centileTextStyle ?. size ?? 6 ) * ( textMultiplier ?? 1 ) ,
208
+ fontFamily : centileStyle . centileTextStyle ?. name ?? 'Montserrat' ,
209
+ fontWeight : centileStyle . centileTextStyle ?. weight ?? 400 ,
210
+ fill : centileStyle ?. centileStroke ?? black ,
200
211
} ,
201
212
heightSDS : {
202
213
data : {
@@ -275,11 +286,19 @@ function makeAllStyles(
275
286
activeColour : chartStyle ?. toggleButtonActiveColour ?? black ,
276
287
inactiveColour : chartStyle ?. toggleButtonInactiveColour ?? midGrey ,
277
288
fontFamily : chartStyle ?. toggleButtonTextStyle ?. name ?? 'Arial' ,
289
+ fontWeight : chartStyle ?. toggleButtonTextStyle ?. weight ?? 400 ,
278
290
color : chartStyle ?. toggleButtonTextStyle ?. colour ?? white ,
279
291
fontSize : chartStyle ?. toggleButtonTextStyle ?. size ?? 14 ,
280
292
fontStyle : chartStyle ?. toggleButtonTextStyle ?. style === 'italic' ? 'italic' : 'normal' ,
281
293
margin : 0
282
294
} ,
295
+ referenceTextStyle : {
296
+ fontSize : referenceStyle ?. size ?? 8 ,
297
+ fontFamily : referenceStyle ?. name ?? 'Arial' ,
298
+ color : referenceStyle ?. colour ?? black ,
299
+ fontWeight : referenceStyle ?. weight ?? 200 ,
300
+ fontStyle : referenceStyle ?. style ?? 'normal' ,
301
+ } ,
283
302
} ;
284
303
}
285
304
0 commit comments