当前位置: 首页>>代码示例>>Python>>正文


Python Select.on_change方法代码示例

本文整理汇总了Python中bokeh.models.widgets.Select.on_change方法的典型用法代码示例。如果您正苦于以下问题:Python Select.on_change方法的具体用法?Python Select.on_change怎么用?Python Select.on_change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.widgets.Select的用法示例。


在下文中一共展示了Select.on_change方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_sidebar

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
def make_sidebar():
    global sidebar, master_selector
    master_selector = Select(title="MASTOR SELECTOR:", value="test", options=["test", 'sandbox', 'template', "timeseries", "mdr_history"])
    def selector_func(attrname, old, new):
        new_master_plot( master_selector.value )
    master_selector.on_change('value', selector_func )
    sidebar = vform(master_selector)
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:9,代码来源:plotman.py

示例2: layout

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
def layout():

    date_select = DateRangeSlider(
        name="period",
        title="Period:",
        value=(start, end),
        bounds=(bounds_start, bounds_end),
        value_labels='show',
        range=(dict(days=1), None))
    date_select.on_change('value', on_date_change)

    country_select = Select(title="Host Site Country:", value="World",
                            options=country_choices)
    country_select.on_change('value', on_country_change)

    controls = VBoxModelForm(_children=[Paragraph(text="Date Range"),
                                        Paragraph(text=""),  # spacing hack
                                        Paragraph(text=""),
                                        date_select, country_select])

    vboxsmall = VBoxModelForm(_children=[controls, source_par])
    #hbox1 = HBox(children=[job_loc_plot_builder(), vboxsmall])
    #hbox2 = HBox(children=[weekday_builder(), jobtype_builder()])
    #layout = VBox(children=[hbox1, hbox2])
    layout = VBox(children=[vboxsmall])

    return layout
开发者ID:rebeccabilbro,项目名称:demo,代码行数:29,代码来源:new_demo.py

示例3: compose_layout

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
    def compose_layout(self):
        """Compose the layout ot the app, the main elements are the widgets to
        select the dataset, the metric, a div for the title, a plot and a table
        """

        # Load metrics and datasets
        self.metrics = get_metrics(default='AM1')
        self.datasets = get_datasets(default='cfht')

        # Get args from the app URL or use defaults
        args = get_url_args(doc=curdoc,
                            defaults={'metric': self.metrics['default']})

        self.selected_dataset = args['ci_dataset']

        self.selected_metric = args['metric']

        # get specifications for the selected metric
        self.specs = get_specs(self.selected_metric)

        self.selected_window = args['window']

        # dataset select widget
        dataset_select = Select(title="Data Set:",
                                value=self.selected_dataset,
                                options=self.datasets['datasets'], width=100)

        dataset_select.on_change("value", self.on_dataset_change)

        # thresholds are used to make plot annotations
        self.configure_thresholds()

        # metric select widget
        metric_select = Select(title="Metric:", value=self.selected_metric,
                               options=self.metrics['metrics'], width=100)

        metric_select.on_change("value", self.on_metric_change)

        self.data = \
            get_meas_by_dataset_and_metric(self.selected_dataset,
                                           self.selected_metric,
                                           self.selected_window)

        self.update_data_source()
        self.make_plot()
        self.make_table()

        if len(self.data['values']) < 1:
            self.loading.text = "No data to display"
        else:
            self.loading.text = ""

        self.layout = column(row(widgetbox(metric_select, width=150),
                                 widgetbox(dataset_select, width=150)),
                             widgetbox(self.title, width=1000),
                             self.plot,
                             widgetbox(self.table_title, width=1000),
                             self.table)
开发者ID:lsst-sqre,项目名称:qa-dashboard,代码行数:60,代码来源:main.py

示例4: create_layout

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
def create_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 = WidgetBox(children=[year_select, location_select],height=150,width=600)
    layout = Column(children=[controls, pyramid(), population()])

    return layout
开发者ID:NamiStudio,项目名称:bokeh,代码行数:13,代码来源:population_server.py

示例5: create_layout

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
def create_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
开发者ID:brianpanneton,项目名称:bokeh,代码行数:13,代码来源:population_server.py

示例6: create_layout

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
    def create_layout(self):
        from bokeh.models.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)
开发者ID:Wombatpm,项目名称:bokeh,代码行数:16,代码来源:app_reveal.py

示例7: main

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
def main():
    state_xs, state_ys = get_us_state_outline()
    left, right = minmax(state_xs)
    bottom, top = minmax(state_ys)
    plot = Figure(title=TITLE, plot_width=1000,
                  plot_height=700,
                  tools="pan, wheel_zoom, box_zoom, reset",
                  x_range=Range1d(left, right),
                  y_range=Range1d(bottom, top),
                  x_axis_label='Longitude',
                  y_axis_label='Latitude')

    plot_state_outline(plot, state_xs, state_ys)

    density_overlay = DensityOverlay(plot, left, right, bottom, top)
    density_overlay.draw()

    grid_slider = Slider(title="Details", value=density_overlay.gridcount,
                         start=10, end=100, step=10)
    grid_slider.on_change("value", density_overlay.grid_change_listener)

    radiance_slider = Slider(title="Min. Radiance",
                             value=density_overlay.radiance,
                             start=np.min(density_overlay.rad),
                             end=np.max(density_overlay.rad), step=10)
    radiance_slider.on_change("value", density_overlay.radiance_change_listener)

    listener = ViewListener(plot, density_overlay, name="viewport")

    plot.x_range.on_change("start", listener)
    plot.x_range.on_change("end", listener)
    plot.y_range.on_change("start", listener)
    plot.y_range.on_change("end", listener)

    backends = ["CPU", "HSA"]
    default_value = backends[kde.USE_HSA]
    backend_select = Select(name="backend", value=default_value,
                            options=backends)
    backend_select.on_change('value', density_overlay.backend_change_listener)

    doc = curdoc()
    doc.add(VBox(children=[plot, grid_slider, radiance_slider, backend_select]))
    doc.add_periodic_callback(density_overlay.periodic_callback, 0.5)
开发者ID:ContinuumIO,项目名称:numba-hsa-examples,代码行数:45,代码来源:lightning_app.py

示例8: DataViewer

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
class DataViewer():

    def __init__(self):
        img = imageio.imread("gray.png").astype(np.uint8)
        self.target = np.empty(img.shape[:2], dtype=np.uint32)
        view = self.target.view(dtype=np.uint8).reshape((img.shape[0], img.shape[1], 4))
        view[:, :, :3] = img
        view[:, :, 3] = 255
        self.fig = self.define_figure('image')
        self.source = ColumnDataSource(data={"image": [self.target],
                                             "dh": [self.target.shape[0]],
                                             "dw": [self.target.shape[1]]})
        self.regist_image(self.fig, self.source)
        self.select = Select(title="Option:",
                             value="gray.png",
                             options=["gray.png", "white.png", "black.png", "julia.jpeg"])
        self.plot = column(self.select, self.fig)
        self.select.on_change("value", self.update_image)

    def define_figure(self, title):
        return figure(title=title,
                      match_aspect=True,
                      tools="",)

    def regist_image(self, fig, source):
        fig.image_rgba('image',
                       x=0, y=0,
                       dh="dh",
                       dw="dw",
                       source=source)

    def update_image(self, attr, old, new):
        print(attr, old, new)
        img = imageio.imread(new).astype(np.uint8)
        img_ = np.empty(img.shape[:2], dtype=np.uint32)
        view = img_.view(dtype=np.uint8).reshape((img.shape[0], img.shape[1], 4))
        view[:, :, :3] = img
        view[:, :, 3] = 255
        self.fig.title.text = new
        self.source.data = {"image": [img_],
                            "dh": [img_.shape[0]],
                            "dw": [img_.shape[1]]}
开发者ID:terasakisatoshi,项目名称:PythonCode,代码行数:44,代码来源:visualizer.py

示例9: str

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
                   tools="pan,wheel_zoom,box_zoom,reset,resize")

    barchart.title = "Formula SAE Michigan " + str(year) + " Total Scores by Place"

    barchart._xaxis.axis_label = "Teams"
    barchart._xaxis.axis_line_color = None
    barchart._xaxis.major_tick_line_color = None
    barchart._xaxis.minor_tick_line_color = None
    barchart._xaxis.major_label_text_font_size = '0.6em'

    barchart._yaxis.axis_label = "Total Score"
    barchart._yaxis.axis_line_color = None
    barchart._yaxis.major_tick_line_color = None
    barchart._yaxis.minor_tick_line_color = None

    barchart.outline_line_color = None

    barchart.toolbar_location = 'right'

    barchart.logo = None

    return barchart


select_year.on_change('value', on_year_change)

# Bokeh plotting output
layout = HBox(children=[select_year, generate_chart(int(selectable_years[-1]))])

curdoc().add_root(layout)
开发者ID:kktse,项目名称:fsaem,代码行数:32,代码来源:team_rankings.py

示例10: NumeralTickFormatter

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
    barchart._yaxis.formatter = NumeralTickFormatter(format="0%")
    barchart.y_range = Range1d(0, 1)

    barchart.outline_line_color = None

    barchart.toolbar_location = 'right'

    barchart.logo = None

    for renderer in barchart.select(GlyphRenderer):
        if renderer.data_source.data['height'] != [0]:
            year = renderer.data_source.data['year']
            num_dnf = data['dnfs'].loc[data['year'] == year]
            num_entries = data['entries'].loc[data['year'] == year]
            percent_dnf = data['percentage_dnf'].loc[data['year'] == year]
            hover = HoverTool(renderers=[renderer],
                              tooltips=[("# DNFs", '%d' % num_dnf.values[0]),
                                        ("# Entries", '%d' % num_entries.values[0]),
                                        ("% DNF", '%.2f%%' % (100 * percent_dnf.values[0]))])
            barchart.add_tools(hover)
    

    return barchart


select_event.on_change('value', on_event_change)

layout = HBox(children=[select_event, generate_chart(selectable_events[2])])

curdoc().add_root(layout)
开发者ID:kktse,项目名称:fsaem,代码行数:32,代码来源:competition_forfeits.py

示例11: StockApp

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]

#.........这里部分代码省略.........
        top = hist.max()

        p = figure(
            title=' Histogram',
            plot_width=600, plot_height=400,
            tools="",
            title_text_font_size="16pt",
            x_range=[start, end],
            y_range=[0, top],
            x_axis_label = ' Bins',
            y_axis_label = 'Bin Count' 
        )
        p.rect(center, hist / 2.0, width, hist)
        return p

    def make_plots(self):

        self.hist_plots()

    def hist_plots(self):
        self.hist1 = self.path_plot()
        self.hist2 = self.hist_den_plot()
        self.hist3 = self.mc_results()

    def set_children(self):
        self.children = [self.mainrow, self.second_row]
        self.mainrow.children = [self.input_box, self.hist1]
        self.second_row.children = [self.hist2, self.hist3]
        self.input_box.children = [self.ticker1_box, self.ticker2_box, self.ticker3_box,self.ticker4_box,self.ticker5_box]
        self.ticker1_box.children =[self.ticker1_select, self.ticker1p_select]
        self.ticker2_box.children =[self.ticker2_select, self.ticker2p_select]
        self.ticker3_box.children =[self.ticker3_select, self.ticker3_1_select, self.ticker3_2_select]
        self.ticker4_box.children =[self.ticker4_select, self.ticker4_1_select, self.ticker4_2_select]
        self.ticker5_box.children =[self.button_select]

    def input_change(self, obj, attrname, old, new):
        if obj == self.ticker4_2_select:
            self.ticker4_2 = new
        if obj == self.ticker4_1_select:
            self.ticker4_1 = new
        if obj == self.ticker4_select:
            self.ticker4 = new
        if obj == self.ticker3_2_select:
            self.ticker3_2 = new
        if obj == self.ticker3_1_select:
            self.ticker3_1 = new
        if obj == self.ticker3_select:
            self.ticker3 = new
        if obj == self.ticker2p_select:
            self.ticker2p = new
        if obj == self.ticker2_select:
            self.ticker2 = new
        if obj == self.ticker1p_select:
            self.ticker1p = new
        if obj == self.ticker1_select:
            self.ticker1 = new
        if obj == self.button_select:
            self.button = new 
            if 'run' in self.button:
                self.make_source()
                self.make_plots()
                self.set_children()
                curdoc().add(self)

        #self.make_source()
        #self.make_plots()
        #self.set_children()
        #curdoc().add(self)

    def setup_events(self):
        super(StockApp, self).setup_events()
        if self.ticker1_select:
            self.ticker1_select.on_change('value', self, 'input_change')
        if self.ticker1p_select:
            self.ticker1p_select.on_change('value', self, 'input_change')
        if self.ticker2_select:
            self.ticker2_select.on_change('value', self, 'input_change')
        if self.ticker2p_select:
            self.ticker2p_select.on_change('value', self, 'input_change')
        if self.ticker3_select:
            self.ticker3_select.on_change('value', self, 'input_change')
        if self.ticker3_1_select:
            self.ticker3_1_select.on_change('value', self, 'input_change')
        if self.ticker3_2_select:
            self.ticker3_2_select.on_change('value', self, 'input_change')
        if self.ticker4_select:
            self.ticker4_select.on_change('value', self, 'input_change')
        if self.ticker4_1_select:
            self.ticker4_1_select.on_change('value', self, 'input_change')
        if self.ticker4_2_select:
            self.ticker4_2_select.on_change('value', self, 'input_change')
        if self.button_select:
            self.button_select.on_change('value',self, 'input_change')

    @property
    def Y(self):
        tmpdf = pd.DataFrame(self.main_mc(int(self.ticker3_1),int(self.ticker3),float(self.ticker3_2),self.ticker4_2,float(self.ticker4_1)))
        tmpdf.columns = ['Col_' + str(i) for i in xrange(len(tmpdf.columns))]
        #print tmpdf
        return tmpdf
开发者ID:steve98654,项目名称:bokeh-demos,代码行数:104,代码来源:mc_bokeh.py

示例12: widgetbox

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]
                        vis_name = PROBE_LABELS[each2][1]
                        break
            for each2 in vis_glyphs:
                if each2 == vis_name:
                    vis_glyphs[each2].append(each)
    # TODO: Set visibility programatically
    legend = plot.legend[0].legends
    legend = []
    for each in visible_d:
        # Set visibility of all plots
        for each2 in vis_glyphs[each]:
            each2.glyph.line_alpha = visible_d[each][1]
            try:
                each2.glyph.fill_alpha = visible_d[each][1]
            except:
                continue
        if visible_d[each] == OFF:
            continue
        else:
            legend.append((visible_d[each][0], vis_glyphs[each]))
    plot.legend[0].legends = legend

    #[orp_line.legend, orp_line.alpha] = visible_d['orp']
cycle.on_change('value', update_date)

# Set up layouts and add to document
inputs = widgetbox(cycle, probes, measure)

curdoc().add_root(row(inputs, plot, width=1200))
curdoc().title = "Reactor 1 Cycle Test Visualization"
开发者ID:manewton,项目名称:BioReactor-Data-Logging,代码行数:32,代码来源:bokehcycles.py

示例13: Display

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]

#.........这里部分代码省略.........
        else:
            status_text = ("There are {0} file(s) in the "
                           "'Data' folder. ").format(length)

        status_text += ("Click <strong>Rescan folder</strong> to rescan the "
                        "data folder.")

        # Ensure we have a 'None' option and that it's the default
        files.insert(0, self.data_file_none)

        # Update the control
        self.file_select.options = files
        self.file_select.value = files[0]

        self.file_status.text = status_text

    def read_file_tab(self):

        """Lets the user choose a data file to read"""

        # Drop down list
        self.file_select = Select(name='Data files',
                                  value='',
                                  options=[],
                                  title='Data files')
        # Status text
        self.file_status = Div(text='', width=self.page_width)

        # Update the file_select and file_status controls with scan data
        self.scan_folder()

        # This line is here deliberately. The scan_folder would trigger
        # the on-change function and we don't want that first time around.
        self.file_select.on_change('value', self.file_changed)

        # Re-scan button
        file_rescan = Button(label="Rescan folder", button_type="success")
        file_rescan.on_click(self.scan_folder)

        # Layout
        c = column(self.file_select,
                   self.file_status,
                   file_rescan)

        return Panel(child=c, title="Read from file")

    # Config tab
    # ==========
    def config_read(self):

        """Reads config data to disk"""

        if not self.device_connected:
            self.config_status.text = ("Cannot read the UT330 device "
                                       "config data "
                                       "because no UT330 device connected.")
            return

        # Get the config data
        if self.config_connected():
            # The device has been read OK
            self.config_device_read = True
        else:
            self.config_device_read = False

    def config_write(self):
开发者ID:MikeWoodward,项目名称:UT330B,代码行数:70,代码来源:UI.py

示例14: plot

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]

