def update_graph(): global numRep, repoNames p = figure(plot_width=400, plot_height=400, title=text.value, x_range=usernameList, y_range=[0, biggestNumRep + 1], toolbar_location=None, tools="") if response.status_code == 404: t = Title() t.text = "USER NOT FOUND" p.title = t p.vbar(x=usernameList, width=0.8, bottom=0, top=numRepList, color="firebrick") p.yaxis.ticker = FixedTicker(ticks=list(range(0, biggestNumRep + 2))) p.yaxis.axis_label = "No. of repositories" if response.status_code != 404: repoDict = json.loads(response.text) repoNames = [] for entry in repoDict: repoNames.append(entry["name"]) radio = RadioButtonGroup(labels=repoNames, active=0) #radio.on_click(specific_repo) specific_repo(0) else: radio = RadioButtonGroup(labels=[]) newGraph = column(text, radio, row(p, pie), width=1000) graphs.children = newGraph.children
def __init__(self): self.handler = server_thread.SERVER_HANDLER self.latest_status = None self.flasher_list = list(OnOffState.__members__.keys()) self.ds_list = list(OnOffState.__members__.keys()) self.b_flasher_updating = False self.b_ds_updating = False self.b_flasher = RadioButtonGroup( labels=self.flasher_list, active=self.flasher_list.index("MAYBEON")) self.b_flasher.on_click(self.flasher_change) t_flasher = Div(text="<h3>Flasher</h3>") self.b_ds = RadioButtonGroup(labels=self.ds_list, active=self.ds_list.index("MAYBEON")) self.b_ds.on_click(self.ds_change) t_ds = Div(text="<h3>Data Sending</h3>") t_expert = Div(text="<h1><u>EXPERT</u></h1>") wb_list = [ [t_expert], [t_flasher], [self.b_flasher], [t_ds], [self.b_ds], ] self.layout = layout(wb_list)
def init_radio_groups() -> Tuple[RadioButtonGroup, ...]: tweet_nontweet_grp = RadioButtonGroup(labels=["nontweets", "tweets"], active=0, css_classes=['t_nt_grp'], width=200, width_policy='fit') conf_bucket_grp = RadioButtonGroup(labels=["max", "min"], active=0, css_classes=['bucket_grp'], width=100, width_policy='fit') pred_exp_class_grp = RadioButtonGroup(labels=["tp", "tn", "fp", "fn"], active=0, css_classes=['cc_grp'], width=200, width_policy='fit') return tweet_nontweet_grp, conf_bucket_grp, pred_exp_class_grp
def startserver(doc): file_input = FileInput(accept=".ulg, .csv") file_input.on_change('value', upload_new_data_sim) file_input2 = FileInput(accept=".ulg, .csv") file_input2.on_change('value', upload_new_data_real) intro_text = Div(text="""<H2>Sim/Real Thiel Coefficient Calculator</H2>""", width=500, height=100, align="center") sim_upload_text = Paragraph(text="Upload a simulator datalog:", width=500, height=15) real_upload_text = Paragraph( text="Upload a corresponding real-world datalog:", width=500, height=15) #checkbox_group = CheckboxGroup(labels=["x", "y", "vx","vy","lat","lon"], active=[0, 1]) sim_reverse_button = RadioButtonGroup(labels=["Sim Default", "Reversed"], active=0) sim_reverse_button.on_change('active', lambda attr, old, new: reverse_sim()) real_reverse_button = RadioButtonGroup(labels=["Real Default", "Reversed"], active=0) real_reverse_button.on_change('active', lambda attr, old, new: reverse_real()) simsource_static.selected.on_change('indices', simselection_change) # The below are in case you want to see the x axis range change as you pan. Poorly documented elsewhere! #ts1.x_range.on_change('end', lambda attr, old, new: print ("TS1 X range = ", ts1.x_range.start, ts1.x_range.end)) #ts2.x_range.on_change('end', lambda attr, old, new: print ("TS2 X range = ", ts2.x_range.start, ts2.x_range.end)) ts1.x_range.on_change( 'end', lambda attr, old, new: change_sim_scale(ts1.x_range.start)) ts2.x_range.on_change( 'end', lambda attr, old, new: change_real_scale(ts2.x_range.start)) # set up layout widgets = column(datatype, stats) sim_button = column(sim_reverse_button) real_button = column(real_reverse_button) main_row = row(widgets) series = column(ts1, sim_button, ts2, real_button) layout = column(main_row, series) # initialize update() doc.add_root(intro_text) doc.add_root(sim_upload_text) doc.add_root(file_input) doc.add_root(real_upload_text) doc.add_root(file_input2) doc.add_root(layout) doc.title = "Flight data"
def __init__(self): Report.__init__(self, 'DQS') self.title = Div(text="DESI Nightly Intake - Data QA Scientist", css_classes=['h1-title-style'], width=1000) inst = """ The Data Quality Scientist (DQS) is responsible for analyzing all exposures for their quality. Submit problems as they arise throughout the night and complete the DQS checklist once an hour. Let the Lead Observer know if you encounter any issues. """ self.instructions = Div(text=inst, css_classes=['inst-style'], width=500) self.page_logo = Div(text="<img src='DQS_Report/static/logo.png'>", width=350, height=300) self.dqs_checklist = [ "Are all images being transferred to Night Watch?", "Did you check the observing conditions?", "Did you check the guiding?" ] self.quality_list = ['Good', 'Not Sure', 'No Data', 'Bad'] self.quality_btns = RadioButtonGroup(labels=self.quality_list, active=0)
def modify_doc(doc): with open('window_size.pickle', 'rb') as handle: project_dict = pickle.load(handle) data = project_dict['rollbar-gem'][1] source = ColumnDataSource(data) plot = figure(x_axis_type='linear', y_range=(0, 55), y_axis_label='Improvement (%)', x_axis_label='Risk Threshold') plot.line('x', 'y', source=source) def callback(attr, old, new): global project_name if attr == 'active': data = project_dict[project_name_dict[new]][1] project_name = project_name_dict[new] else: data = project_dict[project_name][new] source.data = ColumnDataSource(data=data).data slider = Slider(start=1, end=100, value=1, step=1, title="Window Size") slider.on_change('value', callback) radio_button_group = RadioButtonGroup(labels=project_list, active=0) radio_button_group.on_change('active', callback) doc.add_root(column(radio_button_group, slider, plot)) doc.theme = Theme(filename="../../theme.yaml")
def modify_doc(doc): with open('er_batch_size.pickle', 'rb') as handle: project_dict = pickle.load(handle) data = project_dict['bb'][0.1] source = ColumnDataSource(data) plot = figure(x_axis_type='linear', y_range=(-200, 200), y_axis_label='Improvement (%)', x_axis_label='Batch Size') plot.line('x', 'y', source=source) def callback(attr, old, new): global project_name if attr == 'active': data = project_dict[project_name_dict[new]][0.1] project_name = project_name_dict[new] else: new = float('{:2f}'.format(new)) data = project_dict[project_name][new] source.data = ColumnDataSource(data=data).data slider = Slider(start=0.1, end=1, value=0.1, step=0.01, title="Risk Threshold") slider.on_change('value', callback) radio_button_group = RadioButtonGroup( labels=er_project_list, active=0) radio_button_group.on_change('active', callback) doc.add_root(column(radio_button_group, slider, plot)) doc.theme = Theme(filename="../theme.yaml")
def initialise_directory(self) -> None: self.variable_selection = parse_directory(self.directory, glob="dump*.gsd") logger.debug("Pressures present: %s", self.variable_selection.keys()) self._pressures = sorted(list(self.variable_selection.keys())) self._pressure_button = RadioButtonGroup( name="Pressure ", labels=self._pressures, active=0, width=self.controls_width, ) self._pressure_button.on_change("active", self.update_temperature_button) pressure = self._pressures[self._pressure_button.active] self._temperatures = sorted( list(self.variable_selection[pressure].keys())) self._temperature_button = Select( name="Temperature", options=self._temperatures, value=self._temperatures[0], width=self.controls_width, ) self._temperature_button.on_change("value", self.update_crystal_button) temperature = self._temperature_button.value self._crystals = sorted( list(self.variable_selection[pressure][temperature].keys())) self._crystal_button = RadioButtonGroup(name="Crystal", labels=self._crystals, active=0, width=self.controls_width) self._crystal_button.on_change("active", self.update_index_button) crystal = self._crystals[self._crystal_button.active] self._iter_index = sorted( list(self.variable_selection[pressure][temperature] [crystal].keys())) self._iter_index_button = Select( name="Iteration Index", options=self._iter_index, value=self._iter_index[0], width=self.controls_width, ) self._iter_index_button.on_change("value", self.update_current_trajectory)
def create_orientation_group(self) -> RadioButtonGroup: orientation = self.legend.orientation.title() active = self.ORIENTATION_LABELS.index(orientation) button_group = RadioButtonGroup(labels=self.ORIENTATION_LABELS, active=active, width=210) button_group.on_change("active", self.handle_orientation_change) return button_group
def make_plot_type_buttons(plot_type): return RadioButtonGroup( labels=PLOT_TYPES, active=PLOT_TYPES.index(plot_type), callback=CustomJS( code="reloadWithParams('plot_type', cb_obj.labels[cb_obj.active])" ), )
def make_overview_tab(): # labels = ["Summary", "Statistics", "Demand Profile", "Price Profile"] labels = ["Summary", "Statistics"] radio_button_group = RadioButtonGroup(labels=labels, active=0) source_datatable = ColumnDataSource() data_table = DataTable(source=source_datatable, index_position=None) return radio_button_group, data_table, source_datatable
def initialise_trajectory_interface(self) -> None: logger.debug("Loading Models: %s", self.order_functions.keys()) self._order_parameter = RadioButtonGroup( name="Classification algorithm:", labels=list(self.order_functions.keys()), active=0, width=self.controls_width, ) self._order_parameter.on_click(self.radio_update_frame)
def switch_embeddings_button_group(settings): """Create radio button group for switching between UMAP, tSNE, and PCA.""" default_embedding = settings['embeddings']['default'] del settings['embeddings']['default'] button_labels = list(settings['embeddings'].keys()) default_embedding_idx = button_labels.index(default_embedding) radio_button_group = RadioButtonGroup(labels=button_labels, active=default_embedding_idx) return radio_button_group
def modify_doc(doc): source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"])) plot = Plot(plot_height=400, plot_width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0) plot.add_glyph(source, Circle(x='x', y='y', size=20)) plot.add_tools(CustomAction(callback=CustomJS(args=dict(s=source), code=RECORD("data", "s.data")))) group = RadioButtonGroup(labels=LABELS, css_classes=["foo"]) def cb(active): source.data['val'] = [active, "b"] group.on_click(cb) doc.add_root(column(group, plot))
def __init__(self, secondary): self.secondary = secondary self.handler = server_thread.SERVER_HANDLER self.b_connect = RadioButtonGroup(labels=['DISCONNECT', 'CONNECT'], active=0) self.b_connect.on_click(self.connect) self.layout = self.b_connect
def init_wdg_dict(read_list): """Generate the widget dictionary""" widget_dict = OrderedDict() widget_dict['read_list'] = Select(title="Select read to visualise:", options=read_list) widget_dict['signal_position'] = RadioButtonGroup(labels=['START', 'END'], active=1) widget_dict['scaled_signal'] = RadioButtonGroup( labels=['SCALED (pA)', 'UNSCALED (raw)'], active=0) widget_dict['plot_width'] = TextInput(title='Plot Width (px)', value=str(data['PLOT_WIDTH'])) widget_dict['plot_height'] = TextInput(title='Plot Height (px)', value=str(data['PLOT_HEIGHT'])) widget_dict['read_list'].on_change('value', update_file) widget_dict['signal_position'].on_change('active', update_toggle) widget_dict['scaled_signal'].on_change('active', update_scale) widget_dict['plot_width'].on_change('value', update_size_w) widget_dict['plot_height'].on_change('value', update_size_h) return widget_dict
def create_horizontal_alignment_select(self) -> RadioButtonGroup: value = HorizontalAlignment[self.text_align] active = self.HORIZONTAL_ALIGNMENT.index(value) h_align_select = RadioButtonGroup( labels=["Left", "Center", "Right"], active=active, width=210, disabled=isinstance(self.model, Axis), ) h_align_select.on_change("active", self.handle_horizontal_align_change) return h_align_select
def __init__(self): self.handler = server_thread.SERVER_HANDLER self.latest_status = None self.hv_options = list(OnOffState.__members__.keys()) self.b_hv_updating = False self.b_hv = RadioButtonGroup(labels=self.hv_options, active=self.hv_options.index("MAYBEON")) self.b_hv.on_click(self.hv_change) t_hv = Div(text="<h3>HV</h3>") self.b_hv_level = RadioButtonGroup( labels=['UNKNOWN', 'LOW', 'MED', 'HIGH'], active=0) self.b_hv_level.on_click(self.hv_level_change) self.t_hv_level = Div(text="<h3>HV LEVEL (requires ready)</h3>") options = list(GUITriggerSettings.__members__.keys()) self.b_trigger = Select(title="", value=options[0], options=options) self.t_trigger = Div(text="<h3>TRIGGER (requires ready)</h3>") self.b_trigger_apply = Button(label="APPLY", width=100) self.b_trigger_apply.on_click(self.trigger_change) self.w_time_input = TextInput() self.w_time_input_apply = Button(label="APPLY", width=100) self.w_time_input_apply.on_click(self.time_input_change) self.w_time_input_refresh = Button(label="REFRESH", width=100) self.w_time_input_refresh.on_click(self.update_time_input) self.t_time_input = Div( text="<h3>Observation Time (requires ready):</h3>") self.tk = tk.Tk() self.tk.withdraw() self.tk.lift() self.tk.attributes('-topmost', True) wb_list = [[t_hv], [self.b_hv], [self.t_hv_level], [self.b_hv_level], [self.t_trigger], [self.b_trigger], [self.b_trigger_apply], [self.t_time_input], [self.w_time_input], [self.w_time_input_apply, self.w_time_input_refresh]] self.layout = layout(wb_list)
def test_displays_options_list_of_string_labels(self, bokeh_model_page): group = RadioButtonGroup(labels=LABELS, css_classes=["foo"]) page = bokeh_model_page(group) div = page.driver.find_element_by_css_selector('div.foo') labels = div.find_elements_by_tag_name('label') assert len(labels) == 3 for i, label in enumerate(labels): assert label.text == LABELS[i] el = label.find_element_by_tag_name('input') assert el.get_attribute('value') == str(i) assert el.get_attribute('type') == 'radio'
def setup_mmt_legendboxArr(self, maxBoxNum, maxLegendNum): legendNum = ["number" for i in range(maxLegendNum)] mmtLegendBoxArr = [] for boxIndex in range(maxBoxNum): boxTitle = Button(label="", width=0, height=0, visible=False) mmtLegendNum = RadioButtonGroup(labels=legendNum, active=0, visible=False) boxHeader = column(boxTitle, mmtLegendNum) legendArr = [boxHeader] for legendIndex in range(maxLegendNum): legendArr.append( Button(label="", width=0, height=0, visible=False)) mmtLegendBoxArr.append(column(legendArr)) return row(mmtLegendBoxArr)
def init_widgets(data_start_date, data_end_date, source): """Initializes the widgets to be displayed adjacent the plot Args: data_start_date: the first date given in the data data_end_date: the last date given in the data source: data for the current day that is displayed by the widgets initially """ date_slider = DateSlider(title="Date Range: ", start=date.fromisoformat(data_start_date.split("T")[0]), end=date.fromisoformat(data_end_date.split("T")[0]), value=date.fromisoformat(data_end_date.split("T")[0]), step=86400000, sizing_mode="stretch_width") radio_button_group = RadioButtonGroup(labels=["New Positives", "Cumulative Number of Positives", "Total Number of Tests", "Cumulative Number of Tests"], active=0, sizing_mode="stretch_width") button = Button(label="Play", button_type="primary") columns = [ TableColumn(field="name", title="County"), TableColumn(field="new_positives", title="New Positives"), ] data_table = DataTable(source=source, columns=columns, sizing_mode="stretch_both", index_position=None) return date_slider, radio_button_group, button, data_table
def test_js_on_change_executes(self, bokeh_model_page): group = RadioButtonGroup(labels=LABELS, css_classes=["foo"]) group.js_on_click(CustomJS(code=RECORD("active", "cb_obj.active"))) page = bokeh_model_page(group) el = page.driver.find_element_by_css_selector('.foo .bk-btn:nth-child(3)') el.click() results = page.results assert results['active'] == 2 el = page.driver.find_element_by_css_selector('.foo .bk-btn:nth-child(1)') el.click() results = page.results assert results['active'] == 0 assert page.has_no_console_errors()
def test_js_on_change_executes(self, bokeh_model_page: BokehModelPage) -> None: group = RadioButtonGroup(labels=LABELS) group.js_on_click(CustomJS(code=RECORD("active", "cb_obj.active"))) page = bokeh_model_page(group) el = find_element_for(page.driver, group, ".bk-btn:nth-child(3)") el.click() results = page.results assert results['active'] == 2 el = find_element_for(page.driver, group, ".bk-btn:nth-child(1)") el.click() results = page.results assert results['active'] == 0 assert page.has_no_console_errors()
def __init__(self): self.parentText = TextInput( title='Parent ID (enter species name here if sample is original)') self.typeButtons = RadioButtonGroup( labels=[i.name for i in Sample.Type], active=0) self.noteText = TextInput(title='Note') self.dateText = TextInput( title="Creation Date (format 'Day-Month-Year' UTC)", value=datetime.datetime.strftime( datetime.datetime.now(datetime.timezone.utc), '%d-%m-%Y')) self.button = Button(label='Create!') self.copiesSelector = Select(title='Number of Copies', value=str(1), options=[str(i) for i in range(1, 10)]) self.widget = Panel(child=bokeh.layouts.layout([[self.parentText], [self.typeButtons], [self.noteText], [self.dateText], [self.copiesSelector], [self.button]]), title='New Sample')
def __init__(self): self._graph_layout = side_pos self.slider = Slider(start=1, end=60, value=7, step=1, title="X Zoom") self.plot = bokeh.plotting.figure(plot_width=400, plot_height=400, x_range=Range1d(-1, -1 + self.slider.value, bounds=(-2, 4e6)), y_range=Range1d(0, 1, bounds=(-0.5, 1.5)), tools='') self.slider.js_on_change( 'value', CustomJS(args=dict(slider=self.slider, plot=self.plot), code=''' var days = slider.value; plot.x_range.end=plot.x_range.start + days; plot.x_range.change.emit(); ''')) self.xSelectSwitch = RadioButtonGroup( labels=['By Generation', 'By Date'], active=0) self.plot.toolbar.logo = None self.plot.title.text = "Samples" self.plot.yaxis.visible = False self.plot.ygrid.visible = False self.plot.xaxis[0].ticker.min_interval = 1 self.plot.xaxis[0].ticker.num_minor_ticks = 0 self.plot.xaxis[0].axis_label = 'Generations' self.pallete = bokeh.palettes.Spectral4 tools = [TapTool(), WheelZoomTool(), PanTool(), ResetTool()] # HoverTool(tooltips={'ID':"@id",'Type':'@type','Notes':'@notes'})] tools[1].dimensions = 'height' # vertical zoom only self.plot.add_tools(*tools) self.plot.toolbar.active_scroll = tools[ 1] # sets the scroll zoom to be active immediately. self.colors = ['red', 'blue', 'green', 'purple', 'cyan', 'yellow'] self.widget = Column(self.plot, self.slider, self.xSelectSwitch)
def test_server_on_change_round_trip( self, bokeh_server_page: BokehServerPage) -> None: group = RadioButtonGroup(labels=LABELS) def modify_doc(doc): source = ColumnDataSource(dict(x=[1, 2], y=[1, 1], val=["a", "b"])) plot = Plot(height=400, width=400, x_range=Range1d(0, 1), y_range=Range1d(0, 1), min_border=0) plot.add_glyph(source, Circle(x='x', y='y', size=20)) plot.tags.append( CustomJS(name="custom-action", args=dict(s=source), code=RECORD("data", "s.data"))) def cb(event): source.data['val'] = [group.active, "b"] group.on_event('button_click', cb) doc.add_root(column(group, plot)) page = bokeh_server_page(modify_doc) el = find_element_for(page.driver, group, ".bk-btn:nth-child(3)") el.click() page.eval_custom_action() results = page.results assert results['data']['val'] == [2, "b"] el = find_element_for(page.driver, group, ".bk-btn:nth-child(1)") el.click() page.eval_custom_action() results = page.results assert results['data']['val'] == [0, "b"]
def test_js_on_change_executes(self, bokeh_model_page): group = RadioButtonGroup(labels=LABELS, css_classes=["foo"]) group.js_on_click(CustomJS(code=RECORD("active", "cb_obj.active"))) page = bokeh_model_page(group) el = page.driver.find_element_by_css_selector( 'div.foo div label input[value="2"]') el = el.find_element_by_xpath('..') el.click() results = page.results assert results['active'] == 2 el = page.driver.find_element_by_css_selector( 'div.foo div label input[value="0"]') el = el.find_element_by_xpath('..') el.click() results = page.results assert results['active'] == 0 assert page.has_no_console_errors()
def __init__(self, X, Y, patch_xs, patch_ys): self.workspace = figure(x_range=[x_low-2,x_high+2], y_range=[0,.6], toolbar_location=None) self.plot = self.workspace.line(x=X, y=Y, line_width=4) self.point = self.workspace.circle(x=[0], y=[-1], size=10, color="red") self.fx = self.workspace.circle(x=[0], y=[-1], size=10, color="red") self.sample_y = self.workspace.circle(x=[0], y=[-1], size=10, color="black") self.vertical = self.workspace.line(x=[0,0], y=[0,0], color="red", line_width=2) self.horizontal = self.workspace.line(x=[0,0], y=[0,0], color="red", line_width=2) self.slice = self.workspace.line(x=[0,0], y=[0,0], color="black", line_width=4) self.patches = self.workspace.patches(patch_xs, patch_ys, alpha=.3, line_width=2) self.filler1 = PreText(text='', width=200, height=250) self.filler2 = PreText(text='', width=200, height=250) ## for choosing update function self.radio = RadioButtonGroup( labels=['Stepping out', 'Doubling'], active=0) self.radio.on_click(self.radio_handler) ## for progressing demo self.button = Button(label="Next") self.button.on_click(self.callback) curdoc().add_root(row(column(self.filler1, self.button), self.workspace, column(self.filler2, self.radio)))
def animate(): global callback_id if button_animation.label == '► Play': button_animation.label = '❚❚ Pause' callback_id = curdoc().add_periodic_callback(animate_update, 200) else: button_animation.label = '► Play' curdoc().remove_periodic_callback(callback_id) """ ----------- Set up widgets and events ----------- """ # Button to choose the feature to display in the map label_features = ["intranational", "international"] # labels of possible features button_choice = RadioButtonGroup(labels=["Intranational", "International"], active=0) button_choice.on_change('active', update_map) # As the RadioButton isn't implemented with a title option, we add a PreText object before it title_button_choice = PreText(text="Choose the type of flights to visualize", style={ 'font-size': '12pt', 'color': 'black', 'font-family': 'sans-serif' }) # Description for Slider slider_explanation = PreText(text="Slider per day", style={ 'font-size': '9pt', 'color': 'black', 'font-family': 'sans-serif'
############################################################################### """ CLM settings """ ############################################################################### clm_div = Div(text="<h2>CLM settings</h2>", sizing_mode="stretch_width") ### Radio buttons - run type type_run_div = Div( text= '''Select the <a href="https://noresmhub.github.io/NorESM_LandSites_Platform/" target="_blank">model run type</a>.''', css_classes=['item-description'], sizing_mode='stretch_width') type_run_labels = constraints_dict['type_run']['valid_values'] type_run_radio = RadioButtonGroup(labels=type_run_labels, active=0) #show(runtype_radio_buttons) ### Radio buttons - run mode type_model_div = Div( text= '''Select the <a href="https://noresmhub.github.io/NorESM_LandSites_Platform/" target="_blank">model run mode</a>.''', css_classes=['item-description'], sizing_mode='stretch_width') type_model_labels = constraints_dict['type_model']['valid_values'] type_model_radio = RadioButtonGroup(labels=type_model_labels, active=0) ### Column for display clm_settings_section = column(clm_div, type_run_div, type_run_radio, type_model_div, type_model_radio)