Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e980e44
Linting/formatting
camdecoster Sep 29, 2025
212f892
Return empty string for undefined value in templateFormatString
camdecoster Sep 29, 2025
75b157f
Refactoring
camdecoster Oct 2, 2025
5f3670f
Add fallback value for template strings
camdecoster Oct 3, 2025
336e9ae
Add fallback to calls to hovertemplateString
camdecoster Oct 3, 2025
02a4cad
Add fallback to calls to texttemplateString
camdecoster Oct 3, 2025
77bc2b9
Add fallback to calls to texttemplateStringForShapes
camdecoster Oct 7, 2025
85b67e9
Update defaults calculations
camdecoster Oct 6, 2025
680c793
Add helper function for template fallback attributes
camdecoster Oct 6, 2025
52c29cc
Add fallback value to attributes files
camdecoster Oct 7, 2025
f623b22
Update esbuild strip meta plugin to handle more joined arrays
camdecoster Oct 8, 2025
074f8a0
Return array from ternary
camdecoster Oct 8, 2025
6f3daa8
Update tests per default fallback value
camdecoster Oct 8, 2025
6719bd3
Update schema
camdecoster Oct 8, 2025
84fc044
Update test baselines
camdecoster Oct 8, 2025
e719f74
Rename object keys
camdecoster Oct 8, 2025
fb7a40c
Add/update tests to check fallback value
camdecoster Oct 9, 2025
faaae28
Add draftlog
camdecoster Oct 9, 2025
5c032c6
Fix typos
camdecoster Oct 21, 2025
a0ce641
Update fallback `editType` to match template
camdecoster Oct 21, 2025
14ab31c
Handle undefined values and missing values differently
camdecoster Oct 23, 2025
4f79efe
Update default fallback value and template attribute descriptions
camdecoster Oct 23, 2025
257475c
Add tests for missing and undefined values
camdecoster Oct 23, 2025
a148edd
Update schema
camdecoster Oct 23, 2025
c40fe9f
Merge remote-tracking branch 'origin/master' into cam/7564/return-emp…
camdecoster Oct 23, 2025
6a66148
Revert "Update test baselines"
camdecoster Oct 23, 2025
5215f13
Always use fallback for missing values, except when fallback is false
camdecoster Oct 24, 2025
30f87f3
Update schema
camdecoster Oct 24, 2025
b61d70d
Update mocks to show fallback values
camdecoster Oct 24, 2025
d900ca3
Update tests per final behavior
camdecoster Oct 24, 2025
a061787
Update baseline images
camdecoster Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add fallback value to attributes files
  • Loading branch information
