Ok, So I want to go one step further. I don't know if it is possible with a dash.
I want to create a form ( probably WTForm from Flask ).
The form should have date
and annotation/comments
section.
When someone submits a form, it will save to the database.
Then dash will read it and show on the graph.
My graph looks like that:
On the x-axis
will be date
from FlaskForm representing Event that it was stored in the database, and annotation
will be showed in the graph itself when I hover to that exact date
Something similar to this one:
And now, can you please tell me if it's possible? What tools should I use it? It's just a concept, but I think will be helpful for everyone.
Including custom CSS or JavaScript in your Dash apps is simple. Just create a folder named assets in the root of your app directory and include your CSS and JavaScript files in that folder. Dash will automatically serve all of the files that are included in this folder.
Link components and callbacks. Dash Pages uses these components and abstracts away the callback logic required for URL routing, making it easy to get up and running with a multi-page app. If you want to build a multi-page app without Pages, see the Multi Page Apps without Pages section below.
Streamlit is more structured and focused more on simplicity. It only supports Python-based data analysis and has a limited set of widgets (for example, sliders) to choose from. Dash is more adaptable.
Dash is a web app framework that provides pure Python abstraction around HTML, CSS, and JavaScript. Instead of writing HTML or using an HTML templating engine, you compose your layout using Python with the Dash HTML Components module ( dash.
In plotly you can display text using annotation. Example:
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 1, 3, 2, 4, 3, 4, 6, 5]
)
trace2 = go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
y=[0, 4, 5, 1, 2, 2, 3, 4, 2]
)
data = [trace1, trace2]
layout = go.Layout(
showlegend=False,
annotations=[
dict(
x=2,
y=5,
xref='x',
yref='y',
text='max',
showarrow=True,
arrowhead=7,
ax=0,
ay=-40
)
]
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)
Ref : https://plot.ly/python/text-and-annotations
Hope that answers your question. Also refer to mode='lines+markers+text'
in scatter plot(Adding Text to Data in Line and Scatter Plots
section of plotly doc)
Pretty late here, but check out dbc.Input from dash-bootstrap-components.
https://dash-bootstrap-components.opensource.faculty.ai/l/components/input
There are form types, inputs, etc.
How I would do it is add a few inputs, etc. as well as a submit button. The submit button would trigger the function that creates the graphs, adds the relevant things, and returns the figure to the graph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With