working on 0.5 changes
This commit is contained in:
parent
3cc9425219
commit
625c92a985
@ -54,7 +54,7 @@ function _initialize_backend(::PlotlyBackend; kw...)
|
|||||||
JSON._print(io::IO, state::JSON.State, dt::Union{Date,DateTime}) = print(io, '"', dt, '"')
|
JSON._print(io::IO, state::JSON.State, dt::Union{Date,DateTime}) = print(io, '"', dt, '"')
|
||||||
|
|
||||||
_js_path = Pkg.dir("Plots", "deps", "plotly-latest.min.js")
|
_js_path = Pkg.dir("Plots", "deps", "plotly-latest.min.js")
|
||||||
_js_code = open(readall, _js_path, "r")
|
_js_code = open(@compat(readstring), _js_path, "r")
|
||||||
|
|
||||||
# borrowed from https://github.com/plotly/plotly.py/blob/2594076e29584ede2d09f2aa40a8a195b3f3fc66/plotly/offline/offline.py#L64-L71 c/o @spencerlyon2
|
# borrowed from https://github.com/plotly/plotly.py/blob/2594076e29584ede2d09f2aa40a8a195b3f3fc66/plotly/offline/offline.py#L64-L71 c/o @spencerlyon2
|
||||||
_js_script = """
|
_js_script = """
|
||||||
@ -222,15 +222,15 @@ function plotly_domain(sp::Subplot, letter)
|
|||||||
[pcts[i1], pcts[i1]+pcts[i2]]
|
[pcts[i1], pcts[i1]+pcts[i2]]
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: this should actually take into account labels, font sizes, etc
|
# # TODO: this should actually take into account labels, font sizes, etc
|
||||||
# sets (left, top, right, bottom)
|
# # sets (left, top, right, bottom)
|
||||||
function plotly_minpad(sp::Subplot)
|
# function plotly_minpad(sp::Subplot)
|
||||||
(12mm, 2mm, 2mm, 8mm)
|
# (12mm, 2mm, 2mm, 8mm)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
function _update_min_padding!(sp::Subplot{PlotlyBackend})
|
# function _update_min_padding!(sp::Subplot{PlotlyBackend})
|
||||||
sp.minpad = plotly_minpad(sp)
|
# sp.minpad = plotly_minpad(sp)
|
||||||
end
|
# end
|
||||||
|
|
||||||
# tickssym(letter) = Symbol(letter * "ticks")
|
# tickssym(letter) = Symbol(letter * "ticks")
|
||||||
# limssym(letter) = Symbol(letter * "lims")
|
# limssym(letter) = Symbol(letter * "lims")
|
||||||
|
|||||||
@ -166,9 +166,9 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function _update_min_padding!(sp::Subplot{PlotlyBackend})
|
# function _update_min_padding!(sp::Subplot{PlotlyBackend})
|
||||||
sp.minpad = plotly_minpad(sp)
|
# sp.minpad = plotly_minpad(sp)
|
||||||
end
|
# end
|
||||||
|
|
||||||
# function plotlyjs_finalize(plt::Plot)
|
# function plotlyjs_finalize(plt::Plot)
|
||||||
# plotly_finalize(plt)
|
# plotly_finalize(plt)
|
||||||
|
|||||||
@ -287,7 +287,8 @@ function png(plt::AbstractPlot{UnicodePlotsBackend}, fn::AbstractString)
|
|||||||
println("\n\n\n\n\n\n")
|
println("\n\n\n\n\n\n")
|
||||||
gui(plt)
|
gui(plt)
|
||||||
|
|
||||||
@osx_only begin
|
# @osx_only begin
|
||||||
|
@compat @static if is_apple()
|
||||||
# BEGIN HACK
|
# BEGIN HACK
|
||||||
|
|
||||||
# wait while the plot gets drawn
|
# wait while the plot gets drawn
|
||||||
|
|||||||
@ -20,9 +20,15 @@ function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr
|
|||||||
end
|
end
|
||||||
|
|
||||||
function open_browser_window(filename::AbstractString)
|
function open_browser_window(filename::AbstractString)
|
||||||
@osx_only return run(`open $(filename)`)
|
@compat @static if is_apple()
|
||||||
@linux_only return run(`xdg-open $(filename)`)
|
return run(`open $(filename)`)
|
||||||
@windows_only return run(`$(ENV["COMSPEC"]) /c start $(filename)`)
|
end
|
||||||
|
@compat @static if is_linux()
|
||||||
|
return run(`xdg-open $(filename)`)
|
||||||
|
end
|
||||||
|
@compat @static if is_windows()
|
||||||
|
return run(`$(ENV["COMSPEC"]) /c start $(filename)`)
|
||||||
|
end
|
||||||
warn("Unknown OS... cannot open browser window.")
|
warn("Unknown OS... cannot open browser window.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -436,7 +436,7 @@ type BezierCurve{T <: FixedSizeArrays.Vec}
|
|||||||
control_points::Vector{T}
|
control_points::Vector{T}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.call(bc::BezierCurve, t::Real)
|
@compat function (bc::BezierCurve)(t::Real)
|
||||||
p = zero(P2)
|
p = zero(P2)
|
||||||
n = length(bc.control_points)-1
|
n = length(bc.control_points)-1
|
||||||
for i in 0:n
|
for i in 0:n
|
||||||
|
|||||||
@ -7,10 +7,10 @@ const pct = Length{:pct, Float64}(1.0)
|
|||||||
|
|
||||||
const _cbar_width = 5mm
|
const _cbar_width = 5mm
|
||||||
|
|
||||||
Base.(:.*)(m::Measure, n::Number) = m * n
|
@compat Base.:.*(m::Measure, n::Number) = m * n
|
||||||
Base.(:.*)(n::Number, m::Measure) = m * n
|
@compat Base.:.*(n::Number, m::Measure) = m * n
|
||||||
Base.(:-)(m::Measure, a::AbstractArray) = map(ai -> m - ai, a)
|
@compat Base.:-(m::Measure, a::AbstractArray) = map(ai -> m - ai, a)
|
||||||
Base.(:-)(a::AbstractArray, m::Measure) = map(ai -> ai - m, a)
|
@compat Base.:-(a::AbstractArray, m::Measure) = map(ai -> ai - m, a)
|
||||||
Base.zero(::Type{typeof(mm)}) = 0mm
|
Base.zero(::Type{typeof(mm)}) = 0mm
|
||||||
Base.one(::Type{typeof(mm)}) = 1mm
|
Base.one(::Type{typeof(mm)}) = 1mm
|
||||||
Base.typemin(::typeof(mm)) = -Inf*mm
|
Base.typemin(::typeof(mm)) = -Inf*mm
|
||||||
@ -18,15 +18,15 @@ Base.typemax(::typeof(mm)) = Inf*mm
|
|||||||
Base.convert{F<:AbstractFloat}(::Type{F}, l::AbsoluteLength) = convert(F, l.value)
|
Base.convert{F<:AbstractFloat}(::Type{F}, l::AbsoluteLength) = convert(F, l.value)
|
||||||
|
|
||||||
# TODO: these are unintuitive and may cause tricky bugs
|
# TODO: these are unintuitive and may cause tricky bugs
|
||||||
# Base.(:+)(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 + m2.value))
|
# @compat Base.:+(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 + m2.value))
|
||||||
# Base.(:+)(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * (1 + m1.value))
|
# @compat Base.:+(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * (1 + m1.value))
|
||||||
# Base.(:-)(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 - m2.value))
|
# @compat Base.:-(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * (1 - m2.value))
|
||||||
# Base.(:-)(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * (m1.value - 1))
|
# @compat Base.:-(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * (m1.value - 1))
|
||||||
|
|
||||||
Base.(:*)(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * m2.value)
|
@compat Base.:*(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value * m2.value)
|
||||||
Base.(:*)(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * m1.value)
|
@compat Base.:*(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value * m1.value)
|
||||||
Base.(:/)(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value / m2.value)
|
@compat Base.:/(m1::AbsoluteLength, m2::Length{:pct}) = AbsoluteLength(m1.value / m2.value)
|
||||||
Base.(:/)(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value / m1.value)
|
@compat Base.:/(m1::Length{:pct}, m2::AbsoluteLength) = AbsoluteLength(m2.value / m1.value)
|
||||||
|
|
||||||
|
|
||||||
Base.zero(::Type{typeof(pct)}) = 0pct
|
Base.zero(::Type{typeof(pct)}) = 0pct
|
||||||
@ -42,11 +42,11 @@ right(bbox::BoundingBox) = left(bbox) + width(bbox)
|
|||||||
bottom(bbox::BoundingBox) = top(bbox) + height(bbox)
|
bottom(bbox::BoundingBox) = top(bbox) + height(bbox)
|
||||||
Base.size(bbox::BoundingBox) = (width(bbox), height(bbox))
|
Base.size(bbox::BoundingBox) = (width(bbox), height(bbox))
|
||||||
|
|
||||||
# Base.(:*){T,N}(m1::Length{T,N}, m2::Length{T,N}) = Length{T,N}(m1.value * m2.value)
|
# @compat Base.:*{T,N}(m1::Length{T,N}, m2::Length{T,N}) = Length{T,N}(m1.value * m2.value)
|
||||||
ispositive(m::Measure) = m.value > 0
|
ispositive(m::Measure) = m.value > 0
|
||||||
|
|
||||||
# union together bounding boxes
|
# union together bounding boxes
|
||||||
function Base.(:+)(bb1::BoundingBox, bb2::BoundingBox)
|
@compat function Base.:+(bb1::BoundingBox, bb2::BoundingBox)
|
||||||
# empty boxes don't change the union
|
# empty boxes don't change the union
|
||||||
ispositive(width(bb1)) || return bb2
|
ispositive(width(bb1)) || return bb2
|
||||||
ispositive(height(bb1)) || return bb2
|
ispositive(height(bb1)) || return bb2
|
||||||
|
|||||||
@ -675,48 +675,48 @@ end
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function rotate(x::Real, y::Real, θ::Real; center = (0,0))
|
# function rotate(x::Real, y::Real, θ::Real; center = (0,0))
|
||||||
cx = x - center[1]
|
# cx = x - center[1]
|
||||||
cy = y - center[2]
|
# cy = y - center[2]
|
||||||
xrot = cx * cos(θ) - cy * sin(θ)
|
# xrot = cx * cos(θ) - cy * sin(θ)
|
||||||
yrot = cy * cos(θ) + cx * sin(θ)
|
# yrot = cy * cos(θ) + cx * sin(θ)
|
||||||
xrot + center[1], yrot + center[2]
|
# xrot + center[1], yrot + center[2]
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
# ---------------------------------------------------------------------------
|
# # ---------------------------------------------------------------------------
|
||||||
|
#
|
||||||
type EllipseRecipe <: PlotRecipe
|
# type EllipseRecipe <: PlotRecipe
|
||||||
w::Float64
|
# w::Float64
|
||||||
h::Float64
|
# h::Float64
|
||||||
x::Float64
|
# x::Float64
|
||||||
y::Float64
|
# y::Float64
|
||||||
θ::Float64
|
# θ::Float64
|
||||||
end
|
# end
|
||||||
EllipseRecipe(w,h,x,y) = EllipseRecipe(w,h,x,y,0)
|
# EllipseRecipe(w,h,x,y) = EllipseRecipe(w,h,x,y,0)
|
||||||
|
#
|
||||||
# return x,y coords of a rotated ellipse, centered at the origin
|
# # return x,y coords of a rotated ellipse, centered at the origin
|
||||||
function rotatedEllipse(w, h, x, y, θ, rotθ)
|
# function rotatedEllipse(w, h, x, y, θ, rotθ)
|
||||||
# # coord before rotation
|
# # # coord before rotation
|
||||||
xpre = w * cos(θ)
|
# xpre = w * cos(θ)
|
||||||
ypre = h * sin(θ)
|
# ypre = h * sin(θ)
|
||||||
|
#
|
||||||
# rotate and translate
|
# # rotate and translate
|
||||||
r = rotate(xpre, ypre, rotθ)
|
# r = rotate(xpre, ypre, rotθ)
|
||||||
x + r[1], y + r[2]
|
# x + r[1], y + r[2]
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
function getRecipeXY(ep::EllipseRecipe)
|
# function getRecipeXY(ep::EllipseRecipe)
|
||||||
x, y = unzip([rotatedEllipse(ep.w, ep.h, ep.x, ep.y, u, ep.θ) for u in linspace(0,2π,100)])
|
# x, y = unzip([rotatedEllipse(ep.w, ep.h, ep.x, ep.y, u, ep.θ) for u in linspace(0,2π,100)])
|
||||||
top = rotate(0, ep.h, ep.θ)
|
# top = rotate(0, ep.h, ep.θ)
|
||||||
right = rotate(ep.w, 0, ep.θ)
|
# right = rotate(ep.w, 0, ep.θ)
|
||||||
linex = Float64[top[1], 0, right[1]] + ep.x
|
# linex = Float64[top[1], 0, right[1]] + ep.x
|
||||||
liney = Float64[top[2], 0, right[2]] + ep.y
|
# liney = Float64[top[2], 0, right[2]] + ep.y
|
||||||
Any[x, linex], Any[y, liney]
|
# Any[x, linex], Any[y, liney]
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
function getRecipeArgs(ep::EllipseRecipe)
|
# function getRecipeArgs(ep::EllipseRecipe)
|
||||||
[(:line, (3, [:dot :solid], [:red :blue], :path))]
|
# [(:line, (3, [:dot :solid], [:red :blue], :path))]
|
||||||
end
|
# end
|
||||||
|
|
||||||
# -------------------------------------------------
|
# -------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user