cosapp.tools.views.d3js

Build a D3js view of a System.

Functions

d3_html(system[, embeddable])

Return D3.JS HTML content of system.

to_d3(system[, show, size])

Return the representation of this system in HTML format.

Classes

D3JsRenderer(system[, embeddable])

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

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

Bases: BaseRenderer

Utility class to export a system as HTML using D3.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 self.system into a dictionary with 4 keys: name, full_name, children and size.

  • name key is a string with the system name.

  • full_name key is a string with Module contextual name.

  • children key is a list containing dictionaries of same format for children system .

  • size key is the display size of system in D3 plot.

Returns:

Dictionary containing elements to draw the System using D3JS library

Return type:

Dict

classmethod get_globals()[source]

Returns a dict containing class-wide environment and HTML data

static get_level(syst) int[source]

Return the number of child levels of input system

html_content() str[source]

Return D3 HTML content of renderer’s system as a character string.

Return type:

str

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

Return a dictionary of three keys.

  • d3_js key holds the content of D3.js library.

  • draw_js key holds the content of the draw function implemented in d3_draw.js.

  • d3_styles key holds the css style of D3 plot.

Returns:

The necessary resources to render Jinja template

Return type:

Dict[str, Dict]

classmethod html_template() Template[source]

Return the Jinja template used to create HTML file.

Return type:

Template

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

Return D3.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

cosapp.tools.views.d3js.to_d3(system: System, show=True, size=435) None[source]

Return the representation of this system in HTML format.

Returns:

HTML formatted representation

Return type:

str