@@ -4,15 +4,20 @@ var docs = require('../constants/docs');
4
4
var FORMAT_LINK = docs . FORMAT_LINK ;
5
5
var DATE_FORMAT_LINK = docs . DATE_FORMAT_LINK ;
6
6
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
+ }
16
21
17
22
function describeVariables ( extra ) {
18
23
var descPart = extra . description ? ' ' + extra . description : '' ;
@@ -45,7 +50,7 @@ exports.hovertemplateAttrs = function(opts, extra) {
45
50
description : [
46
51
'Template string used for rendering the information that appear on hover box.' ,
47
52
'Note that this will override `hoverinfo`.' ,
48
- templateFormatStringDescription ,
53
+ templateFormatStringDescription ( { supportOther : true } ) ,
49
54
'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data.' ,
50
55
'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.' ,
51
56
descPart ,
@@ -74,7 +79,7 @@ exports.texttemplateAttrs = function(opts, extra) {
74
79
description : [
75
80
'Template string used for rendering the information text that appear on points.' ,
76
81
'Note that this will override `textinfo`.' ,
77
- templateFormatStringDescription ,
82
+ templateFormatStringDescription ( ) ,
78
83
'Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.' ,
79
84
descPart
80
85
] . join ( ' ' )
0 commit comments