Layout
Deephaven provides many options to adjust table layout using the Layout Hints class.
Locking column order
Designated columns in Deephaven tables can be "locked" in place at the start or the end of the column order. This enables the query author to ensure a consistent experience for all authorized users of that table. This feature uses the .layoutHints
method.
Locking columns in starting or ending order in a table is accomplished in the query language by importing the LayoutHintBuilder
class and then setting one or more of the following three parameters:
atFront()
– This method locks one or more columns to the beginning of the table. Column names are used as the argument(s).atEnd()
– This method locks one or more columns to the end of the table. Column names are used as the argument(s).savedLayouts()
– This parameter impacts users with whom this table is shared. When set totrue
, other users can rearrange the non-locked columns and then save their own layout for the specified table. When set tofalse
, other users can rearrange the non-locked columns, but they cannot save the new column order. When the table is opened again, the column order will revert to the default order specified by the query author.
For example, the following query locks some of the table's columns:
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t=db.t("LearnDeephaven", "StockQuotes").where("Date=`2017-08-25`")
t2=t.update().layoutHints(LayoutHintBuilder
.get()
.atFront("USym","Timestamp")
.atEnd("Sym", "SecurityType")
.savedLayouts(false)
)
importjava("com.illumon.iris.db.tables.utils.LayoutHintBuilder")
t=db.t("LearnDeephaven", "StockQuotes").where("Date=`2017-08-25`")
t2=t.update(java_array("java.lang.String", [])).layoutHints(LayoutHintBuilder.get().atFront("USym","Timestamp").atEnd("Sym", "SecurityType").savedLayouts(False))
The query first imports the LayoutHintBuilder
class, accesses the source data, then uses the get()
method to create a new instance of the LayoutHintBuilder
that:
- locks the USym and Timestamp columns to the front of the table,
- locks the Sym and SecurityType to the end of the table,
- and specifies that no changes to the layout can be saved by authorized users upon closing and reopening the table.
A select
, update
, updateView
, or where
operation must be included before the .layoutHints()
operation in the query to ensure the changes are made only to the new t2
table. This enables Deephaven to create the t2
table as an individual object before continuing to the next method.
Hiding columns
When a table is open in Deephaven, columns can be manually hidden using Hide Column in the right-click column header menu. However, columns can be hidden from view by default, ensuring they are hidden for all users who access that table. This feature uses the .layoutHints
and .hide
methods.
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t1=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`")
.layoutHints(LayoutHintBuilder.get().hide("USym","SecurityType","Source"))
from deephaven import *
t1=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`") \
.layoutHints(LayoutHintBuilder.get().hide("USym","SecurityType","Source"))
- They can be unhidden via the Choose Columns option in the right-click column menu.
- Selecting Reset Columns will hide them again.
Freezing columns
Designated columns in Deephaven tables can be "frozen" in place on the left side of the table, and will remain in view even when horizontally scrolling through the table. Similar to the "freeze panes" option in spreadsheet software, this feature enables users to keep key columns in view as they read table data.
Deephaven offers two ways to accomplish this: by creating a new LayoutHintsBuilder
and using the freeze()
method in a query, or through the Deephaven console.
Note
See: Freeze Columns
import com.illumon.iris.db.tables.utils.LayoutHintBuilder
t=db.t("LearnDeephaven", "StockTrades").where("Date=`2017-08-21`")
.layoutHints(LayoutHintBuilder
.get()
.freeze("USym","Exchange")
)
LayoutHintBuilder = jpy.get_type("com.illumon.iris.db.tables.utils.LayoutHintBuilder")
t=db.t("LearnDeephaven", "StockTrades")\
.where("Date=`2017-08-21`")\
.layoutHints(LayoutHintBuilder\
.get()\
.freeze("USym","Exchange"))
The horizontal scrollbar at the bottom of the table begins at the Date column because the USym and Exchange columns are frozen in place and always stay in view.
The frozen columns can be dragged and moved within their space to the left of the table.
Note
To unfreeze a column in Deephaven Classic, right-click the column header and select Unfreeze Column from the drop-down list:
This layout hint is compatible with other layout hints, such as Saved Layouts. The following behaviors should be noted when freezing columns via a query:
- If a column is locked and also frozen by the query language, it cannot be unfrozen by using the right-click method in the GUI. If an unfrozen column is locked using the query language, it cannot be frozen in the GUI.
- Frozen columns are saved to the workspace and reloaded. If a user specifies columns to freeze via a query and then modifies those columns in the UI, the workspace will load the latest changes rather than what is in the query.
- Frozen columns can be hidden and restored just like any other column. The Reset Columns option will restore frozen columns to the original state defined in the query.
Warning
Freezing columns is not currently supported on Tree Tables.