Skip to content

Commit

Permalink
Work towards #90
Browse files Browse the repository at this point in the history
Implemented and test added. Will close with documentation on gh-pages
branch
  • Loading branch information
randyzwitch committed Dec 1, 2015
1 parent e4890a2 commit 0626de4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ build_script:
Pkg.clone(pwd(), \"Vega\"); Pkg.build(\"Vega\")"

test_script:
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.add(\"PyCall\");Pkg.add(\"RDatasets\");Pkg.test(\"Vega\")"
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.add(\"RDatasets\");Pkg.test(\"Vega\")"
6 changes: 3 additions & 3 deletions src/intermediates/modifiers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function legend!(v::VegaVisualization; title::AbstractString="Group", show::Bool
end

#Use ColorBrewer.jl scales
function colorscheme!(v::VegaVisualization; palette::Union{Tuple{AbstractString,Any}, AbstractString, Array} = "ordinal10")
function colorscheme!(v::VegaVisualization; palette::Union{Tuple{AbstractString,Any}, AbstractString, Array} = "ordinal10", reversePalette::Bool = false)

#See if group or color key exists
i = findfirst([z.name == "group" for z in v.scales])
Expand All @@ -66,11 +66,11 @@ function colorscheme!(v::VegaVisualization; palette::Union{Tuple{AbstractString,

#colorscheme, single color or array of arbitrary string colors
if isa(palette, Tuple)
s.range = colorpalettes[palette[1]]["$(palette[2])"]
reversePalette == true? s.range = reverse(colorpalettes[palette[1]]["$(palette[2])"]) : s.range = colorpalettes[palette[1]]["$(palette[2])"]
elseif isa(palette, AbstractString)
s.range = [palette]
elseif isa(palette, Array)
s.range = palette
reversePalette == true? s.range = reverse([palette]) : s.range = [palette]
end

return v
Expand Down
12 changes: 11 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,21 @@ ylim!(a, _type = "pow")
@test typeof(a) == VegaVisualization

#51 lineplot with sqrt yaxis
println("Test 50")
println("Test 51")
x = [1:100; 1:100]
y = [collect(1:100) + randn(100); 3.0 + 1.5 * collect(1:100) + randn(100)]
group = [[1 for i in 1:100]; [2 for i in 1:100]]

a = lineplot(x = x, y = y, group = group)
ylim!(a, _type = "sqrt")
@test typeof(a) == VegaVisualization

#52 reverse keyword for colorscheme!
println("Test 52")
x = [1:100; 1:100]
y = [collect(1:100) + randn(100); 3.0 + 1.5 * collect(1:100) + randn(100)]
group = [[1 for i in 1:100]; [2 for i in 1:100]]

a = lineplot(x = x, y = y, group = group)
colorscheme!(a, palette = ("wesanderson", "BottleRocket1"), reversePalette = true)
@test typeof(a) == VegaVisualization

0 comments on commit 0626de4

Please sign in to comment.