Integration: #956 chart.options dataLabels resets the series' own settings

Without it, turning Data Labels on did nothing for an imported chart whose series read showVal 0.
This commit is contained in:
aiongg
2026-10-24 06:15:41 +00:00
parent cac379b5ee
commit aed303e504
2 changed files with 25 additions and 0 deletions
+4
View File
@@ -1818,6 +1818,10 @@ fn chart_options(s: &mut Session, p: &Value) -> Result<Value> {
}
if let Some(v) = bool_param(p, "dataLabels") {
c.data_labels = v;
// A series' own setting would otherwise keep overriding the chart-wide switch.
for series in &mut c.series {
series.data_labels = None;
}
}
if let Some(v) = bool_param(p, "gridlines") {
c.gridlines = v;
+21
View File
@@ -152,3 +152,24 @@ fn a_combo_chart_keeps_each_groups_own_label_setting() {
assert!(!c.series_data_labels(&c.series[0]), "so the bars stay quiet");
assert!(c.series_data_labels(&c.series[1]), "the line takes the chart-wide on");
}
/// Turning Data Labels on through `chart.options` shows the labels of series that the file
/// switched off one by one.
#[test]
fn chart_options_data_labels_on_overrides_series_off() {
use deckcraft_engine::Session;
let p = reimport(&bar_chart_pptx(), |xml| xml.replace("<c:cat>", r#"<c:dLbls><c:showVal val="0"/></c:dLbls><c:cat>"#));
assert!(chart_of(&p).series.iter().all(|s| !chart_of(&p).series_data_labels(s)), "every series starts quiet");
let path = std::env::temp_dir().join("deckcraft_series_labels_off.pptx");
std::fs::write(&path, deckcraft_pptx::export(&p).expect("export")).expect("write");
let mut s = Session::with_new();
s.execute("file.open", &serde_json::json!({"path": path.to_string_lossy()})).expect("open");
let doc = s.doc().unwrap().doc.clone();
let id = doc.slides[0].shapes.iter().find(|sh| matches!(sh.kind, ShapeKind::Chart(_))).expect("chart").id.0;
assert!(chart_of(&doc).series.iter().all(|x| !chart_of(&doc).series_data_labels(x)));
s.execute("chart.options", &serde_json::json!({"id": id, "dataLabels": true})).expect("options");
let doc = s.doc().unwrap().doc.clone();
let c = chart_of(&doc);
assert!(c.series.iter().all(|x| c.series_data_labels(x)), "every series shows its labels");
let _ = std::fs::remove_file(path);
}