self
}
+ pub fn with_optional_title(self, title: Option<Value>) -> Self {
+ if let Some(title) = title {
+ self.with_title(title)
+ } else {
+ self
+ }
+ }
+
/// Returns this pivot table with the given `caption`.
///
/// The caption is displayed below the pivot table. Captions are optional.
self
}
+ pub fn with_optional_caption(self, caption: Option<Value>) -> Self {
+ if let Some(caption) = caption {
+ self.with_caption(caption)
+ } else {
+ self
+ }
+ }
+
/// Returns this pivot table with the given `corner_text`.
///
/// The corner text is displayed in the top-left corner of the pivot table,
&self,
graph: &Graph,
footnotes: &pivot::Footnotes,
- cell_footnotes: Option<&Series>,
dims: &[Dim],
series: &BTreeMap<&str, Series>,
warn: &mut dyn FnMut(LegacyXmlWarning),
let mut data = HashMap::new();
let mut coords = Vec::with_capacity(dims.len());
let cell_formats = graph.interval.labeling.decode_format_map(&series);
+ let cell_footnotes = series.get("footnotes");
'outer: for (i, cell) in cell.values.iter().enumerate() {
coords.clear();
for dim in dims {
dims: &mut [Dim],
data: &mut HashMap<Vec<usize>, Value>,
footnotes: &pivot::Footnotes,
- cell_footnotes: Option<&Series>,
warn: &mut dyn FnMut(LegacyXmlWarning),
) {
+ let has_cell_footnotes = series.contains_key("footnotes");
for scp in graph
.facet_layout
.children
dims,
data,
&footnotes,
- cell_footnotes.is_some(),
+ has_cell_footnotes,
);
}
}
None,
&look.areas[Area::Data(RowParity::Even)],
&footnotes,
- cell_footnotes.is_some(),
+ has_cell_footnotes,
);
}
}
let series = self.decode_series(binary_data, warn);
let (mut dims, current_layer) = self.decode_dimensions(graph, &series, &footnotes);
- let cell_footnotes = graph
- .interval
- .footnotes(true)
- .and_then(|footnotes| series.get(footnotes.variable.as_str()));
- let mut data = self.decode_data(graph, &footnotes, cell_footnotes, &dims, &series, warn);
+ let mut data = self.decode_data(graph, &footnotes, &dims, &series, warn);
Self::decode_styles(
- graph,
- &look,
- &series,
- &mut dims,
- &mut data,
- &footnotes,
- cell_footnotes,
- warn,
+ graph, &look, &series, &mut dims, &mut data, &footnotes, warn,
);
- let mut pivot_table = PivotTable::new(
+ Ok(PivotTable::new(
dims.into_iter()
.map(|dim| (dim.axis, dim.dimension))
.collect::<Vec<_>>(),
.with_data(data)
.with_layer(¤t_layer)
.with_decimal(Decimal::for_lang(&self.lang))
- .with_date(self.decode_date(warn));
-
- if let Some(title) = title {
- pivot_table = pivot_table.with_title(title);
- }
- if let Some(caption) = caption {
- pivot_table = pivot_table.with_caption(caption);
- }
- Ok(pivot_table)
+ .with_date(self.decode_date(warn))
+ .with_optional_title(title)
+ .with_optional_caption(caption))
}
}