data
}
- pub fn decode(
- &self,
- data: IndexMap<String, IndexMap<String, Vec<DataValue>>>,
- look: Look,
+ fn decode_styles(
+ graph: &Graph,
+ look: &Look,
+ series: &BTreeMap<&str, Series>,
+ dims: &mut [Dim],
+ data: &mut HashMap<Vec<usize>, Value>,
+ footnotes: &pivot::Footnotes,
+ cell_footnotes: Option<&Series>,
warn: &mut dyn FnMut(LegacyXmlWarning),
- ) -> Result<PivotTable, super::Error> {
- let mut graph = None;
- let mut labels = EnumMap::from_fn(|_| Vec::new());
- for child in &self.children {
- match child {
- VisChild::Graph(g) => graph = Some(g),
- VisChild::LabelFrame(label_frame) => {
- if let Some(label) = &label_frame.label
- && let Some(purpose) = label.purpose
- {
- labels[purpose].push(label);
- }
- }
- VisChild::Container(c) => {
- for label_frame in &c.label_frames {
- if let Some(label) = &label_frame.label
- && let Some(purpose) = label.purpose
- {
- labels[purpose].push(label);
- }
- }
- }
- VisChild::Style(_)
- | VisChild::SourceVariable(_)
- | VisChild::DerivedVariable(_)
- | VisChild::Other => (),
- }
- }
- let Some(graph) = graph else { todo!() };
-
- let footnotes = self.decode_footnotes(graph, &labels[Purpose::Footnote]);
-
- let title = LabelFrame::decode_label(&labels[Purpose::Title], &footnotes);
- let caption_labels = if !labels[Purpose::SubTitle].is_empty() {
- &labels[Purpose::SubTitle]
- } else {
- &labels[Purpose::Footnote]
- };
- let caption = LabelFrame::decode_label(caption_labels, &footnotes);
-
- let series = self.decode_series(data, warn);
- let (mut dims, current_layer) = self.decode_dimensions(graph, &series, &footnotes);
-
- let cell_footnotes = graph
- .interval
- .footnotes()
- .and_then(|footnotes| series.get(footnotes.variable.as_str()));
- let mut data = self.decode_data(graph, &footnotes, cell_footnotes, &dims, &series, warn);
-
+ ) {
for scp in graph
.facet_layout
.children
intersect,
&look,
&series,
- dims.as_mut_slice(),
- &mut data,
+ dims,
+ data,
&footnotes,
cell_footnotes.is_some(),
);
}
}
}
+ }
+
+ pub fn decode(
+ &self,
+ data: IndexMap<String, IndexMap<String, Vec<DataValue>>>,
+ look: Look,
+ warn: &mut dyn FnMut(LegacyXmlWarning),
+ ) -> Result<PivotTable, super::Error> {
+ let mut graph = None;
+ let mut labels = EnumMap::from_fn(|_| Vec::new());
+ for child in &self.children {
+ match child {
+ VisChild::Graph(g) => graph = Some(g),
+ VisChild::LabelFrame(label_frame) => {
+ if let Some(label) = &label_frame.label
+ && let Some(purpose) = label.purpose
+ {
+ labels[purpose].push(label);
+ }
+ }
+ VisChild::Container(c) => {
+ for label_frame in &c.label_frames {
+ if let Some(label) = &label_frame.label
+ && let Some(purpose) = label.purpose
+ {
+ labels[purpose].push(label);
+ }
+ }
+ }
+ VisChild::Style(_)
+ | VisChild::SourceVariable(_)
+ | VisChild::DerivedVariable(_)
+ | VisChild::Other => (),
+ }
+ }
+ let Some(graph) = graph else { todo!() }; //XXX
+
+ let footnotes = self.decode_footnotes(graph, &labels[Purpose::Footnote]);
+
+ let title = LabelFrame::decode_label(&labels[Purpose::Title], &footnotes);
+ let caption_labels = if !labels[Purpose::SubTitle].is_empty() {
+ &labels[Purpose::SubTitle]
+ } else {
+ &labels[Purpose::Footnote]
+ };
+ let caption = LabelFrame::decode_label(caption_labels, &footnotes);
+
+ let series = self.decode_series(data, warn);
+ let (mut dims, current_layer) = self.decode_dimensions(graph, &series, &footnotes);
+
+ let cell_footnotes = graph
+ .interval
+ .footnotes()
+ .and_then(|footnotes| series.get(footnotes.variable.as_str()));
+ let mut data = self.decode_data(graph, &footnotes, cell_footnotes, &dims, &series, warn);
+
+ Self::decode_styles(
+ graph,
+ &look,
+ &series,
+ &mut dims,
+ &mut data,
+ &footnotes,
+ cell_footnotes,
+ warn,
+ );
let dimensions = dims
.into_iter()