Panel basics
Last updated
Was this helpful?
Last updated
Was this helpful?
Panel is designed to make plots interactive. To create an interactive dashboard we need a few elements. We need widgets
to allow the user to change the view. We need layouts
(Panel objects) to arrange and order visuals. And we need a function(s)
that generates the visuals with the input parameters generated from the widgets. And we need the interact
function to generate the interactive user interface. The interactive dashboard can be deployed to a html page by using the panel object .show()
method.
The interactive dashboards can be showed in your notebook. However, the panel.extension
first has to be loaded to initialize the required JavaScript in the notebook context.
Widgets allow the user to change the view of the plot by making selections, clicking buttons and typing into textboxes. Panel
supports different type of widgets. Widgets such as radiobuttons, autocomplete input, Date or numeric sliders bounded by a start
and end
value, Boolean buttons like a toggle, Datetime pickers, Textinputs, Colorpickers and even widgets that interact with dataframes. All the widget options can be found here:
The function should be a function that generates a visual, for instance a plot and that takes arguments as input for creating the visual. It is wise to use default arguments to generate a default visual in case nothing is selected or set by the user
Panel
layout objects allow combining plots into a Row
, Column
, Tabs
or a Grid
.
There are four main types of Panel
layout objects:
Row
: A Row
arranges a list of components horizontally.
Column
: A Column
arranges a list of components vertically.
Tabs
: A Tabs
object lays out a list of components as selectable tabs.
GridSpec
: A GridSpec
lays out components on a grid.
The interact
function (panel.interact
) automatically creates user interface controls for exploring code and data interactively. It combines the function with the input by calling the interact method with the function and input.
If no widget is specified it will generate automatically a widget from the input parameters of the given function
.show()
The
.show()
method starts a bokeh server instance then opens a browser tab to point to it
Putting it all together we can use the following as a base for a dashboard
see also
You can also deploy the dashboard from a for other users viewable server see the documentation or