Comments (1)
The examples should run on with both Dash 2 and 1. Does it work for you if you swap out the Dash 1 import statements for Dash 2? That would look like this:
import dash
from dash import Input, Output, dcc, html, dash_table
import pandas as pd
import json
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv')
df['id'] = df['country']
df.set_index('id', inplace=True, drop=False)
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.RadioItems(
id='filter-query-read-write',
options=[
{'label': 'Read filter_query', 'value': 'read'},
{'label': 'Write to filter_query', 'value': 'write'}
],
value='read'
),
html.Br(),
dcc.Input(id='filter-query-input', placeholder='Enter filter query'),
html.Div(id='filter-query-output'),
html.Hr(),
dash_table.DataTable(
id='datatable-advanced-filtering',
columns=[
{'name': i, 'id': i, 'deletable': True} for i in df.columns
# omit the id column
if i != 'id'
],
data=df.to_dict('records'),
editable=True,
page_action='native',
page_size=10,
filter_action="native"
),
html.Hr(),
html.Div(id='datatable-query-structure', style={'whitespace': 'pre'})
])
@app.callback(
Output('filter-query-input', 'style'),
Output('filter-query-output', 'style'),
Input('filter-query-read-write', 'value')
)
def query_input_output(val):
input_style = {'width': '100%'}
output_style = {}
if val == 'read':
input_style.update(display='none')
output_style.update(display='inline-block')
else:
input_style.update(display='inline-block')
output_style.update(display='none')
return input_style, output_style
@app.callback(
Output('datatable-advanced-filtering', 'filter_query'),
Input('filter-query-input', 'value')
)
def write_query(query):
if query is None:
return ''
return query
@app.callback(
Output('filter-query-output', 'children'),
Input('datatable-advanced-filtering', 'filter_query')
)
def read_query(query):
if query is None:
return "No filter query"
return dcc.Markdown('`filter_query = "{}"`'.format(query))
@app.callback(
Output('datatable-query-structure', 'children'),
Input('datatable-advanced-filtering', 'derived_filter_query_structure')
)
def display_query(query):
if query is None:
return ''
return html.Details([
html.Summary('Derived filter query structure'),
html.Div(dcc.Markdown('''```json
{}
```'''.format(json.dumps(query, indent=4))))
])
if __name__ == '__main__':
app.run_server(debug=True)
from dash-docs.
Related Issues (20)
- formatting relative %changes with colour scale HOT 1
- R: "Sharing data between callbacks" doesn't mention dccStore, and gives outdated advice of using hidden divs
- python: some unclear parts in "Sharing data between callbacks"
- DataTable filtering: filter_action doesn't work if the columns property is not specified HOT 1
- Spelling update HOT 1
- Update Link in documentation HOT 1
- Examples with `trigger_id = ctx.triggered[0]["prop_id"].split(".")[0]` potentially misleading as command only gets the first trigger HOT 1
- Mutable default arguments in AIO example 1 HOT 1
- Dash docs - AIO reference && community components reference
- Questionable practices in the Pattern Matching Callbacks example
- Text overflow in tooltip sample app HOT 1
- 'Kubernetes Installation' link throws 500 error HOT 2
- Shouldn't the Editable DataTable docs Contain a CSV List Editor? HOT 3
- Where to update current dash.testing docs?
- Coiled + Dash + Dask example is out of date HOT 7
- Basic layout example in docs not working HOT 3
- Document how to use javascript modules for clientside functions
- Potential performance issue: groupby performance regression in pandas 1.2.x HOT 1
- Update "Syntax Highlighting With Markdown" instructions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash-docs.