Skip to content

Commit

Permalink
Merge pull request #74 from jonathanBieler/pull-request/80aa0e8d
Browse files Browse the repository at this point in the history
fix crash when zooming on a plot without ticks
  • Loading branch information
timholy authored Aug 16, 2017
2 parents cae4c0a + 80aa0e8 commit 8032557
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/display_gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,20 +433,32 @@ function GtkUtilities.panzoom(f::Figure)
aes = _aes(f)
xview = (aes.xviewmin, aes.xviewmax)
yview = (aes.yviewmin, aes.yviewmax)

if xview == (nothing, nothing)
xview = (minimum(aes.x),maximum(aes.x))
end
if yview == (nothing, nothing)
yview = (minimum(aes.y),maximum(aes.y))
end

panzoom(f.canvas, xview, yview)
end

function GtkUtilities.panzoom_mouse(f::Figure; kwargs...)
aes = _aes(f)
xflip = aes.xtick[end] < aes.xtick[1]
yflip = aes.ytick[end] > aes.ytick[1]
xtick = aes.xtick != nothing ? aes.xtick : aes.x
ytick = aes.ytick != nothing ? aes.ytick : aes.y
xflip = xtick[end] < xtick[1]
yflip = ytick[end] > ytick[1]
panzoom_mouse(f.canvas; xpanflip=xflip, ypanflip=yflip, user_to_data=(c,x,y)->dev2data(c,x,y), kwargs...)
end

function GtkUtilities.panzoom_key(f::Figure; kwargs...)
aes = _aes(f)
xflip = aes.xtick[end] < aes.xtick[1]
yflip = aes.ytick[end] > aes.ytick[1]
xtick = aes.xtick != nothing ? aes.xtick : aes.x
ytick = aes.ytick != nothing ? aes.ytick : aes.y
xflip = xtick[end] < xtick[1]
yflip = ytick[end] > ytick[1]
panzoom_key(f.canvas; xpanflip=xflip, ypanflip=yflip, kwargs...)
end

Expand Down

0 comments on commit 8032557

Please sign in to comment.