Views

The View type is the main visual type and determines how the metrics returned by a Source are rendered.

class lumen.views.View(**params)

A View renders the data returned by a Source as a Viewable Panel object. The base class provides methods which query the Source for the latest data given the current filters and applies all specified transforms.

Subclasses should use these methods to query the data and return a Viewable Panel object in the get_panel method.

filters = param.List(readonly=False)

A list of Filter object providing the query parameters for the Source.

source = param.ClassSelector(readonly=False)

The Source to query for the data.

selection_group = param.String(readonly=False)

Declares a selection group the plot is part of. This feature requires the separate HoloViews library.

transforms = param.List(readonly=False)

A list of transforms to apply to the data returned by the Source before visualizing it.

table = param.String(readonly=False)

The table being visualized.

field = param.String(readonly=False)

The field being visualized.

classmethod from_spec(spec, source, filters)

Resolves a View specification given the schema of the Source it will be filtering on.

Parameters
  • spec (dict) – Specification declared as a dictionary of parameter values.

  • source (lumen.sources.Source) – The Source object containing the tables the View renders.

  • filters (list(lumen.filters.Filter)) – A list of Filter objects which provide query values for the Source.

Returns

Return type

The resolved View object.

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

get_panel()

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

get_value(field=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

update(*events, invalidate_cache=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.

Returns

stale – Whether the panel on the View is stale and needs to be rerendered.

Return type

bool

View types

class lumen.views.hvPlotView(**params)

The hvPlotView renders the queried data as a bokeh plot generated with hvPlot. hvPlot allows for a concise declaration of a plot via its simple API.

Parameters inherited from:

lumen.views.base.View: filters, source, selection_group, transforms, table, field

kind = param.String(readonly=False)

The kind of plot, e.g. ‘scatter’ or ‘line’.

x = param.String(readonly=False)

The column to render on the x-axis.

y = param.String(readonly=False)

The column to render on the y-axis.

opts = param.Dict(readonly=False)

HoloViews option to apply on the plot.

streaming = param.Boolean(readonly=False)

Whether to stream new data to the plot or rerender the plot.

selection_expr = param.Parameter(readonly=False)

class lumen.views.IndicatorView(**params)

The IndicatorView renders the latest field value as a Panel Indicator.

Parameters inherited from:

lumen.views.base.View: filters, source, selection_group, transforms, table, field

indicator = param.Selector(readonly=False)

The name of the panel Indicator type.

label = param.String(readonly=False)

A custom label to use for the Indicator.

class lumen.views.StringView(**params)

The StringView renders the latest value of the field as a HTML string with a specified fontsize.

Parameters inherited from:

lumen.views.base.View: filters, source, selection_group, transforms, table, field

font_size = param.String(readonly=False)

The font size of the rendered field value.