I am currently running an app displaying the table widget from the bokeh library. The python library creates a html file containing interactive js elements such as graphs and tables.
Whereas with graphs there seem to be lots of options to customize colors etc, this is not the case with the table which comes in the form of a 'widget'.
A slightly changed code example from the doc for a Jupyter notebook is
# coding: utf-8
# In[1]:
from bokeh.io import output_notebook
output_notebook()
# In[2]:
from datetime import date
from random import randint
from bokeh.io import show
from bokeh.layouts import widgetbox
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn
data = dict(
dates=[date(2014, 3, i+1) for i in range(10)],
number=[randint(-100, 100) for i in range(10)],
)
source = ColumnDataSource(data)
columns = [
TableColumn(field="dates", title="Date", formatter=DateFormatter()),
TableColumn(field="number", title="Number"),
]
data_table = DataTable(source=source, columns=columns, width=400, height=280)
show(widgetbox(data_table))
Is it possible to format the output in such a way that negative values are assigned color = red, high values are printed bold etc?
Is such a task maybe easier with other libraries such as plotly (no experience yet)?
Someone asked this a few weeks ago. bokeh DataTable with conditionally coloured cells
You can use that example to perform most of the formatting you would need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With