Skip to content

Commit 8d4acac

Browse files
committed
fixed waterfall attributes
1 parent 8eb01bd commit 8d4acac

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

src/traces/waterfall/attributes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var lineAttrs = require('../scatter/attributes').line;
55
var baseAttrs = require('../../plots/attributes');
66
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
77
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
8+
var tooltiptemplateAttrs = require('../../plots/template_attributes').tooltiptemplateAttrs;
89
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
910
var constants = require('./constants');
1011
var extendFlat = require('../../lib/extend').extendFlat;
@@ -87,7 +88,9 @@ module.exports = {
8788
}),
8889

8990
tooltip: barAttrs.tooltip,
90-
tooltiptemplate: barAttrs.tooltiptemplate,
91+
tooltiptemplate: extendFlat({}, tooltiptemplateAttrs({}, {
92+
keys: constants.eventDataKeys
93+
}), {dflt: 'initial: %{initial}<br>delta: %{delta}<br>final: %{final}'}),
9194

9295
textinfo: {
9396
valType: 'flaglist',

src/traces/waterfall/defaults.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
4747
coerce('hovertext');
4848
coerce('hovertemplate');
4949

50+
coerce('tooltip');
51+
coerce('tooltiptemplate');
52+
5053
var textposition = coerce('textposition');
5154
handleText(traceIn, traceOut, layout, coerce, textposition, {
5255
moduleHasSelected: false,
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"data": [
3+
{
4+
"type": "waterfall",
5+
"y": [ 1, -2, 1 ],
6+
"yaxis": "y2",
7+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>initial: %{initial}<br>delta: %{delta}<br>final: %{final}",
8+
"tooltip": {"arrowcolor": "blue"}
9+
},
10+
{
11+
"type": "waterfall",
12+
"y": [ 2, -1, 2 ],
13+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
14+
"tooltip": {"arrowcolor": "blue"}
15+
},
16+
{
17+
"type": "waterfall",
18+
"y": [ 1, -3, 0 ],
19+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
20+
"tooltip": {"arrowcolor": "blue"}
21+
},
22+
{
23+
"type": "waterfall",
24+
"y": [ 1, -2, 1 ],
25+
"alignmentgroup": "top",
26+
"hovertext": "alignmentgroup: top",
27+
"xaxis": "x2",
28+
"yaxis": "y2",
29+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
30+
"tooltip": {"arrowcolor": "blue"}
31+
},
32+
{
33+
"type": "waterfall",
34+
"y": [ 2, -1, 2 ],
35+
"hovertext": "alignmentgroup: top<br>offsetgroup: 1",
36+
"alignmentgroup": "bottom",
37+
"offsetgroup": "1",
38+
"xaxis": "x2",
39+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
40+
"tooltip": {"arrowcolor": "blue"}
41+
},
42+
{
43+
"type": "waterfall",
44+
"y": [ 1, -3, 0 ],
45+
"hovertext": "alignmentgroup: top<br>offsetgroup: 2",
46+
"alignmentgroup": "bottom",
47+
"offsetgroup": "2",
48+
"xaxis": "x2",
49+
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
50+
"tooltip": {"arrowcolor": "blue"}
51+
}
52+
],
53+
"layout": {
54+
"showlegend": false,
55+
"grid": {
56+
"rows": 2,
57+
"columns": 2,
58+
"roworder": "bottom to top"
59+
},
60+
"colorway": [ "blue", "orange", "green" ],
61+
"margin": { "t": 20 },
62+
"xaxis": {
63+
"title": {
64+
"text": "no alignmentgroup<br>no offsetgroup"
65+
}
66+
},
67+
"xaxis2": {
68+
"title": {
69+
"text": "with alignmentgroup<br>with offsetgroup"
70+
}
71+
}
72+
},
73+
"config": {
74+
"editable": true,
75+
"modeBarButtonsToAdd": [
76+
"tooltip",
77+
"hoverclosest",
78+
"hovercompare",
79+
"togglespikelines"
80+
],
81+
"displaylogo": false,
82+
"displayModeBar": true
83+
}
84+
}

0 commit comments

Comments
 (0)