Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotly2.min.js version? #28

Closed
cwiese opened this issue Jan 4, 2022 · 6 comments
Closed

plotly2.min.js version? #28

cwiese opened this issue Jan 4, 2022 · 6 comments
Labels
documentation Improvements or additions to documentation

Comments

@cwiese
Copy link

cwiese commented Jan 4, 2022

I am trying to use a relatively new feature "Legend.groupclick" in plotlyjs. How can I tell what version of plotly2.min.js code has included in this repo?

@essenciary
Copy link
Member

The latest version, 0.9.1 is using Plotly plotly.js v2.8.3 - you can see it in the file itself. https://raw.githubusercontent.com/GenieFramework/StipplePlotly.jl/main/assets/js/plotly2.min.js

@cwiese
Copy link
Author

cwiese commented Jan 6, 2022

I did not realize the version was in the code :-) ..Upgraded and it works! Thanks !

PS) Using Plotlybase.jl has allowed me to use shapes, annotations and many other missing attributes. Dict{Symbol, Any) + Plotlybase.attr. is all that is needed.

@essenciary
Copy link
Member

Can you please share some code sample of the integration?

@cwiese
Copy link
Author

cwiese commented Jan 6, 2022

Certainly - I hope to find the time to create a PR - with the minor required change and a few examples.

Note things that can not be done with current StipplePlotly (shapes and additionally subplot axis with secondary)

using Genie, Genie.Renderer.Html, Stipple, StipplePlotly
using PlotlyBase

Genie.config.log_requests = false

xx = -π:(2π/250):π

xxs = -3.0:0.2:3.0

# Data:

pl1 = PlotlyBase.GenericTrace(Dict(
    :x => xx, :y => sin.(xx), :plot => StipplePlotly.Charts.PLOT_TYPE_SCATTER, :row => 1, :col => 1, :legendgroup => "group1", :legendgrouptitle => PlotlyBase.attr(text = "1 Group Title"), :showlegend => true, 
    :name => "sine", :mode => "lines", :xaxis => "x", :yaxis => "y", :line => PlotlyBase.attr(color = "#ee22cc", dash="solid")
))

ps1 = PlotlyBase.GenericTrace(Dict(
    :x => xxs, :y => sin.(xxs) .+ rand(Float64, size(xxs)) .- 3.5, :plot => StipplePlotly.Charts.PLOT_TYPE_SCATTER,  :row => 1, :col => 1,  :legendgroup => "group1",  :legendgrouptitle => PlotlyBase.attr(text = "1 Group Title"), :showlegend => true, 
    :name => "sine", :mode => "markers", :xaxis => "x", :yaxis => "y11", :marker => PlotlyBase.attr(color= "#ccd9ea", symbol="circle", size=10, opacity=0.8)
 ))

pl2 = PlotlyBase.GenericTrace(Dict(
    :x => xx, :y => sinh.(xx), :plot => StipplePlotly.Charts.PLOT_TYPE_SCATTER, :row => 2, :col => 1,  :legendgroup => "group2",  :legendgrouptitle => PlotlyBase.attr(text = "1 Group Title222"), :showlegend => true, 
    :name => "sinh", :mode => "lines", :xaxis => "x2", :yaxis => "y2", :line => PlotlyBase.attr(color = "#aadd22", dash="dot")
 ))

ps2 = PlotlyBase.GenericTrace(Dict(
    :x => xxs, :y => sinh.(xxs) .+ 3.0 .* rand(Float64, size(xxs)) .- 21.5, :plot => StipplePlotly.Charts.PLOT_TYPE_SCATTER,  :row => 2, :col => 1,  :legendgroup => "group2",  :legendgrouptitle => PlotlyBase.attr(text = "1 Group Title222"), :showlegend => true, 
    :name => "sinh", :mode => "markers", :xaxis => "x2", :yaxis => "y22", :marker => PlotlyBase.attr(color = "#cc12dd", symbol="circle-open", size=14)
 ))

plotdata = [pl1, ps1, pl2, ps2];

#plotdata = [pl2, ps2];

layout = PlotlyBase.Layout(
    Dict{Symbol, Any}(
        :grid => PlotlyBase.attr(columns = 1, rows = 2, pattern = "independent", ygap = 100),
        :xaxis => PlotlyBase.attr(xy = "x", index = 1, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="XXXX"),
        :xaxis2 => PlotlyBase.attr(xy = "x", index = 2, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="XXXX2", anchor="y2"),
        :yaxis => PlotlyBase.attr(xy = "y", index = 1, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="response A"),
        :yaxis11 => PlotlyBase.attr(xy = "y", index = 11, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="response A2", overlaying = "y", side = "right"),
        :yaxis2 => PlotlyBase.attr(xy = "y", index = 2, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="response B"),
        :yaxis22 => PlotlyBase.attr(xy = "y", index = 22, ticks = "outside", showline = true, zeroline = false, font_family = "Arial Black", font_size = 16, title="response B2", overlaying = "y2", side = "right"),
        :annotations => [PlotlyBase.attr(yanchor = "bottom", xanchor = "center", y = 0.9999999999999999, x = 0.5, yref = "paper", xref = "paper", text = "title1", font_size = 20, font_family = "Arial Black", showarrow = false),
                         PlotlyBase.attr(yanchor = "bottom", xanchor = "center", y = 0.33, x = 0.5, yref = "paper", xref = "paper", text = "title2", font_size = 20, font_family = "Arial Black", showarrow = false)]
    ))

    #  vertical_spacing::Float64 = ismissing(subplot_titles) ? 0.3 / rows : 0.5 / rows
    ##     dy = subplot_titles ? 0.55 / nr : 0.3 / nr

Base.@kwdef mutable struct Model <: ReactiveModel
    data::R{Vector{AbstractTrace}} = plotdata
    layout::R{AbstractLayout} = layout
    config::R{StipplePlotly.PlotConfig} = StipplePlotly.PlotConfig()
end

model = Stipple.init(Model())

function ui()
  page(
    vm(model), class="container", [
        plot(:data, layout = :layout, config = :config)
    ]
  ) |> html
end

route("/", ui)

up()

@essenciary
Copy link
Member

Cool, thanks! Let me reopen this so we don't forget about it :)

@essenciary essenciary reopened this Jan 6, 2022
@essenciary essenciary added the documentation Improvements or additions to documentation label Jan 6, 2022
@hhaensel
Copy link
Member

hhaensel commented Oct 7, 2024

We don't support the StipplePlotly API any longer, it's considered legacy. But we will keep it for backward compatibility.
So I think we can close this.

Just to comment on the title, we just released a new version with the latest plotly release v2.35.2

@hhaensel hhaensel closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants