neuralib.dashboard.base.ViewComponent
- class neuralib.dashboard.base.ViewComponent[source]
Bases:
objectA UI component that provides certain graph on specific data type.
General Structure
>>> class MyView(ViewComponent): ... # for ColumnDataSource attribute's name, there is no hard rule ... data_a: ColumnDataSource ... # for GlyphRenderer attribute's name, it should be named with prefix 'render_' ... render_a: GlyphRenderer ... def __init__(self): ... # initialize an empty data ... self.data_a = ColumnDataSource(data=dict(...)) ... def plot(self, figure): ... # plotting data ... self.render_a = figure.plot(self.data_a) ... # function to update the render, data ... def update(self, data): ... # update data ... self.data_a.activity = dict(...)
Implement Note
I suggest make plotting related properties as @property, because they usually need to update/invalid other attributes/properties when it is updated. In order to improve the performance, you don’t need to update the graph/render for each property update in an event loop. Because most render update functions have to process data and set value into
ColumnDataSource, andColumnDataSourceneed to sync the content with the web browser, it will take many times for every property update. You can mention (in document) the caller have to call the render update function after several properties update function.- __init__()
Methods
__init__()list_renders([pattern, recursive])list all renders for those name contain pattern.
plot(fig, **kwargs)plot data in figure.
set_visible(visible[, pattern])Set the visible state of renders for those name contain pattern.
update()update the plot
- abstractmethod plot(fig, **kwargs)[source]
plot data in figure.
- Parameters:
fig (Any) – Figure.
kwargs – plotting parameters.
- set_visible(visible, pattern=None)[source]
Set the visible state of renders for those name contain pattern. It is a recursive function that it also update the renders inside the
ViewComponentattributes.- Parameters:
visible (bool)
pattern (str | None) – str in attribute name
- list_renders(pattern=None, recursive=False)[source]
list all renders for those name contain pattern.
- Parameters:
pattern (str | None) – str in attribute name
recursive (bool) – recursive find all renders from
ViewComponentattributes.
- Returns:
- Return type:
list[GlyphRenderer]