plotly / documentation

Issue tracker for Plotly's open-source documentation.
421 stars 551 forks source link

What about Dash? #1654

Closed nicolaskruchten closed 4 years ago

nicolaskruchten commented 4 years ago

We need to add, to every R and Python page other than the "Is Plotly Free?" pages, a section at the bottom that reads something like:

What about Dash?

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library. Everywhere in this page that you see fig.show(), you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or the output of any Plotly Express function
# fig.add_trace( ... )
# fig.update_layout( ... ) 

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div(
    dcc.Graph(figure=fig)
)

app.run_server(debug=True)
nicolaskruchten commented 4 years ago

@jdamiba let's try to knock this one out this week please.

nicolaskruchten commented 4 years ago

Open to ideas about the phrasing and the exact code being shown. maybe the code needs to be page-specific, so as to reuse one of the simpler cells, to make it an actual copy-pasteable example... that would be labour-intensive but worth it IMO.

nicolaskruchten commented 4 years ago

@chriddyp @emmanuelle @alexcjohnson input is welcome on this first pass!

The idea here is that all doc pages get the same little block (for now) and then in some near future we can do per-page blocks that don't show an empty figure.

@jdamiba and I figured out that actually we can append a little bit of Markdown to the notebooks right before rendering them in the CI step, so that this block will get formatted just like any other doc, without having to be manually pasted everywhere. Here is the R PR for this https://github.com/plotly/plotly.r-docs/pull/41 and the Python bit can just go in here somewhere once we agree on the details: https://github.com/plotly/plotly.py/blob/master/doc/Makefile#L32

chriddyp commented 4 years ago

Nice! I might change the first line to be:

fig = go.Figure() # or the output of any Plotly Express function, like `fig = px.scatter(...)`
chriddyp commented 4 years ago

and also:

app.layout = html.Div([
    dcc.Graph(figure=fig)
])
chriddyp commented 4 years ago

Since most folks working in plotly are working in jupyter, maybe let's also do this until we fix this in the library level

app.run_server(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter