File tree Expand file tree Collapse file tree 4 files changed +38
-24
lines changed Expand file tree Collapse file tree 4 files changed +38
-24
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,27 @@ module.exports = function(opts) {
20
20
var editType = opts . editType ;
21
21
var colorEditType = opts . colorEditType ;
22
22
if ( colorEditType === undefined ) colorEditType = editType ;
23
+
24
+ var weight = {
25
+ editType : editType ,
26
+ valType : 'integer' ,
27
+ min : 1 ,
28
+ max : 1000 ,
29
+ extras : [ 'normal' , 'bold' ] ,
30
+ dflt : 'normal' ,
31
+ description : [
32
+ 'Sets the weight (or boldness) of the font.'
33
+ ] . join ( ' ' )
34
+ } ;
35
+
36
+ if ( opts . noNumericWeightValues ) {
37
+ weight . valType = 'enumerated' ;
38
+ weight . values = weight . extras ;
39
+ weight . extras = undefined ;
40
+ weight . min = undefined ;
41
+ weight . max = undefined ;
42
+ }
43
+
23
44
var attrs = {
24
45
family : {
25
46
valType : 'string' ,
@@ -49,17 +70,7 @@ module.exports = function(opts) {
49
70
editType : colorEditType
50
71
} ,
51
72
52
- weight : {
53
- editType : editType ,
54
- valType : 'integer' ,
55
- min : 1 ,
56
- max : 1000 ,
57
- extras : [ 'normal' , 'bold' ] ,
58
- dflt : 'normal' ,
59
- description : [
60
- 'Sets the weight (or boldness) of the font.'
61
- ] . join ( ' ' )
62
- } ,
73
+ weight : weight ,
63
74
64
75
style : {
65
76
editType : editType ,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ var attrs = module.exports = overrideAll({
41
41
editType : 'calc' ,
42
42
colorEditType : 'style' ,
43
43
arrayOk : true ,
44
+ noNumericWeightValues : true ,
44
45
variantValues : [ 'normal' , 'small-caps' ] ,
45
46
description : 'Sets the text font.'
46
47
} ) ,
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ function convertTextStyle(gd, trace) {
190
190
if (
191
191
isArrayOrTypedArray ( tfs ) ||
192
192
Array . isArray ( tff ) ||
193
- Array . isArray ( tfw ) ||
193
+ Lib . isArrayOrTypedArray ( tfw ) ||
194
194
Array . isArray ( tfy ) ||
195
195
Array . isArray ( tfv )
196
196
) {
@@ -207,7 +207,7 @@ function convertTextStyle(gd, trace) {
207
207
) * plotGlPixelRatio ;
208
208
209
209
fonti . family = Array . isArray ( tff ) ? tff [ i ] : tff ;
210
- fonti . weight = Array . isArray ( tfw ) ? tfw [ i ] : tfw ;
210
+ fonti . weight = weightFallBack ( Lib . isArrayOrTypedArray ( tfw ) ? tfw [ i ] : tfw ) ;
211
211
fonti . style = Array . isArray ( tfy ) ? tfy [ i ] : tfy ;
212
212
fonti . variant = Array . isArray ( tfv ) ? tfv [ i ] : tfv ;
213
213
}
@@ -216,7 +216,7 @@ function convertTextStyle(gd, trace) {
216
216
optsOut . font = {
217
217
size : tfs * plotGlPixelRatio ,
218
218
family : tff ,
219
- weight : tfw ,
219
+ weight : weightFallBack ( tfw ) ,
220
220
style : tfy ,
221
221
variant : tfv
222
222
} ;
@@ -225,6 +225,12 @@ function convertTextStyle(gd, trace) {
225
225
return optsOut ;
226
226
}
227
227
228
+ function weightFallBack ( w ) {
229
+ if ( w <= 1000 ) {
230
+ return w > 500 ? 'bold' : 'normal' ;
231
+ }
232
+ return w ;
233
+ }
228
234
229
235
function convertMarkerStyle ( gd , trace ) {
230
236
var count = trace . _length ;
Original file line number Diff line number Diff line change @@ -65049,13 +65049,11 @@
65049
65049
"description": "Sets the weight (or boldness) of the font.",
65050
65050
"dflt": "normal",
65051
65051
"editType": "calc",
65052
- "extras": [
65052
+ "valType": "enumerated",
65053
+ "values": [
65053
65054
"normal",
65054
65055
"bold"
65055
- ],
65056
- "max": 1000,
65057
- "min": 1,
65058
- "valType": "integer"
65056
+ ]
65059
65057
},
65060
65058
"weightsrc": {
65061
65059
"description": "Sets the source reference on Chart Studio Cloud for `weight`.",
@@ -70939,13 +70937,11 @@
70939
70937
"description": "Sets the weight (or boldness) of the font.",
70940
70938
"dflt": "normal",
70941
70939
"editType": "calc",
70942
- "extras": [
70940
+ "valType": "enumerated",
70941
+ "values": [
70943
70942
"normal",
70944
70943
"bold"
70945
- ],
70946
- "max": 1000,
70947
- "min": 1,
70948
- "valType": "integer"
70944
+ ]
70949
70945
},
70950
70946
"weightsrc": {
70951
70947
"description": "Sets the source reference on Chart Studio Cloud for `weight`.",
You can’t perform that action at this time.
0 commit comments