Ejemplo n.º 1
0
app.debug = True
app.config['key'] = 'secret'
socketio = SocketIO(app)

from dash_clustering_iris import Dash
dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-clustering
# We're using the template "layout_single_column_and_controls" which uses the
# includes blocks: 'controls.html', main_pane.html'.
utils.write_templates(
    {
        'header': [el('h4', {}, 'Iris K-means clustering')],
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-clustering
        'main_pane': [graph('iris')],
    },
    name)


@app.route('/')
def index():

    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('pong')
def onpong(app_state):
    messages = dash.on_pong(app_state)
    emit('postMessage', json.dumps(messages,
Ejemplo n.º 2
0
app = Flask(name)
app.debug = True
app.config['key'] = 'secret'
socketio = SocketIO(app)

from example_3_click_events_state import Dash
dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-3-click-events
# We're using the template "layout_two_column_and_controls" which uses the
# includes blocks: 'controls.html', 'leftgraph.html', and 'rightgraph.html'.
utils.write_templates(
    {
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-3-click-events
        'leftgraph': [graph('bubbles')],
        'rightgraph': [graph('line-chart')]
    }, name
)


@app.route('/')
def index():

    return render_template('layouts/layout_two_column_and_controls.html',
                           app_name=name)


@socketio.on('pong')
def onpong(app_state):
    messages = dash.on_pong(app_state)
Ejemplo n.º 3
0
                'value': 0,
                'min': 1,
                'max': 10,
                'step': 0.1
            }),
            el('label', {}, 'Title'),
            el('input', {
                'type': 'text',
                'name': 'title',
                'placeholder': 'Type away',
                'class': 'u-full-width'
            }, '')
        ],

        'main_pane': [
            graph('sine-wave')
        ]
    }, name
)


@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('replot')
def replot(app_state):
    print(app_state)
    frequency = float(app_state['frequency'])
Ejemplo n.º 4
0
# includes blocks: 'header.html', 'controls.html', and 'main_pane.html'.
utils.write_templates(
    {
        'header': [
            el('H1', {}, 'Yahoo Finance Explorer'),
        ],
        'controls': [
            el('label', {'for': 'ticker'}, 'Ticker'),
            el('input', {
                'name': 'ticker',
                'type': 'text',
                'value': 'GOOG',
                'class': 'u-full-width'
            }, '')
        ],
        'main_pane': [graph('line-chart')]
    }, name
)


@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('replot')
def replot(app_state):
    update_graph(app_state)

Ejemplo n.º 5
0
                    'name': 'frequency',
                    'value': 0,
                    'min': 1,
                    'max': 10,
                    'step': 0.1
                }),
            el('label', {}, 'Title'),
            el(
                'input', {
                    'type': 'text',
                    'name': 'title',
                    'placeholder': 'Type away',
                    'class': 'u-full-width'
                }, '')
        ],
        'main_pane': [graph('sine-wave')]
    }, name)


@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('replot')
def replot(app_state):
    print(app_state)
    frequency = float(app_state['frequency'])
    x = np.linspace(0, 2 * 3.14, 500)
    y = np.sin(frequency * x)
Ejemplo n.º 6
0
app.debug = True
app.config["key"] = "secret"
socketio = SocketIO(app)

from example_3_click_events_state import Dash

dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-3-click-events
# We're using the template "layout_two_column_and_controls" which uses the
# includes blocks: 'controls.html', 'leftgraph.html', and 'rightgraph.html'.
utils.write_templates(
    {
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-3-click-events
        "leftgraph": [graph("bubbles")],
        "rightgraph": [graph("line-chart")],
    },
    name,
)


@app.route("/")
def index():

    return render_template("layouts/layout_two_column_and_controls.html", app_name=name)


@socketio.on("pong")
def onpong(app_state):
    messages = dash.on_pong(app_state)
Ejemplo n.º 7
0
        }]

        return messages


dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-clustering
# We're using the template "layout_single_column_and_controls" which uses the
# includes blocks: 'controls.html', main_pane.html'.
utils.write_templates(
    {
        'header': [el('h4', {}, 'Histogram of @python_tip likes')],
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-clustering
        'main_pane': [graph('hist')],
    },
    name)


@app.route('/')
def index():

    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('pong')
