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

Lines changed: 9 additions & 14 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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
},

0 commit comments

Comments
 (0)