diff --git a/CHANGELOG.md b/CHANGELOG.md index 36a5b78e2..16f882cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Added `fillto` to `BarPlot` aesthetics [#535](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/535). + ## v0.8.3 - 2024-08-23 - Fixed incorrect x/y axis assignment for the `violin` plot type [#528](https://github.com/MakieOrg/AlgebraOfGraphics.jl/pull/528). diff --git a/src/aesthetics.jl b/src/aesthetics.jl index f93b3dc7b..c3a5bf177 100644 --- a/src/aesthetics.jl +++ b/src/aesthetics.jl @@ -82,8 +82,8 @@ function aesthetic_mapping(::Type{BarPlot}, N::Int) positionals = if N == 1 [ 1 => :direction => dictionary([ - :y => AesY, - :x => AesX, + :y => AesY, + :x => AesX, ]) ] else @@ -107,6 +107,10 @@ function aesthetic_mapping(::Type{BarPlot}, N::Int) ]), :dodge => AesDodge, :stack => AesStack, + :fillto => :direction => dictionary([ + :y => AesY, + :x => AesX, + ]), ]) end diff --git a/test/reference_tests.jl b/test/reference_tests.jl index 2db16e928..30fef2b69 100644 --- a/test/reference_tests.jl +++ b/test/reference_tests.jl @@ -39,6 +39,18 @@ reftest("barplot row layout") do data((; x = ["A", "B", "C"], y = 1:3, z = ["X", "Y", "Z"])) * mapping(:x, :y; row = :z) * visual(BarPlot) |> draw end +reftest("barplot fillto") do + df = (; x = 11:20, upper = 1:10, lower = 0:-1:-9) + spec = data(df) * mapping(:x, :upper, fillto = :lower) * visual(BarPlot) + draw(spec) +end + +reftest("barplot fillto direction x") do + df = (; x = 11:20, upper = 1:10, lower = 0:-1:-9) + spec = data(df) * mapping(:x, :upper, fillto = :lower) * visual(BarPlot, direction = :x) + draw(spec) +end + for (plottype, name) in zip([Lines, Scatter], ["lines", "scatter"]) reftest("$name") do data((; x = [1, 3, 2, 4], y = ["A", "B", "C", "D"])) * mapping(:x, :y) * visual(plottype) |> draw diff --git a/test/reference_tests/barplot fillto direction x ref.png b/test/reference_tests/barplot fillto direction x ref.png new file mode 100644 index 000000000..9f7212b0f Binary files /dev/null and b/test/reference_tests/barplot fillto direction x ref.png differ diff --git a/test/reference_tests/barplot fillto ref.png b/test/reference_tests/barplot fillto ref.png new file mode 100644 index 000000000..bd1455665 Binary files /dev/null and b/test/reference_tests/barplot fillto ref.png differ