Closed
Description
Text on Shapes feature
Expand the Shape API to support adding a text label to any line or shape.
Labels can be styled similarly to text annotations, and support options for setting their position relative to the shape or line.
Proposed API
Here is the proposed API for Text on Shapes, as discussed with @alexcjohnson :
label
: Top-level property to be added toshape
, holding all label optionstext
: The label’s textfont
: The label’s font properties (same properties as for Annotation)color
family
size
position
: The label’s position relative to the shape. Possible values:[ left | center | right ] [ top | middle | bottom ]
; OR[ start | end ]
for linestextangle
: Rotation angle of the label. Possible values : number between -180 and 180 ; OR[ auto ]
for lines (same angle as line)xanchor
: The x-component of the anchor point on the label used to determine position (in the pre-rotated reference frame). Possible values :[ left | center | right ]
yanchor
: The y-component of the anchor point on the label used to determine position (in the pre-rotated reference frame). Possible values :[ top | middle | bottom ]
padding
: Offset of label relative toxanchor
andyanchor
(symmetrical on all sides)
Revised 10 Jan 2023: Changed angle
property name to textangle
To-dos
- Add above properties to shape attributes
- Implement basic functionality of rendering text relative to shape position
- Properly handle re-render on pan/zoom
- Properly handle re-render on shape move
- Implement
xanchor
- Implement
yanchor
- Implement
padding
- Implement
position
- Implement
textangle
- Numeric angles
-
auto
angle for lines
- Implement
font
- Correctly handle multiline labels
- Correctly handle clipping outside plot area
- Properly set defaults for all properties
- Add image test
- Add Jasmine test
Partnership
Development of this feature is sponsored by Volkswagen's Center of Excellence for Battery Systems.