camdecoster committed Oct 9, 2025
commit 52c29ccc8c591c527085f08e6399ebd6ea889bd8
3 changes: 2 additions & 1 deletion src/components/shapes/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var extendFlat = require('../../lib/extend').extendFlat;
var templatedArray = require('../../plot_api/plot_template').templatedArray;
var axisPlaceableObjs = require('../../constants/axis_placeable_objects');
var basePlotAttributes = require('../../plots/attributes');
var shapeTexttemplateAttrs = require('../../plots/template_attributes').shapeTexttemplateAttrs;
const { shapeTexttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var shapeLabelTexttemplateVars = require('./label_texttemplate');

module.exports = templatedArray('shape', {
Expand Down Expand Up @@ -331,6 +331,7 @@ module.exports = templatedArray('shape', {
].join(' ')
},
texttemplate: shapeTexttemplateAttrs({}, { keys: Object.keys(shapeLabelTexttemplateVars) }),
texttemplatefallback: templatefallbackAttrs(),
font: fontAttrs({
editType: 'calc+arraydraw',
colorEditType: 'arraydraw',
Expand Down
3 changes: 2 additions & 1 deletion src/components/shapes/draw_newshape/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var basePlotAttributes = require('../../../plots/attributes');
var fontAttrs = require('../../../plots/font_attributes');
var dash = require('../../drawing/attributes').dash;
var extendFlat = require('../../../lib/extend').extendFlat;
var shapeTexttemplateAttrs = require('../../../plots/template_attributes').shapeTexttemplateAttrs;
const { shapeTexttemplateAttrs, templatefallbackAttrs } = require('../../../plots/template_attributes');
var shapeLabelTexttemplateVars = require('../label_texttemplate');

module.exports = overrideAll(
Expand Down Expand Up @@ -150,6 +150,7 @@ module.exports = overrideAll(
{ newshape: true },
{ keys: Object.keys(shapeLabelTexttemplateVars) }
),
texttemplatefallback: templatefallbackAttrs(),
font: fontAttrs({
description: 'Sets the new shape label text font.'
}),
Expand Down
19 changes: 5 additions & 14 deletions src/traces/bar/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

var scatterAttrs = require('../scatter/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var fontAttrs = require('../../plots/font_attributes');
var constants = require('./constants');
Expand Down Expand Up @@ -78,19 +77,11 @@ module.exports = {
yhoverformat: axisHoverFormat('y'),

text: scatterAttrs.text,
texttemplate: texttemplateAttrs(
{ editType: 'plot' },
{
keys: constants.eventDataKeys
}
),
texttemplate: texttemplateAttrs({ editType: 'plot' }, { keys: constants.eventDataKeys }),
texttemplatefallback: templatefallbackAttrs(),
hovertext: scatterAttrs.hovertext,
hovertemplate: hovertemplateAttrs(
{},
{
keys: constants.eventDataKeys
}
),
hovertemplate: hovertemplateAttrs({}, { keys: constants.eventDataKeys }),
hovertemplatefallback: templatefallbackAttrs(),

textposition: {
valType: 'enumerated',
Expand Down
3 changes: 2 additions & 1 deletion src/traces/barpolar/attributes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var extendFlat = require('../../lib/extend').extendFlat;
var scatterPolarAttrs = require('../scatterpolar/attributes');
var barAttrs = require('../bar/attributes');
Expand Down Expand Up @@ -59,6 +59,7 @@ module.exports = {

hoverinfo: scatterPolarAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs(),
hovertemplatefallback: templatefallbackAttrs(),

selected: barAttrs.selected,
unselected: barAttrs.unselected
Expand Down
3 changes: 2 additions & 1 deletion src/traces/box/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var scatterAttrs = require('../scatter/attributes');
var barAttrs = require('../bar/attributes');
var colorAttrs = require('../../components/color/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var extendFlat = require('../../lib/extend').extendFlat;

var scatterMarkerAttrs = scatterAttrs.marker;
Expand Down Expand Up @@ -410,6 +410,7 @@ module.exports = {
}),
hovertext: extendFlat({}, scatterAttrs.hovertext, { description: 'Same as `text`.' }),
hovertemplate: hovertemplateAttrs({ description: 'N.B. This only has an effect when hovering on points.' }),
hovertemplatefallback: templatefallbackAttrs(),

hoveron: {
valType: 'flaglist',
Expand Down
3 changes: 2 additions & 1 deletion src/traces/choropleth/attributes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var scatterGeoAttrs = require('../scattergeo/attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var baseAttrs = require('../../plots/attributes');
Expand Down Expand Up @@ -84,6 +84,7 @@ module.exports = extendFlat(
flags: ['location', 'z', 'text', 'name']
}),
hovertemplate: hovertemplateAttrs(),
hovertemplatefallback: templatefallbackAttrs(),
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},

Expand Down
3 changes: 2 additions & 1 deletion src/traces/choroplethmap/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var choroplethAttrs = require('../choropleth/attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var baseAttrs = require('../../plots/attributes');
var extendFlat = require('../../lib/extend').extendFlat;

Expand Down Expand Up @@ -98,6 +98,7 @@ module.exports = extendFlat(

hoverinfo: choroplethAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs({}, { keys: ['properties'] }),
hovertemplatefallback: templatefallbackAttrs(),
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},

Expand Down
3 changes: 2 additions & 1 deletion src/traces/choroplethmapbox/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var choroplethAttrs = require('../choropleth/attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var baseAttrs = require('../../plots/attributes');
var extendFlat = require('../../lib/extend').extendFlat;

Expand Down Expand Up @@ -98,6 +98,7 @@ module.exports = extendFlat(

hoverinfo: choroplethAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs({}, { keys: ['properties'] }),
hovertemplatefallback: templatefallbackAttrs(),
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},

Expand Down
3 changes: 2 additions & 1 deletion src/traces/cone/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var colorScaleAttrs = require('../../components/colorscale/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var mesh3dAttrs = require('../mesh3d/attributes');
var baseAttrs = require('../../plots/attributes');

Expand Down Expand Up @@ -146,6 +146,7 @@ var attrs = {
},

hovertemplate: hovertemplateAttrs({ editType: 'calc' }, { keys: ['norm'] }),
hovertemplatefallback: templatefallbackAttrs(),
uhoverformat: axisHoverFormat('u', 1),
vhoverformat: axisHoverFormat('v', 1),
whoverformat: axisHoverFormat('w', 1),
Expand Down
2 changes: 2 additions & 0 deletions src/traces/contour/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ module.exports = extendFlat(
yhoverformat: axisHoverFormat('y'),
zhoverformat: axisHoverFormat('z', 1),
hovertemplate: heatmapAttrs.hovertemplate,
hovertemplatefallback: heatmapAttrs.hovertemplatefallback,
texttemplate: extendFlat({}, heatmapAttrs.texttemplate, {
description: [
'For this trace it only has an effect if `coloring` is set to *heatmap*.',
heatmapAttrs.texttemplate.description
].join(' ')
}),
texttemplatefallback: heatmapAttrs.texttemplatefallback,
textfont: extendFlat({}, heatmapAttrs.textfont, {
description: [
'For this trace it only has an effect if `coloring` is set to *heatmap*.',
Expand Down
3 changes: 2 additions & 1 deletion src/traces/densitymap/attributes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var colorScaleAttrs = require('../../components/colorscale/attributes');
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var baseAttrs = require('../../plots/attributes');
var scatterMapAttrs = require('../scattermap/attributes');

Expand Down Expand Up @@ -76,6 +76,7 @@ module.exports = extendFlat(
flags: ['lon', 'lat', 'z', 'text', 'name']
}),
hovertemplate: hovertemplateAttrs(),
hovertemplatefallback: templatefallbackAttrs(),
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},
colorScaleAttrs('', {
Expand Down
3 changes: 2 additions & 1 deletion src/traces/densitymapbox/attributes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var colorScaleAttrs = require('../../components/colorscale/attributes');
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
const { hovertemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var baseAttrs = require('../../plots/attributes');
var scatterMapboxAttrs = require('../scattermapbox/attributes');

Expand Down Expand Up @@ -76,6 +76,7 @@ module.exports = extendFlat(
flags: ['lon', 'lat', 'z', 'text', 'name']
}),
hovertemplate: hovertemplateAttrs(),
hovertemplatefallback: templatefallbackAttrs(),
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},
colorScaleAttrs('', {
Expand Down
19 changes: 5 additions & 14 deletions src/traces/funnel/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ var barAttrs = require('../bar/attributes');
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 texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var constants = require('./constants');
var extendFlat = require('../../lib/extend').extendFlat;
var Color = require('../../components/color');
Expand All @@ -28,12 +27,8 @@ module.exports = {
yhoverformat: axisHoverFormat('y'),

hovertext: barAttrs.hovertext,
hovertemplate: hovertemplateAttrs(
{},
{
keys: constants.eventDataKeys
}
),
hovertemplate: hovertemplateAttrs({}, { keys: constants.eventDataKeys }),
hovertemplatefallback: templatefallbackAttrs(),

hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
flags: ['name', 'x', 'y', 'text', 'percent initial', 'percent previous', 'percent total']
Expand All @@ -52,12 +47,8 @@ module.exports = {
].join(' ')
},
// TODO: incorporate `label` and `value` in the eventData
texttemplate: texttemplateAttrs(
{ editType: 'plot' },
{
keys: constants.eventDataKeys.concat(['label', 'value'])
}
),
texttemplate: texttemplateAttrs({ editType: 'plot' }, { keys: constants.eventDataKeys.concat(['label', 'value']) }),
texttemplatefallback: templatefallbackAttrs(),

text: barAttrs.text,
textposition: barAttrs.textposition,
Expand Down
19 changes: 5 additions & 14 deletions src/traces/funnelarea/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
var pieAttrs = require('../pie/attributes');
var baseAttrs = require('../../plots/attributes');
var domainAttrs = require('../../plots/domain').attributes;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');

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

Expand Down Expand Up @@ -47,23 +46,15 @@ module.exports = {
flags: ['label', 'text', 'value', 'percent']
}),

texttemplate: texttemplateAttrs(
{ editType: 'plot' },
{
keys: ['label', 'color', 'value', 'text', 'percent']
}
),
texttemplate: texttemplateAttrs({ editType: 'plot' }, { keys: ['label', 'color', 'value', 'text', 'percent'] }),
texttemplatefallback: templatefallbackAttrs(),

hoverinfo: extendFlat({}, baseAttrs.hoverinfo, {
flags: ['label', 'text', 'value', 'percent', 'name']
}),

hovertemplate: hovertemplateAttrs(
{},
{
keys: ['label', 'color', 'value', 'text', 'percent']
}
),
hovertemplate: hovertemplateAttrs({}, { keys: ['label', 'color', 'value', 'text', 'percent'] }),
hovertemplatefallback: templatefallbackAttrs(),

textposition: extendFlat({}, pieAttrs.textposition, {
values: ['inside', 'none'],
Expand Down
28 changes: 10 additions & 18 deletions src/traces/heatmap/attributes.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

var scatterAttrs = require('../scatter/attributes');
var baseAttrs = require('../../plots/attributes');
var fontAttrs = require('../../plots/font_attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
var colorScaleAttrs = require('../../components/colorscale/attributes');

var extendFlat = require('../../lib/extend').extendFlat;
const colorScaleAttrs = require('../../components/colorscale/attributes');
const { extendFlat } = require('../../lib/extend');
const baseAttrs = require('../../plots/attributes');
const { axisHoverFormat } = require('../../plots/cartesian/axis_format_attributes');
const fontAttrs = require('../../plots/font_attributes');
const { hovertemplateAttrs, templatefallbackAttrs, texttemplateAttrs } = require('../../plots/template_attributes');
const scatterAttrs = require('../scatter/attributes');

module.exports = extendFlat(
{
Expand Down Expand Up @@ -117,15 +115,9 @@ module.exports = extendFlat(
zhoverformat: axisHoverFormat('z', 1),

hovertemplate: hovertemplateAttrs(),
texttemplate: texttemplateAttrs(
{
arrayOk: false,
editType: 'plot'
},
{
keys: ['x', 'y', 'z', 'text']
}
),
hovertemplatefallback: templatefallbackAttrs(),
texttemplate: texttemplateAttrs({ arrayOk: false, editType: 'plot' }, { keys: ['x', 'y', 'z', 'text'] }),
texttemplatefallback: templatefallbackAttrs(),
textfont: fontAttrs({
editType: 'plot',
autoSize: true,
Expand Down
24 changes: 6 additions & 18 deletions src/traces/histogram/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

var barAttrs = require('../bar/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var fontAttrs = require('../../plots/font_attributes');
var makeBinAttrs = require('./bin_attributes');
var constants = require('./constants');
Expand Down Expand Up @@ -192,22 +191,11 @@ module.exports = {
].join(' ')
},

hovertemplate: hovertemplateAttrs(
{},
{
keys: constants.eventDataKeys
}
),

texttemplate: texttemplateAttrs(
{
arrayOk: false,
editType: 'plot'
},
{
keys: ['label', 'value']
}
),
hovertemplate: hovertemplateAttrs({}, { keys: constants.eventDataKeys }),
hovertemplatefallback: templatefallbackAttrs(),

texttemplate: texttemplateAttrs({ arrayOk: false, editType: 'plot' }, { keys: ['label', 'value'] }),
texttemplatefallback: templatefallbackAttrs(),

textposition: extendFlat({}, barAttrs.textposition, {
arrayOk: false
Expand Down
5 changes: 3 additions & 2 deletions src/traces/histogram2d/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ var makeBinAttrs = require('../histogram/bin_attributes');
var heatmapAttrs = require('../heatmap/attributes');
var baseAttrs = require('../../plots/attributes');
var axisHoverFormat = require('../../plots/cartesian/axis_format_attributes').axisHoverFormat;
var hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
const { hovertemplateAttrs, texttemplateAttrs, templatefallbackAttrs } = require('../../plots/template_attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');

var extendFlat = require('../../lib/extend').extendFlat;
Expand Down Expand Up @@ -70,7 +69,9 @@ module.exports = extendFlat(
yhoverformat: axisHoverFormat('y'),
zhoverformat: axisHoverFormat('z', 1),
hovertemplate: hovertemplateAttrs({}, { keys: ['z'] }),
hovertemplatefallback: templatefallbackAttrs(),
texttemplate: texttemplateAttrs({ arrayOk: false, editType: 'plot' }, { keys: ['z'] }),
texttemplatefallback: templatefallbackAttrs(),
textfont: heatmapAttrs.textfont,
showlegend: extendFlat({}, baseAttrs.showlegend, { dflt: false })
},
Expand Down
Loading