diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f9a6d15..e1f33c05b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Added +- Bar and histogram layers now support the `linewidth` and `linetype` + aesthetics. - New `TABULATE` clause renders a query result as a table instead of a plot. Tables are rendered via new `html` writer. `TABULATE` supports the following clauses: diff --git a/src/plot/layer/geom/bar.rs b/src/plot/layer/geom/bar.rs index 1d0543c58..8062c1c21 100644 --- a/src/plot/layer/geom/bar.rs +++ b/src/plot/layer/geom/bar.rs @@ -41,6 +41,8 @@ impl GeomTrait for Bar { ("fill", DefaultAestheticValue::String("black")), ("stroke", DefaultAestheticValue::String("black")), ("opacity", DefaultAestheticValue::Number(0.8)), + ("linewidth", DefaultAestheticValue::Number(1.0)), + ("linetype", DefaultAestheticValue::String("solid")), ], } } diff --git a/src/plot/layer/geom/histogram.rs b/src/plot/layer/geom/histogram.rs index 19302187c..974045374 100644 --- a/src/plot/layer/geom/histogram.rs +++ b/src/plot/layer/geom/histogram.rs @@ -29,6 +29,8 @@ impl GeomTrait for Histogram { ("fill", DefaultAestheticValue::String("black")), ("stroke", DefaultAestheticValue::String("black")), ("opacity", DefaultAestheticValue::Number(0.8)), + ("linewidth", DefaultAestheticValue::Number(1.0)), + ("linetype", DefaultAestheticValue::String("solid")), // pos2 and pos1end are produced by stat_histogram but not valid for manual MAPPING ("pos2", DefaultAestheticValue::Delayed), ("pos1end", DefaultAestheticValue::Delayed), diff --git a/src/plot/main.rs b/src/plot/main.rs index ff45cf5b7..53669d2b5 100644 --- a/src/plot/main.rs +++ b/src/plot/main.rs @@ -505,8 +505,15 @@ mod tests { assert!(bar.is_supported("fill")); assert!(bar.is_supported("pos2")); // Bar accepts optional pos2 assert!(bar.is_supported("pos1")); // Bar accepts optional pos1 + assert!(bar.is_supported("linewidth")); + assert!(bar.is_supported("linetype")); assert_eq!(bar.required(), &[] as &[&str]); // No required aesthetics + // Histogram geom + let histogram = Geom::histogram().aesthetics(); + assert!(histogram.is_supported("linewidth")); + assert!(histogram.is_supported("linetype")); + // Text geom - requires label let text = Geom::text().aesthetics(); assert!(text.is_supported("label"));