def create(cls):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()
        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        obj.text = Select(title="Select initial shape",
                          name='text',
                          value='step',
                          options=["step", "sine"])
        obj.solver = Select(title="Select solver",
                            name='solver',
                            value='ftbs',
                            options=["ftbs", "macCormack", "lax_friedrich"])

        obj.CFL = Slider(title="CFL",
                         name='CFL',
                         value=0.4,
                         start=0.1,
                         end=1.0,
                         step=0.1)
        obj.time = Slider(title="time",
                          name='time',
                          value=0.0,
                          start=0.0,
                          end=1.0,
                          step=0.1)
        obj.Period = Slider(title="Period T (applicable for sine)",
                            name='Period',
                            value=0.6,
                            start=0.2,
                            end=1.0,
                            step=0.2)

        toolset = "crosshair,pan,reset,resize,save,wheel_zoom"
        # Generate a figure container
        plot = figure(title_text_font_size="12pt",
                      plot_height=400,
                      plot_width=400,
                      tools=toolset,
                      title=obj.text.value,
                      x_range=[0, 1.5],
                      y_range=[-0.25, 1.5])

        # Plot the line by the x,y values in the source property
        plot.line('x', 'y', source=obj.source, line_width=3, line_alpha=0.6)

        obj.plot = plot
        obj.update_data()

        obj.inputs = VBoxForm(
            children=[obj.text, obj.solver, obj.CFL, obj.time, obj.Period])

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj
Exemplo n.º 2
0
    def create(cls):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.word_source = ColumnDataSource(dict(x=[], y=[], text=[]))
        obj.target_source = ColumnDataSource(dict(tx=[], ty=[], ttext=[]))
        obj.line_source = ColumnDataSource(dict(word_path_x=[],
                                                word_path_y=[]))

        obj.text = TextInput(title="Word", name='word', value='gay')

        obj.year = Slider(title="Year",
                          name='year',
                          value=1900,
                          start=1900,
                          end=2000,
                          step=5)

        obj.basis = Slider(title="Basis Year",
                           name='basis',
                           value=2000,
                           start=1900,
                           end=2000,
                           step=5)

        toolset = "crosshair,pan,reset,resize,save,wheel_zoom"
        # Generate a figure container
        plot = figure(title_text_font_size="12pt",
                      plot_height=400,
                      plot_width=400,
                      tools=toolset,
                      title="Word Path",
                      x_range=[-1, 1],
                      y_range=[-1, 1])

        #      plot.line("x", "y", source=obj.source)
        glyph = Text(x="x", y="y", text="text", text_color="#96deb3")
        plot.add_glyph(obj.word_source, glyph)
        glypht = Text(x="tx", y="ty", text="ttext")
        plot.add_glyph(obj.target_source, glypht)
        glyphline = Line(x="word_path_x",
                         y="word_path_y",
                         line_width=4,
                         line_alpha=0.3,
                         line_color='red')
        plot.add_glyph(obj.line_source, glyphline)

        obj.plot = plot
        obj.update_data(True, True)

        obj.inputs = VBoxForm(children=[obj.text, obj.year, obj.basis])

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj
Exemplo n.º 3
0
    def create(cls):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        obj.text = TextInput(title="title", name='title', value='my sine wave')

        obj.offset = Slider(title="offset",
                            name='offset',
                            value=0.0,
                            start=-5.0,
                            end=5.0,
                            step=0.1)
        obj.amplitude = Slider(title="amplitude",
                               name='amplitude',
                               value=1.0,
                               start=-5.0,
                               end=5.0)
        obj.phase = Slider(title="phase",
                           name='phase',
                           value=0.0,
                           start=0.0,
                           end=2 * np.pi)
        obj.freq = Slider(title="frequency",
                          name='frequency',
                          value=1.0,
                          start=0.1,
                          end=5.1)

        toolset = "crosshair,pan,reset,resize,save,wheel_zoom"

        # Generate a figure container
        plot = figure(title_text_font_size="12pt",
                      plot_height=400,
                      plot_width=400,
                      tools=toolset,
                      title=obj.text.value,
                      x_range=[0, 4 * np.pi],
                      y_range=[-2.5, 2.5])

        # Plot the line by the x,y values in the source property
        plot.line('x', 'y', source=obj.source, line_width=3, line_alpha=0.6)

        obj.plot = plot
        obj.update_data()

        obj.inputs = VBoxForm(children=[
            obj.text, obj.offset, obj.amplitude, obj.phase, obj.freq
        ])

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj
Exemplo n.º 4
0
def groupEverything(sliders, dropdown, data_table):
    hboxes = groupSliders(sliders)
    inputs = VBox(
        children=[dropdown, hboxes[0], hboxes[1], hboxes[2], hboxes[3]],
        width=100,
        height=60)
    #hbox = HBox(children=[inputs, p])
    vbox = VBoxForm(children=[inputs, data_table])
    return vbox
Exemplo n.º 5
0
 def create(cls):
     print "creating app..."
     obj = cls()
     obj.button = Button(label="Foo", type="success")
     obj.button.label = "Bar"
     obj.controls = VBoxForm(children=[obj.button])
     obj.children.append(obj.controls)
     print "created app!"
     return obj
Exemplo n.º 6
0
    def create(cls):
        """
        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        obj.text = TextInput(title="title", name='title', value='my sin wave')

        obj.offset = Slider(title="offset",
                            name='offset',
                            value=0.0,
                            start=-5.0,
                            end=5.0,
                            step=0.1)
        obj.amplitude = Slider(title="amplitude",
                               name='amplitude',
                               value=1.0,
                               start=-5.0,
                               end=5.0)
        obj.phase = Slider(title="phase",
                           name='phase',
                           value=0.0,
                           start=0.0,
                           end=2 * np.pi)
        obj.freq = Slider(title="frequency",
                          name='frequency',
                          value=1.0,
                          start=0.1,
                          end=5.1)

        toolset = "crosshair,pan,reset,resize,save,wheel_zoom"

        obj.plot = line('x',
                        'y',
                        tools=toolset,
                        source=obj.source,
                        plot_width=400,
                        plot_height=400,
                        line_width=3,
                        line_alpha=0.6,
                        title=obj.text.value,
                        x_range=[0, 4 * np.pi],
                        y_range=[-2.5, 2.5])

        obj.update_data()

        obj.inputs = VBoxForm(children=[
            obj.text, obj.offset, obj.amplitude, obj.phase, obj.freq
        ])

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj
Exemplo n.º 7
0
    def get_app(self):
        # Set up layouts and add to document
        inputs = VBoxForm(children=[
            self.text, self.offset, self.amplitude, self.phase, self.freq
        ])

        hbox = HBox(children=[inputs, self.plot])

        return hbox
Exemplo n.º 8
0
    def create(cls):
        # ==============================================================================
        # creates initial layout and data
        # ==============================================================================
        obj = cls()

        # default values
        m = 1

        obj.myObj = ColumnDataSource(data=dict(someObjects=[ObjA(calls=0)]))

        # initialize data source
        obj.source = ColumnDataSource(data=dict(x=[], y=[]))

        # initialize controls
        # slider controlling stepsize of the solver
        obj.slope = Slider(
            title="slope", name='slope',
            value=m, start=-1, end=1, step=.05
        )

        # initialize plot
        toolset = "crosshair,pan,reset,resize,wheel_zoom,box_zoom"
        # Generate a figure container
        plot = figure(title_text_font_size="12pt",
                      plot_height=400,
                      plot_width=400,
                      tools=toolset,
                      # title=obj.text.value,
                      title="line",
                      x_range=[0, 1],
                      y_range=[-1, 1]
                      )
        # Plot the numerical solution by the x,t values in the source property
        plot.line('x', 'y', source=obj.source)
        obj.plot = plot

        # calculate data
        #obj.update_data()

        # lists all the controls in our app
        obj.controls = VBoxForm(
            children=[
                obj.slope
            ]
        )

        # make layout
        obj.children.append(obj.controls)
        obj.children.append(obj.plot)

        # don't forget to return!
        return obj
Exemplo n.º 9
0
    def set_children(self):
        self.input_frame = VBoxForm(children=[
            self.min_excitation,
            self.max_excitation,
            self.min_emission,
            self.max_emission,
            self.chrom_class_select,
        ])

        self.plot_frame = HBox(children=[self.plot])
        self.top_frame = HBox(children=[self.plot_frame, self.input_frame])
        self.table_frame = HBox(children=[self.data_table])
        self.main_frame = VBox(children=[self.top_frame, self.table_frame])
        self.children = [self.main_frame]
Exemplo n.º 10
0
    def create(cls):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        ## create the obj of the app
        obj = cls()
        obj.inputs = VBoxForm()
        ## create input widgets
        obj.make_inputs()
        ## create data source
        obj.make_source()       
        ##
        obj.make_plots()
        ## layout
        obj.set_children()
        return obj
Exemplo n.º 11
0
    def create(cls):
        """
        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        # create layout widgets
        obj = cls()
        obj.mainrow = HBox()
        obj.histrow = HBox()
        obj.statsbox = VBox()
        obj.input_box = VBoxForm()

        # create input widgets
        obj.make_inputs()

        # outputs
        obj.pretext = PreText(text="", width=500)
        obj.make_source()
        obj.make_plots()
        obj.make_stats()

        # layout
        obj.set_children()
        return obj
Exemplo n.º 12
0
    def create(cls):
        # ==============================================================================
        # creates initial layout and data
        # ==============================================================================
        obj = cls()

        # initialize data source
        obj.source = ColumnDataSource(data=dict(z=[]))

        # initialize controls
        # slider controlling stepsize of the solver
        obj.value2 = Slider(title="value2",
                            name='value2',
                            value=1,
                            start=-1,
                            end=+1,
                            step=.1)
        # slider controlling initial value of the ode
        obj.value1 = Slider(title="value1",
                            name='value1',
                            value=0,
                            start=-1,
                            end=+1,
                            step=.1)

        # initialize plot
        toolset = "crosshair,pan,reset,resize,wheel_zoom,box_zoom"
        # Generate a figure container
        plot = figure(
            title_text_font_size="12pt",
            plot_height=400,
            plot_width=400,
            tools=toolset,
            # title=obj.text.value,
            title="somestuff",
            x_range=[-1, 1],
            y_range=[-1, 1])
        # Plot the numerical solution by the x,t values in the source property

        plot.image(
            image='z',
            x=-1,
            y=-1,
            dw=2,
            dh=2,
            #palette="Spectral11",
            color_mapper=LinearColorMapper(palette=svg_palette_jet,
                                           low=-2,
                                           high=2),
            source=obj.source)

        obj.plot = plot
        # calculate data
        obj.update_data()

        # lists all the controls in our app
        obj.controls = VBoxForm(children=[obj.value1, obj.value2])

        # make layout
        obj.children.append(obj.plot)
        obj.children.append(obj.controls)

        # don't forget to return!
        return obj
Exemplo n.º 13
0
                    line = " "
                try:
                    func = stackIds[id][1:-4]
                    func = ' '.join(func)
                    func = func.split("+")[0][:150]
                except:
                    func = " "

                tooltip[str(c)].append(line + " : " + func)
        source.data = dict(x=x,
                           y=y,
                           size=s,
                           t1=tooltip["1"],
                           t2=tooltip["2"],
                           t3=tooltip["3"],
                           t4=tooltip["4"],
                           t5=tooltip["5"],
                           t6=tooltip["6"],
                           t7=tooltip["7"],
                           t8=tooltip["8"],
                           t9=tooltip["9"],
                           t10=tooltip["10"])
        print "Finished generating stacktraces..."


filename.on_change('value', update_data1)
time.on_change('value', update_data3)
inputs = VBoxForm(children=[filename, time])

curdoc().add_root(HBox(children=[inputs, plot], width=5250))
Exemplo n.º 14
0
# Set up callbacks
def update_title(attrname, old, new):
    plot.title = text.value


text.on_change('value', update_title)


def update_data(attrname, old, new):

    # Get the current slider values
    a = amplitude.value
    b = offset.value
    w = phase.value
    k = freq.value

    # Generate the new curve
    x = np.linspace(0, 4 * np.pi, N)
    y = a * np.sin(k * x + w) + b

    source.data = dict(x=x, y=y)


for w in [offset, amplitude, phase, freq]:
    w.on_change('value', update_data)

# Set up layouts and add to document
inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])

curdoc().add_root(HBox(children=[inputs, plot]))
Exemplo n.º 15
0
    def create(cls):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        obj = cls()

        obj.allLinkData = ColumnDataSource(
            data=dict(X=[], Y=[], LANES=[], color=[]))

        obj.selectedLinkData = ColumnDataSource(
            data=dict(X=[], Y=[], LANES=[], color=[]))

        obj.allSegmentData = ColumnDataSource(data=dict(xmid=[],
                                                        ymid=[],
                                                        length=[],
                                                        width=[],
                                                        angle=[],
                                                        link_id=[],
                                                        label=[],
                                                        ffspeed=[],
                                                        speed=[],
                                                        observations=[]))

        obj.selectedSegmentData = ColumnDataSource(data=dict(xmid=[],
                                                             ymid=[],
                                                             length=[],
                                                             width=[],
                                                             angle=[],
                                                             link_id=[],
                                                             label=[],
                                                             ffspeed=[],
                                                             speed=[],
                                                             observations=[]))

        obj.hour = Slider(title="Time of Day",
                          name="hour",
                          value=0,
                          start=0,
                          end=23,
                          step=1)

        # Generate a figure container
        # TODO - add box_zoom tool back in when bokeh makes it work
        #        without distorting the proportions
        plot = figure(
            plot_width=900,  # in units of px
            plot_height=900,
            x_axis_type=None,
            y_axis_type=None,
            tools="pan,wheel_zoom,reset,hover,save",
            title="SF Taxi Speeds")

        # TODO - fix/remove this when bokeh makes hover tool work for lines
        # see: https://github.com/bokeh/bokeh/issues/2031
        plot.rect(x='xmid',
                  y='ymid',
                  height='length',
                  width='width',
                  angle='angle',
                  source=obj.allSegmentData,
                  line_alpha=0,
                  fill_alpha=0)

        hover = plot.select(dict(type=HoverTool))
        hover.tooltips = OrderedDict([("ID", "@link_id"), ("LABEL", "@label"),
                                      ("FFSPEED", "@ffspeed"),
                                      ("SPEED", "@speed"),
                                      ("OBSERVATIONS", "@observations")])

        # plot the links
        plot.multi_line(xs='X',
                        ys='Y',
                        line_width='LANES',
                        line_color='color',
                        source=obj.selectedLinkData)

        obj.plot = plot
        obj.update_data()

        obj.inputs = VBoxForm(children=[obj.hour])

        obj.children.append(obj.plot)
        obj.children.append(obj.inputs)

        return obj
Exemplo n.º 16
0
    }


def on_year_change(attrname, old, new):
    # Set the value of the select widget forcefully to prevent race condition
    select_year.value = new
    update_data()


def on_event_change(attrname, old, new):
    # Set the value of the select widget forcefully to prevent race condition
    select_event.value = new
    update_data()


def update_data():
    update_histogram_data(select_year.value, select_event.value)
    plot.title = "FSAE Michigan - Histogram - " + select_event.value + " - " + select_year.value


select_year.on_change('value', on_year_change)
select_event.on_change('value', on_event_change)

# Bokeh plotting output
inputs = VBoxForm(children=[select_event, select_year])
layout = HBox(children=[inputs, plot])

