Skip to content

Commit 2384391

Browse files
committed
turn axishoverformat into a function to make different flavors depending on trace
1 parent 67a194d commit 2384391

File tree

22 files changed

+88
-93
lines changed

22 files changed

+88
-93
lines changed

src/plots/hoverformat_attributes.js

+9-14
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22

33
var FORMAT_LINK = require('../constants/docs').FORMAT_LINK;
44

5-
function axisHoverFormat(str) {
5+
module.exports = function axisHoverFormat(x, mockedAxis) {
66
return {
77
valType: 'string',
88
dflt: '',
99
editType: 'none',
1010
description: [
11-
'Sets the hover text formatting rule for the ' + str + ' using d3 formatting mini-languages',
12-
'which are very similar to those in Python. See:',
13-
FORMAT_LINK
11+
'Sets the hover text formatting rule for `' + x + '`',
12+
' using d3 formatting mini-languages which are very similar to those in Python.',
13+
'See: ' + FORMAT_LINK,
14+
'By default the values are formatted using ' + (
15+
mockedAxis ?
16+
'generic number format' :
17+
('`' + x + 'axis.hoverformat`')
18+
) + '.',
1419
].join(' ')
1520
};
16-
}
17-
18-
module.exports = {
19-
uhoverformat: axisHoverFormat('u component'),
20-
vhoverformat: axisHoverFormat('v component'),
21-
whoverformat: axisHoverFormat('w component'),
22-
23-
xhoverformat: axisHoverFormat('x axis'),
24-
yhoverformat: axisHoverFormat('y aixs'),
25-
zhoverformat: axisHoverFormat('z axis')
2621
};

src/traces/bar/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var scatterAttrs = require('../scatter/attributes');
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
77
var colorScaleAttrs = require('../../components/colorscale/attributes');
@@ -105,8 +105,8 @@ module.exports = {
105105
yperiod0: scatterAttrs.yperiod0,
106106
xperiodalignment: scatterAttrs.xperiodalignment,
107107
yperiodalignment: scatterAttrs.yperiodalignment,
108-
xhoverformat: hoverformatAttrs.xhoverformat,
109-
yhoverformat: hoverformatAttrs.yhoverformat,
108+
xhoverformat: axisHoverFormat('x'),
109+
yhoverformat: axisHoverFormat('y'),
110110

111111
text: scatterAttrs.text,
112112
texttemplate: texttemplateAttrs({editType: 'plot'}, {

src/traces/box/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var scatterAttrs = require('../scatter/attributes');
44
var barAttrs = require('../bar/attributes');
55
var colorAttrs = require('../../components/color/attributes');
6-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
6+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
77
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
88
var extendFlat = require('../../lib/extend').extendFlat;
99

@@ -71,8 +71,8 @@ module.exports = {
7171
yperiod0: scatterAttrs.yperiod0,
7272
xperiodalignment: scatterAttrs.xperiodalignment,
7373
yperiodalignment: scatterAttrs.yperiodalignment,
74-
xhoverformat: hoverformatAttrs.xhoverformat,
75-
yhoverformat: hoverformatAttrs.yhoverformat,
74+
xhoverformat: axisHoverFormat('x'),
75+
yhoverformat: axisHoverFormat('y'),
7676

7777
name: {
7878
valType: 'string',

src/traces/candlestick/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var extendFlat = require('../../lib').extendFlat;
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var OHLCattrs = require('../ohlc/attributes');
66
var boxAttrs = require('../box/attributes');
77

@@ -22,8 +22,8 @@ module.exports = {
2222
xperiod: OHLCattrs.xperiod,
2323
xperiod0: OHLCattrs.xperiod0,
2424
xperiodalignment: OHLCattrs.xperiodalignment,
25-
xhoverformat: hoverformatAttrs.xhoverformat,
26-
yhoverformat: hoverformatAttrs.yhoverformat,
25+
xhoverformat: axisHoverFormat('x'),
26+
yhoverformat: axisHoverFormat('y'),
2727

2828
x: OHLCattrs.x,
2929
open: OHLCattrs.open,

src/traces/cone/attributes.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var colorScaleAttrs = require('../../components/colorscale/attributes');
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var mesh3dAttrs = require('../mesh3d/attributes');
77
var baseAttrs = require('../../plots/attributes');
@@ -153,12 +153,12 @@ var attrs = {
153153
},
154154

155155
hovertemplate: hovertemplateAttrs({editType: 'calc'}, {keys: ['norm']}),
156-
uhoverformat: hoverformatAttrs.uhoverformat,
157-
vhoverformat: hoverformatAttrs.vhoverformat,
158-
whoverformat: hoverformatAttrs.whoverformat,
159-
xhoverformat: hoverformatAttrs.xhoverformat,
160-
yhoverformat: hoverformatAttrs.yhoverformat,
161-
zhoverformat: hoverformatAttrs.zhoverformat,
156+
uhoverformat: axisHoverFormat('u', 1),
157+
vhoverformat: axisHoverFormat('v', 1),
158+
whoverformat: axisHoverFormat('w', 1),
159+
xhoverformat: axisHoverFormat('x'),
160+
yhoverformat: axisHoverFormat('y'),
161+
zhoverformat: axisHoverFormat('z'),
162162

163163
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
164164
};

src/traces/contour/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var heatmapAttrs = require('../heatmap/attributes');
44
var scatterAttrs = require('../scatter/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var colorScaleAttrs = require('../../components/colorscale/attributes');
77
var dash = require('../../components/drawing/attributes').dash;
88
var fontAttrs = require('../../plots/font_attributes');
@@ -37,9 +37,9 @@ module.exports = extendFlat({
3737
transpose: heatmapAttrs.transpose,
3838
xtype: heatmapAttrs.xtype,
3939
ytype: heatmapAttrs.ytype,
40-
xhoverformat: hoverformatAttrs.xhoverformat,
41-
yhoverformat: hoverformatAttrs.yhoverformat,
42-
zhoverformat: hoverformatAttrs.zhoverformat,
40+
xhoverformat: axisHoverFormat('x'),
41+
yhoverformat: axisHoverFormat('y'),
42+
zhoverformat: axisHoverFormat('z', 1),
4343
hovertemplate: heatmapAttrs.hovertemplate,
4444
hoverongaps: heatmapAttrs.hoverongaps,
4545
connectgaps: extendFlat({}, heatmapAttrs.connectgaps, {

src/traces/funnel/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var barAttrs = require('../bar/attributes');
44
var lineAttrs = require('../scatter/attributes').line;
55
var baseAttrs = require('../../plots/attributes');
6-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
6+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
77
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
88
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
99
var constants = require('./constants');
@@ -24,8 +24,8 @@ module.exports = {
2424
yperiod0: barAttrs.yperiod0,
2525
xperiodalignment: barAttrs.xperiodalignment,
2626
yperiodalignment: barAttrs.yperiodalignment,
27-
xhoverformat: hoverformatAttrs.xhoverformat,
28-
yhoverformat: hoverformatAttrs.yhoverformat,
27+
xhoverformat: axisHoverFormat('x'),
28+
yhoverformat: axisHoverFormat('y'),
2929

3030
hovertext: barAttrs.hovertext,
3131
hovertemplate: hovertemplateAttrs({}, {

src/traces/heatmap/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var scatterAttrs = require('../scatter/attributes');
44
var baseAttrs = require('../../plots/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
77
var colorScaleAttrs = require('../../components/colorscale/attributes');
88

@@ -111,9 +111,9 @@ module.exports = extendFlat({
111111
editType: 'plot',
112112
description: 'Sets the vertical gap (in pixels) between bricks.'
113113
},
114-
xhoverformat: hoverformatAttrs.xhoverformat,
115-
yhoverformat: hoverformatAttrs.yhoverformat,
116-
zhoverformat: hoverformatAttrs.zhoverformat,
114+
xhoverformat: axisHoverFormat('x'),
115+
yhoverformat: axisHoverFormat('y'),
116+
zhoverformat: axisHoverFormat('z', 1),
117117

118118
hovertemplate: hovertemplateAttrs(),
119119
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})

src/traces/histogram/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var barAttrs = require('../bar/attributes');
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var makeBinAttrs = require('./bin_attributes');
77
var constants = require('./constants');
@@ -23,8 +23,8 @@ module.exports = {
2323
].join(' ')
2424
},
2525

26-
xhoverformat: hoverformatAttrs.xhoverformat,
27-
yhoverformat: hoverformatAttrs.yhoverformat,
26+
xhoverformat: axisHoverFormat('x'),
27+
yhoverformat: axisHoverFormat('y'),
2828

2929
text: extendFlat({}, barAttrs.text, {
3030
description: [

src/traces/histogram2d/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var histogramAttrs = require('../histogram/attributes');
44
var makeBinAttrs = require('../histogram/bin_attributes');
55
var heatmapAttrs = require('../heatmap/attributes');
66
var baseAttrs = require('../../plots/attributes');
7-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
7+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
88
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
99
var colorScaleAttrs = require('../../components/colorscale/attributes');
1010

@@ -65,9 +65,9 @@ module.exports = extendFlat(
6565
xgap: heatmapAttrs.xgap,
6666
ygap: heatmapAttrs.ygap,
6767
zsmooth: heatmapAttrs.zsmooth,
68-
xhoverformat: hoverformatAttrs.xhoverformat,
69-
yhoverformat: hoverformatAttrs.yhoverformat,
70-
zhoverformat: hoverformatAttrs.zhoverformat,
68+
xhoverformat: axisHoverFormat('x'),
69+
yhoverformat: axisHoverFormat('y'),
70+
zhoverformat: axisHoverFormat('z', 1),
7171
hovertemplate: hovertemplateAttrs({}, {keys: 'z'}),
7272
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
7373
},

src/traces/histogram2dcontour/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var histogram2dAttrs = require('../histogram2d/attributes');
44
var contourAttrs = require('../contour/attributes');
55
var colorScaleAttrs = require('../../components/colorscale/attributes');
6-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
6+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
77

88
var extendFlat = require('../../lib/extend').extendFlat;
99

@@ -39,9 +39,9 @@ module.exports = extendFlat({
3939
smoothing: contourAttrs.line.smoothing,
4040
editType: 'plot'
4141
},
42-
xhoverformat: hoverformatAttrs.xhoverformat,
43-
yhoverformat: hoverformatAttrs.yhoverformat,
44-
zhoverformat: hoverformatAttrs.zhoverformat,
42+
xhoverformat: axisHoverFormat('x'),
43+
yhoverformat: axisHoverFormat('y'),
44+
zhoverformat: axisHoverFormat('z'),
4545
hovertemplate: histogram2dAttrs.hovertemplate
4646
},
4747
colorScaleAttrs('', {

src/traces/isosurface/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var colorScaleAttrs = require('../../components/colorscale/attributes');
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var meshAttrs = require('../mesh3d/attributes');
77
var baseAttrs = require('../../plots/attributes');
@@ -207,9 +207,9 @@ var attrs = module.exports = overrideAll(extendFlat({
207207
description: 'Same as `text`.'
208208
},
209209
hovertemplate: hovertemplateAttrs(),
210-
xhoverformat: hoverformatAttrs.xhoverformat,
211-
yhoverformat: hoverformatAttrs.yhoverformat,
212-
zhoverformat: hoverformatAttrs.zhoverformat,
210+
xhoverformat: axisHoverFormat('x'),
211+
yhoverformat: axisHoverFormat('y'),
212+
zhoverformat: axisHoverFormat('z'),
213213

214214
showlegend: extendFlat({}, baseAttrs.showlegend, {dflt: false})
215215
},

src/traces/mesh3d/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var colorScaleAttrs = require('../../components/colorscale/attributes');
4-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
4+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var surfaceAttrs = require('../surface/attributes');
77
var baseAttrs = require('../../plots/attributes');
@@ -90,9 +90,9 @@ module.exports = extendFlat({
9090
},
9191
hovertemplate: hovertemplateAttrs({editType: 'calc'}),
9292

93-
xhoverformat: hoverformatAttrs.xhoverformat,
94-
yhoverformat: hoverformatAttrs.yhoverformat,
95-
zhoverformat: hoverformatAttrs.zhoverformat,
93+
xhoverformat: axisHoverFormat('x'),
94+
yhoverformat: axisHoverFormat('y'),
95+
zhoverformat: axisHoverFormat('z'),
9696

9797
delaunayaxis: {
9898
valType: 'enumerated',

src/traces/ohlc/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var extendFlat = require('../../lib').extendFlat;
44
var scatterAttrs = require('../scatter/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var dash = require('../../components/drawing/attributes').dash;
77
var fxAttrs = require('../../components/fx/attributes');
88
var delta = require('../../constants/delta.js');
@@ -29,8 +29,8 @@ module.exports = {
2929
xperiod: scatterAttrs.xperiod,
3030
xperiod0: scatterAttrs.xperiod0,
3131
xperiodalignment: scatterAttrs.xperiodalignment,
32-
xhoverformat: hoverformatAttrs.xhoverformat,
33-
yhoverformat: hoverformatAttrs.yhoverformat,
32+
xhoverformat: axisHoverFormat('x'),
33+
yhoverformat: axisHoverFormat('y'),
3434

3535
x: {
3636
valType: 'data_array',

src/traces/scatter/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
3+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
44
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
55
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
66
var colorScaleAttrs = require('../../components/colorscale/attributes');
@@ -119,8 +119,8 @@ module.exports = {
119119
yperiod0: axisPeriod0('y0'),
120120
xperiodalignment: axisPeriodAlignment('x'),
121121
yperiodalignment: axisPeriodAlignment('y'),
122-
xhoverformat: hoverformatAttrs.xhoverformat,
123-
yhoverformat: hoverformatAttrs.yhoverformat,
122+
xhoverformat: axisHoverFormat('x'),
123+
yhoverformat: axisHoverFormat('y'),
124124

125125
stackgroup: {
126126
valType: 'string',

src/traces/scatter3d/attributes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var scatterAttrs = require('../scatter/attributes');
44
var colorAttributes = require('../../components/colorscale/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
77
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
88
var baseAttrs = require('../../plots/attributes');
@@ -90,9 +90,9 @@ var attrs = module.exports = overrideAll({
9090
}),
9191
hovertemplate: hovertemplateAttrs(),
9292

93-
xhoverformat: hoverformatAttrs.xhoverformat,
94-
yhoverformat: hoverformatAttrs.yhoverformat,
95-
zhoverformat: hoverformatAttrs.zhoverformat,
93+
xhoverformat: axisHoverFormat('x'),
94+
yhoverformat: axisHoverFormat('y'),
95+
zhoverformat: axisHoverFormat('z'),
9696

9797
mode: extendFlat({}, scatterAttrs.mode, // shouldn't this be on-par with 2D?
9898
{dflt: 'lines+markers'}),

src/traces/scattergl/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var baseAttrs = require('../../plots/attributes');
44
var scatterAttrs = require('../scatter/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var colorScaleAttrs = require('../../components/colorscale/attributes');
77

88
var extendFlat = require('../../lib/extend').extendFlat;
@@ -27,8 +27,8 @@ var attrs = module.exports = overrideAll({
2727
yperiod0: scatterAttrs.yperiod0,
2828
xperiodalignment: scatterAttrs.xperiodalignment,
2929
yperiodalignment: scatterAttrs.yperiodalignment,
30-
xhoverformat: hoverformatAttrs.xhoverformat,
31-
yhoverformat: hoverformatAttrs.yhoverformat,
30+
xhoverformat: axisHoverFormat('x'),
31+
yhoverformat: axisHoverFormat('y'),
3232

3333
text: scatterAttrs.text,
3434
hovertext: scatterAttrs.hovertext,

src/traces/splom/attributes.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var scatterAttrs = require('../scatter/attributes');
44
var colorScaleAttrs = require('../../components/colorscale/attributes');
5-
var hoverformatAttrs = require('../../plots/hoverformat_attributes');
5+
var axisHoverFormat = require('../../plots/hoverformat_attributes');
66
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
77
var scatterGlAttrs = require('../scattergl/attributes');
88
var cartesianIdRegex = require('../../plots/cartesian/constants').idRegex;
@@ -131,8 +131,8 @@ module.exports = {
131131

132132
hovertemplate: hovertemplateAttrs(),
133133

134-
xhoverformat: hoverformatAttrs.xhoverformat,
135-
yhoverformat: hoverformatAttrs.yhoverformat,
134+
xhoverformat: axisHoverFormat('x'),
135+
yhoverformat: axisHoverFormat('y'),
136136

137137
marker: markerAttrs,
138138

0 commit comments

Comments
 (0)