-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
restyle/relayout refactor #1999
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 16 commits
4d3e2ec
95d7d71
3326ecc
a948cce
dd52922
f90f079
e036fea
69e0188
bbfe399
29931ec
fad72a2
e895b32
7a7dc6d
c87b01a
658e5cb
f49ae5e
7ea0d25
284c87f
b9826c8
7c38a4a
96cc57f
cb94e95
238e248
42662ba
50aa1ca
62a1392
87b26d5
040ed1b
388a7fe
6e8a68c
4f8fc66
97ddf48
fe7db79
68f5dbc
d15e541
7ec1634
a107466
42805c2
8d9feaf
0a98a6d
e4227aa
0729921
407ae5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
var ARROWPATHS = require('./arrow_paths'); | ||
var fontAttrs = require('../../plots/font_attributes'); | ||
var cartesianConstants = require('../../plots/cartesian/constants'); | ||
var extendFlat = require('../../lib/extend').extendFlat; | ||
|
||
|
||
module.exports = { | ||
|
@@ -21,6 +20,7 @@ module.exports = { | |
valType: 'boolean', | ||
role: 'info', | ||
dflt: true, | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Determines whether or not this annotation is visible.' | ||
].join(' ') | ||
|
@@ -29,6 +29,7 @@ module.exports = { | |
text: { | ||
valType: 'string', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the text associated with this annotation.', | ||
'Plotly uses a subset of HTML tags to do things like', | ||
|
@@ -41,19 +42,23 @@ module.exports = { | |
valType: 'angle', | ||
dflt: 0, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the angle at which the `text` is drawn', | ||
'with respect to the horizontal.' | ||
].join(' ') | ||
}, | ||
font: extendFlat({}, fontAttrs, { | ||
font: fontAttrs({ | ||
editType: 'docalcAutorange', | ||
colorEditType: 'doarraydraw', | ||
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. Could you point me toward what 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. Never mind. Found it in the suppressed diff. 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. Wait, where is 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. I think at one point I had 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. If I understand correctly, In this case, I prefer setting |
||
description: 'Sets the annotation text font.' | ||
}), | ||
width: { | ||
valType: 'number', | ||
min: 1, | ||
dflt: null, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets an explicit width for the text box. null (default) lets the', | ||
'text set the box width. Wider text will be clipped.', | ||
|
@@ -65,6 +70,7 @@ module.exports = { | |
min: 1, | ||
dflt: null, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets an explicit height for the text box. null (default) lets the', | ||
'text set the box height. Taller text will be clipped.' | ||
|
@@ -76,13 +82,15 @@ module.exports = { | |
max: 1, | ||
dflt: 1, | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: 'Sets the opacity of the annotation (text + arrow).' | ||
}, | ||
align: { | ||
valType: 'enumerated', | ||
values: ['left', 'center', 'right'], | ||
dflt: 'center', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the horizontal alignment of the `text` within the box.', | ||
'Has an effect only if `text` spans more two or more lines', | ||
|
@@ -95,6 +103,7 @@ module.exports = { | |
values: ['top', 'middle', 'bottom'], | ||
dflt: 'middle', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the vertical alignment of the `text` within the box.', | ||
'Has an effect only if an explicit height is set to override', | ||
|
@@ -105,12 +114,14 @@ module.exports = { | |
valType: 'color', | ||
dflt: 'rgba(0,0,0,0)', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: 'Sets the background color of the annotation.' | ||
}, | ||
bordercolor: { | ||
valType: 'color', | ||
dflt: 'rgba(0,0,0,0)', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the color of the border enclosing the annotation `text`.' | ||
].join(' ') | ||
|
@@ -120,6 +131,7 @@ module.exports = { | |
min: 0, | ||
dflt: 1, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the padding (in px) between the `text`', | ||
'and the enclosing border.' | ||
|
@@ -130,6 +142,7 @@ module.exports = { | |
min: 0, | ||
dflt: 1, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the width (in px) of the border enclosing', | ||
'the annotation `text`.' | ||
|
@@ -140,6 +153,7 @@ module.exports = { | |
valType: 'boolean', | ||
dflt: true, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Determines whether or not the annotation is drawn with an arrow.', | ||
'If *true*, `text` is placed near the arrow\'s tail.', | ||
|
@@ -149,6 +163,7 @@ module.exports = { | |
arrowcolor: { | ||
valType: 'color', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: 'Sets the color of the annotation arrow.' | ||
}, | ||
arrowhead: { | ||
|
@@ -157,26 +172,33 @@ module.exports = { | |
max: ARROWPATHS.length, | ||
dflt: 1, | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: 'Sets the annotation arrow head style.' | ||
}, | ||
arrowsize: { | ||
valType: 'number', | ||
min: 0.3, | ||
dflt: 1, | ||
role: 'style', | ||
description: 'Sets the size (in px) of annotation arrow head.' | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the size of the annotation arrow head, relative to `arrowwidth`.', | ||
'A value of 1 (default) gives a head about 3x as wide as the line.' | ||
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. Thanks 📚 |
||
].join(' ') | ||
}, | ||
arrowwidth: { | ||
valType: 'number', | ||
min: 0.1, | ||
role: 'style', | ||
description: 'Sets the width (in px) of annotation arrow.' | ||
editType: 'docalcAutorange', | ||
description: 'Sets the width (in px) of annotation arrow line.' | ||
}, | ||
standoff: { | ||
valType: 'number', | ||
min: 0, | ||
dflt: 0, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets a distance, in pixels, to move the arrowhead away from the', | ||
'position it is pointing at, for example to point at the edge of', | ||
|
@@ -188,6 +210,7 @@ module.exports = { | |
ax: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the x component of the arrow tail about the arrow head.', | ||
'If `axref` is `pixel`, a positive (negative) ', | ||
|
@@ -200,6 +223,7 @@ module.exports = { | |
ay: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the y component of the arrow tail about the arrow head.', | ||
'If `ayref` is `pixel`, a positive (negative) ', | ||
|
@@ -217,6 +241,7 @@ module.exports = { | |
cartesianConstants.idRegex.x.toString() | ||
], | ||
role: 'info', | ||
editType: 'docalc', | ||
description: [ | ||
'Indicates in what terms the tail of the annotation (ax,ay) ', | ||
'is specified. If `pixel`, `ax` is a relative offset in pixels ', | ||
|
@@ -234,6 +259,7 @@ module.exports = { | |
cartesianConstants.idRegex.y.toString() | ||
], | ||
role: 'info', | ||
editType: 'docalc', | ||
description: [ | ||
'Indicates in what terms the tail of the annotation (ax,ay) ', | ||
'is specified. If `pixel`, `ay` is a relative offset in pixels ', | ||
|
@@ -251,6 +277,7 @@ module.exports = { | |
cartesianConstants.idRegex.x.toString() | ||
], | ||
role: 'info', | ||
editType: 'docalc', | ||
description: [ | ||
'Sets the annotation\'s x coordinate axis.', | ||
'If set to an x axis id (e.g. *x* or *x2*), the `x` position', | ||
|
@@ -263,6 +290,7 @@ module.exports = { | |
x: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the annotation\'s x position.', | ||
'If the axis `type` is *log*, then you must take the', | ||
|
@@ -280,6 +308,7 @@ module.exports = { | |
values: ['auto', 'left', 'center', 'right'], | ||
dflt: 'auto', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the text box\'s horizontal position anchor', | ||
'This anchor binds the `x` position to the *left*, *center*', | ||
|
@@ -298,6 +327,7 @@ module.exports = { | |
valType: 'number', | ||
dflt: 0, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Shifts the position of the whole annotation and arrow to the', | ||
'right (positive) or left (negative) by this many pixels.' | ||
|
@@ -310,6 +340,7 @@ module.exports = { | |
cartesianConstants.idRegex.y.toString() | ||
], | ||
role: 'info', | ||
editType: 'docalc', | ||
description: [ | ||
'Sets the annotation\'s y coordinate axis.', | ||
'If set to an y axis id (e.g. *y* or *y2*), the `y` position', | ||
|
@@ -322,6 +353,7 @@ module.exports = { | |
y: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the annotation\'s y position.', | ||
'If the axis `type` is *log*, then you must take the', | ||
|
@@ -339,6 +371,7 @@ module.exports = { | |
values: ['auto', 'top', 'middle', 'bottom'], | ||
dflt: 'auto', | ||
role: 'info', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Sets the text box\'s vertical position anchor', | ||
'This anchor binds the `y` position to the *top*, *middle*', | ||
|
@@ -357,6 +390,7 @@ module.exports = { | |
valType: 'number', | ||
dflt: 0, | ||
role: 'style', | ||
editType: 'docalcAutorange', | ||
description: [ | ||
'Shifts the position of the whole annotation and arrow up', | ||
'(positive) or down (negative) by this many pixels.' | ||
|
@@ -367,6 +401,7 @@ module.exports = { | |
values: [false, 'onoff', 'onout'], | ||
dflt: false, | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Makes this annotation respond to clicks on the plot.', | ||
'If you click a data point that exactly matches the `x` and `y`', | ||
|
@@ -385,6 +420,7 @@ module.exports = { | |
xclick: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Toggle this annotation when clicking a data point whose `x` value', | ||
'is `xclick` rather than the annotation\'s `x` value.' | ||
|
@@ -393,6 +429,7 @@ module.exports = { | |
yclick: { | ||
valType: 'any', | ||
role: 'info', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Toggle this annotation when clicking a data point whose `y` value', | ||
'is `yclick` rather than the annotation\'s `y` value.' | ||
|
@@ -401,6 +438,7 @@ module.exports = { | |
hovertext: { | ||
valType: 'string', | ||
role: 'info', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets text to appear when hovering over this annotation.', | ||
'If omitted or blank, no hover label will appear.' | ||
|
@@ -410,6 +448,7 @@ module.exports = { | |
bgcolor: { | ||
valType: 'color', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the background color of the hover label.', | ||
'By default uses the annotation\'s `bgcolor` made opaque,', | ||
|
@@ -419,23 +458,27 @@ module.exports = { | |
bordercolor: { | ||
valType: 'color', | ||
role: 'style', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the border color of the hover label.', | ||
'By default uses either dark grey or white, for maximum', | ||
'contrast with `hoverlabel.bgcolor`.' | ||
].join(' ') | ||
}, | ||
font: extendFlat({}, fontAttrs, { | ||
font: fontAttrs({ | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Sets the hover label text font.', | ||
'By default uses the global hover font and size,', | ||
'with color from `hoverlabel.bordercolor`.' | ||
].join(' ') | ||
}) | ||
}), | ||
editType: 'doarraydraw' | ||
}, | ||
captureevents: { | ||
valType: 'boolean', | ||
role: 'info', | ||
editType: 'doarraydraw', | ||
description: [ | ||
'Determines whether the annotation text box captures mouse move', | ||
'and click events, or allows those events to pass through to data', | ||
|
@@ -445,11 +488,13 @@ module.exports = { | |
'you must explicitly enable `captureevents`.' | ||
].join(' ') | ||
}, | ||
editType: 'docalc', | ||
|
||
_deprecated: { | ||
ref: { | ||
valType: 'string', | ||
role: 'info', | ||
editType: 'docalc', | ||
description: [ | ||
'Obsolete. Set `xref` and `yref` separately instead.' | ||
].join(' ') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
docalc+autorange
be a sensible name for this? It sounds like an enum camelcased and concatenated, but I could be mistaken.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Unless I'm mistaken, this adds no new labels. That's just plugging into what already exists. Still seems like maybe an enum in disguise, but nothing to change here then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One additional note while digging through here is that the
do-
prefix seems to be carried forward from what was originally just internal variable names. WouldeditType: 'calcAutorange'
oreditType: 'calc+autorange'
make sense? It seems a bit friendlier if you're trying to make sense of the schema as a standalone concept.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docalcAutorange
is a single thing, means "do a recalc only if there's an autoranged axis related to this attribute" - Actually, ideally we'd specify what to do if there isn't an autoranged axis... so likedocalcAutorange+dostyle
or something.Yeah totally, good idea! And to help us out (to figure out what
editType
a new attribute should get) I should probably describe somewhere what these flags actually mean in terms of the code paths they lead to.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
calcIfAutorange
?FWIW, I have a history of making bad choices here for lack of really understanding the implications of some schema concepts. If you want I can try making
docs/schema.md
that explains, at the very least, what some of the schema items link up with. Some of the concepts like_isLinkedToArray
get a little subtle. Even for the fifth time interacting with it, I think a brief description with links to a couple relevant spots in the code would help.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏆
Definitely time for something like that! @etpinard thoughts about how/where to do this? Should it be a standalone thing, or somehow included in
Plotly.PlotSchema.get()
or...?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My vote would be for not including in the code so that it's as accessible and readable as possible without having to realize it's an API function and instantiate anything in order to access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd vote for adding a attribute-like edit type declaration object in
edit_types.js
with adescription
field. For example,That
description
field would get stripped off by thecompress_attributes
transform.Plotly.PlotSchema.get().defs.editTypes
would then return the list of edit types with their description.I see your point @rreusser about relying an API function to show docs being less-than-ideal. But since we already have a hard time keeping https://github.com/plotly/documentation/ up to speed, adding another layer of static (e.g. a github wiki or a
docs/
directory) documentation sounds dangerous. No docs is better than bad docs, right? That said, it wouldn't hurt adding a few lines in our CONTRIBUTING.md over the edit types.