PerspectiveView  type: perspective#

class lumen.views.base.PerspectiveView(*, aggregates, column_pivots, columns, computed_columns, filters, plugin, row_pivots, selectable, sort, theme, controls, download, field, limit, loading_indicator, pipeline, rerender, selection_group, title, name)#

PerspectiveView renders data into a Perspective widget.

See https://panel.holoviz.org/reference/panes/Perspective.html for more details.


Parameters#

aggregates

type: dict
default: None
How to aggregate. For example {x: “distinct count”}

column_pivots

type: Any
default: None
Possible values: ``
A list of source columns to pivot by. For example [“x”, “y”]

columns

type: Any
default: None
Possible values: ``
A list of source columns to show as columns. For example [“x”, “y”]

computed_columns

type: Any
default: None
Possible values: ``
A list of computed columns. For example [“”x”+”index””]

filters

type: list[Any]
default: None
How to filter. For example [[“x”, “<”, 3],[“y”, “contains”, “abc”]]

plugin

type: Any
default: 'datagrid'
Possible values: 'hypergrid' | 'datagrid' | 'd3_y_bar' | 'd3_x_bar' | 'd3_xy_line' | 'd3_y_line' | 'd3_y_area' | 'd3_y_scatter' | 'd3_xy_scatter' | 'd3_treemap' | 'd3_sunburst' | 'd3_heatmap' | 'd3_candlestick' | 'd3_ohlc'
The name of a plugin to display the data. For example hypergrid or d3_xy_scatter.

row_pivots

type: Any
default: None
Possible values: ``
A list of source columns to group by. For example [“x”, “y”]

selectable

type: bool
default: True
Whether items are selectable.

sort

type: list[Any]
default: None
How to sort. For example[[“x”,”desc”]]

theme

type: Any
default: 'material'
Possible values: 'material' | 'material-dark' | 'monokai' | 'solarized' | 'solarized-dark' | 'vaporwave' | 'pro' | 'pro-dark'
The style of the PerspectiveViewer. For example material-dark


Methods#

PerspectiveView.get_data()#

Queries the Source for the specified table applying any filters and transformations specified on the View. Unlike get_value this should be used when multiple return values are expected.

Returns:

The queried table after filtering and transformations are applied.

Return type:

DataFrame

PerspectiveView.get_panel() Perspective#

Constructs and returns a Panel object which will represent a view of the queried table.

Returns:

A Panel Viewable object representing a current representation of the queried table.

Return type:

panel.Viewable

PerspectiveView.get_value(field: str | None = None)#

Queries the Source for the data associated with a particular field applying any filters and transformations specified on the View. Unlike get_data this method returns a single scalar value associated with the field and should therefore only be used if only a single.

Parameters:

field (str (optional)) – The field from the table to return; if None uses field defined on the View.

Returns:

A single scalar value representing the current value of the queried field.

Return type:

object

PerspectiveView.servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) Viewable#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Parameters:
  • title (str) – A string title to give the Document (if served as an app)

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

  • area (str (deprecated)) – The area of a template to add the component too. Only has an effect if pn.config.template has been set.

  • target (str) – Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Return type:

The Panel object itself

PerspectiveView.show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) threading.Thread | 'Server'#

Starts a Bokeh server and displays the Viewable in a new tab.

Parameters:
  • title (str | None) – A string title to give the Document (if served as an app)

  • port (int (optional, default=0)) – Allows specifying a specific port

  • address (str) – The address the server should listen on for HTTP requests.

  • websocket_origin (str or list(str) (optional)) – A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

  • threaded (boolean (optional, default=False)) – Whether to launch the Server on a separate thread, allowing interactive use.

  • verbose (boolean (optional, default=True)) – Whether to print the address and port

  • open (boolean (optional, default=True)) – Whether to open the server in a new browser tab

  • location (boolean or panel.io.location.Location) – Whether to create a Location component to observe and set the URL location.

Returns:

server – Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

Return type:

bokeh.server.Server or panel.io.server.StoppableThread

PerspectiveView.to_spec(context: Dict[str, Any] | None = None) Dict[str, Any]#

Exports the full specification to reconstruct this component.

Parameters:

context (Dict[str, Any]) – Context contains the specification of all previously serialized components, e.g. to allow resolving of references.

Return type:

Declarative specification of this component.

PerspectiveView.update(*events: Event, invalidate_cache: bool = True)#

Triggers an update in the View.

Parameters:
  • events (tuple) – param events that may trigger an update.

  • invalidate_cache (bool) – Whether to clear the View’s cache.