-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from plotly/adapt-for-DashBase-v1
Adapt for DashBase v1
- Loading branch information
Showing
14 changed files
with
92 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[deps] | ||
Dash = "1b08a953-4be3-4667-9a23-3db579824955" | ||
DashBase = "03207cf0-e2b3-4b91-9ca8-690cf0fb507e" | ||
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" | ||
PlotlyBase = "a03496cd-edff-5a9b-9e67-9cda94a718b5" | ||
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using Dash | ||
using PlotlyBase | ||
|
||
app = dash() | ||
app.layout = html_div() do | ||
dcc_graph(id = "graph", | ||
|
1 change: 1 addition & 0 deletions
1
test/integration/base/jl_plotly_graph/jlpg002_plotlyjs_graph.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using Dash | ||
using PlotlyJS | ||
|
||
app = dash() | ||
app.layout = html_div() do | ||
dcc_graph(id = "graph", | ||
|
23 changes: 23 additions & 0 deletions
23
test/integration/base/jl_plotly_graph/jlpg003_plots_plotly_graph.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Dash | ||
using Plots | ||
plotly() | ||
|
||
app = dash() | ||
app.layout = html_div() do | ||
dcc_graph(id = "graph", figure = plot((1:10, 1:10))), | ||
html_button("draw", id = "draw"), | ||
html_div("", id = "status") | ||
end | ||
|
||
callback!(app, | ||
Output("graph", "figure"), | ||
Output("status", "children"), | ||
Input("draw", "n_clicks")) do nclicks | ||
return if isnothing(nclicks) | ||
no_update(), "first" | ||
else | ||
plot([(1:10, 1:10), (1:10, 1:2:20)]), "second" | ||
end | ||
end | ||
|
||
run_server(app) |
23 changes: 23 additions & 0 deletions
23
test/integration/base/jl_plotly_graph/jlpg004_plots_plotlyjs_graph.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Dash | ||
using Plots | ||
plotlyjs() | ||
|
||
app = dash() | ||
app.layout = html_div() do | ||
dcc_graph(id = "graph", figure = plot((1:10, 1:10))), | ||
html_button("draw", id = "draw"), | ||
html_div("", id = "status") | ||
end | ||
|
||
callback!(app, | ||
Output("graph", "figure"), | ||
Output("status", "children"), | ||
Input("draw", "n_clicks")) do nclicks | ||
return if isnothing(nclicks) | ||
no_update(), "first" | ||
else | ||
plot([(1:10, 1:10), (1:10, 1:2:20)]), "second" | ||
end | ||
end | ||
|
||
run_server(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
import pathlib | ||
import os.path | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
curr_path = pathlib.Path(__file__).parent.absolute() | ||
def jl_test_file_path(filename): | ||
return os.path.join(curr_path, "jl_plotly_graph", filename) | ||
|
||
def _run_test(dashjl, filename, percy_snapshot_prefix): | ||
fp = jl_test_file_path(filename) | ||
name = f"{percy_snapshot_prefix} figure callback" | ||
|
||
|
||
|
||
def test_jlpg001_plotly_graph(dashjl): | ||
fp = jl_test_file_path("jlpg001_plotly_graph.jl") | ||
dashjl.start_server(fp) | ||
dashjl.wait_for_element_by_css_selector( | ||
"#graph", timeout=20 | ||
) | ||
dashjl.wait_for_element_by_css_selector("#graph", timeout=20) | ||
|
||
dashjl.wait_for_text_to_equal("#status", "first", timeout=10) | ||
|
||
dashjl.percy_snapshot(name="PlotlyBase figure layout") | ||
dashjl.percy_snapshot(name=f"{percy_snapshot_prefix} figure layout") | ||
|
||
dashjl.find_element("#draw").click() | ||
dashjl.wait_for_text_to_equal("#status", "second", timeout=10) | ||
dashjl.percy_snapshot(name=name) | ||
|
||
|
||
def test_jlpg001_plotly_graph(dashjl): | ||
_run_test(dashjl, "jlpg001_plotly_graph.jl", "PlotlyBase") | ||
|
||
def test_jlpg002_plotlyjs_graph(dashjl): | ||
_run_test(dashjl, "jlpg002_plotlyjs_graph.jl", "PlotlyJS") | ||
|
||
def test_jlpg003_plots_plotly_graph(dashjl): | ||
_run_test(dashjl, "jlpg003_plots_plotly_graph.jl", "Plots plotly") | ||
|
||
dashjl.percy_snapshot(name="PlotlyBase figure callback") | ||
def test_jlpg004_plots_plotlyjs_graph(dashjl): | ||
_run_test(dashjl, "jlpg004_plots_plotlyjs_graph.jl", "Plots plotlyjs") |