コード例 #1
0
    def plot_table(self, **params):
        try:
            from bokeh.models.widgets import DataTable, TableColumn
            df, metrics = self._handle_data(**params)

            columns = list()
            for col in df.columns.to_list():
                columns.append(TableColumn(field=col, title=col))
            source = ColumnDataSource(df)
            p2 = DataTable(columns=columns,
                           source=source,
                           fit_columns=True,
                           max_height=(self.plot_height - 20),
                           max_width=(self.plot_width - 40),
                           index_width=0)
            p2.width = (self.plot_width - 30)
            p2.height = (self.plot_height - 20)
            return p2
        except Exception as e:
            return f"<br><br> Plot error: <br> {str(e)}"
コード例 #2
0
ファイル: makehtml.py プロジェクト: sparce/NAF
original_source = ColumnDataSource(df)

numform = NumberFormatter(format='0.00')

strcolumns = [
    TableColumn(field=x, title=x) for x in ["coach", "race", "nation"]
]
numcolumns = [
    TableColumn(field=x, title=x, formatter=numform)
    for x in ["mu", "phi", "value"]
]

data_table = DataTable(source=source, columns=strcolumns + numcolumns)

data_table.height = 1000
data_table.width = 500

# callback code to be used by all the filter widgets
# requires (source, original_source, race_select_obj,target_object)
combined_callback_code = """
var data = source.get('data');
var original_data = original_source.get('data');
var race = race_select_obj.get('value');
console.log("race: " + race);

for (var key in original_data) {
    data[key] = [];
    for (var i = 0; i < original_data['race'].length; ++i) {
        if (race === "ALL" || original_data['race'][i] === race) {
            data[key].push(original_data[key][i]);
        }