cosapp.tools.views.visjs

Build a VISjs view of a System.

Functions

to_visjs(system, filename[, embeddable])

Export a system as HTML using vis.JS library.

visjs_html(system[, embeddable])

Returns vis.JS HTML content of system.

Classes

VisJsRenderer(system[, embeddable])

Utility class to export a system as HTML using vis.JS library.

class cosapp.tools.views.visjs.VisJsRenderer(system: System, embeddable=False)[source]

Bases: BaseRenderer

Utility class to export a system as HTML using vis.JS library.

Parameters:
  • system (System) – System to export

  • embeddable (bool, optional) – Is the HTML to be embedded in an existing page? Default: False

get_data() Dict[source]

Convert the System in a dictionary with 4 keys: title, nodes, edges and groups.

The title is a string with the Module name. The nodes is a list of dictionaries defining node for vis JS library. The edges is a list of dictionaries defining edge for vis JS library. The groups is a list of string defining the nodes clusters for vis JS library.

Parameters:

focus_system (System or None) – System on which the visualization should focus by default

Returns:

Dictionary containing elements to draw the System using visJS library

Return type:

dict

classmethod get_globals()[source]

Returns a dict containing class-wide environment and HTML data

get_system_group(system: System)[source]
static get_system_label(system: System)[source]
get_system_title(system: System)[source]
html_content() str[source]

Returns vis.JS HTML content of renderer”s system as a character string.

classmethod html_resources() Dict[str, str][source]

Return a dictionary of two keys.

  • visJS key holds the content of vis.js library.

  • visCSS key holds the css style of plot.

Returns:

The necessary resources to render Jinja template

Return type:

Dict[str, Dict]

classmethod html_template()[source]

Return the Jinja template used to create HTML file.

Return type:

Template

cosapp.tools.views.visjs.to_visjs(system: System, filename: str, embeddable=False) None[source]

Export a system as HTML using vis.JS library.

Parameters:
  • system (System) – System to export

  • filename (str) – Filename to write to

  • embeddable (bool, optional) – Is the HTML to be embedded in an existing page? Default: False

cosapp.tools.views.visjs.visjs_html(system: System, embeddable=False) str[source]

Returns vis.JS HTML content of system.

Parameters:
  • system (System) – System to export

  • embeddable (bool, optional) – Is the HTML to be embedded in an existing page? Default: False