);
}
-fn d4(title: &str, borders: EnumMap<Border, BorderStyle>) -> PivotTable {
+fn d4(
+ title: &str,
+ borders: EnumMap<Border, BorderStyle>,
+ show_dimension_labels: bool,
+) -> PivotTable {
let a = Dimension::builder(
Axis3::X,
Group::builder("a")
- .with_label_shown()
+ .with_show_label(show_dimension_labels)
.with("a1")
.with(Group::builder("ag1").with("a2").with("a3")),
);
let b = Dimension::builder(
Axis3::X,
Group::builder("b")
- .with_label_shown()
+ .with_show_label(show_dimension_labels)
.with(Group::builder("bg1").with("b1").with("b2"))
.with("b3"),
);
let c = Dimension::builder(
Axis3::Y,
Group::builder("c")
- .with_label_shown()
+ .with_show_label(show_dimension_labels)
.with("c1")
.with(Group::builder("cg1").with("c2").with("c3")),
);
let d = Dimension::builder(
Axis3::Y,
Group::builder("d")
- .with_label_shown()
+ .with_show_label(show_dimension_labels)
.with(Group::builder("dg1").with("d1").with("d2"))
.with("d3"),
);
"Dimension Borders 1",
EnumMap::from_fn(|border| match border {
Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => SOLID_BLUE,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
"Dimension Borders 2",
EnumMap::from_fn(|border| match border {
Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => SOLID_BLUE,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
"Category Borders 1",
EnumMap::from_fn(|border| match border {
Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => DASHED_RED,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
"Category Borders 2",
EnumMap::from_fn(|border| match border {
Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => DASHED_RED,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
"Category and Dimension Borders 1",
EnumMap::from_fn(|border| match border {
Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => SOLID_BLUE,
Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::X))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::Y)) => DASHED_RED,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
"Category and Dimension Borders 2",
EnumMap::from_fn(|border| match border {
Border::Dimension(RowColBorder(HeadingRegion::Rows, Axis2::Y))
- | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
- stroke: Stroke::Solid,
- color: Color::BLUE,
- },
+ | Border::Dimension(RowColBorder(HeadingRegion::Columns, Axis2::X)) => SOLID_BLUE,
Border::Category(RowColBorder(HeadingRegion::Rows, Axis2::Y))
- | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => BorderStyle {
- stroke: Stroke::Dashed,
- color: Color::RED,
- },
+ | Border::Category(RowColBorder(HeadingRegion::Columns, Axis2::X)) => DASHED_RED,
_ => BorderStyle::none(),
}),
+ true,
);
assert_rendering(
&pivot_table,
",
);
}
+
+const SOLID_BLUE: BorderStyle = BorderStyle {
+ stroke: Stroke::Solid,
+ color: Color::BLUE,
+};
+
+const DASHED_RED: BorderStyle = BorderStyle {
+ stroke: Stroke::Dashed,
+ color: Color::RED,
+};
+
+#[test]
+fn category_and_dimension_borders_3() {
+ let pivot_table = d4(
+ "Category and Dimension Borders 3",
+ EnumMap::from_fn(|border| match border {
+ Border::Dimension(_) => SOLID_BLUE,
+ Border::Category(_) => DASHED_RED,
+ _ => BorderStyle::none(),
+ }),
+ false,
+ );
+ assert_rendering(
+ &pivot_table,
+ "\
+Category and Dimension Borders 3
+ bg1 │
+ ╌╌╌╌╌╌╌╌╌┬╌╌╌╌╌╌╌╌┤
+ b1 │ b2 │ b3
+ ╶──┬─────┼──┬─────┼──┬─────
+ │ ag1 │ │ ag1 │ │ ag1
+ ├╌╌┬╌╌┤ ├╌╌┬╌╌┤ ├╌╌┬╌╌
+ a1│a2┊a3│a1│a2┊a3│a1│a2┊a3
+dg1┊d1│ c1 0│ 1┊ 2│ 3│ 4┊ 5│ 6│ 7┊ 8
+ ┊ ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼──
+ ┊ │cg1┊c2 9│10┊11│12│13┊14│15│16┊17
+ ┊ │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ ┊ │ ┊c3 18│19┊20│21│22┊23│24│25┊26
+ ├──┼───┴─────┼──┼──┼──┼──┼──┼──┼──┼──
+ ┊d2│ c1 27│28┊29│30│31┊32│33│34┊35
+ ┊ ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼──
+ ┊ │cg1┊c2 36│37┊38│39│40┊41│42│43┊44
+ ┊ │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ ┊ │ ┊c3 45│46┊47│48│49┊50│51│52┊53
+───┴──┼───┴─────┼──┼──┼──┼──┼──┼──┼──┼──
+ d3│ c1 54│55┊56│57│58┊59│60│61┊62
+ ├───┬─────┼──┼──┼──┼──┼──┼──┼──┼──
+ │cg1┊c2 63│64┊65│66│67┊68│69│70┊71
+ │ ├╌╌╌╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌┼╌╌┼╌╌+╌╌
+ │ ┊c3 72│73┊74│75│76┊77│78│79┊80
+",
+ );
+}