As promised
plot = StipplePlotly.PlotData(
x = rand(100),
y = rand(100),
mode = "markers",
plot = StipplePlotly.Charts.PLOT_TYPE_SCATTER,
marker = Dict(:color => "#" * hex(color, :auto))
)
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.
marker = Dict(:color => "#" .* hex.(colors, :auto))
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).