plotly / dash-table-experiments

NO LONGER SUPPORTED - use https://github.com/plotly/dash-table instead
MIT License
174 stars 57 forks source link

feature request: Hello World Example #63

Open rutgerhofste opened 6 years ago

rutgerhofste commented 6 years ago

Is it possible to include a hello world example? The current usage.py contains unnecessary complexity.

As a new user I find it hard to understand how to parse a pandas.DataFrame into a dt.DataTable component and I didnt't pay much attention to the 'records' setting in to_dict(). A hello world example would just launch an app with a dt.DataTable component from a simple pandas dataframe. Something like:

import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
import dash_table_experiments as dt
import json
import pandas as pd
import numpy as np
import plotly

app = dash.Dash()

app.scripts.config.serve_locally = True

df_simple = pd.DataFrame({
    'x': ['A', 'B', 'C', 'D', 'E', 'F'],
    'y': [4, 3, 1, 2, 3, 6],
    'z': ['a', 'b', 'c', 'a', 'b', 'c']
})

app.layout = html.Div([
    html.H4('Hello World'),
    dt.DataTable(
        # The df.to_dict("records") will create a list of dictionaries that dash can handle. 
        rows = df_simple.to_dict("records")
        )
    ])

if __name__ == '__main__':
    app.run_server(debug=True)