Python bokeh.models.widgets.Panel() Examples
The following are 7
code examples of bokeh.models.widgets.Panel().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh.models.widgets
, or try the search function
.
Example #1
Source File: bokeh.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
def generate_model(self, figurepage_idx: int = 0) -> Model: """Returns a model generated from internal blueprints""" if figurepage_idx >= len(self.figurepages): raise RuntimeError(f'Cannot generate model for FigurePage with index {figurepage_idx} as there are only {len(self.figurepages)}.') figurepage = self.figurepages[figurepage_idx] if not self._is_optreturn: tabs = self.generate_model_tabs(figurepage) else: tabs = [] # now append analyzer tab(s) analyzers = figurepage.analyzers panel_analyzer = self.get_analyzer_panel(analyzers) if panel_analyzer is not None: tabs.append(panel_analyzer) # append meta tab if not self._is_optreturn: assert figurepage.strategy is not None meta = Div(text=metadata.get_metadata_div(figurepage.strategy)) metapanel = Panel(child=meta, title="Meta") tabs.append(metapanel) model = Tabs(tabs=tabs) # attach the model to the underlying figure for later reference (e.g. unit test) figurepage.model = model return model
Example #2
Source File: bokeh.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
def _get_nodata_panel(self): chart_grid = gridplot([], toolbar_location=self.p.scheme.toolbar_location, toolbar_options={'logo': None}) return Panel(child=chart_grid, title="No Data")
Example #3
Source File: bokeh.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
def get_analyzer_panel(self, analyzers: List[bt.Analyzer]) -> Optional[Panel]: if len(analyzers) == 0: return None table_width = int(self.p.scheme.analyzer_tab_width / self.p.scheme.analyzer_tab_num_cols) acolumns = [] for analyzer in analyzers: table_header, elements = self._tablegen.get_analyzers_tables(analyzer, table_width) acolumns.append(column([table_header] + elements)) childs = gridplot(acolumns, ncols=self.p.scheme.analyzer_tab_num_cols, toolbar_options={'logo': None}) return Panel(child=childs, title='Analyzers')
Example #4
Source File: liveclient.py From backtrader_plotting with GNU General Public License v3.0 | 5 votes |
def __init__(self, doc: Document, push_fnc, bokeh_fac: callable, push_data_fnc:callable, strategy: bt.Strategy, figurepage_idx: int = 0, lookback: int = 20): self._slider_aspectratio = None self._push_data_fnc = push_data_fnc self._push_fnc = push_fnc self._figurepage_idx = figurepage_idx self.last_data_index = -1 self._lookback = lookback self._strategy = strategy self._current_group = None self.document = doc self._bokeh_fac = bokeh_fac self._bokeh = None bokeh = self._bokeh_fac() # temporary bokeh object to get tradingdomains and scheme self._scheme = copy(bokeh.p.scheme) # preserve original scheme as originally provided by the user tradingdomains = bokeh.list_tradingdomains(strategy) self._current_group = tradingdomains[0] self._select_tradingdomain = Select(value=self._current_group, options=tradingdomains) self._select_tradingdomain.on_change('value', self._on_select_group) btn_refresh_analyzers = Button(label='Refresh Analyzers', width=100) btn_refresh_analyzers.on_click(self._on_click_refresh_analyzers) td_label = Div(text="Trading Domain:", margin=(9, 5, 15, 5)) controls = row(children=[td_label, self._select_tradingdomain, btn_refresh_analyzers]) self.model = column(children=[controls, Tabs(tabs=[])], sizing_mode=self._scheme.plot_sizing_mode) # append meta tab meta = Div(text=metadata.get_metadata_div(strategy)) self._panel_metadata = Panel(child=meta, title="Meta") self._refreshmodel()
Example #5
Source File: plotting.py From gnomad_methods with MIT License | 5 votes |
def plot_hail_hist_both( hist_data: hl.Struct, title: str, normalize: bool = True, log: bool = False ): p1 = plot_hail_hist(hist_data, title, log) p2 = plot_hail_hist_cumulative( hist_data, f"{title} (Cumulative)", normalize, log=log ) return Tabs( tabs=[Panel(child=p1, title="Raw"), Panel(child=p2, title="Cumulative")] )
Example #6
Source File: plotting.py From gnomad_methods with MIT License | 5 votes |
def linear_and_log_tabs(plot_func: Callable, **kwargs) -> Tabs: panels = [] for axis_type in ["linear", "log"]: fig = plot_func(**kwargs, axis_type=axis_type) panel = Panel(child=fig, title=axis_type) panels.append(panel) return Tabs(tabs=panels)
Example #7
Source File: bokeh.py From backtrader_plotting with GNU General Public License v3.0 | 4 votes |
def generate_model_tabs(self, fp: FigurePage, tradingdomain=None) -> List[Panel]: observers = [x for x in fp.figure_envs if isinstance(x.master, bt.Observer)] datas = [x for x in fp.figure_envs if isinstance(x.master, bt.DataBase)] inds = [x for x in fp.figure_envs if isinstance(x.master, bt.Indicator)] # now assign figures to tabs # 1. assign default tabs if no manual tab is assigned for figure in [x for x in datas if x.plottab is None]: figure.plottab = 'Plots' if self.is_tabs_single else 'Datas' for figure in [x for x in inds if x.plottab is None]: figure.plottab = 'Plots' if self.is_tabs_single else 'Indicators' for figure in [x for x in observers if x.plottab is None]: figure.plottab = 'Plots' if self.is_tabs_single else 'Observers' # 2. group panels by desired tabs # groupby expects the groups to be sorted or else will produce duplicated groups sorted_figs = list(itertools.chain(datas, inds, observers)) # 3. filter tradingdomains if tradingdomain is not None: filtered = [] for f in sorted_figs: lgs = f.get_tradingdomains() for lg in lgs: if lg is True or lg == tradingdomain: filtered.append(f) sorted_figs = filtered sorted_figs.sort(key=lambda x: x.plottab) tabgroups = itertools.groupby(sorted_figs, lambda x: x.plottab) panels = [] def build_panel(objects, panel_title): if len(objects) == 0: return Bokeh._sort_plotobjects(objects) g = gridplot([[x.figure] for x in objects], toolbar_options={'logo': None}, toolbar_location=self.p.scheme.toolbar_location, sizing_mode=self.p.scheme.plot_sizing_mode, ) panels.append(Panel(title=panel_title, child=g)) for tabname, figures in tabgroups: build_panel(list(figures), tabname) return panels # endregion