Using the Inter Panel Blackboard

s-Dashboard has a simple messaging system, known as the blackboard, for panels to communicate with each other implemented as a blackboard containing JSON messages. You can use the Blackboard to change the output for a panel by modifying that panel’s query template.

Panels Sending Messages to Blackboard

Two panel types are currently enabled to send messages to the blackboard.

Panel Preference Field for Blackboard User Event Result
Geographical Streams > World EventsGeographical Streams > Pan & Zoom Event Clicks To Clicks on event circle Sends name of event and other information.
Table Sent To Clicks on cell Sends value of the cell, along with the row and column in the table.
Clicks on button Custom

Each blackboard message includes a property channel* containing a string used to control individual panels. If it’s filled in, it’s the channel string that this panel should listen to. Any message posted to the blackboad with a channel property equal to, in this case, “table_selection”, will cause the panel to be refreshed. You can use the other properties of the blackboard message to modify the SELECT statement.

Sample Process

The following steps walk you through using the Inter Panel Blackboard to modify the SELECT statement for a panel.

  • Begin by creating a dashboard with three panels in a horizontal layout frame. See the topic - Creating Dashboard Layouts* in this guide for more details on setting up layouts.
  • In the leftmost panel, for input select SALES.AGGT0 and for panel type select Table. In the panel preferences, set *Maximum Rows *to 100. From that panel’s menu, select Reopen Input to re-read the table. You should have 1 column with 20 rows.
  • In the middle panel, for input select SALES.AGGT0 and for panel type select Table. From that panel’s menu, select Reopen Input to re-read the table. You should have several columns and 25 rows.
  • In the rightmost panel, for panel select System > Blackboard. You do not need to select an input for this panel. This will display messages being posted to the blackboard.
  • Change the layout to “Horizontal, leftmost is 10%”.

You should have something that looks like this, except that your blackboard panel will be empty:

  • In the single-column panel on the left, set the panel preference Send To to table_selection. Now when you click on cells in the table you should see messages in the blackboard panel.

Modifying a Panel’s Query Template Using a Blackboard

You can use the Blackboard to change the output for a panel by modifying that panel’s query template. In Input Preferences, each s-Dashboard panel has a field with that lets you modify a SELECT query for the panel. By default, the query selects all the columns from the input (the panel also lets you choose whether or not to include ROWTIME). See the topic Customizing the SELECT template for more details on this field. The SELECT query uses the Underscore.js template function documented at https://underscorejs.org/#template. You can use <%= … %> to insert the result of a JavaScript expression and <% … %> to execute arbitrary JavaScript (with the function print() available to add text to the result of the template).

There are a number of variables available for use in the template, as documented at Customizing the SELECT template.

The base query (an empty template is as follows:

SELECT <%= selection %> FROM <%= from %>

<%= selection %> can contain “ * ”, “STREAM ROWTIME,"" or a similar statement given the type of the input and the input preferences, while <%= from %> should contain the fully qualified name of the input stream or table.

In order to make use of a blackboard message, you need to append a WHERE clause to this base query, using the msg variable.

You incorporate the blackboard message using the variable msg. This variable contains the blackboard message posted to the channel the panel is listening to. In order to make sure you only output the WHERE clause if there is a message from the Blackboard, you also need to include JavaScript along the following lines:

<% if (msg) print('where "N" >= ' + msg.value); %>

The resulting clause will be *WHERE “N” >= Go to the Input Preferences for the middle panel (SALES.AGGT1) and paste in the following code as one line:

SELECT <%= selection %> FROM <%= from %> <% if (msg) print('where "N" >= ' + msg.value); %>

Set Listen To to table_selection.

Clicking on cells in the left table should now control which rows are shown in the middle panel. This is a simple mechanism with a lot of possibilities. For more information on how to customize the SELECT statement, please contact SQLstream support.

Monitoring Blackboard with System Panels

There are two system panels that let you monitor the blackboard: The SYSTEM > Blackboard panel shows a log of blackboard activity. The SYSTEM > Button Panel lets you test posting to the blackboard.