-
-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: Add template string fallback attributes #7577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e980e44
212f892
75b157f
5f3670f
336e9ae
02a4cad
77bc2b9
85b67e9
680c793
52c29cc
f623b22
074f8a0
6f3daa8
6719bd3
84fc044
e719f74
fb7a40c
faaae28
5c032c6
a0ce641
14ab31c
4f79efe
257475c
a148edd
c40fe9f
6a66148
5215f13
30f87f3
b61d70d
d900ca3
a061787
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| 'use strict'; | ||
| const { DATE_FORMAT_LINK, FORMAT_LINK } = require('../constants/docs'); | ||
|
|
||
| function templateFormatStringDescription(opts = {}) { | ||
| const { supportOther } = opts; | ||
| function templateFormatStringDescription({ supportOther } = {}) { | ||
| const supportOtherText = | ||
| ' as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, *xother* will be added to those with different x positions from the first point. An underscore before or after *(x|y)other* will add a space on that side, only when this field is shown.'; | ||
|
|
||
|
|
@@ -34,53 +33,43 @@ function describeVariables({ description, keys = [] }) { | |
| return descPart; | ||
| } | ||
|
|
||
| exports.hovertemplateAttrs = (opts = {}, extra = {}) => { | ||
| const hovertemplate = { | ||
| valType: 'string', | ||
| dflt: '', | ||
| editType: opts.editType || 'none', | ||
| description: [ | ||
| 'Template string used for rendering the information that appear on hover box.', | ||
| 'Note that this will override `hoverinfo`.', | ||
| templateFormatStringDescription({ supportOther: true }), | ||
| 'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data.', | ||
| 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', | ||
| describeVariables(extra), | ||
| 'Anything contained in tag `<extra>` is displayed in the secondary box, for example `<extra>%{fullData.name}</extra>`.', | ||
| 'To hide the secondary box completely, use an empty tag `<extra></extra>`.' | ||
| ].join(' ') | ||
| }; | ||
|
|
||
| if (opts.arrayOk !== false) hovertemplate.arrayOk = true; | ||
|
|
||
| return hovertemplate; | ||
| }; | ||
|
|
||
| exports.texttemplateAttrs = (opts = {}, extra = {}) => { | ||
| const texttemplate = { | ||
| valType: 'string', | ||
| dflt: '', | ||
| editType: opts.editType || 'calc', | ||
| description: [ | ||
| 'Template string used for rendering the information text that appear on points.', | ||
| 'Note that this will override `textinfo`.', | ||
| templateFormatStringDescription(), | ||
| 'Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', | ||
| describeVariables(extra) | ||
| ].join(' ') | ||
| }; | ||
|
|
||
| if (opts.arrayOk !== false) texttemplate.arrayOk = true; | ||
| exports.hovertemplateAttrs = ({ editType = 'none', arrayOk } = {}, extra = {}) => ({ | ||
| valType: 'string', | ||
| dflt: '', | ||
| editType, | ||
| description: [ | ||
| 'Template string used for rendering the information that appear on hover box.', | ||
| 'Note that this will override `hoverinfo`.', | ||
| templateFormatStringDescription({ supportOther: true }), | ||
| 'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data.', | ||
| 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', | ||
| describeVariables(extra), | ||
| 'Anything contained in tag `<extra>` is displayed in the secondary box, for example `<extra>%{fullData.name}</extra>`.', | ||
| 'To hide the secondary box completely, use an empty tag `<extra></extra>`.' | ||
| ].join(' '), | ||
| ...(arrayOk !== false ? { arrayOk: true } : {}) | ||
| }); | ||
|
|
||
| return texttemplate; | ||
| }; | ||
| exports.texttemplateAttrs = ({ editType = 'calc', arrayOk } = {}, extra = {}) => ({ | ||
| valType: 'string', | ||
| dflt: '', | ||
| editType, | ||
| description: [ | ||
| 'Template string used for rendering the information text that appears on points.', | ||
| 'Note that this will override `textinfo`.', | ||
| templateFormatStringDescription(), | ||
| 'Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', | ||
camdecoster marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| describeVariables(extra) | ||
| ].join(' '), | ||
| ...(arrayOk !== false ? { arrayOk: true } : {}) | ||
| }); | ||
|
|
||
| exports.shapeTexttemplateAttrs = (opts = {}, extra = {}) => ({ | ||
| exports.shapeTexttemplateAttrs = ({ editType = 'arraydraw', newshape }, extra = {}) => ({ | ||
| valType: 'string', | ||
| dflt: '', | ||
| editType: opts.editType || 'arraydraw', | ||
| editType, | ||
| description: [ | ||
| `Template string used for rendering the ${opts.newshape ? 'new ' : ''}shape's label.`, | ||
| `Template string used for rendering the ${newshape ? 'new ' : ''}shape's label.`, | ||
| 'Note that this will override `text`.', | ||
| 'Variables are inserted using %{variable},', | ||
| 'for example "x0: %{x0}".', | ||
|
|
@@ -97,3 +86,10 @@ exports.shapeTexttemplateAttrs = (opts = {}, extra = {}) => ({ | |
| describeVariables(extra) | ||
| ].join(' ') | ||
| }); | ||
|
|
||
| exports.templatefallbackAttrs = ({ editType = 'none' } = {}) => ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to set the correct
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After reviewing the changes again, I think it should be |
||
| valType: 'string', | ||
| dflt: '', | ||
| editType, | ||
| description: "Fallback value that's displayed when a variable referenced in a template can't be found." | ||
camdecoster marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.