當前位置: 首頁>>代碼示例>>Python>>正文


Python widgets.DataTable方法代碼示例

本文整理匯總了Python中bokeh.models.widgets.DataTable方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.DataTable方法的具體用法?Python widgets.DataTable怎麽用?Python widgets.DataTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bokeh.models.widgets的用法示例。


在下文中一共展示了widgets.DataTable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: modify_document

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def modify_document(self, doc):

        controller = self.network.notes[0]
        notes_df = pd.DataFrame(self.network.notes[1]).reset_index()
        notes_df.columns = ["index", "notes"]
        notes = ColumnDataSource(notes_df)
        self.columns = [
            TableColumn(field="index", title="Timestamp"),
            TableColumn(field="notes", title="Notes"),
        ]
        self.data_table = DataTable(source=notes, columns=self.columns)
        layout = row([self.data_table])
        doc.add_root(layout)
        doc.title = "Notes for {}".format(controller)
        # doc.add_periodic_callback(self.update_data,100)
        return doc 
開發者ID:ChristianTremblay,項目名稱:BAC0,代碼行數:18,代碼來源:BokehRenderer.py

示例2: pad_plots

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def pad_plots(plots):
    """
    Accepts a grid of bokeh plots in form of a list of lists and
    wraps any DataTable or Tabs in a WidgetBox with appropriate
    padding. Required to avoid overlap in gridplot.
    """
    widths = []
    for row in plots:
        row_widths = []
        for p in row:
            width = pad_width(p)
            row_widths.append(width)
        widths.append(row_widths)
    plots = [[WidgetBox(p, width=w) if isinstance(p, (DataTable, Tabs)) else p
              for p, w in zip(row, ws)] for row, ws in zip(plots, widths)]
    return plots 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:18,代碼來源:util.py

示例3: _create_data_table

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def _create_data_table(
    source: ColumnDataSource, schema: ProcSchema, legend_col: str = None
):
    """Return DataTable widget for source."""
    column_names = [
        schema.user_name,
        schema.user_id,
        schema.logon_id,
        schema.process_id,
        schema.process_name,
        schema.cmd_line,
        schema.parent_id,
        schema.parent_name,
        schema.target_logon_id,
    ]

    if legend_col and legend_col not in column_names:
        column_names.append(legend_col)

    date_fmt = "%F %T"
    columns = [
        TableColumn(
            field=schema.time_stamp,
            title=schema.time_stamp,
            formatter=DateFormatter(format=date_fmt),
        )
    ]
    columns2 = [
        TableColumn(field=col, title=col)
        for col in column_names
        if col in source.column_names
    ]

    data_table = DataTable(
        source=source, columns=columns + columns2, width=950, height=150
    )
    return data_table 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:39,代碼來源:process_tree.py

示例4: make_plot

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.title = Paragraph(text=TITLE)
        self.data_table = DataTable(source=self.source, width=390, height=275, columns=[
            TableColumn(field="zipcode", title="Zipcodes", width=100),
            TableColumn(field="population", title="Population", width=100, formatter=NumberFormatter(format="0,0")),
            TableColumn(field="city", title="City")
        ])
        return column(self.title, self.data_table) 
開發者ID:GoogleCloudPlatform,項目名稱:bigquery-bokeh-dashboard,代碼行數:11,代碼來源:population.py

示例5: _build_optresult_selector

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def _build_optresult_selector(self, optresults) -> Tuple[DataTable, ColumnDataSource]:
        # 1. build a dict with all params and all user columns
        data_dict = defaultdict(list)
        for optres in optresults:
            for param_name, _ in optres[0].params._getitems():
                param_val = optres[0].params._get(param_name)
                data_dict[param_name].append(param_val)

            for usercol_label, usercol_fnc in self._usercolumns.items():
                data_dict[usercol_label].append(usercol_fnc(optres))

        # 2. build a pandas DataFrame
        df = DataFrame(data_dict)

        # 3. now sort and limit result
        if self._sortcolumn is not None:
            df = df.sort_values(by=[self._sortcolumn], ascending=self._sortasc)

        if self._num_result_limit is not None:
            df = df.head(self._num_result_limit)

        # 4. build column info for Bokeh table
        tab_columns = []
        for colname in data_dict.keys():
            formatter = NumberFormatter(format='0.000')

            if len(data_dict[colname]) > 0 and isinstance(data_dict[colname][0], int):
                formatter = StringFormatter()

            tab_columns.append(TableColumn(field=colname, title=f'{colname}', sortable=False, formatter=formatter))

        # TODO: currently table size is hardcoded
        cds = ColumnDataSource(df)
        selector = DataTable(source=cds, columns=tab_columns, width=1600, height=150)
        return selector, cds 
開發者ID:verybadsoldier,項目名稱:backtrader_plotting,代碼行數:37,代碼來源:optbrowser.py

