Ejemplo n.º 1
0
 def make_inputs(self):
     self.ticker1_select = Select(
         name='ticker1',
         value='AAPL',
         options=['AAPL', 'GOOG', 'INTC', 'BRCM', 'YHOO']
     )
     self.ticker2_select = Select(
         name='ticker2',
         value='GOOG',
         options=['AAPL', 'GOOG', 'INTC', 'BRCM', 'YHOO']
     )
Ejemplo n.º 2
0
def layout():
    year_select = Select(title="Year:", value="2010", options=years)
    location_select = Select(title="Location:", value="World", options=locations)

    year_select.on_change('value', on_year_change)
    location_select.on_change('value', on_location_change)

    controls = HBox(children=[year_select, location_select])
    layout = VBox(children=[controls, pyramid(), population()])

    return layout
Ejemplo n.º 3
0
    def create_layout(self):
        from bokeh.widgets import Select, HBox, VBox

        years = list(map(str, sorted(self.df.Year.unique())))
        locations = sorted(self.df.Location.unique())

        year_select = Select(title="Year:", value="2010", options=years)
        location_select = Select(title="Location:",
                                 value="World",
                                 options=locations)

        year_select.on_change('value', self.on_year_change)
        location_select.on_change('value', self.on_location_change)

        controls = HBox(year_select, location_select)
        self.layout = VBox(controls, self.plot)
Ejemplo n.º 4
0
    def create(self):
        manufacturers = sorted(mpg["manufacturer"].unique())
        models = sorted(mpg["model"].unique())
        transmissions = sorted(mpg["trans"].unique())
        drives = sorted(mpg["drv"].unique())
        classes = sorted(mpg["class"].unique())

        manufacturer_select = Select(title="Manufacturer:",
                                     value="All",
                                     options=["All"] + manufacturers)
        manufacturer_select.on_change('value', self.on_manufacturer_change)
        model_select = Select(title="Model:",
                              value="All",
                              options=["All"] + models)
        model_select.on_change('value', self.on_model_change)
        transmission_select = Select(title="Transmission:",
                                     value="All",
                                     options=["All"] + transmissions)
        transmission_select.on_change('value', self.on_transmission_change)
        drive_select = Select(title="Drive:",
                              value="All",
                              options=["All"] + drives)
        drive_select.on_change('value', self.on_drive_change)
        class_select = Select(title="Class:",
                              value="All",
                              options=["All"] + classes)
        class_select.on_change('value', self.on_class_change)

        columns = [
            TableColumn(field="manufacturer",
                        header="Manufacturer",
                        type="autocomplete",
                        source=manufacturers),
            TableColumn(field="model",
                        header="Model",
                        type="autocomplete",
                        source=models),
            TableColumn(field="displ",
                        header="Displacement",
                        type="numeric",
                        format="0.00"),
            TableColumn(field="year", header="Year", type="numeric"),
            TableColumn(field="cyl", header="Cylinders", type="numeric"),
            TableColumn(field="trans",
                        header="Transmission",
                        type="dropdown",
                        strict=True,
                        source=transmissions),
            TableColumn(field="drv",
                        header="Drive",
                        type="autocomplete",
                        strict=True,
                        source=drives),
            TableColumn(field="class",
                        header="Class",
                        type="autocomplete",
                        strict=True,
                        source=classes),
            TableColumn(field="cty", header="City MPG", type="numeric"),
            TableColumn(field="hwy", header="Highway MPG", type="numeric"),
        ]
        handson_table = HandsonTable(source=self.source,
                                     columns=columns,
                                     sorting=True)

        xdr = DataRange1d(sources=[self.source.columns("index")])
        #xdr = FactorRange(factors=manufacturers)
        ydr = DataRange1d(
            sources=[self.source.columns("cty"),
                     self.source.columns("hwy")])
        plot = Plot(title=None,
                    data_sources=[self.source],
                    x_range=xdr,
                    y_range=ydr,
                    plot_width=800,
                    plot_height=300)
        xaxis = LinearAxis(plot=plot)
        plot.below.append(xaxis)
        yaxis = LinearAxis(plot=plot)
        ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)
        plot.left.append(yaxis)
        cty = Glyph(data_source=self.source,
                    glyph=Circle(x="index",
                                 y="cty",
                                 fill_color="#396285",
                                 size=8,
                                 fill_alpha=0.5,
                                 line_alpha=0.5))
        hwy = Glyph(data_source=self.source,
                    glyph=Circle(x="index",
                                 y="hwy",
                                 fill_color="#CE603D",
                                 size=8,
                                 fill_alpha=0.5,
                                 line_alpha=0.5))
        select_tool = BoxSelectTool(renderers=[cty, hwy], select_y=False)
        plot.tools.append(select_tool)
        overlay = BoxSelectionOverlay(tool=select_tool)
        plot.renderers.extend([cty, hwy, ygrid, overlay])

        controls = VBox(children=[
            manufacturer_select, model_select, transmission_select,
            drive_select, class_select
        ],
                        width=200)
        top_panel = HBox(children=[controls, plot])
        layout = VBox(children=[top_panel, handson_table])

        return layout