It must have been too early, I confused colors for quasar elements, which are based on classnames. That’s what csscolors() is meant for.
Plotly markers are colored differently, I’ll paste an example soon.
where color can be any colorant type, e.g. RGB, RGBA, etc.
If you intend to supply different colors for different markers, then color needs to be a vector and the marker keyword needs to receive broadcasting syntax.
If you want to add a color vector that is reflected in the front-end immediately there are two possibilities.
Setup a backend handler that modifies the data
on(model.colors) do colors
model.plot.marker[:color] = colors
notify(model.plot)
end
Setup a frontend handler (‘watcher’)
Stipple.js_watch = """
colors: function (val) {
this.plot.marker.color = val
}
"""
The latter sends less data over the webchannel (at least unless we have implemented element-wise updates). In case of large data this might be relevant. I assume that for the watcher case you need to make sure that you update the colors field after the client connects. So probably you should define colors in the model after the plot data or you should call push!(model, :colors => model.colors) in the isready handler after push!(model).
@hhaensel, I want to add a scale bar showing the range of the values color coded in the plotted markers.How I can add it in the script above. I know how to do it in plotly.
A plot that has been generated with PlotlyBase (or PlotlyJS) can be directly implemented in a Stipple UI by plotly(:plotname), e.g.
using Stipple, StipplePlotly
using PlotlyBase
@reactive! mutable struct Example <: ReactiveModel
plot::R{Plot} = Plot()
end
function ui(model::Example)
page(model, class = "container", [
plotly(:plot)
])
end
model = init(Example, debounce=0)
route("/") do
model |> ui |> html
end
up()
# now connect to localhost with a browser and then execute the following lines.
for i in 1:30
model.plot[] = Plot(rand(100, 2))
sleep(0.1)
end
The translation to the StipplePlotly API is also straight forward, but the axis definition deviates from the python syntax: