CodeForPhilly / chime

COVID-19 Hospital Impact Model for Epidemics
https://codeforphilly.github.io/chime/
MIT License
205 stars 151 forks source link

["dash"] Move legends under charts #532

Closed jlubken closed 4 years ago

jlubken commented 4 years ago

Description:

Move chart legends under charts. Avoids squashing charts in mobile.

[x] This is something we can copy over from streamlit (screenshots if applicable)

adibiasio commented 4 years ago

I'll try this issue!

adibiasio commented 4 years ago

@jlubken I've figured out a way to set the legend location, however, it requires access to the plotly figures. I can't seem to find them in visualizations.py

On the Dash-Plotly website they have some examples of usign Graph(). Here's one of them,

import dash_core_components as dcc
import plotly.express as px

df = px.data.iris() # iris is a pandas DataFrame
fig = px.scatter(df, x="sepal_width", y="sepal_length")

dcc.Graph(figure=fig)

They always provide a figure object to the figure kwarg, but we don't use figures when creating the dash graphs, we only provide an id kwarg

https://github.com/CodeForPhilly/chime/blob/f884ba97fce8e4df91d1972af54c263bcee7e0ec/src/chime_dash/app/components/visualizations.py#L43

How do the graphs access the data? Are the figure objects being passed in later on?