Class: Renderer

Renderer

The Renderer class is designed to provide generic rendering capabilities that can be reused across applications. This base class stores functionality that is common across all renderer implementations, mainly the execution of the 'hook' function to give access to the generated DOM elements to provide application specific behavior.
Typically each unique component generated from a renderer will be under a separate specification attribute. For example the text elements of the TextByFrequencyRenderer is under 'text' and the frequency distribution elements are under 'frequency'.
Each of the separate components SHOULD accept *Key attributes to instruct it as to where the relevant data should be found in the tile data object. Each of these separate components SHOULD accept isolated RenderThemes (in the case that RenderThemes are used).

new Renderer(spec)

Instantiate a Renderer object.
Name Type Description
spec Object The specification object.
{
    hook {Function} - The hook function that is executed on every rendered entry providing the following arguments:
        elem    {HTMLElement} - The html element for the entry.
        entry   {Object}      - The data entry.
        entries {Array}       - All entries for the tile.
        data    {Object}      - The raw data object for the tile.
}

Methods

Add a hook function to the renderer.
Name Type Description
hook function the callback function.
Remove a hook function from the renderer.
Name Type Description
hook function the callback function.

select(selectedEntry)

Select all entries in the rendered layer that also share the same selected value. The 'selectKey' of the 'select' option must be set.
Name Type Description
selectedEntry Object The selected data entry.
Unselect all entries in the rendered layer.