working on args

This commit is contained in:
Thomas Breloff 2015-10-06 10:07:18 -05:00
parent 70db97d576
commit b6855b6fba
4 changed files with 20 additions and 10 deletions

View File

@ -301,8 +301,6 @@ wraptuple(x) = (x,)
# given one value (:log, or :flip, or (-1,1), etc), set the appropriate arg
function processAxisArg(d::Dict, axisletter::AbstractString, arg)
T = typeof(arg)
delete!(d, symbol(axisletter * "axis"))
if T <: Symbol
arg = get(_scaleAliases, arg, arg)
@ -338,8 +336,6 @@ end
function processLineArg(d::Dict, arg)
T = typeof(arg)
delete!(d, :line)
if T <: Symbol
arg = get(_typeAliases, arg, arg)
@ -367,13 +363,13 @@ end
function processMarkerArg(d::Dict, arg)
T = typeof(arg)
delete!(d, :marker)
if T <: Symbol
arg = get(_markerAliases, arg, arg)
println(arg)
if arg in _allMarkers
println("HERE ", arg)
d[:marker] = arg
elseif arg != :match && !handleColors!(d, arg, :markercolor)
warn("Skipped marker arg $arg. Unknown symbol.")
@ -393,19 +389,28 @@ end
function preprocessArgs!(d::Dict)
replaceAliases!(d, _keyAliases)
# handle axis args
for axisletter in ("x", "y")
for arg in wraptuple(get(d, symbol(axisletter * "axis"), ()))
asym = symbol(axisletter * "axis")
for arg in wraptuple(get(d, asym, ()))
processAxisArg(d, axisletter, arg)
end
delete!(d, asym)
end
# handle line args
for arg in wraptuple(get(d, :line, ()))
processLineArg(d, arg)
end
delete!(d, :line)
# handle marker args... default to ellipse if shape not set
for arg in wraptuple(get(d, :marker, ()))
processMarkerArg(d, arg)
end
if haskey(d, :marker) && typeof(d[:marker]) <: Tuple
d[:marker] = :ellipse
end
end
# -----------------------------------------------------------------------------

View File

@ -277,7 +277,8 @@ function addGadflySeries!(gplt, d::Dict, initargs::Dict)
# Should ensure from this side that colors which are the same are merged together
push!(guide.labels, d[:label])
push!(guide.colors, d[:marker] == :none ? first(d[:color]) : d[:markercolor])
# push!(guide.colors, d[:marker] == :none ? first(d[:color]) : d[:markercolor])
push!(guide.colors, getColor(d[d[:marker] == :none ? :color : :markercolor], 1))
end
# end
end

View File

@ -14,7 +14,7 @@ function createGadflyAnnotation(d::Dict)
shape = ohlcshape(x, y, d[:markersize])
d[:y] = Float64[z.open for z in y]
d[:linetype] = :none
return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(nothing), Gadfly.stroke(d[:color])))
return Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(nothing), Gadfly.stroke(getColor(d[:color],1)))
elseif marker == :rect
shape = square(x, y, sz)
@ -54,7 +54,7 @@ function createGadflyAnnotation(d::Dict)
shape = Gadfly.circle(xs,ys,[sz])
end
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(d[:markercolor]), Gadfly.stroke(colorant"white")))
Gadfly.Guide.annotation(Gadfly.compose(Gadfly.context(), shape, Gadfly.fill(getColorVector(d[:markercolor])), Gadfly.stroke(colorant"white")))
end

View File

@ -82,6 +82,7 @@ abstract ColorScheme
getColor(scheme::ColorScheme, idx::Integer) = getColor(scheme, 0.0, idx)
getColor(scheme::ColorScheme, z::AbstractFloat) = getColor(scheme, z, 0)
getColorVector(scheme::ColorScheme) = [getColor(scheme, 0.0, 1)]
colorscheme(scheme::ColorScheme) = scheme
colorscheme(s::Symbol) = haskey(_gradients, s) ? ColorGradient(s) : ColorWrapper(convertColor(s))
@ -144,6 +145,8 @@ function getColor(gradient::ColorGradient, z::Real, idx::Int)
cs[end]
end
getColorVector(gradient::ColorGradient) = [gradient.cs[1]]
function interpolate(c1::Colorant, c2::Colorant, w::Real)
lab1 = Lab(c1)
lab2 = Lab(c2)
@ -179,6 +182,7 @@ end
typealias CVec ColorVector
getColor(scheme::ColorVector, z::Real, idx::Int) = convertColor(scheme.v[mod1(idx, length(scheme.v))])
getColorVector(scheme::ColorVector) = scheme.v
# --------------------------------------------------------------