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

JSON for vectors of traces. #39

Merged
merged 1 commit into from
May 16, 2016

Conversation

EricForgy
Copy link
Contributor

My previous PR ( #38 ) allowed for string interpolation of basic PlotlyJS types including GenericTrace. In addition to those, we also need vectors of generic traces. This PR completes that.

I use this in Pages.jl for sending JS commands from Julia to a browser, e.g.

n = 10
trace1 = scatter(;x = 1:n, y = rand(n))
trace2 = scatter(;x = 1:n, y = rand(n))
data = [trace1, trace2]
layout = Layout(;title = "Create a new <div> and plot an array of traces",
    width = 600,
    height = 300
)
id = "Plot2"
add_div(id)
Pages.broadcast("script","""Plotly.newPlot("$(id)",$(data),$(layout));""")

Without this PR, I'd need to do this instead:

n = 10
trace1 = scatter(;x = 1:n, y = rand(n))
trace2 = scatter(;x = 1:n, y = rand(n))
data = [trace1, trace2]
layout = Layout(;title = "Create a new <div> and plot an array of traces",
    width = 600,
    height = 300
)
id = "Plot2"
add_div(id)
Pages.broadcast("script","""Plotly.newPlot("$(id)",[$(trace1),$(trace2)],$(layout));""") # Note the individual traces.

@sglyon
Copy link
Member

sglyon commented May 16, 2016

Looks great to me, thanks!

@sglyon sglyon merged commit 3256e79 into JuliaPlots:master May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants