11'use strict' ;
22const { DATE_FORMAT_LINK , FORMAT_LINK } = require ( '../constants/docs' ) ;
33
4+ const MISSING_UNDEFINED_DESCRIPTION = [
5+ "Variables that can't be found will be replaced with the specifier." ,
6+ 'For example, a template of "data: %{x}, %{y}" will result in a value of "data: 1, %{y}" if x is 1 and y is missing.' ,
7+ 'Variables with an undefined value will be replaced with the fallback value.'
8+ ] . join ( ' ' ) ;
9+
410function templateFormatStringDescription ( { supportOther } = { } ) {
511 const supportOtherText =
612 ' as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown.' ;
@@ -13,7 +19,8 @@ function templateFormatStringDescription({ supportOther } = {}) {
1319 'for details on the formatting syntax.' ,
1420 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".' ,
1521 DATE_FORMAT_LINK ,
16- 'for details on the date formatting syntax.'
22+ 'for details on the date formatting syntax.' ,
23+ MISSING_UNDEFINED_DESCRIPTION
1724 ] . join ( ' ' ) ;
1825}
1926exports . templateFormatStringDescription = templateFormatStringDescription ;
@@ -64,7 +71,7 @@ exports.texttemplateAttrs = ({ editType = 'calc', arrayOk } = {}, extra = {}) =>
6471 ...( arrayOk !== false ? { arrayOk : true } : { } )
6572} ) ;
6673
67- exports . shapeTexttemplateAttrs = ( { editType = 'arraydraw' , newshape } , extra = { } ) => ( {
74+ exports . shapeTexttemplateAttrs = ( { editType = 'arraydraw' , newshape } = { } , extra = { } ) => ( {
6875 valType : 'string' ,
6976 dflt : '' ,
7077 editType,
@@ -83,13 +90,14 @@ exports.shapeTexttemplateAttrs = ({ editType = 'arraydraw', newshape }, extra =
8390 'd3 number formatting, for example "Length in cm: %{x0*2.54}", "%{slope*60:.1f} meters per second."' ,
8491 'For log axes, variable values are given in log units.' ,
8592 'For date axes, x/y coordinate variables and center variables use datetimes, while all other variable values use values in ms.' ,
86- describeVariables ( extra )
93+ describeVariables ( extra ) ,
94+ MISSING_UNDEFINED_DESCRIPTION
8795 ] . join ( ' ' )
8896} ) ;
8997
9098exports . templatefallbackAttrs = ( { editType = 'none' } = { } ) => ( {
9199 valType : 'string' ,
92- dflt : '' ,
100+ dflt : '- ' ,
93101 editType,
94- description : "Fallback value that's displayed when a variable referenced in a template can't be found ."
102+ description : "Fallback value that's displayed when a variable referenced in a template has an undefined value ."
95103} ) ;
0 commit comments