1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Legend configuration types.
/// Legend item flow direction.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LegendDirection {
#[default]
Column,
Row,
}
/// Vertical alignment of the legend within the chart shell.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LegendVerticalAlign {
Top,
#[default]
Middle,
Bottom,
}
/// Horizontal alignment of the legend within the chart shell.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum LegendHorizontalAlign {
Left,
#[default]
Middle,
Right,
}
/// Legend placement within the chart shell.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct LegendPosition {
/// Vertical alignment.
pub vertical: LegendVerticalAlign,
/// Horizontal alignment.
pub horizontal: LegendHorizontalAlign,
}
/// Configuration for the embedded or composed legend.
#[derive(Clone, Debug, PartialEq)]
pub struct LegendConfig {
/// When true, the legend is not rendered.
pub hidden: bool,
/// Item layout direction.
pub direction: LegendDirection,
/// Placement within the chart shell.
pub position: LegendPosition,
/// Inset from the chart shell edge in pixels.
pub padding: f64,
/// Gap between legend items in pixels.
pub item_gap: f64,
/// Gap between color mark and label in pixels.
pub mark_gap: f64,
/// Color swatch width and height in pixels.
pub item_mark_size: f64,
/// When true, series visibility checkboxes are not shown.
pub disable_series_toggle: bool,
}
impl Default for LegendConfig {
fn default() -> Self {
Self {
hidden: false,
direction: LegendDirection::Column,
position: LegendPosition {
vertical: LegendVerticalAlign::Middle,
horizontal: LegendHorizontalAlign::Right,
},
padding: 8.0,
item_gap: 8.0,
mark_gap: 6.0,
item_mark_size: 12.0,
disable_series_toggle: false,
}
}
}