Skip to content

Allow passing Python Objects to Dash components via serialization#1782

Draft
akksi wants to merge 9 commits into
plotly:devfrom
akksi:feature/handle-property-types
Draft

Allow passing Python Objects to Dash components via serialization#1782
akksi wants to merge 9 commits into
plotly:devfrom
akksi:feature/handle-property-types

Conversation

@akksi

@akksi akksi commented Sep 27, 2021

Copy link
Copy Markdown
Contributor

e.g.

# DataFrame serialization example
import dash
import dash_table as dt
import dash_html_components as html
from dash.dependencies import Input, Output
from dash._utils import serializer
import pandas as pd

df = pd.read_csv('https://git.io/Juf1t')
app = dash.Dash()

app.layout = html.Div([
    dt.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in df.columns],
        data=df,
        fixed_rows={'headers': True},
    ),
    html.Div(id='output'),
])

@app.callback(Output('output', 'children'), Input('table', 'data'))
def update_1(value):
    print(serializer.unserialize(value))
    return str(value)

app.run_server(debug=True)

@akksi akksi changed the title Allow passing Python Objects to Dash components by serialization Allow passing Python Objects to Dash components via serialization Sep 27, 2021
making possible to accept complex data types (currently Pandas DataFrame) as Layout properties
@akksi akksi force-pushed the feature/handle-property-types branch from 765c26a to 62cfdf9 Compare September 27, 2021 12:06
@gvwilson gvwilson self-assigned this Jul 23, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added feature something new P2 considered for next cycle community community contribution labels Aug 13, 2024
@ndrezn ndrezn self-assigned this Aug 22, 2024
@ndrezn

ndrezn commented Aug 22, 2024

Copy link
Copy Markdown
Member

Assigning myself as we are exploring this feature for Dash. It's not clear this is the implementation we will move forward with but this is a great proposed strategy for handling Python objects directly in Dash components!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community community contribution feature something new P2 considered for next cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants