Example #1
0
from react import Dash
from components import div, Dropdown

dash = Dash(__name__)

food_groups = ['fruits', 'vegetables']
food_varities = {
    'fruits': [{'val': c, 'label': c} for c in ['apples', 'oranges']],
    'vegetables': [{'val': c, 'label': c} for c in ['kale', 'radishes']]
}
colors = {
    'apples': [{'val': c, 'label': c} for c in
               ['apple green', 'apple red']],
    'oranges': [{'val': c, 'label': c} for c in
                ['orange ruby', 'orange pink']],
    'kale': [{'val': c, 'label': c} for c in
             ['kale green', 'kale evergreen']],
    'radishes': [{'val': c, 'label': c} for c in
                 ['radish red', 'radish pink']]
}

dash.layout = div([
    Dropdown(id='xdata', options=[{'val': c, 'label': c} for c in food_groups])
])
dash.layout['xdata'].selected = dash.layout['xdata'].options[0]['val']
dash.layout.append(
    Dropdown(id='ydata', options=food_varities[dash.layout['xdata'].selected])
)
dash.layout['ydata'].selected = dash.layout['ydata'].options[0]['val']

dash.layout.append(
Example #2
0
# This code generated this page.

import os

from react import Dash
from components import (Dropdown, RadioButton, TextInput, Slider, PlotlyGraph,
                        CheckList, div, pre, hr, h4)

dash = Dash(__name__)

option_list = [('apples', 'Apples'), ('oranges', 'Oranges')]

component_list = [
    Dropdown(id='dropdown',
             options=[{
                 'val': v,
                 'label': l
             } for (v, l) in option_list]),
    RadioButton(id='radio',
                name='fruit',
                options=[{
                    'val': v,
                    'label': l
                } for (v, l) in option_list]),
    TextInput(id='textinput', label='Name', placeholder='James Murphy'),
    Slider(id='slider', min=-5, max=5, value=3, step=0.2, label='time'),
    CheckList(id='checklist',
              options=[{
                  'id': id,
                  'label': l,
                  'checked': False
Example #3
0
# This code generated this page.

import os

from react import Dash
from components import (Dropdown, RadioButton, TextInput, Slider, PlotlyGraph,
                        CheckList, div, pre, hr, h4)

dash = Dash(__name__)


option_list = [('apples', 'Apples'), ('oranges', 'Oranges')]

component_list = [
    Dropdown(id='dropdown',
             options=[{'val': v, 'label': l} for (v, l) in option_list]),
    RadioButton(
        id='radio',
        name='fruit',
        options=[{'val': v, 'label': l} for (v, l) in option_list]),

    TextInput(
        id='textinput',
        label='Name',
        placeholder='James Murphy'
    ),

    Slider(id='slider', min=-5, max=5, value=3, step=0.2, label='time'),

    CheckList(id='checklist', options=[{'id': id, 'label': l,
                                        'checked': False}
Example #4
0
from react import Dash
from components import div, Dropdown, label

dash = Dash(__name__)


def gen_dropdown(id):
    return Dropdown(id=id,
                    options=[{
                        'val': c,
                        'label': c
                    } for c in ['a', 'b', 'c']],
                    selected='a')


components = []
for id in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'O']:
    components.append(label(id))
    components.append(gen_dropdown(id))

dash.layout = div(components)

import time


@dash.react('O', ['C', 'B', 'D', 'E'])
def update_odata(c, b, d, e):
    print 'O'
    time.sleep(10)
    return {'selected': 'b'}
Example #5
0
import pandas.io.data as web

from react import Dash
from components import div, h2, PlotlyGraph, Dropdown, label

from datetime import datetime as dt
df = web.DataReader("aapl", 'yahoo', dt(2007, 10, 1), dt(2009, 4, 1))

dash = Dash(__name__)

dash.layout = div([
    h2('hello dash'),
    div(className='row', content=[
        div(className='two columns', content=[
            div([
                label('select x data'),
                Dropdown(id='xdata', options=[{'val': c, 'label': c}
                                              for c in df.columns])
            ]),
            div([
                label('select y data'),
                Dropdown(id='ydata', options=[{'val': c, 'label': c}
                                              for c in df.columns])
            ]),
        ]),
        div(className='ten columns', content=[
            PlotlyGraph(id='graph')
        ])
    ])
])
Example #6
0
from react import Dash
from components import div, Dropdown, label

dash = Dash(__name__)


def gen_dropdown(id):
    return Dropdown(id=id, options=[{"val": c, "label": c} for c in ["a", "b", "c"]], selected="a")


components = []
for id in ["A", "B", "C", "D", "E", "F", "G", "O"]:
    components.append(label(id))
    components.append(gen_dropdown(id))

dash.layout = div(components)

import time


@dash.react("O", ["C", "B", "D", "E"])
def update_odata(c, b, d, e):
    print "O"
    time.sleep(10)
    return {"selected": "b"}


@dash.react("A", ["C"])
def update_adata(c):
    print "A"
    time.sleep(10)
Example #7
0
import pandas.io.data as web

from react import Dash
from components import div, h2, PlotlyGraph, Dropdown, label

from datetime import datetime as dt

df = web.DataReader("aapl", 'yahoo', dt(2007, 10, 1), dt(2009, 4, 1))

dash = Dash(__name__)

dash.layout = div([
    h2('hello dash'),
    div(className='row',
        content=[
            div(className='two columns',
                content=[
                    div([
                        label('select x data'),
                        Dropdown(id='xdata',
                                 options=[{
                                     'val': c,
                                     'label': c
                                 } for c in df.columns])
                    ]),
                    div([
                        label('select y data'),
                        Dropdown(id='ydata',
                                 options=[{
                                     'val': c,
                                     'label': c
Example #8
0
from react import Dash
from components import div, Dropdown

dash = Dash(__name__)

food_groups = ["fruits", "vegetables"]
food_varities = {
    "fruits": [{"val": c, "label": c} for c in ["apples", "oranges"]],
    "vegetables": [{"val": c, "label": c} for c in ["kale", "radishes"]],
}
colors = {
    "apples": [{"val": c, "label": c} for c in ["apple green", "apple red"]],
    "oranges": [{"val": c, "label": c} for c in ["orange ruby", "orange pink"]],
    "kale": [{"val": c, "label": c} for c in ["kale green", "kale evergreen"]],
    "radishes": [{"val": c, "label": c} for c in ["radish red", "radish pink"]],
}

dash.layout = div([Dropdown(id="xdata", options=[{"val": c, "label": c} for c in food_groups])])
dash.layout["xdata"].selected = dash.layout["xdata"].options[0]["val"]
dash.layout.append(Dropdown(id="ydata", options=food_varities[dash.layout["xdata"].selected]))
dash.layout["ydata"].selected = dash.layout["ydata"].options[0]["val"]

dash.layout.append(Dropdown(id="zdata", options=colors[dash.layout["ydata"].selected]))
dash.layout["zdata"].selected = dash.layout["zdata"].options[0]["val"]


@dash.react("ydata", ["xdata"])
def update_ydata(xdata):
    new_dropdown = {"options": food_varities[xdata.selected]}
    new_dropdown["selected"] = new_dropdown["options"][0]["val"]
    return new_dropdown