Linking Plots

Linked Views is a feature in Deephaven that enables a user to interactively filter the content in one Deephaven table or plot based on the content selected in another Deephaven table.

To use Linked Views among tables or plots in the Deephaven console, the objects must first be "associated" to each other. One table is the source table and the other table is the target table or plot. When linking tables, a filter is applied to define the column in each table that should be linked. When a row in the source table is double clicked, the respective columns in the target table are filtered according to the filter parameters assigned during the linking process. Similarly, when a plot becomes the target of a link, the plot will instantly rechart its data according to the row clicked in the source table.

See also: Linking Tables

Any OneClick dataset can be linked to a table in the Deephaven Console. In addition to being able to pair the plot with a OneClick panel, a OneClick plot can act as the "target table" in a Linked Views pair.

See also: OneClick Plotting

The syntax for a OneClick dataset follows:

oneClick(source, "ColName1", "ColName2", …)

  • source is the table containing the data to be charted.
  • Additional arguments represent the name(s) of each column (as a string) to be available for filtering, either by a OneClick panel, or using the Linked View Filter Editor.

Once both the source and target objects are open in your workspace, Linked Views can be initiated using the right-click table data menu. They can be in different panels or in multiple tabbed panel sets, but they must be open and available in the console.

Note: The examples shown below use data from the LearnDeephaven namespace. The following query can be used to recreate these tables in your own console:

from deephaven import *

StockTrades=db.t("LearnDeephaven", "StockTrades") \
    .where("Date=`2017-08-21`")
toc = plt.oneClick(StockTrades, "USym")

RetailPlot = plt.plot("USym", toc, "Timestamp", "Last").show()
StockTrades=db.t("LearnDeephaven", "StockTrades")
        .where("Date=`2017-08-21`")
toc = oneClick(StockTrades, "USym")
RetailPlot = plot("USym", toc, "Timestamp", "Last").show()

The first line of the query is the source of the data for the chart. The second line of the query applies the oneClick method to the table StockTrades and specifies the column USym should be enabled for OneClick filtering. The query saves the OneClick SelectableDataSet to the variable toc. However, toc is not visible in the Deephaven console. The third line of the query creates a plot using data from the variable toc. Data in the Timestamp column is used for the X values and data from the Last column is used for the Y values. The plot will open with a prompt to apply a filter on the USym column.

To initiate the linking process, right-click anywhere within the body of the table or plot. The drop-down menu on the source table presents options for Make Link To... and Make Link From..., as shown below:

When the Make Link To... option is selected, the table initially selected (in this case, the StockTrades table on the bottom) becomes the "source" table and the cursor will change to a link icon with a down arrow .

Click anywhere within the plot to designate it as the "target table" (in this case, RetailPlot at the top of the Deephaven console window functions as the target table). The Linked View Filter Editor will open as shown below. The background colors of the table and plot's tabs will change to signify the source and the target.

The drop-down menu on the target plot will only present the option to Make Link From.... Plots can only function as a target "table."

When the Make Link From... option is selected, the plot becomes the "target" table, and the cursor changes to a link icon with an up arrow.  However, the same Filter Editor opens after clicking the "source" table.

As with linking tables, it is possible to possible to link one target plot to multiple source tables. However, you can only apply one filter from one source at a time. 

Adding Filter Parameters

Once both the source and target are selected, the Filter Editor window is used to assign the columns that should be linked and how they should be filtered.

Click the + button located at the bottom left corner of the window to create a new filter. A new row will be added to the panel. 

When linking plots, the only Target Column(s) available are those specified in the query.  In this example, the USym column automatically becomes the Target Column and no other options are available.  The Operation will be "equals" by default: this cannot be changed, as linking plots only supports equals. Double-click Source Column to see a list of the columns in the source table.

Note: The Filter Editor allows you to choose any column, however, you must choose a meaningful value or the filter operation will throw an error or result in a blank plot. You can also add multiple source columns, but the plot will load as blank unless the columns have duplicate data.

Functional parameters are shown below.

The following matching features may be turned on or off using the Attempt to Match Columns checkbox in the Linked View Filter Editor:

  • Link Column Matching - When you create a new link, the dialog will attempt to set the pull down menus so that the Source column is the same as the first match in the Target columns. If no match is found, they default to the first value of each.
  • Match Source Column to Target Column/Match Target Column to Source Column - When you change the Source or Target column, the dialog will attempt to set the corresponding column to match. In other words, if the Source is set to USym, the Target column will automatically change to USym, and vice versa. If no match is found, it is left alone.

Your on/off selection is saved in the workspace, and all dialogs that open in a new Deephaven session with remain in the last used state.

The Autopopulate Links button will populate the Linked View Filter Editor with matching sets of source and target columns, as shown below:

Once you have added all your filter conditions, complete the linking process by clicking OK. The objects are now linked according to those parameters.

Filtering the Target Plot

When a row in the source table is double-clicked, the target plot is filtered based on the parameters specified and the value(s) in the row of the source table that was double-clicked.

For example, in the screenshot below, the highlighted row in the StockTrades (source) table contains AAPL as the USym value. The plot immediately charts the data, and will be the same when any row with AAPL is clicked.

Clicking a row where the USym contains MSFT, for example, produces a new chart:

The tab for the target, RetailPlot, includes the link icon with an up arrow, while the tab for the source, StockTrades, includes the link icon with a down arrow.

Edit or Remove Links

When a table is linked to a plot, right-clicking in the source table presents two additional options in the context menu: Remove All Links and Edit Links....

Selecting Remove All Links removes all links between the source and target objects. Removing the links will not alter the current plot. Closing either the table or plot in the console also automatically removes any links.

Selecting Edit Links... opens a dialog window that presents the filter parameters associated with the object selected. Filter parameters can be changed, added or deleted, although as explained above only certain parameters will meaningfully filter the plot.

Selecting the Replace Filters on Link Update checkbox will clear all existing filters on Link Targets before applying applying filters from a link update. For example, let's say you have two sources linked to one target, and each source has different filter parameters configured. Filters from a previous link event from Source 1 would be cleared from the target before applying filters from a link event from Source 2.

Saving Linked Views

Saving linked views in your workspace is possible only if the source table and target table/plot are generated from a persistent query. Once you have established your links and set the filter parameters, click Save at the top of Deephaven console.

Linked views generated from persistent queries will remain linked and will reestablish themselves if queries are restarted for any reason or after closing and reopening Deephaven.


Last Updated: 16 February 2021 18:07 -04:00 UTC    Deephaven v.1.20200928  (See other versions)

Deephaven Documentation     Copyright 2016-2020  Deephaven Data Labs, LLC     All Rights Reserved