Skip to content

Commit

Permalink
Refactor attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranOMara committed Aug 1, 2018
1 parent 2378887 commit 1f1a5bf
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 27 deletions.
31 changes: 23 additions & 8 deletions src/geom/rect.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
using Compose: x_measure, y_measure

struct RectangularGeometry{S} <: Gadfly.GeometryElement

struct SatisticalGeometryElement{S} <: Gadfly.GeometryElement
default_statistic::S
tag::Symbol
function RectangularGeometry{S}(;default_statistic = S(), tag = empty_tag) where S <: Gadfly.StatisticElement
# function SatisticalGeometryElement{S}(;default_statistic=S(), tag=empty_tag) where S <: Gadfly.StatisticElement
# new(default_statistic, tag)
# end

function SatisticalGeometryElement{S}(default_statistic=S(), tag=empty_tag) where S <: Gadfly.StatisticElement
new(default_statistic, tag)
end
end

function RectangularGeometry(stat::S) where S <: Gadfly.StatisticElement
RectangularGeometry{S}()
# function SatisticalGeometryElement{S}(::S, default_statistic::S, tag::Symbol) where S <: Gadfly.StatisticElement
# new(default_statistic, tag)
# end
end

RectangularGeometry(;tag=empty_tag) = RectangularGeometry{Stat.Identity}(tag=tag)
# function SatisticalGeometryElement{S}(::S; default_statistic::S=S(), tag::Symbol=empty_tag) where S <: Gadfly.StatisticElement
# SatisticalGeometryElement{S}(default_statistic = default_statistic, tag = tag)
# end

const RectangularGeometry = SatisticalGeometryElement{Stat.Identity}

# function RectangularGeometry(default_statistic = Stat.Identity(), tag = empty_tag)
# RectangularGeometry(default_statistic, default_statistic, tag)
# end


"""
Geom.rect
Expand All @@ -21,12 +35,13 @@ Draw colored rectangles with the corners specified by the
`xmin`, `xmax`, `ymin` and `ymax` aesthetics. Optionally
specify their `color`.
"""
const rect = RectangularGeometry
# const rect = RectangularGeometry
rect() = RectangularGeometry(Gadfly.Stat.Identity())

default_statistic(geom::RectangularGeometry) = geom.default_statistic

element_aesthetics(::RectangularGeometry) =
[:x, :y, :xmin, :xmax, :ymin, :ymax, :color]
[:xmin, :xmax, :ymin, :ymax, :color]

# Render rectangle geometry.
#
Expand Down
41 changes: 22 additions & 19 deletions src/geom/rectbin.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
### should refactor to RectangleGeometry with Identity as the default Stat.
struct RectangularBinGeometry <: Gadfly.GeometryElement
default_statistic::Gadfly.StatisticElement
tag::Symbol
end
# ### should refactor to RectangleGeometry with Identity as the default Stat.
# struct RectangularBinGeometry <: Gadfly.GeometryElement
# default_statistic::Gadfly.StatisticElement
# tag::Symbol
# end

function RectangularBinGeometry(
default_statistic::Gadfly.StatisticElement=Gadfly.Stat.rectbin();
tag=empty_tag)
RectangularBinGeometry(default_statistic, tag)
end
const RectangularBinGeometry = SatisticalGeometryElement{Stat.RectbinStatistic}

# function RectangularBinGeometry(
# default_statistic::Gadfly.StatisticElement=Gadfly.Stat.rectbin();
# tag=empty_tag)
# RectangularBinGeometry(default_statistic, default_statistic, tag)
# end

"""
Geom.rectbin
Draw equal sizes rectangles centered at `x` and `y` positions. Optionally
specify their `color`.
"""
const rectbin = RectangularBinGeometry

"""
Geom.rect
# const rectbin = RectangularBinGeometry
rectbin() = RectangularBinGeometry(Gadfly.Stat.rectbin())

Draw colored rectangles with the corners specified by the
`xmin`, `xmax`, `ymin` and `ymax` aesthetics. Optionally
specify their `color`.
"""
rect() = RectangularBinGeometry(Gadfly.Stat.Identity())
# """
# Geom.rect
#
# Draw colored rectangles with the corners specified by the
# `xmin`, `xmax`, `ymin` and `ymax` aesthetics. Optionally
# specify their `color`.
# """
# rect() = RectangularBinGeometry(Gadfly.Stat.Identity())

"""
Geom.histogram2d[(; xbincount=nothing, xminbincount=3, xmaxbincount=150,
Expand Down

0 comments on commit 1f1a5bf

Please sign in to comment.