#.........这里部分代码省略.........

        elif chnk in ['24hr', '30days']:
            chunk_ID.text = '{} \nSTART: {} \nEND:   {}'.format(g, e2ts(startend[0]), e2ts(startend[1]))
        elif chnk == '-ALL-':
            chunk_ID.text = '{} \nSTART: {} \nEND:   {}'.format(g,e2ts(depth.data['x'][0] /1000),
                                                                  e2ts(depth.data['x'][-1]/1000))


        vert_vel.data  = calc_vert_vel(depth.data)

        mbpump.data,_     = load_sensor(g, 'm_de_oil_vol', chnk, chindex)
        if len(mbpump.data['x']) > 1:
            #for yax in fig2.select('mbpump'):
            #    yax.legend = 'm_de_oil_vol'
            pass
        else:
            mbpump.data,_     = load_sensor(g, 'm_ballast_pumped', chnk, chindex)
            #for yax in fig2.select('mbpump'):
            #    yax.legend = 'm_ballast_pumped'
        battpos.data,_ = load_sensor(g, 'm_battpos',    chnk, chindex)
        pitch.data,_   = load_sensor(g, 'm_pitch',      chnk, chindex)
        pitch.data['y'] = [math.degrees(y) for y in pitch.data['y']]

        mfin.data,_     = load_sensor(g, 'm_fin',     chnk, chindex)
        cfin.data,_     = load_sensor(g, 'c_fin',     chnk, chindex)
        mroll.data,_    = load_sensor(g, 'm_roll',    chnk, chindex)
        mheading.data,_ = load_sensor(g, 'm_heading', chnk, chindex)
        cheading.data,_ = load_sensor(g, 'c_heading', chnk, chindex)
        mfin.data['y']     = [math.degrees(y) for y in mfin.data['y']]
        cfin.data['y']     = [math.degrees(y) for y in cfin.data['y']]
        mheading.data['y'] = [math.degrees(y) for y in mheading.data['y']]
        cheading.data['y'] = [math.degrees(y) for y in cheading.data['y']]
        mroll.data['y']    = [math.degrees(y) for y in mroll.data['y']]

        fig1.yaxis[1].visible = True
        fig2.yaxis[1].visible = True
        fig3.yaxis[1].visible = True


    #GLIDER SELECTS
    def glider_buttons(increment):
        ops = gliders.options
        new_index = ops.index(gliders.value) + increment
        if new_index >= len(ops):
            new_index = 0
        elif new_index < 0:
            new_index = len(ops)-1
        gliders.value = ops[new_index]
        chunkation_update(None, None, None) #reset chunk indicator and clicks
    def next_glider_func():
        glider_buttons(1)
    def prev_glider_func():
        glider_buttons(-1)
    def update_glider(attrib,old,new):
        chunk_indicator.value = '0'
        #update_data(None,None,None)


    gliders.on_change('value', update_glider)
    next_glider.on_click(next_glider_func)
    prev_glider.on_click(prev_glider_func)


        #CHUNK SELECTS
    def chunkation_update(attrib,old,new):
        chunk_indicator.value = '0'
        prev_chunk.clicks = 0
        next_chunk.clicks = 0
        update_data(None,None,None)
        if new == '-ALL-':
            chunk_indicator.value = '-'

    def chunk_func():
        chunkdiff = prev_chunk.clicks - next_chunk.clicks
        if chunkdiff < 0:
            prev_chunk.clicks = 0
            next_chunk.clicks = 0
            chunkdiff = 0
        print (chunkdiff)
        chunk_indicator.value = str(chunkdiff)

    def chunk_indicator_update(attrib,old,new):
        try:
            if abs(int(old)-int(new))>1: #manual update, triggers new non-manual indicator update, ie else clause below
                prev_chunk.clicks = int(new)
                next_chunk.clicks = 0
            else:
                update_data('chunk',int(old),int(new))
            print("UPDATE", old, new)
        except Exception as e:
            print(type(e),e, old, new)

    chunkations.on_change('value', chunkation_update)
    chunk_indicator.on_change('value', chunk_indicator_update)
    next_chunk.on_click(chunk_func)
    prev_chunk.on_click(chunk_func)

    update_data(None,None,None)

    return vplot(control_box, figs)
开发者ID:ssb109,项目名称:WHOI_OOI_Glider_Repo,代码行数:104,代码来源:plot_overview.py

示例15: ShoeApp

# 需要导入模块: from bokeh.models.widgets import Select [as 别名]
# 或者: from bokeh.models.widgets.Select import on_change [as 别名]