示例6: get_logged_messages

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def get_logged_messages(logged_messages, plot_width):
    """
    get a bokeh widgetbox object with a table of the logged text messages
    :param logged_messages: ulog.logged_messages
    """
    log_times = []
    log_levels = []
    log_messages = []
    for m in logged_messages:
        m1, s1 = divmod(int(m.timestamp/1e6), 60)
        h1, m1 = divmod(m1, 60)
        log_times.append("{:d}:{:02d}:{:02d}".format(h1, m1, s1))
        log_levels.append(m.log_level_str())
        log_messages.append(m.message)
    log_data = dict(
        times=log_times,
        levels=log_levels,
        messages=log_messages)
    source = ColumnDataSource(log_data)
    columns = [
        TableColumn(field="times", title="Time",
                    width=int(plot_width*0.15), sortable=False),
        TableColumn(field="levels", title="Level",
                    width=int(plot_width*0.1), sortable=False),
        TableColumn(field="messages", title="Message",
                    width=int(plot_width*0.75), sortable=False),
        ]
    data_table = DataTable(source=source, columns=columns, width=plot_width,
                           height=300, sortable=False, selectable=False)
    div = Div(text="""<b>Logged Messages</b>""", width=int(plot_width/2))
    return widgetbox(div, data_table, width=plot_width) 
開發者ID:PX4,項目名稱:flight_review,代碼行數:33,代碼來源:plotted_tables.py

示例7: compute_plot_size

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def compute_plot_size(plot):
    """
    Computes the size of bokeh models that make up a layout such as
    figures, rows, columns, widgetboxes and Plot.
    """
    if isinstance(plot, GridBox):
        ndmapping = NdMapping({(x, y): fig for fig, y, x in plot.children}, kdims=['x', 'y'])
        cols = ndmapping.groupby('x')
        rows = ndmapping.groupby('y')
        width = sum([max([compute_plot_size(f)[0] for f in col]) for col in cols])
        height = sum([max([compute_plot_size(f)[1] for f in row]) for row in rows])
        return width, height
    elif isinstance(plot, (Div, ToolbarBox)):
        # Cannot compute size for Div or ToolbarBox
        return 0, 0
    elif isinstance(plot, (Row, Column, WidgetBox, Tabs)):
        if not plot.children: return 0, 0
        if isinstance(plot, Row) or (isinstance(plot, ToolbarBox) and plot.toolbar_location not in ['right', 'left']):
            w_agg, h_agg = (np.sum, np.max)
        elif isinstance(plot, Tabs):
            w_agg, h_agg = (np.max, np.max)
        else:
            w_agg, h_agg = (np.max, np.sum)
        widths, heights = zip(*[compute_plot_size(child) for child in plot.children])
        return w_agg(widths), h_agg(heights)
    elif isinstance(plot, (Figure, Chart)):
        if plot.plot_width:
            width = plot.plot_width
        else:
            width = plot.frame_width + plot.min_border_right + plot.min_border_left
        if plot.plot_height:
            height = plot.plot_height
        else:
            height = plot.frame_height + plot.min_border_bottom + plot.min_border_top
        return width, height
    elif isinstance(plot, (Plot, DataTable, Spacer)):
        return plot.width, plot.height
    else:
        return 0, 0 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:41,代碼來源:util.py

示例8: pad_width

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def pad_width(model, table_padding=0.85, tabs_padding=1.2):
    """
    Computes the width of a model and sets up appropriate padding
    for Tabs and DataTable types.
    """
    if isinstance(model, Row):
        vals = [pad_width(child) for child in model.children]
        width = np.max([v for v in vals if v is not None])
    elif isinstance(model, Column):
        vals = [pad_width(child) for child in model.children]
        width = np.sum([v for v in vals if v is not None])
    elif isinstance(model, Tabs):
        vals = [pad_width(t) for t in model.tabs]
        width = np.max([v for v in vals if v is not None])
        for model in model.tabs:
            model.width = width
            width = int(tabs_padding*width)
    elif isinstance(model, DataTable):
        width = model.width
        model.width = int(table_padding*width)
    elif isinstance(model, (WidgetBox, Div)):
        width = model.width
    elif model:
        width = model.plot_width
    else:
        width = 0
    return width 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:29,代碼來源:util.py

示例9: EpitopeTable

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def EpitopeTable(self):
        Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.neosData.columns]  # bokeh columns
        data_table = DataTable(columns=Columns, source=ColumnDataSource(self.neosData) ,width=1200, height=200)  # bokeh table

        return(data_table) 
開發者ID:MathOnco,項目名稱:NeoPredPipe,代碼行數:7,代碼來源:NeoPredViz.py

示例10: SummaryTable

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def SummaryTable(self):

        Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.summaryData.columns]  # bokeh columns
        data_table = DataTable(columns=Columns, source=ColumnDataSource(self.summaryData) ,width=1200, height=200)  # bokeh table

        return(data_table) 
開發者ID:MathOnco,項目名稱:NeoPredPipe,代碼行數:8,代碼來源:NeoPredViz.py

