JavaScript Editor

Executes JavaScript code to generate a view. The code in the script editor is executed when displayed in the view (right-click -> Interactive View) or in the KNIME server web portal.

Within the java script code block you have access to the input table and can use a set of predefined libraries to generate the view.

Note, this node is currently under development. Future versions of the node will have more functionality, including the ability to define and use templates and to generate a static view/image output.

Options

Flow Variables

The list contains the flow variables that are currently available at the node input. Double clicking any of the entries will insert the respective identifier at the current cursor position in the JavaScript editor.

Dependencies

Choose from the list of available JavaScript library dependencies. Any entries selected here are available at runtime of the view. Note that this list will be expanded in the future.

CSS

Enter optional CSS instructions for styling the view.

Example

Change the standard font used for rendering for the whole document:

html, body {font-family: sans-serif;}
JavaScript

Enter the JavaScript code to be executed. All HTML elements have to be created in the JavaScript and appended to the <body> element.

If data is available at the input port, a JavaScript object knimeDataTable is automatically created and populated.
The methods available on this object are:

  • knimeDataTable.getNumRows(); Retrieve the amount of rows contained in the table.
  • knimeDataTable.getNumColumns(); Retrieve the amount of columns contained in the table.
  • knimeDataTable.getColumnNames(); Retrieve the column names in a string array.
  • knimeDataTable.getColumnTypes(); Retrieve the converted JavaScript column types in a string array. These can be Boolean, Number, String, SVG, PNG or Undefined.
  • knimeDataTable.getPossibleValues(); Retrieve an array with possible values from the data table spec.
  • knimeDataTable.getRowColors(); Retrieve a string array with CSS-style color information for each row.
  • knimeDataTable.getRows(); Retrieve an array comprising all rows of the data table.
  • knimeDataTable.getColumn(columnID); Retrieve an array of all values contained in the column with the given ID. Note that this operation can be computationally expensive as data is stored per row and has to be converted.

Example

Loop over all values contained in the table object and process only number types:

var rows = knimeDataTable.getRows();
for (var rowID = 0; rowID < knimeDataTable.getNumRows(); rowID++) {
    var row = rows[rowID];
    for (var colID = 0; colID < knimeDataTable.getNumColumns(); colID++) {
        if (knimeDataTable.getColumnTypes()[colID] === 'number') {
            var value = row.data[colID];
            // process value
        }
    }
}

Input Ports

Icon
No description for this port available.

Output Ports

Icon
No description for this port available.

Popular Predecessors

Popular Successors

  • No recommendations found

Views

Interactive View: Javascript editor

Workflows

  • No workflows found

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.