#.........这里部分代码省略.........

        TOOLS = "box_select,lasso_select"
        tooltips = "<span class='tooltip-text'>Name: @name</span>\n<br>"
        tooltips += "<span class='tooltip-text'>Brand: @brand</span>\n<br>"
        tooltips += "<span class='tooltip-text'>Price: @price</span>\n<br>"
        #hover = HoverTool(tooltips="@num_reviews")
        #hover = HoverTool(tooltips="@names")
        hover = HoverTool(tooltips=tooltips)

        #p = figure(tools=TOOLS, width=1100, height=700, x_range=x_rr, y_range=y_rr, title="Price Distribution")
        #p = figure(tools=TOOLS, width=1100, height=700, title="Price Distribution")
        #p = figure(tools=TOOLS, width=1100, height=700, x_range=ranges, title="Price Distribution", angle=pi/4)
        bdf = self.brand_df
        if len(bdf) > 0:
            title = "Brand: " + self.brand_df['brand'].values[0]
        else:
            title = ""
        brand_ranges = orig_order[min_idx:max_idx+1]
        p = figure(tools=TOOLS, width=400, height=400, x_range=brand_ranges, title=title, toolbar_location=None)
        p.xaxis.major_label_orientation = pi/4

        #p.quad(left='xvals', right='rightvals', top='tops', bottom='bottoms', color='fills', source=self.dfsource)
        p.rect(x='xcat', y='brand_y', line_color='black', width='width', height='brand_height', color='fills', source=self.brand_source)
        p.add_tools(hover)

        self.brand_plot = p


    def set_children(self):
        self.children = [self.totalbox]
        self.totalbox.children = [self.plot, self.brandbox]
        self.brandbox.children = [self.brand_plot, self.selectr]
        #self.totalbox.children = [self.mainrow, self.bottomrow]
        #self.mainrow.children = [self.plot]
        #self.bottomrow.children = [self.hist_plot, self.selectr]
        #self.mainrow.children = [self.selectr]
        #self.bottomrow.children = [self.plot]

    def input_change(self, obj, attrname, old, new):
        self.make_source()
        self.make_better_plots()
        self.set_children()
        curdoc().add(self)

    def setup_events(self):
        super(ShoeApp, self).setup_events()
        if self.source:
            self.source.on_change('selected', self, 'selection_change')

        if self.selectr:
            self.selectr.on_change('value', self, 'brand_change')

    def selection_change(self, obj, attrname, old, new):
        #self.make_brand_plot
        #self.set_children()
        #curdoc().add(self)
        bdf = self.brand_df
        min_idx, max_idx = shoes_func.min_max_range(ranges, bdf['price'])
        self.configure_brand_source(min_idx, max_idx)
        self.make_brand_source()
        self.make_brand_plot(min_idx, max_idx)
        self.set_children()
        curdoc().add(self)

    def brand_change(self, obj, attrname, old, new):
        bdf = self.brand_df
        if self.selectr.value is None or self.selectr.value == 'Most Popular Brands':
            return
        self.update_selected_on_source(self.selectr.value)
        self.set_children()
        curdoc().add(self)

    def update_selected_on_source(self, brand):
        # {'2d': {'indices': []}, '1d': {'indices': []}, '0d': {'indices': [], 'flag': False}}
        brand_df = _shoedf[ _shoedf['brand'] == brand ]

        new_indices = {'2d': {'indices': []}, '1d': {'indices': []}, '0d': {'indices': [], 'flag': False}}
        for _id in brand_df.index:
            new_indices['1d']['indices'].append(_id)

        self.source.selected = new_indices


    @property
    def df(self):
        return _shoedf

    @property
    def brand_df(self):

        pandas_df = self.df
        selected = self.source.selected
        if selected['1d']['indices']:
            idxs = selected['1d']['indices']
            sel_brand = pandas_df.iloc[idxs[0], :]['brand']
            #pandas_df = pandas_df.iloc[idxs, :]
            #return _shoedf[_shoedf['brand'] =='manolo blahnik']
            return _shoedf[_shoedf['brand'] == sel_brand]
        else:
            return pandas_df.iloc[0:0, :]
开发者ID:rebeccabilbro,项目名称:demo,代码行数:104,代码来源:shoes_app.py


注:本文中的bokeh.models.widgets.Select.on_change方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。