Skip to content

Commit

Permalink
Concept implementation of apply theme transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranOMara committed Mar 31, 2019
1 parent 2c58230 commit df934ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Each release typically has a number of minor bug fixes beyond what is listed her
* Add dodged boxplots (#1246)
* Add `Stat.dodge` (#1240)
* `Stat.smooth(method=:lm)` confidence bands (#1231)
* Develop Rectangular Geometry. (#1263)
* Develop Rectangular Geometry, and add `apply_theme_transformations!()` hook. (#1263)

# Version 0.9.0
* conditionally depend on DataFrames (#1204)
Expand Down
23 changes: 23 additions & 0 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,18 @@ function render_prepared(plot::Plot,
# IV. Geometries
themes = Theme[layer.theme === nothing ? plot.theme : layer.theme
for layer in plot.layers]

for (layer, stats, aes, theme) in zip(plot.layers, layer_stats, layer_aess, themes)

if length(stats)> 1
@warn "stats" stats
end

for stat in stats
apply_theme_transformations!(layer.geom, stat, aes, theme)
end
end

zips = trim_zip(plot.layers, layer_aess,
layer_subplot_aess,
layer_subplot_datas,
Expand Down Expand Up @@ -1102,6 +1114,17 @@ include("geometry.jl")
include("guide.jl")
include("statistics.jl")

function apply_theme_transformations!(geom::GeometryElement, stat::StatisticElement, aes::Aesthetics, theme::Theme)
# @info "apply_theme_transformations!" geom stat aes theme
end

function apply_theme_transformations!(geom::Geom.RectangularGeometry, stat::Stat.RectbinStatistic, aes::Aesthetics, theme::Theme)

@info "apply_theme_transformations! specific to geom::Geom.RectangularGeometry, stat::Stat.RectbinStatistic combination."

aes.xmax = aes.xmax .* cx .- theme.bar_spacing
aes.ymax = aes.ymax .* cy .- theme.bar_spacing
end

# All aesthetics must have a scale. If none is given, we use a default.
# The default depends on whether the input is discrete or continuous (i.e.,
Expand Down

0 comments on commit df934ec

Please sign in to comment.