From c4c42ed1f5060260aff4dedc5e572e2eb5dfacd3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 23 Aug 2025 20:03:40 -0700 Subject: [PATCH] works better now --- rust/pspp/src/sys/raw.rs | 52 ++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/rust/pspp/src/sys/raw.rs b/rust/pspp/src/sys/raw.rs index 747c34761c..e01888a2de 100644 --- a/rust/pspp/src/sys/raw.rs +++ b/rust/pspp/src/sys/raw.rs @@ -1977,30 +1977,46 @@ impl From<&EncodingReport> for Details { let mut output: Vec = vec![value.metadata_pivot_table().into()]; if !value.valid_encodings.is_empty() { - let numbers = Group::new("#") - .with_multiple((1..=value.valid_encodings.len()).map(|i| format!("{i}"))); + let groups = Group::new("Group").with_label_shown().with_multiple( + (1..=value.valid_encodings.len()).map(|i| Value::new_integer(Some(i as f64))), + ); + let encodings = Group::new("Encoding").with_multiple( + (1..=value + .valid_encodings + .iter() + .map(|encodings| encodings.len()) + .sum()) + .map(|i| Value::new_integer(Some(i as f64))), + ); + let mut data = Vec::new(); + let mut index = 0; + for (group, encodings) in value.valid_encodings.iter().enumerate() { + for encoding in encodings { + data.push(([group, index], encoding.name().into())); + index += 1; + } + } output.push( - PivotTable::new([(Axis3::Y, Dimension::new(numbers))]) - .with_data( - value - .valid_encodings - .iter() - .map(|encodings| { - Value::new_user_text(encodings.iter().map(|e| e.name()).join(", ")) - }) - .enumerate() - .map(|(index, datum)| ([index], datum)), - ) - .into(), + PivotTable::new([ + (Axis3::Y, Dimension::new(groups)), + (Axis3::Y, Dimension::new(encodings).with_all_labels_hidden()), + ]) + .with_title("Valid Encodings") + .with_caption("This table lists all of the encodings that were found to successfully interpret text in the file's header records. Encodings in the same group interpret all of the text in the file the same way.") + .with_data(data) + .into(), ); if !value.strings.is_empty() { let purposes = Group::with_capacity("Purpose", value.strings.len()) .with_label_shown() .with_multiple(value.strings.iter().map(|rs| &rs.name)); - let number = Group::new("Text") - .with_label_shown() - .with_multiple((1..=value.valid_encodings.len()).map(|i| format!("{i}"))); + let number = Group::new("Encoding").with_label_shown().with_multiple( + value + .valid_encodings + .iter() + .map(|encodings| encodings[0].name()), + ); output.push( PivotTable::new([ (Axis3::X, Dimension::new(Group::new("Text").with("Text"))), @@ -2008,7 +2024,7 @@ impl From<&EncodingReport> for Details { (Axis3::Y, Dimension::new(purposes)), ]) .with_title("Alternate Encoded Text Strings") - .with_caption("Text strings in the file dictionary that the previously listed encodings interpret differently, along with the interpretations.") + .with_caption("Text strings in the file dictionary that the previously listed encodings interpret differently, along with the interpretations. The listed encodings are the first in each group.") .with_data(value .strings .iter() -- 2.30.2