@@ -4,15 +4,20 @@ var docs = require('../constants/docs');
44var FORMAT_LINK = docs . FORMAT_LINK ;
55var DATE_FORMAT_LINK = docs . DATE_FORMAT_LINK ;
66
7- var templateFormatStringDescription = [
8- 'Variables are inserted using %{variable}, for example "y: %{y}".' ,
9- 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".' ,
10- FORMAT_LINK ,
11- 'for details on the formatting syntax.' ,
12- 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".' ,
13- DATE_FORMAT_LINK ,
14- 'for details on the date formatting syntax.'
15- ] . join ( ' ' ) ;
7+ function templateFormatStringDescription ( opts ) {
8+ var supportOther = opts && opts . supportOther ;
9+
10+ return [
11+ 'Variables are inserted using %{variable},' ,
12+ 'for example "y: %{y}".' + ( supportOther ? ' as well as %{xother} when positions do not match' : '' ) ,
13+ 'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".' ,
14+ FORMAT_LINK ,
15+ 'for details on the formatting syntax.' ,
16+ 'Dates are formatted using d3-time-format\'s syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}".' ,
17+ DATE_FORMAT_LINK ,
18+ 'for details on the date formatting syntax.'
19+ ] . join ( ' ' ) ;
20+ }
1621
1722function describeVariables ( extra ) {
1823 var descPart = extra . description ? ' ' + extra . description : '' ;
@@ -45,7 +50,7 @@ exports.hovertemplateAttrs = function(opts, extra) {
4550 description : [
4651 'Template string used for rendering the information that appear on hover box.' ,
4752 'Note that this will override `hoverinfo`.' ,
48- templateFormatStringDescription ,
53+ templateFormatStringDescription ( { supportOther : true } ) ,
4954 'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data.' ,
5055 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.' ,
5156 descPart ,
@@ -74,7 +79,7 @@ exports.texttemplateAttrs = function(opts, extra) {
7479 description : [
7580 'Template string used for rendering the information text that appear on points.' ,
7681 'Note that this will override `textinfo`.' ,
77- templateFormatStringDescription ,
82+ templateFormatStringDescription ( ) ,
7883 'Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.' ,
7984 descPart
8085 ] . join ( ' ' )
0 commit comments