Skip to content

Commit

Permalink
fixed waterfall attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
kb- committed Oct 12, 2024
1 parent 7c3d481 commit 9387f03
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/traces/waterfall/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var lineAttrs = require('../scatter/attributes').line;
var baseAttrs = require('../../plots/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var tooltiptemplateAttrs = require('../../plots/template_attributes').tooltiptemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
var constants = require('./constants');
var extendFlat = require('../../lib/extend').extendFlat;
Expand Down Expand Up @@ -87,7 +88,9 @@ module.exports = {
}),

tooltip: barAttrs.tooltip,
tooltiptemplate: barAttrs.tooltiptemplate,
tooltiptemplate: extendFlat({}, tooltiptemplateAttrs({}, {
keys: constants.eventDataKeys
}), {dflt: 'initial: %{initial}<br>delta: %{delta}<br>final: %{final}'}),

textinfo: {
valType: 'flaglist',
Expand Down
3 changes: 3 additions & 0 deletions src/traces/waterfall/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
coerce('hovertext');
coerce('hovertemplate');

coerce('tooltip');
coerce('tooltiptemplate');

var textposition = coerce('textposition');
handleText(traceIn, traceOut, layout, coerce, textposition, {
moduleHasSelected: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"data": [
{
"type": "waterfall",
"y": [ 1, -2, 1 ],
"yaxis": "y2",
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>initial: %{initial}<br>delta: %{delta}<br>final: %{final}",
"tooltip": {"arrowcolor": "blue"}
},
{
"type": "waterfall",
"y": [ 2, -1, 2 ],
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
"tooltip": {"arrowcolor": "blue"}
},
{
"type": "waterfall",
"y": [ 1, -3, 0 ],
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
"tooltip": {"arrowcolor": "blue"}
},
{
"type": "waterfall",
"y": [ 1, -2, 1 ],
"alignmentgroup": "top",
"hovertext": "alignmentgroup: top",
"xaxis": "x2",
"yaxis": "y2",
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
"tooltip": {"arrowcolor": "blue"}
},
{
"type": "waterfall",
"y": [ 2, -1, 2 ],
"hovertext": "alignmentgroup: top<br>offsetgroup: 1",
"alignmentgroup": "bottom",
"offsetgroup": "1",
"xaxis": "x2",
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
"tooltip": {"arrowcolor": "blue"}
},
{
"type": "waterfall",
"y": [ 1, -3, 0 ],
"hovertext": "alignmentgroup: top<br>offsetgroup: 2",
"alignmentgroup": "bottom",
"offsetgroup": "2",
"xaxis": "x2",
"tooltiptemplate": "x: %{x}<br>y: %{y}<br>delta: %{delta}",
"tooltip": {"arrowcolor": "blue"}
}
],
"layout": {
"showlegend": false,
"grid": {
"rows": 2,
"columns": 2,
"roworder": "bottom to top"
},
"colorway": [ "blue", "orange", "green" ],
"margin": { "t": 20 },
"xaxis": {
"title": {
"text": "no alignmentgroup<br>no offsetgroup"
}
},
"xaxis2": {
"title": {
"text": "with alignmentgroup<br>with offsetgroup"
}
}
},
"config": {
"editable": true,
"modeBarButtonsToAdd": [
"tooltip",
"hoverclosest",
"hovercompare",
"togglespikelines"
],
"displaylogo": false,
"displayModeBar": true
}
}

0 comments on commit 9387f03

Please sign in to comment.