@@ -60,8 +60,12 @@ impl<'a> From<&'a str> for FontFamily<'a> {
6060/// ```
6161pub mod text_anchor {
6262 /// The horizontal position of the anchor point relative to the text.
63- #[ derive( Clone , Copy ) ]
63+ #[ derive( Default , Clone , Copy ) ]
6464 pub enum HPos {
65+ /// Default value (Left), except chart axes that might provide a different pos.
66+ /// Use another variant to override the default positionning
67+ #[ default]
68+ Default ,
6569 /// Anchor point is on the left side of the text
6670 Left ,
6771 /// Anchor point is on the right side of the text
@@ -71,8 +75,12 @@ pub mod text_anchor {
7175 }
7276
7377 /// The vertical position of the anchor point relative to the text.
74- #[ derive( Clone , Copy ) ]
78+ #[ derive( Default , Clone , Copy ) ]
7579 pub enum VPos {
80+ /// Default value (Top), except chart axes that might provide a different pos
81+ /// Use another variant to override the default positionning
82+ #[ default]
83+ Default ,
7684 /// Anchor point is on the top of the text
7785 Top ,
7886 /// Anchor point is in the vertical center of the text
@@ -82,7 +90,7 @@ pub mod text_anchor {
8290 }
8391
8492 /// The text anchor position.
85- #[ derive( Clone , Copy ) ]
93+ #[ derive( Default , Clone , Copy ) ]
8694 pub struct Pos {
8795 /// The horizontal position of the anchor point
8896 pub h_pos : HPos ,
@@ -105,22 +113,6 @@ pub mod text_anchor {
105113 pub fn new ( h_pos : HPos , v_pos : VPos ) -> Self {
106114 Pos { h_pos, v_pos }
107115 }
108-
109- /// Create a default text anchor position (top left).
110- ///
111- /// - **returns** The default text anchor position
112- ///
113- /// ```rust
114- /// use plotters_backend::text_anchor::{Pos, HPos, VPos};
115- ///
116- /// let pos = Pos::default();
117- /// ```
118- pub fn default ( ) -> Self {
119- Pos {
120- h_pos : HPos :: Left ,
121- v_pos : VPos :: Top ,
122- }
123- }
124116 }
125117}
126118
0 commit comments