lichtung_plot/builder/
text_layout.rs1use super::Plot;
4use crate::{GuideTextRole, TextLayout};
5
6macro_rules! role {
7 ($name:ident,$bound:ident,$field:ident) => {impl<K:crate::kind::$bound> Plot<K> {
8 #[doc=concat!("Replace the `",stringify!($field),"` text owner's complete layout default.")]
9 #[must_use]
10 pub fn $name(mut self,layout:TextLayout) -> Self {self.description.payload_mut().text_layouts.$field=Some(layout);self}
11 }};
12 ($name:ident,$bound:ident,$field:ident,$index:expr) => {impl<K:crate::kind::$bound> Plot<K> {
13 #[doc=concat!("Replace the `",stringify!($field),"` text owner's complete layout default.")]
14 #[must_use]
15 pub fn $name(mut self,layout:TextLayout) -> Self {self.description.payload_mut().text_layouts.$field[$index]=Some(layout);self}
16 }};
17}
18role!(x_tick_text_layout, XAxisText, ticks, 0);
19role!(y_tick_text_layout, YAxisText, ticks, 1);
20role!(facet_row_text_layout, Facet, facet, 0);
21role!(facet_column_text_layout, Facet, facet, 1);
22role!(estimate_detail_text_layout, EstimateDetailText, estimate);
23role!(significance_text_layout, SignificanceStyle, significance);
24
25impl<K: crate::kind::Legend> Plot<K> {
26 #[must_use]
28 pub fn guide_text_layout(mut self, role: GuideTextRole, layout: TextLayout) -> Self {
29 self.description.payload_mut().text_layouts.guide[role.index()] = Some(layout);
30 self
31 }
32}
33impl Plot<crate::kind::Matrix> {
34 #[must_use]
36 pub fn matrix_row_text_layout(mut self, layout: TextLayout) -> Self {
37 self.description.payload_mut().text_layouts.matrix[0] = Some(layout);
38 self
39 }
40 #[must_use]
42 pub fn matrix_column_text_layout(mut self, layout: TextLayout) -> Self {
43 self.description.payload_mut().text_layouts.matrix[1] = Some(layout);
44 self
45 }
46}
47impl Plot<crate::kind::Heatmap> {
48 #[must_use]
50 pub fn value_text_layout(mut self, layout: TextLayout) -> Self {
51 self.description.payload_mut().text_layouts.value = Some(layout);
52 self
53 }
54 #[must_use]
56 pub fn null_row_text_layout(mut self, layout: TextLayout) -> Self {
57 self.description.payload_mut().text_layouts.null_row = Some(layout);
58 self
59 }
60}
61impl Plot<crate::kind::Waterfall> {
62 #[must_use]
64 pub fn total_text_layout(mut self, layout: TextLayout) -> Self {
65 self.description.payload_mut().text_layouts.total = Some(layout);
66 self
67 }
68}