GenieFramework / GenieFramework/StipplePlotly.jl

Can watch for events on plot behind a tab

Open
#48 3 comments 0 reactions 1 assignee Claimed by @AbhimanyuAryan View on GitHub
bug
Dominant language
Julia
Stars
27
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Click event, for example, is not being captured when the plot is not visible when the js_mounted hook is ran.

in both cases (when I am using tabs or not) the watch_plots fails because the "plot" id is not found yet when js_mounted runs

I get a consoler error vue.js:634

[Vue warn]: Error in mounted hook: "TypeError: Cannot read properties of null (reading 'on')"

TypeError: Cannot read properties of null (reading 'on')

```
using Revise
using Stipple, StipplePlotly, StippleUI
using PlotlyBase

@reactive! mutable struct Example <: ReactiveModel
plot::R{Plot} = Plot(rand(100,2))
plot_click::R{Dict{String, Any}} = Dict{String, Any}()
end

function ui(model::Example)
page(model, class = "container",
row(class = "st-module", [
plotly(:plot, syncevents = true),
]))
end

function handlers(model)
on(model.isready) do isready
isready || return
push!(model)
end

on(model.plot_click) do data
haskey(data, "points") && @info "Selection: $(getindex.(data["points"], "pointIndex"))"
end

return model
end

model = init(Example, debounce=0)

route("/") do
model |> handlers |> ui |> html
end

# The following line will watch all plots that have syncevents enabled
# or that have set syncprefix explicitly.
Stipple.js_mounted(::Example) = watchplots(:Example)
#=
Stipple.js_mounted(::Example) = join([
watchplot(:plot)
])
]=#

up(8000)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.