Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
add support for new histogram event data - #144
Merged
Merged
Conversation
MemberAuthor
Usage importjsonfromtextwrapimportdedentasdimportdashfromdash.dependenciesimportInput, Outputimportdash_core_componentsasdccimportdash_html_componentsashtmlimportdatetimeimportpandasaspddf=pd.read_csv(
('https://raw.githubusercontent.com/plotly/''datasets/master/1962_2006_walmart_store_openings.csv'),
parse_dates=[1, 2],
infer_datetime_format=True
)
future_indices=df['OPENDATE'] >datetime.datetime(year=2050,month=1,day=1)
df.loc[future_indices, 'OPENDATE'] -=datetime.timedelta(days=365.25*100)
app=dash.Dash(__name__)
app.scripts.config.serve_locally=Trueapp.css.config.serve_locally=Truestyles= {
'pre': {
'border': 'thin lightgrey solid',
'overflowX': 'scroll'
}
}
app.layout=html.Div([
dcc.Graph(
id='basic-interactions',
figure={
'data': [
{
'x': df['OPENDATE'],
'text': df['STRCITY'],
'customdata': df['storenum'],
'name': 'Open Date',
'type': 'histogram'
},
# {# 'x': df['date_super'],# 'text': df['STRCITY'],# 'customdata': df['storenum'],# 'name': 'Super Date',# 'type': 'histogram'# }
],
'layout': {}
}
),
html.Div(className='row', children=[
html.Div([
dcc.Markdown(d(""" **Hover Data** Mouse over values in the graph. """)),
html.Pre(id='hover-data', style=styles['pre'])
], className='three columns'),
html.Div([
dcc.Markdown(d(""" **Click Data** Click on points in the graph. """)),
html.Pre(id='click-data', style=styles['pre']),
], className='three columns'),
html.Div([
dcc.Markdown(d(""" **Selection Data** Choose the lasso or rectangle tool in the graph's menu bar and then select points in the graph. """)),
html.Pre(id='selected-data', style=styles['pre']),
], className='three columns'),
html.Div([
dcc.Markdown(d(""" **Zoom and Relayout Data** Click and drag on the graph to zoom or click on the zoom buttons in the graph's menu bar. Clicking on legend items will also fire this event. """)),
html.Pre(id='relayout-data', style=styles['pre']),
], className='three columns')
])
])
@app.callback(Output('hover-data', 'children'), [Input('basic-interactions', 'hoverData')])defdisplay_hover_data(hoverData):
returnjson.dumps(hoverData, indent=2)
@app.callback(Output('click-data', 'children'), [Input('basic-interactions', 'clickData')])defdisplay_click_data(clickData):
returnjson.dumps(clickData, indent=2)
@app.callback(Output('selected-data', 'children'), [Input('basic-interactions', 'selectedData')])defdisplay_selected_data(selectedData):
returnjson.dumps(selectedData, indent=2)
@app.callback(Output('relayout-data', 'children'), [Input('basic-interactions', 'relayoutData')])defdisplay_selected_data(relayoutData):
returnjson.dumps(relayoutData, indent=2)
if__name__=='__main__':
app.run_server(debug=True) |
chriddyp
requested review from
alishobeiri
and removed request for
alishobeiriJanuary 11, 2018 20:25
chriddyp
commented
Jan 11, 2018
MemberAuthor
big thanks to @alexcjohnson for this one 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

thanks to plotly/plotly.js#2113