Skip to content

Commit

Permalink
Attempt to fix broken unitful_color.jl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
non-Jedi committed Mar 18, 2018
1 parent e4729b7 commit a40eb33
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/scale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,26 +575,14 @@ element_aesthetics(::ContinuousColorScale) = [:color]

function apply_scale(scale::ContinuousColorScale,
aess::Vector{Gadfly.Aesthetics}, datas::Gadfly.Data...)
cmin, cmax = Inf, -Inf
for data in datas
data.color === nothing && continue

for c in data.color
c === NA && continue

c = convert(Float64, c)
if c < cmin
cmin = c
end

if c > cmax
cmax = c
end
end
cdata = reduce(vcat, [], [i.color for i in datas if i.color != nothing])
filter!(!isna, cdata)
if !isempty(cdata)
cmin, cmax = extrema(cdata)
else
return
end

(cmin == Inf || cmax == -Inf) && return

if scale.minvalue != nothing
cmin = scale.minvalue
end
Expand Down Expand Up @@ -646,11 +634,11 @@ function apply_scale(scale::ContinuousColorScale,
end

function apply_scale_typed!(ds, field, scale::ContinuousColorScale,
cmin::Float64, cspan::Float64)
cmin, cspan)
for (i, d) in enumerate(field)
if isconcrete(d)
ds[i] = convert(RGB{Float32},
scale.f((convert(Float64, scale.trans.f(d)) - cmin) / cspan))
scale.f((scale.trans.f(d) - cmin) / cspan))
else
ds[i] = NA
end
Expand Down

0 comments on commit a40eb33

Please sign in to comment.