def onpong(app_state):
    messages = dash.on_pong(app_state)
    emit('postMessage', json.dumps(messages,
Ejemplo n.º 8
0
from dash.components import element as el
from dash.components import graph

name = __name__
app = Flask(name)
app.debug = True
app.config['key'] = 'secret'
socketio = SocketIO(app)

# Write the HTML "includes" blocks to /templates/runtime/dash-5-push-to-client
# Alternatively, include the HTML yourself in that folder
utils.write_templates(
    {
        'content': [
            el('h1', {}, 'Refresh the data behind the graph'),
            graph('graph')
        ]
    }, name
)


@app.route('/')
def index():
    return render_template('layouts/layout_full_screen.html',
                           app_name=name)


@socketio.on('replot')
def replot(app_state):
    """ Callback for state changes in the front-end
    """
Ejemplo n.º 9
0
utils.write_templates(
    {
        'header': [
            el('H1', {}, 'Yahoo Finance Explorer'),
        ],
        'controls': [
            el('label', {'for': 'ticker'}, 'Ticker'),
            el(
                'input', {
                    'name': 'ticker',
                    'type': 'text',
                    'value': 'GOOG',
                    'class': 'u-full-width'
                }, '')
        ],
        'main_pane': [graph('line-chart')]
    }, name)


@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)


@socketio.on('replot')
def replot(app_state):
    update_graph(app_state)


def update_graph(app_state):
Ejemplo n.º 10
0
app.debug = True
app.config['key'] = 'secret'
socketio = SocketIO(app)

from example_3_click_events_state import Dash

dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-3-click-events
# We're using the template "layout_two_column_and_controls" which uses the
# includes blocks: 'controls.html', 'leftgraph.html', and 'rightgraph.html'.
utils.write_templates(
    {
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-3-click-events
        'leftgraph': [graph('bubbles')],
        'rightgraph': [graph('line-chart')]
    },
    name)


@app.route('/')
def index():

    return render_template('layouts/layout_two_column_and_controls.html',
                           app_name=name)


@socketio.on('pong')
def onpong(app_state):
    messages = dash.on_pong(app_state)
Ejemplo n.º 11
0
                    'value': 0,
                    'min': 1,
                    'max': 20,
                    'step': 1
                }),
            el('label', {}, 'Title'),
            el('input', {
                'type': 'text',
                'name': 'title',
                'placeholder': 'Type away',
                'class': 'u-full-width'
            }, '')
        ],

        'main_pane': [
            graph(graph_id)
        ]
    }, name
)

@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name = name)

@socketio.on('replot')
def replot(app_state):
    print(app_state) # for debugging

    frequency = float(app_state['frequency'])
    period = float(app_state['period'])
Ejemplo n.º 12
0
app = Flask(name)
app.debug = True
app.config['key'] = 'secret'
socketio = SocketIO(app)

from example_3_click_events_state import Dash
dash = Dash()

# Write the HTML "includes" blocks to /templates/runtime/dash-3-click-events
# We're using the template "layout_two_column_and_controls" which uses the
# includes blocks: 'controls.html', 'leftgraph.html', and 'rightgraph.html'.
utils.write_templates(
    {
        # 'controls.html' is already written as a raw html file in
        # templates/runtime/dash-3-click-events
        'leftgraph': [graph('bubbles')],
        'rightgraph': [graph('polar-area-chart')]
    }, name
)


@app.route('/')
def index():
    return render_template('layouts/layout_two_column_and_controls.html',
                           app_name=name)


@socketio.on('pong')
def onpong(app_state):
    messages = dash.on_pong(app_state)
    emit('postMessage', json.dumps(messages,
Ejemplo n.º 13
0
                'value': 0,
                'min': 10,
                'max': 2000,
                'step': 10
            }),

            el('label', {}, 'Title'),
            el('input', {
                'class': 'u-full-width',
                'type': 'text',
                'placeholder': 'Type away',
                'name': title_input_id})
        ],

        'main_pane': [
            graph(graph_id)
        ]
    }, name
)


last_x = deque([], 100)
last_y = deque([], 100)


@app.route('/')
def index():
    return render_template('layouts/layout_single_column_and_controls.html',
                           app_name=name)