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) {
2020 var editType = opts . editType ;
2121 var colorEditType = opts . colorEditType ;
2222 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+
2344 var attrs = {
2445 family : {
2546 valType : 'string' ,
@@ -49,17 +70,7 @@ module.exports = function(opts) {
4970 editType : colorEditType
5071 } ,
5172
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 ,
6374
6475 style : {
6576 editType : editType ,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ var attrs = module.exports = overrideAll({
4141 editType : 'calc' ,
4242 colorEditType : 'style' ,
4343 arrayOk : true ,
44+ noNumericWeightValues : true ,
4445 variantValues : [ 'normal' , 'small-caps' ] ,
4546 description : 'Sets the text font.'
4647 } ) ,
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ function convertTextStyle(gd, trace) {
190190 if (
191191 isArrayOrTypedArray ( tfs ) ||
192192 Array . isArray ( tff ) ||
193- Array . isArray ( tfw ) ||
193+ Lib . isArrayOrTypedArray ( tfw ) ||
194194 Array . isArray ( tfy ) ||
195195 Array . isArray ( tfv )
196196 ) {
@@ -207,7 +207,7 @@ function convertTextStyle(gd, trace) {
207207 ) * plotGlPixelRatio ;
208208
209209 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 ) ;
211211 fonti . style = Array . isArray ( tfy ) ? tfy [ i ] : tfy ;
212212 fonti . variant = Array . isArray ( tfv ) ? tfv [ i ] : tfv ;
213213 }
@@ -216,7 +216,7 @@ function convertTextStyle(gd, trace) {
216216 optsOut . font = {
217217 size : tfs * plotGlPixelRatio ,
218218 family : tff ,
219- weight : tfw ,
219+ weight : weightFallBack ( tfw ) ,
220220 style : tfy ,
221221 variant : tfv
222222 } ;
@@ -225,6 +225,12 @@ function convertTextStyle(gd, trace) {
225225 return optsOut ;
226226}
227227
228+ function weightFallBack ( w ) {
229+ if ( w <= 1000 ) {
230+ return w > 500 ? 'bold' : 'normal' ;
231+ }
232+ return w ;
233+ }
228234
229235function convertMarkerStyle ( gd , trace ) {
230236 var count = trace . _length ;
Original file line number Diff line number Diff line change @@ -65049,13 +65049,11 @@
6504965049 "description": "Sets the weight (or boldness) of the font.",
6505065050 "dflt": "normal",
6505165051 "editType": "calc",
65052- "extras": [
65052+ "valType": "enumerated",
65053+ "values": [
6505365054 "normal",
6505465055 "bold"
65055- ],
65056- "max": 1000,
65057- "min": 1,
65058- "valType": "integer"
65056+ ]
6505965057 },
6506065058 "weightsrc": {
6506165059 "description": "Sets the source reference on Chart Studio Cloud for `weight`.",
@@ -70939,13 +70937,11 @@
7093970937 "description": "Sets the weight (or boldness) of the font.",
7094070938 "dflt": "normal",
7094170939 "editType": "calc",
70942- "extras": [
70940+ "valType": "enumerated",
70941+ "values": [
7094370942 "normal",
7094470943 "bold"
70945- ],
70946- "max": 1000,
70947- "min": 1,
70948- "valType": "integer"
70944+ ]
7094970945 },
7095070946 "weightsrc": {
7095170947 "description": "Sets the source reference on Chart Studio Cloud for `weight`.",
You can’t perform that action at this time.
0 commit comments