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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#[derive(Debug, Clone)]
pub(crate) struct Scene {
pub width: u32,
pub height: u32,
pub elements: Vec<Element>,
}
#[derive(Debug, Clone)]
pub(crate) enum Element {
Circle(Circle),
Line(Line),
Polyline(Polyline),
Rect(Rect),
SeriesText(Text, usize),
Text(Text),
/// Draws nothing: a `data-*` hook for the optional interactive module, written only with the
/// `hooks` render option.
Hook(Hook),
/// Opens a group whose classes tie what it holds to the diagram nodes it belongs to, for the
/// focus of the HTML profile; [`Element::GroupEnd`] closes it.
Group(String),
/// Opens a group like [`Element::Group`] around a diagram node that has an ID in the
/// specification: the classes, then that ID, which the `hooks` render option writes out as
/// `data-chartlet-node`. [`Element::GroupEnd`] closes it.
NodeGroup(String, String),
/// Opens a group like [`Element::Group`] around a diagram edge that has an ID in the
/// specification: the classes, then that ID, which the `hooks` render option writes out as
/// `data-chartlet-edge`. [`Element::GroupEnd`] closes it.
EdgeGroup(String, String),
GroupEnd,
/// Draws nothing: where a diagram node stands, for the focus link the HTML profile lays over
/// it.
Hotspot(Hotspot),
/// A symbol of an architecture component, see [`crate::symbols`].
Symbol(SymbolUse),
}
/// Where a symbol stands: its name and the top left corner of its square.
#[derive(Debug, Clone)]
pub(crate) struct SymbolUse {
pub name: &'static str,
pub x: f64,
pub y: f64,
}
/// A diagram node the HTML profile can focus: its index, its name, and its box.
#[derive(Debug, Clone)]
pub(crate) struct Hotspot {
pub node: usize,
pub label: String,
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}
/// The geometry and grouping the interactive module reads from a chart, see [`Element::Hook`].
#[derive(Debug, Clone)]
pub(crate) enum Hook {
/// The plot of one pane: `x` maps the time or category axis as `(value, pixel)` pairs, linear
/// between neighbours; `y` maps the value axis by its two ends, linear or, when `log`, linear
/// in the logarithm of the value.
Plot {
pane: usize,
x: Vec<(f64, f64)>,
y: [(f64, f64); 2],
log: bool,
},
/// Opens a group around what one layer draws, by its index among all layers of all panes.
Layer(usize),
/// Opens a group around a diagram object that has an ID in the specification but no focus
/// group of its own, such as a frame: the name of the attribute that carries the ID, then the
/// ID.
Object(&'static str, String),
/// Closes the group of the last [`Hook::Layer`] or [`Hook::Object`].
End,
}
#[derive(Debug, Clone)]
pub(crate) struct Circle {
pub cx: f64,
pub cy: f64,
pub radius: f64,
pub class: &'static str,
/// Series index (0-based) for multi-series charts; used for CSS filtering.
pub series_index: Option<usize>,
/// Index into the specification-declared colors, see [`Polyline`].
pub style_index: Option<usize>,
/// Accessible tooltip text displayed on hover via `<title>`.
pub tooltip: Option<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct Line {
pub x1: f64,
pub y1: f64,
pub x2: f64,
pub y2: f64,
pub class: &'static str,
}
#[derive(Debug, Clone)]
pub(crate) struct Rect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
pub class: &'static str,
/// Series index (0-based) for multi-series charts; used for CSS filtering.
pub series_index: Option<usize>,
/// Index into the specification-declared colors, see [`Polyline`].
pub style_index: Option<usize>,
/// Accessible tooltip text displayed on hover via `<title>`.
pub tooltip: Option<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct Polyline {
pub points: Vec<(f64, f64)>,
pub class: &'static str,
/// Series index (0-based) for multi-series charts; used for CSS filtering.
pub series_index: Option<usize>,
/// Index into the specification-declared colors: a polyline is painted by
/// `.chartlet-style-N` (stroke), a rect by `.chartlet-style-N-swatch` (fill).
pub style_index: Option<usize>,
/// Accessible tooltip text displayed on hover via `<title>`.
pub tooltip: Option<String>,
}
#[derive(Debug, Clone, Copy)]
pub(crate) enum TextAnchor {
Start,
Middle,
End,
}
#[derive(Debug, Clone)]
pub(crate) struct Text {
pub x: f64,
pub y: f64,
pub class: &'static str,
pub anchor: TextAnchor,
pub content: String,
}