-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Support adding text labels to lines and shapes #6454
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 77 commits
7ee2e85
932fa65
1d0e471
e46e1bc
60823dc
2f8c810
e405293
e31de9e
0bcfff3
9972dc9
6d5709a
072edf6
8bee979
8528561
b4a4576
97ee8c4
674abd8
3743de4
c3cc5ed
45a0564
b8085c2
8c0476e
95dd9b6
58e39cb
488318f
c8d20f2
dad6ea5
3134869
f17e218
01ef185
d8c4790
5f39a62
1ab9e24
b9ea251
1f366a8
f1087f3
f1570cf
baec66d
d83e0cd
a91d12f
4948d67
a5e19d3
e55953e
44d5f08
5424ac5
8769cff
f192a16
7ca5cf8
822fe0d
d50da33
8cec651
36771a8
3f9727a
9a4a121
e493873
a17a315
d9bef04
f54f102
f642a52
dfb608e
c20370a
feb2f38
11b3421
ea9493e
52463fa
394b48f
1325b7c
63bb5d9
61e3df7
40933d0
8d35f6e
d5d1927
c34d6de
ffea962
ebe85c4
d113bcf
c703c11
468363e
cdf2d37
9eb7c90
3d2c792
394555c
eaf270d
095561f
b0b8ab1
d927b6a
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
'use strict'; | ||
|
||
var annAttrs = require('../annotations/attributes'); | ||
var fontAttrs = require('../../plots/font_attributes'); | ||
var scatterLineAttrs = require('../../traces/scatter/attributes').line; | ||
var dash = require('../drawing/attributes').dash; | ||
var extendFlat = require('../../lib/extend').extendFlat; | ||
|
@@ -224,6 +225,85 @@ module.exports = templatedArray('shape', { | |
'`config.editable` or `config.edits.shapePosition`.' | ||
].join(' ') | ||
}, | ||
|
||
label: { | ||
text: { | ||
valType: 'string', | ||
dflt: '', | ||
editType: 'arraydraw', | ||
description: 'Sets the text to display with shape.' | ||
}, | ||
font: fontAttrs({ | ||
editType: 'calc+arraydraw', | ||
colorEditType: 'arraydraw', | ||
description: 'Sets the shape label text font.' | ||
}), | ||
textposition: { | ||
valType: 'enumerated', | ||
values: [ | ||
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. It looks like we need to have 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. @archmoj What would be the use case for an 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.
Hmm.. that's a good idea. But as far as I recall we don't have such an option for |
||
'top left', 'top center', 'top right', | ||
'middle left', 'middle center', 'middle right', | ||
'bottom left', 'bottom center', 'bottom right', | ||
'start', 'middle', 'end', | ||
], | ||
editType: 'arraydraw', | ||
description: [ | ||
'Sets the position of the label text relative to the shape.', | ||
'Supported values for rectangles, circles and paths are', | ||
'`top left`, `top center`, `top right`, `middle left`,', | ||
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. Please note that back quotes are used around attribute names not the values. '*top left*, *top center*, *top right*, *middle left*,', |
||
'`middle center`, `middle right`, `bottom left`, `bottom center`,', | ||
'and `bottom right`.', | ||
'Supported values for lines are `start`, `middle`, and `end`.', | ||
'Default: `middle center` for rectangles, circles, and paths; `middle` for lines.', | ||
].join(' ') | ||
}, | ||
textangle: { | ||
valType: 'angle', | ||
dflt: 'auto', | ||
editType: 'calc+arraydraw', | ||
description: [ | ||
'Sets the angle at which the label text is drawn', | ||
'with respect to the horizontal. For lines, angle `auto`', | ||
'is the same angle as the line. For all other shapes,', | ||
'angle `auto` is horizontal.' | ||
].join(' ') | ||
}, | ||
xanchor: { | ||
valType: 'enumerated', | ||
values: ['auto', 'left', 'center', 'right'], | ||
dflt: 'auto', | ||
editType: 'calc+arraydraw', | ||
description: [ | ||
'Sets the label\'s horizontal position anchor', | ||
'This anchor binds the specified `label.textposition` to the *left*, *center*', | ||
'or *right* of the label text.', | ||
'For example, if `label.textposition` is set to *top right* and', | ||
'`xanchor` to *right* then the right-most portion of the', | ||
'label text lines up with the right-most edge of the', | ||
'shape.', | ||
].join(' '), | ||
}, | ||
yanchor: { | ||
valType: 'enumerated', | ||
values: ['top', 'middle', 'bottom'], | ||
editType: 'calc+arraydraw', | ||
description: [ | ||
'Sets the label\'s vertical position anchor', | ||
'This anchor binds the specified `label.textposition` to the *top*, *middle*', | ||
'or *bottom* of the label text.', | ||
'For example, if `label.textposition` is set to *top right* and', | ||
'`yanchor` to *top* then the top-most portion of the', | ||
'label text lines up with the top-most edge of the', | ||
'shape.', | ||
].join(' ') | ||
}, | ||
padding: { | ||
valType: 'number', | ||
dflt: 3, | ||
emilykl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
min: 0, | ||
editType: 'arraydraw', | ||
description: 'Sets padding (in px) between edge of label and edge of shape.' | ||
}, | ||
editType: 'arraydraw' | ||
}, | ||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
editType: 'arraydraw' | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.