From 6c8e42344dcab0dbcd62d0bc84764212845cc423 Mon Sep 17 00:00:00 2001 From: Spencer Lyon Date: Mon, 29 Jan 2018 10:02:12 -0500 Subject: [PATCH] ENH: add update and update! for jupyter frontend --- src/PlotlyJS.jl | 6 +++--- src/displays/ijulia.jl | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 8b241847..94e37519 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -9,9 +9,9 @@ using Base.Iterators # need to import some functions because methods are meta-generated import PlotlyBase: - restyle!, relayout!, addtraces!, deletetraces!, movetraces!, redraw!, - extendtraces!, prependtraces!, purge!, to_image, download_image, - restyle, relayout, addtraces, deletetraces, movetraces, redraw, + restyle!, relayout!, update!, addtraces!, deletetraces!, movetraces!, + redraw!, extendtraces!, prependtraces!, purge!, to_image, download_image, + restyle, relayout, update, addtraces, deletetraces, movetraces, redraw, extendtraces, prependtraces, prep_kwargs, sizes, savefig using Blink diff --git a/src/displays/ijulia.jl b/src/displays/ijulia.jl index 47624fec..193f6d54 100644 --- a/src/displays/ijulia.jl +++ b/src/displays/ijulia.jl @@ -122,6 +122,27 @@ end restyle!(jd::JupyterDisplay, update::Associative=Dict(); kwargs...) = _call_plotlyjs(jd, "restyle", merge(update, prep_kwargs(kwargs))) +function update!( + jd::JupyterDisplay, ind::Int, update::Associative=Dict(); + layout::Layout=Layout(), kwargs... + ) + _call_plotlyjs(jd, "update", merge(update, prep_kwargs(kwargs)), layout, ind-1) +end + +function update!( + jd::JupyterDisplay, inds::AbstractVector{Int}, + update::Associative=Dict(); layout::Layout=Layout(), kwargs... + ) + _call_plotlyjs(jd, "update", merge(update, prep_kwargs(kwargs)), layout, inds-1) +end + +function update!( + jd::JupyterDisplay, update::Associative=Dict(); + layout::Layout=Layout(), kwargs... + ) + _call_plotlyjs(jd, "update", merge(update, prep_kwargs(kwargs)), layout) +end + addtraces!(jd::JupyterDisplay, traces::AbstractTrace...) = _call_plotlyjs(jd, "addTraces", traces)