示例11: test_array_to_bokeh_table

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def test_array_to_bokeh_table(self):
        dataframe = DataFrame(self.rng.rand(2, 3), columns=[str(i) for i in range(3)])
        self.assertTrue(isinstance(array_to_bokeh_table(dataframe), DataTable))
        # Pass logger
        self.assertTrue(isinstance(array_to_bokeh_table(dataframe, logger=logging.getLogger('test')), DataTable))
        # Pass sortable and width
        self.assertTrue(isinstance(array_to_bokeh_table(dataframe,
                                                        sortable={'1' : True, '2' : True},
                                                        width={'1' : 100, '0' : 200}),
                                   DataTable))
        # Pass invalid specifications
        self.assertRaises(ValueError, array_to_bokeh_table, dataframe, sortable={'7' : True, '2' : True})
        self.assertRaises(ValueError, array_to_bokeh_table, dataframe, width={'1' : 100, 10 : 200}) 
開發者ID:automl,項目名稱:CAVE,代碼行數:15,代碼來源:test_bokeh_routines.py

示例12: plot_Scatterplot

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def plot_Scatterplot():

    plotname = inspect.stack()[0][3][5:]
    pandas_bokeh.output_file(os.path.join(PLOT_DIR, f"{plotname}.html"))

    df = df_iris()
    df = df.sample(frac=1)

    # Create Bokeh-Table with DataFrame:
    from bokeh.models.widgets import DataTable, TableColumn
    from bokeh.models import ColumnDataSource

    data_table = DataTable(
        columns=[TableColumn(field=Ci, title=Ci) for Ci in df.columns],
        source=ColumnDataSource(df.head(10)),
    )

    # Create Scatterplot:
    p_scatter = df.plot_bokeh.scatter(
        x="petal length (cm)",
        y="sepal width (cm)",
        category="species",
        title="Iris DataSet Visualization",
        show_figure=False,
    )

    # Combine Div and Scatterplot via grid layout:
    pandas_bokeh.plot_grid([[data_table, p_scatter]], plot_width=400, plot_height=350) 
開發者ID:PatrikHlobil,項目名稱:Pandas-Bokeh,代碼行數:30,代碼來源:make_plots.py

示例13: _create_events_table

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def _create_events_table() -> DataTable:
    """Utility function for creating and styling the events table."""
    formatter = HTMLTemplateFormatter(
        template="""
    <style>
        .AS_POS {color: #0000FF; font-weight: bold;}
        .AS_NEG {color: #0000FF; font-weight: bold;}
        .OP_POS {color: #1aaa0d; font-style: bold;}
        .OP_NEG {color: #f40000;font-style: bold;}
        .NEG_POS {font-style: italic;}
        .NEG_NEG {color: #f40000; font-style: italic;}
        .INT_POS {color: #1aaa0d; font-style: italic;}
        .INT_NEG {color: #f40000; font-style: italic;}
    </style>
    <%= value %>"""
    )
    columns = [
        TableColumn(field="POS_events", title="Positive Examples", formatter=formatter),
        TableColumn(field="NEG_events", title="Negative Examples", formatter=formatter),
    ]
    return DataTable(
        source=ColumnDataSource(),
        columns=columns,
        height=400,
        index_position=None,
        width=2110,
        sortable=False,
        editable=True,
        reorderable=False,
    ) 
開發者ID:NervanaSystems,項目名稱:nlp-architect,代碼行數:32,代碼來源:absa_solution.py

示例14: _update_events

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def _update_events(events: DataTable, in_domain: bool) -> None:
    """Utility function for updating the content of the events table."""
    i = source.selected.indices
    events.source.data.update(
        {
            pol + "_events": stats.loc[aspects[i[0]], pol, in_domain]["Sent_1":].replace(np.nan, "")
            if i
            else []
            for pol in POLARITIES
        }
    ) 
開發者ID:NervanaSystems,項目名稱:nlp-architect,代碼行數:13,代碼來源:absa_solution.py

示例15: _create_examples_table

# 需要導入模塊: from bokeh.models import widgets [as 別名]
# 或者: from bokeh.models.widgets import DataTable [as 別名]
def _create_examples_table() -> DataTable:
    """Utility function for creating and styling the events table."""

    formatter = HTMLTemplateFormatter(
        template="""
    <style>
        .AS {color: #0000FF; font-weight: bold;}
        .OP {color: #0000FF; font-weight: bold;}
    </style>
    <div><%= value %></div>"""
    )
    columns = [
        TableColumn(
            field="Examples", title='<span class="header">Examples</span>', formatter=formatter
        )
    ]
    empty_source = ColumnDataSource()
    empty_source.data = {"Examples": []}
    return DataTable(
        source=empty_source,
        columns=columns,
        height=500,
        index_position=None,
        width=1500,
        sortable=False,
        editable=False,
        reorderable=False,
        header_row=True,
    ) 
開發者ID:NervanaSystems,項目名稱:nlp-architect,代碼行數:31,代碼來源:absa_solution.py


注:本文中的bokeh.models.widgets.DataTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。