Genie Discord forum

I would like to activate interactive drawing within GenieBuilder plots, as described in the Plotly user manual:
using PlotlyJS
text="Click and drag<br> to draw a rectangle <br><br> or select another shape <br>in the modebar"
fig = plot(
Layout(
annotations=[
attr(
x=0.5,
y=0.5,
text=text,
xref="paper",
yref="paper",
showarrow=false,
font_size=20
)
],
shapes=[
attr(
line_color="yellow",
fillcolor="turquoise",
opacity=0.4,
editable=true,
x0=0, x1=1, y0=2, y1=3,
xref="x", yref="y"
)
],
dragmode="drawrect",
# style of new shapes
newshape=attr(
line_color="yellow",
fillcolor="turquoise",
opacity=0.5
)
),
config=PlotConfig(
modeBarButtonsToAdd=[
"drawline",
"drawopenpath",
"drawclosedpath",
"drawcircle",
"drawrect",
"eraseshape"
]
)
)
Can that be done, and if yes: how?
My attempts with adding config as:
config_user = GenieFramework.PlotConfig(staticplot = false, displaymodebar="drawcircle")
and
plot(:appData, layout=:appLayout, config=config_user)
did not add any menu bar items. It would be very useful to have this possibility.

It looks like a lot of these attributes are added, but I have never tried to implement this:

That looks like a really neat feature of PlotlyJS that I have never played around with ๐ณ

thanks. modeBarButtonsToAdd
should be the correct option (I suppose const CONGIG_DEFAULTS
should be renamed to CONFIG_DEFAULTS
).
What is the API to change values?

Yes, it is contained in the dict CONFIG_DEFAULTS, and I think the right way to change this would be using Charts.PlotConfig()

Look closely... it seems like a bug... const CONGIG_DEFAULTS... not CONFIG_DEFAULTS

๐ ๐ ๐ @abhimanyuaryan @Pere or anyone else more experienced than me (practically everyone here) ๐ณ

This looks like a typo in charts.jl line #587... but perhaps I am mistaken. The CONGIG_DEFAULTS is properly referenced later (line 845, 846)

I submitted it as possible issue in github ๐ค

brilliant - thanks a lot!

I hope it helps. I'm new so take my advice with a bit of salt ๐ซข

ok, so here a MWE that illustrates the issue:
using GenieFramework
using PlotlyBase
data = scatter(Dict(
:name => "",
:x => [0, 1],
:y => [0, 0.5],
:marker => Dict(:color => "red")
))
myconfig = PlotlyBase.PlotConfig( displaylogo=true,
modeBarButtonsToAdd=["drawline", "drawopenpath", "drawcircle","eraseshape"]
)
function ui()
[
h1("StipplePlotly ๐ง interactive example")
plot(:appData, config=:appConfig)
]
end
@app begin
@out appData = [ data]
@out appConfig = myconfig
end
@page("/", ui)
up()

If displaylogo=false
, it indeed removes the Plotly logo.
Yet the modeBarButtonsToAdd
does not seem to have an effect, so it seems that some options are propagated, but not all.

Do you maybe have to add StipplePlotly instead of PlotlyBase?

@Boris Kaus I havent tried with such plot options, but will take a look when I get back form vacation in a few days