Skip to content

Commit

Permalink
WIP: 0.7 Requires.jl code
Browse files Browse the repository at this point in the history
  • Loading branch information
sglyon committed Aug 24, 2018
1 parent ca5a349 commit 527211a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 67 deletions.
5 changes: 2 additions & 3 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
julia 0.7
JSON 0.7
Blink 0.3.3
DocStringExtensions
Blink 0.8
Requires
PlotlyBase 0.1.2
PlotlyBase
Reexport 0.2.0
Compat 0.69
34 changes: 0 additions & 34 deletions recession_dates.tsv

This file was deleted.

30 changes: 28 additions & 2 deletions src/PlotlyJS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ export
# frontend methods
init_notebook

@require Rsvg include("savefig_cairo.jl")

function _savefig_cairo(x...)
msg = """
Rsvg.jl must be loaded in order to save in this format. Please ensure
Expand All @@ -79,6 +77,34 @@ function _savefig_cairo(x...)
error(msg)
end


function __init__()
@require IJulia="7073ff75-c697-5162-941a-fcdaad2a7d2a" begin
import IJulia
using IJulia.send_comm # needed for _call_js above to work
global const _ijulia_eval_comm = Ref{IJulia.CommManager.Comm{:plotlyjs_eval}}()
if IJulia.inited
_ijulia_eval_comm[] = IJulia.CommManager.Comm(:plotlyjs_eval)
end
init_notebook()

function IJulia.display_dict(p::JupyterPlot)
if p.view.displayed
Dict()
else
p.view.displayed = true
Dict("text/html" => html_body(p),
"application/vnd.plotly.v1+json" => JSON.lower(p))
end
end
set_display!(JupyterDisplay)
end
@require Rsvg="c4c386cf-5103-5370-be45-f3a111cca3b8" include("savefig_cairo.jl")
@require Juno="e5e0dc1b-0480-54bc-9374-aad01c23163d" include("displays/juno.jl")
@require WebIO="0f1e0344-ec1d-5b48-a673-e5cf874b6c29"include("displays/webio.jl")
end


@init begin
if !isfile(_js_path)
info("plotly.js javascript libary not found -- downloading now")
Expand Down
2 changes: 0 additions & 2 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ Base.copy(sp::SyncPlot) = fork(sp) # defined by each SyncPlot{TD}

using Compat.UUIDs

@require Juno include("displays/juno.jl")
@require WebIO include("displays/webio.jl")
include("displays/electron.jl")
include("displays/ijulia.jl")

Expand Down
26 changes: 0 additions & 26 deletions src/displays/ijulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,3 @@ extendtraces!(jd::JupyterDisplay, update::AbstractDict=Dict(),
prependtraces!(jd::JupyterDisplay, update::AbstractDict=Dict(),
indices::Vector{Int}=[1], maxpoints=-1;) =
_call_plotlyjs(jd, "prependTraces", update, indices-1, maxpoints)


# --------------------------------------------- #
# Code to run once when the notebook starts up! #
# --------------------------------------------- #

@require IJulia begin
import IJulia
using IJulia.send_comm # needed for _call_js above to work
global const _ijulia_eval_comm = Ref{IJulia.CommManager.Comm{:plotlyjs_eval}}()
if IJulia.inited
_ijulia_eval_comm[] = IJulia.CommManager.Comm(:plotlyjs_eval)
end
init_notebook()

function IJulia.display_dict(p::JupyterPlot)
if p.view.displayed
Dict()
else
p.view.displayed = true
Dict("text/html" => html_body(p),
"application/vnd.plotly.v1+json" => JSON.lower(p))
end
end
set_display!(JupyterDisplay)
end

0 comments on commit 527211a

Please sign in to comment.