好的,所以我想更进一步。我不知道是否可以用破折号。
我想创建一个表单(可能是来自 Flask 的 WTForm )。
表格应该有 date
和 annotation/comments
部分。
当有人提交表单时,它会保存到数据库中。
然后破折号将读取它并显示在图表上。
我的图表看起来像这样:
关于 x-axis
将是 date
来自 FlaskForm 表示它存储在数据库中的事件,以及 annotation
当我将鼠标悬停在精确位置时,将显示在图表中 date
类似于这个的东西:
现在,你能告诉我这是否可能吗?我应该使用什么工具?这只是一个概念,但我认为对每个人都有帮助。
最佳答案
在 plotly 中,您可以使用注释显示文本。例子:
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)
引用:https://plot.ly/python/text-and-annotations希望这能回答你的问题。另请参阅
mode='lines+markers+text'
在散点图中(Adding Text to Data in Line and Scatter Plots
部分 plotly 文档)
关于python - 将表单添加到 Dash/Plotly 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51837333/