let mut output: Vec<Item> = 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"))),
(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()