首页 > 解决方案 > 范围选择器内的 Dash Plotly 日期选择器

问题描述

我正在尝试在范围选择器内的按钮上设置日期选择器,将我的选择增加到 1M、6M、1Y 等之外。按照显示新按钮的代码。我只是不知道如何添加动作。感谢任何帮助。

def drawGraph():
return html.Div([
dbc.Card(
dbc.CardBody([
dcc.Graph(
figure = px.area(
stocks_close.AMZN, title = 'Amazon',
height=600
).update_xaxes(
title_text = 'Data',
rangeslider_visible = True,
rangeselector = dict(
buttons = list([
dict(count = 0, label = 'Date Range', step = 'all', stepmode = 'backward'),
dict(count = 5, label = '5D', step = 'day', stepmode = 'backward'),
dict(count = 1, label = '1M', step = 'month', stepmode = 'backward'),
dict(count = 6, label = '6M', step = 'month', stepmode = 'backward'),
dict(count = 1, label = 'YTD', step = 'year', stepmode = 'todate'),
dict(count = 1, label = '1Y', step = 'year', stepmode = 'backward'),
dict(count = 2, label = '2Y', step = 'year', stepmode = 'backward'),
dict(step = 'all')]))

标签: plotlyplotly-dash

解决方案


推荐阅读