multi-select dropdown Bokeh - python

I know that there are a bunch of widgets available in Bokeh, here:
https://docs.bokeh.org/en/latest/docs/user_guide/interaction/widgets.html
How can I integrate Bokeh Dropdown Menu with MultiSelect (or extend the Dropdown) in order to have a Multi-Select Dropdown? Is there anything built-in?
My expected result is a dropdown which one can select/deselect multiple options.

You can write you own custom Bokeh model extension using TypeScript. See Extending Bokeh for more information. Scroll down for links to some nice examples. You will need to install nodejs on your system to be able to compile TypeScript.
If the widget height is your main consideration than you could think of replacing the MultiSelect with CheckboxButtonGroup.

Related

How to allow dropdowns in the sidebar navigation TOC of the Furo Sphinx theme?

I want to allow users to have dropdown menus (with a little arrow) in the TOC tree that is in the navigation sidebar in the Furo theme. I saw that some themes like book-theme allow for this by specifying a theme option, but I am currently puzzled as to how this can be done for the Furo theme.
I tried looking into whether there were theme options or I adding the content tree directly, but I failed to find any. I tried adding sphrinxcontrib.fulltoc extensions, which works without Furo, but throws an error when used in combination with Furo.
I ran into the same issue with adding a dropdown in the sidebar using furo. Here is what I did:
I added the following extensions in my conf.py:
myst_enable_extensions = [
"html_image",
"html_admonition",
"colon_fence",
"sphinx.ext.autodoc",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"furo.sphinxext",
"myst_parser",
"sphinx_copybutton",
"sphinx_design",
"sphinx_inline_tabs"]
I'm not sure which one of these actually creates the arrow for the dropdown, but it worked for me.
I looked at how they did it in the furo docs to get the answer: https://pradyunsg.me/furo/
Github for furo docs: https://github.com/pradyunsg/furo/tree/main/docs

multiselect dropdown using ipywidgets?

I wanted to create a multiselect dropdown with checkboxes using ipywidgets, but with dropdown it is possible to select only one option. Would there be any possible way to implement this? ipywidgets also has an html widget, can this be done with html? If it isnt possible to achieve this, then what would be the best alternative approach?

Restrict the number of rows displayed in DataTable on Bokeh Server

I have a Bokeh application, accessed through the command prompt using bokeh serve --show my_app.
On one of the tabs, there is a DataTable widget displaying millions of rows, which makes the page choppy and unresponsive.
Is there any way to restrict the number of rows that are displayed in a DataTable without explicitly restricting the data source behind it? It's important that the user is able to sort the DataTable and see the extremities of the full dataset.
The Bokeh CDSView is probably what you are after (see Filtering Data section)

Include folium in bokeh tabs

I would like to add a folium map to a bokeh tab.
Is it possible?
When I try i have an error like: expected an instance of type LayoutDOM, got folium of type map.
Otherwise is there another way to do chart in python with map and include it in tab?
Thank you :)
Bokeh has its own set of objects to represent the built-in widgets that it can display. Only these Bokeh objects can go inside Bokeh layouts like tab panes. However, one of the available widgets is Div, which let you put an HTML div with arbitrary content inside a Bokeh layout e.g.
div = Div(text="whatever HTML code you want")
layout = column(plot, div)
So you could put the raw HTML for a map as the content for one of these Div objects.

How to draw an html table using bokeh?

I am new to bokeh, I search for examples in the documentation but it appears to me there is not in built method for creating tables. I have some data that I want to show in tabular format. I was wondering what is the easiest way to do that using Bokeh?
The reason I want to draw tables using Bokeh is because I am trying to put a table and two bar charts in the same html report. I was hoping to use one library(Bokeh) to do all my drawing because otherwise I will have to generate table using html generator and then add the html for bar chart generated via Bokeh to that. Hope that explains.
There's no built-in support to create an HTML table as of Bokeh 0.9.1, however it is very simple to embed Bokeh plots and widgets inside your own custom HTML templates. For instance, the new spectrogram shows a very customized HTML document with Bokeh plots and widgets embedded:
https://www.youtube.com/watch?v=L6p7Cd3uDis
So, I would recommend taking this approach. The documentation for embedding is located here:
http://docs.bokeh.org/en/latest/docs/user_guide/embed.html

Categories