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 to shape, holding all label options
text : The label’s text
font : The label’s font properties (same properties as for Annotation)
position : The label’s position relative to the shape. Possible values: [ left | center | right ] [ top | middle | bottom ] ; OR [ start | end ] for lines
textangle : 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 to xanchor and yanchor (symmetrical on all sides)
cc @alexcjohnson @archmoj
Revised 10 Jan 2023: Changed angle property name to textangle
To-dos
Partnership
Development of this feature is sponsored by Volkswagen's Center of Excellence for Battery Systems.
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)colorfamilysizeposition: 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 toxanchorandyanchor(symmetrical on all sides)cc @alexcjohnson @archmoj
Revised 10 Jan 2023: Changed
angleproperty name totextangleTo-dos
xanchoryanchorpaddingpositiontextangleautoangle for linesfontPartnership
Development of this feature is sponsored by Volkswagen's Center of Excellence for Battery Systems.