예제 #1
0
def test_plotly(remove_build):
    """
    Tests plotly.
    """
    viz = Plotly()
    ctrl = Nouislider()
    ctrl2 = Button()

    path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build')
    layout = Layout(directory=path)
    layout.add_visual(viz)
    layout.add_controller(ctrl)
    layout.add_controller(ctrl2)
    layout.subscribe(callback, ctrl.on_change)
    layout.subscribe(callback, ctrl2.on_click)
    layout.build()

    env = os.environ
    env['PYTHONPATH'] = '{}:{}'.format(os.getcwd(),
                                       os.environ.get('PYTHONPATH', ''))
    server = subprocess.Popen(os.path.join(path, 'src/server.py'), env=env)
    time.sleep(5)

    driver = PhantomJS()
    driver.get('http://localhost:9991')

    assert driver.title == 'Bowtie App'

    server.kill()
예제 #2
0
파일: random_walk.py 프로젝트: vdt/bowtie
def construct():
    from bowtie import Layout
    layout = Layout(debug=True)
    layout.add_controller(sigma)
    layout.add_visual(mainplot)
    layout.schedule(0.1, walk)

    layout.build()
예제 #3
0
def test_build(remove_build):
    ctrl = Nouislider()
    viz = Plotly()

    layout = Layout()
    layout.add_controller(ctrl)
    layout.add_visual(viz)
    layout.subscribe(ctrl.on_change, callback)
    layout.build()
예제 #4
0
파일: test_compile.py 프로젝트: vdt/bowtie
def test_build(remove_build):
    """
    Tests the build process.
    """
    ctrl = Nouislider()
    viz = Plotly()

    path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build')
    layout = Layout(directory=path)
    layout.add_controller(ctrl)
    layout.add_visual(viz)
    layout.subscribe(callback, ctrl.on_change)
    layout.build()
예제 #5
0
def construct(path):
    from bowtie import Layout
    description = """
Bowtie Demo
===========

Demonstrates interactive elements with the iris dataset.
Select some attributes to plot and select some data on the 2d plot.
Change the alpha parameter to see how that affects the model.
"""
    layout = Layout(description=description,
                    background_color='PaleTurquoise',
                    debug=False)
    layout.add_controller(xdown)
    layout.add_controller(ydown)
    layout.add_controller(zdown)
    layout.add_controller(alphaslider)
    layout.add_visual(mainplot)
    layout.add_visual(mplot3)
    layout.add_visual(linear, next_row=True)
    layout.add_visual(table1)

    layout.subscribe(pairplot, xdown.on_change, ydown.on_change)
    layout.subscribe(threeplot, xdown.on_change, ydown.on_change,
                     zdown.on_change)
    layout.subscribe(mainregress, mainplot.on_select, alphaslider.on_change)

    layout.build()
예제 #6
0
"""

from bowtie.control import Nouislider
from bowtie.visual import Plotly

import numpy as np
from numpy import random as rng
import plotlywrapper as pw

sigma = Nouislider(caption='Sigma', start=1, minimum=0.1, maximum=50)
mainplot = Plotly()

data = np.zeros(100).tolist()


def walk():
    value = float(sigma.get())
    data.pop(0)
    data.append(value * rng.randn() + data[-1])
    mainplot.do_all(pw.line(data).to_json())


if __name__ == "__main__":
    from bowtie import Layout
    layout = Layout(debug=False)
    layout.add_controller(sigma)
    layout.add_visual(mainplot)
    layout.schedule(0.1, walk)

    layout.build()