update_data()

curdoc().add_root(layout)
    def create(cls):

        obj = cls()

        obj.source = ColumnDataSource(data=dict(x_y=[], y=[]))
        obj.source2 = ColumnDataSource(data=dict(x_z=[], z=[]))
        obj.source3 = ColumnDataSource(data=dict(x_a=[], a=[]))

        obj.text = TextInput(title="title", name='title', value='MSFT')

        obj.toggle = CheckboxGroup(labels=["Closes", "MVA_1", "MVA_2"],
                                   active=[0, 1, 2])

        obj.MVA_1 = Slider(title="MVA_1",
                           name='MVA_1',
                           value=100,
                           start=-0.0,
                           end=500.0,
                           step=10)
        obj.MVA_2 = Slider(title="MVA_2",
                           name='MVA_2',
                           value=200,
                           start=-0.0,
                           end=500.0,
                           step=10)

        toolset = "crosshair,pan,reset,resize,save,wheel_zoom"

        plot = figure(title_text_font_size="12pt",
                      plot_height=400,
                      plot_width=400,
                      tools=toolset,
                      title=obj.text.value,
                      x_axis_type="datetime")

        plot.line('x_y',
                  'y',
                  source=obj.source,
                  line_width=3,
                  line_alpha=0.6,
                  line_color="red",
                  name='closes')

        plot.line('x_z',
                  'z',
                  source=obj.source2,
                  line_width=3,
                  line_alpha=0.6,
                  line_color="blue",
                  name='av1')

        plot.line('x_a',
                  'a',
                  source=obj.source3,
                  line_width=3,
                  line_alpha=0.6,
                  line_color="green",
                  name='av2')

        obj.plot = plot
        obj.update_data()

        obj.inputs = VBoxForm(children=[
            obj.text,
            obj.toggle,
            obj.MVA_1,
            obj.MVA_2,
        ])

        obj.children.append(obj.inputs)
        obj.children.append(obj.plot)

        return obj
Exemplo n.º 18
0
        selected = selected[selected.Cast.str.contains(cast_val)==True]
    return selected

def update(attrname, old, new):
    df = select_movies()
    x_name = axis_map[x_axis.value]
    y_name = axis_map[y_axis.value]

    p.xaxis.axis_label = x_axis.value
    p.yaxis.axis_label = y_axis.value
    p.title = "%d movies selected" % len(df)
    source.data = dict(
        x=df[x_name],
        y=df[y_name],
        color=df["color"],
        title=df["Title"],
        year=df["Year"],
        revenue=df["revenue"],
        alpha=df["alpha"],
    )

controls = [reviews, boxoffice, genre, min_year, max_year, oscars, director, cast, x_axis, y_axis]
for control in controls:
    control.on_change('value', update)

inputs = HBox(VBoxForm(controls), width=300)

update(None, None, None) # initial load of the data

curdoc().add_root(HBox(inputs, p, width=1100))
Exemplo n.º 19
0
             top="top",
             bottom="bottom",
             fill_color="#b3de69",
             fill_alpha=0.1)
plot.add_glyph(sourceQuad, glyph)

RangeStartX = 0
RangeEndX = 1
text_start_x = TextInput(title="X range start",
                         name='x_range_start',
                         value="0")
text_end_x = TextInput(title="X range end", name='x_range_end', value="1")
text_start_x.on_change('value', update_data)
text_end_x.on_change('value', update_data)

toolset = "box_zoom,resize,pan,reset,save,x_wheel_zoom"

plot_zoomed.x_range.callback = CustomJS(args=dict(xrange=plot_zoomed.x_range,
                                                  start_x=text_start_x,
                                                  end_x=text_end_x),
                                        code="""
var start = xrange.get("start");
var end = xrange.get("end");
start_x.set("value",start.toString());
end_x.set("value",end.toString());
start_x.trigger('change');
end_x.trigger('change');
""")

curdoc().add_root(VBoxForm(children=[plot_zoomed, plot], width=1000))