pub struct Annotation { /* private fields */ }
Implementations§
Source§impl Annotation
impl Annotation
pub fn new() -> Annotation
Sourcepub fn visible(self, visible: bool) -> Annotation
pub fn visible(self, visible: bool) -> Annotation
Determines whether or not this annotation is visible.
Sourcepub fn text(self, text: &str) -> Annotation
pub fn text(self, text: &str) -> Annotation
Sourcepub fn text_angle(self, text_angle: f64) -> Annotation
pub fn text_angle(self, text_angle: f64) -> Annotation
Sets the angle at which the text
is drawn with respect to the horizontal.
Sourcepub fn font(self, font: Font) -> Annotation
pub fn font(self, font: Font) -> Annotation
Sets the annotation text font.
Sourcepub fn width(self, width: f64) -> Annotation
pub fn width(self, width: f64) -> Annotation
Sets an explicit width for the text box. null (default) lets the text set the box width.
Wider text will be clipped. There is no automatic wrapping; use
to start a new line.
Sourcepub fn height(self, height: f64) -> Annotation
pub fn height(self, height: f64) -> Annotation
Sets an explicit height for the text box. null (default) lets the text set the box height. Taller text will be clipped.
Sourcepub fn opacity(self, opacity: f64) -> Annotation
pub fn opacity(self, opacity: f64) -> Annotation
Sets the opacity of the annotation (text + arrow).
Sourcepub fn align(self, align: HAlign) -> Annotation
pub fn align(self, align: HAlign) -> Annotation
Sets the horizontal alignment of the text
within the box. Has an effect only if text
spans two or more lines (i.e. text
contains one or more
HTML tags) or if an explicit
width is set to override the text width.
Sourcepub fn valign(self, valign: VAlign) -> Annotation
pub fn valign(self, valign: VAlign) -> Annotation
Sets the vertical alignment of the text
within the box. Has an effect only if an explicit
height is set to override the text height.
Sourcepub fn background_color<C: Color>(self, background_color: C) -> Annotation
pub fn background_color<C: Color>(self, background_color: C) -> Annotation
Sets the background color of the annotation.
Sourcepub fn border_color<C: Color>(self, border_color: C) -> Annotation
pub fn border_color<C: Color>(self, border_color: C) -> Annotation
Sets the color of the border enclosing the annotation text
.
Sourcepub fn border_pad(self, border_pad: f64) -> Annotation
pub fn border_pad(self, border_pad: f64) -> Annotation
Sets the padding (in px) between the text
and the enclosing border.
Sourcepub fn border_width(self, border_width: f64) -> Annotation
pub fn border_width(self, border_width: f64) -> Annotation
Sets the width (in px) of the border enclosing the annotation text
.
Sourcepub fn show_arrow(self, show_arrow: bool) -> Annotation
pub fn show_arrow(self, show_arrow: bool) -> Annotation
Determines whether or not the annotation is drawn with an arrow. If “True”, text
is
placed near the arrow’s tail. If “False”, text
lines up with the x
and y
provided.
Sourcepub fn arrow_color<C: Color>(self, arrow_color: C) -> Annotation
pub fn arrow_color<C: Color>(self, arrow_color: C) -> Annotation
Sets the color of the annotation arrow.
Sourcepub fn arrow_head(self, arrow_head: u8) -> Annotation
pub fn arrow_head(self, arrow_head: u8) -> Annotation
Sets the end annotation arrow head style. Integer between or equal to 0 and 8.
Sourcepub fn start_arrow_head(self, start_arrow_head: u8) -> Annotation
pub fn start_arrow_head(self, start_arrow_head: u8) -> Annotation
Sets the start annotation arrow head style. Integer between or equal to 0 and 8.
Sourcepub fn arrow_side(self, arrow_side: ArrowSide) -> Annotation
pub fn arrow_side(self, arrow_side: ArrowSide) -> Annotation
Sets the annotation arrow head position.
Sourcepub fn arrow_size(self, arrow_size: f64) -> Annotation
pub fn arrow_size(self, arrow_size: f64) -> Annotation
Sets the size of the end annotation arrow head, relative to arrowwidth
. A value of 1
(default) gives a head about 3x as wide as the line.
Sourcepub fn start_arrow_size(self, start_arrow_size: f64) -> Annotation
pub fn start_arrow_size(self, start_arrow_size: f64) -> Annotation
Sets the size of the start annotation arrow head, relative to arrowwidth
. A value of 1
(default) gives a head about 3x as wide as the line.
Sourcepub fn arrow_width(self, arrow_width: f64) -> Annotation
pub fn arrow_width(self, arrow_width: f64) -> Annotation
Sets the width (in px) of annotation arrow line.
Sourcepub fn stand_off(self, stand_off: f64) -> Annotation
pub fn stand_off(self, stand_off: f64) -> Annotation
Sets a distance, in pixels, to move the end arrowhead away from the position it is pointing
at, for example to point at the edge of a marker independent of zoom. Note that this
shortens the arrow from the ax
/ ay
vector, in contrast to xshift
/ yshift
which
moves everything by this amount.
Sourcepub fn start_stand_off(self, start_stand_off: f64) -> Annotation
pub fn start_stand_off(self, start_stand_off: f64) -> Annotation
Sets a distance, in pixels, to move the start arrowhead away from the position it is
pointing at, for example to point at the edge of a marker independent of zoom. Note that
this shortens the arrow from the ax
/ ay
vector, in contrast to xshift
/ yshift
which moves everything by this amount.
Sourcepub fn ax<C: NumOrString>(self, ax: C) -> Annotation
pub fn ax<C: NumOrString>(self, ax: C) -> Annotation
Sets the x component of the arrow tail about the arrow head. If axref
is pixel
, a
positive (negative) component corresponds to an arrow pointing from right to left (left
to right). If axref
is an axis, this is an absolute value on that axis, like x
, NOT a
relative value.
Sourcepub fn ay<C: NumOrString>(self, ay: C) -> Annotation
pub fn ay<C: NumOrString>(self, ay: C) -> Annotation
Sets the y component of the arrow tail about the arrow head. If ayref
is pixel
, a
positive (negative) component corresponds to an arrow pointing from bottom to top (top to
bottom). If ayref
is an axis, this is an absolute value on that axis, like y
, NOT a
relative value.
Sourcepub fn ax_ref(self, ax_ref: &str) -> Annotation
pub fn ax_ref(self, ax_ref: &str) -> Annotation
Indicates in what terms the tail of the annotation (ax,ay) is specified. If pixel
, ax
is a relative offset in pixels from x
. If set to an x axis id (e.g. “x” or “x2”), ax
is
specified in the same terms as that axis. This is useful for trendline annotations which
should continue to indicate the correct trend when zoomed.
Sourcepub fn ay_ref(self, ay_ref: &str) -> Annotation
pub fn ay_ref(self, ay_ref: &str) -> Annotation
Indicates in what terms the tail of the annotation (ax,ay) is specified. If pixel
, ay
is a relative offset in pixels from y
. If set to a y axis id (e.g. “y” or “y2”), ay
is
specified in the same terms as that axis. This is useful for trendline annotations which
should continue to indicate the correct trend when zoomed.
Sourcepub fn x_ref(self, x_ref: &str) -> Annotation
pub fn x_ref(self, x_ref: &str) -> Annotation
Sets the annotation’s x coordinate axis. If set to an x axis id (e.g. “x” or “x2”), the x
position refers to an x coordinate If set to “paper”, the x
position refers to the
distance from the left side of the plotting area in normalized coordinates where 0 (1)
corresponds to the left (right) side.
Sourcepub fn x<C: NumOrString>(self, x: C) -> Annotation
pub fn x<C: NumOrString>(self, x: C) -> Annotation
Sets the annotation’s x position. If the axis type
is “log”, then you must take the log
of your desired range. If the axis type
is “date”, it should be date strings, like date
data, though Date objects and unix milliseconds will be accepted and converted to strings.
If the axis type
is “category”, it should be numbers, using the scale where each category
is assigned a serial number from zero in the order it appears.
Sourcepub fn x_anchor(self, x_anchor: Anchor) -> Annotation
pub fn x_anchor(self, x_anchor: Anchor) -> Annotation
Sets the text box’s horizontal position anchor This anchor binds the x
position to the
“left”, “center” or “right” of the annotation. For example, if x
is set to 1, xref
to
“paper” and xanchor
to “right” then the right-most portion of the annotation lines up with
the right-most edge of the plotting area. If “auto”, the anchor is equivalent to “center”
for data-referenced annotations or if there is an arrow, whereas for paper-referenced with
no arrow, the anchor picked corresponds to the closest side.
Sourcepub fn x_shift(self, x_shift: f64) -> Annotation
pub fn x_shift(self, x_shift: f64) -> Annotation
Shifts the position of the whole annotation and arrow to the right (positive) or left (negative) by this many pixels.
Sourcepub fn y_ref(self, y_ref: &str) -> Annotation
pub fn y_ref(self, y_ref: &str) -> Annotation
Sets the annotation’s y coordinate axis. If set to an y axis id (e.g. “y” or “y2”), the y
position refers to an y coordinate If set to “paper”, the y
position refers to the
distance from the bottom of the plotting area in normalized coordinates where 0 (1)
corresponds to the bottom (top).
Sourcepub fn y<C: NumOrString>(self, y: C) -> Annotation
pub fn y<C: NumOrString>(self, y: C) -> Annotation
Sets the annotation’s y position. If the axis type
is “log”, then you must take the log of
your desired range. If the axis type
is “date”, it should be date strings, like date data,
though Date objects and unix milliseconds will be accepted and converted to strings. If the
axis type
is “category”, it should be numbers, using the scale where each category is
assigned a serial number from zero in the order it appears.
Sourcepub fn y_anchor(self, y_anchor: Anchor) -> Annotation
pub fn y_anchor(self, y_anchor: Anchor) -> Annotation
Sets the text box’s vertical position anchor This anchor binds the y
position to the
“top”, “middle” or “bottom” of the annotation. For example, if y
is set to 1, yref
to
“paper” and yanchor
to “top” then the top-most portion of the annotation lines up with the
top-most edge of the plotting area. If “auto”, the anchor is equivalent to “middle” for
data-referenced annotations or if there is an arrow, whereas for paper-referenced with no
arrow, the anchor picked corresponds to the closest side.
Sourcepub fn y_shift(self, y_shift: f64) -> Annotation
pub fn y_shift(self, y_shift: f64) -> Annotation
Shifts the position of the whole annotation and arrow up (positive) or down (negative) by this many pixels.
Sourcepub fn click_to_show(self, click_to_show: TruthyEnum<ClickToShow>) -> Annotation
pub fn click_to_show(self, click_to_show: TruthyEnum<ClickToShow>) -> Annotation
Makes this annotation respond to clicks on the plot. If you click a data point that exactly
matches the x
and y
values of this annotation, and it is hidden (visible: false), it
will appear. In “onoff” mode, you must click the same point again to make it disappear, so
if you click multiple points, you can show multiple annotations. In “onout” mode, a click
anywhere else in the plot (on another data point or not) will hide this annotation. If you
need to show/hide this annotation in response to different x
or y
values, you can set
xclick
and/or yclick
. This is useful for example to label the side of a bar. To label
markers though, standoff
is preferred over xclick
and yclick
.
Sourcepub fn x_click<C: NumOrString>(self, x_click: C) -> Annotation
pub fn x_click<C: NumOrString>(self, x_click: C) -> Annotation
Toggle this annotation when clicking a data point whose x
value is xclick
rather than
the annotation’s x
value.
Sourcepub fn y_click<C: NumOrString>(self, y_click: C) -> Annotation
pub fn y_click<C: NumOrString>(self, y_click: C) -> Annotation
Toggle this annotation when clicking a data point whose y
value is yclick
rather than
the annotation’s y
value.
Sourcepub fn hover_text(self, hover_text: &str) -> Annotation
pub fn hover_text(self, hover_text: &str) -> Annotation
Sets text to appear when hovering over this annotation. If omitted or blank, no hover label will appear.
Sourcepub fn hover_label(self, hover_label: Label) -> Annotation
pub fn hover_label(self, hover_label: Label) -> Annotation
Label displayed on mouse hover.
Sourcepub fn capture_events(self, capture_events: bool) -> Annotation
pub fn capture_events(self, capture_events: bool) -> Annotation
Determines whether the annotation text box captures mouse move and click events, or allows
those events to pass through to data points in the plot that may be behind the annotation.
By default captureevents
is “false” unless hovertext
is provided. If you use the event
plotly_clickannotation
without hovertext
you must explicitly enable captureevents
.
Sourcepub fn name(self, name: &str) -> Annotation
pub fn name(self, name: &str) -> Annotation
When used in a template, named items are created in the output figure in addition to any
items the figure already has in this array. You can modify these items in the output figure
by making your own item with templateitemname
matching this name
alongside your
modifications (including visible: false
or enabled: false
to hide it). Has no effect
outside of a template.
Sourcepub fn template_item_name(self, template_item_name: &str) -> Annotation
pub fn template_item_name(self, template_item_name: &str) -> Annotation
Used to refer to a named item in this array in the template. Named items from the template
will be created even without a matching item in the input figure, but you can modify one by
making an item with templateitemname
matching its name
, alongside your modifications
(including visible: false
or enabled: false
to hide it). If there is no template or no
matching item, this item will be hidden unless you explicitly show it with visible: true
.