Dashboards, slicing
Slicing defines multiple dashboard variants and lets the user pick which one is shown. This page focuses on the language mechanics behind slices and how they affect tiles.
Table of contents
Slices are defined once per script
Slicing starts by creating a dedicated Slices table with slice by. The table is upstream of the
data it slices, and the definition can appear only once in a script. The title: option sets the name
shown in the slice selector.
table Products[pid] = with
[| as pid, as Name, as Price |]
[| "P-01", "Widget", 12.0 |]
[| "P-02", "Gizmo", 18.0 |]
table Slices[slice] = slice by pid title: Products.Name
show table "Selected product" sliced with
Products.Name
Products.Price { unit: "$" }
show scalar "All products" with count(Products.*)
The sliced annotation partitions tile data
Tiles marked sliced have separate data for each slice. These variants are computed during the run;
changing the selection displays an already computed variant. Tiles without the annotation keep
their global data, although StyleCode can still vary their appearance per slice.
The annotation takes no argument. Envision uses the slice dimension of the tile’s data table.
The source table of slice by receives that dimension automatically. Other tables may need an
explicit assignment such as Orders.slice = Products.slice. For a sliced linechart, the grouping
expression must also come from a table carrying slice. See slices
for complete examples.
The slice dimension can also be the primary dimension of Slices itself,
or part of a cross table such as cross(Slices, Month). A product-by-month
cross table can keep all months visible while showing only the selected
product.
Slice selectors are tiles too
The selector UI is part of the dashboard. Use slicepicker for a drop-down or slicetree for a hierarchy. These tiles make the slice context visible next to the data it controls.
table Products[pid] = with
[| as pid, as Category, as Name, as Price |]
[| "P-01", "Hardware", "Widget", 12.0 |]
[| "P-02", "Hardware", "Gizmo", 18.0 |]
[| "P-03", "Accessories", "Case", 6.0 |]
[| "P-04", "Accessories", "Cable", 4.0 |]
table Slices[slice] = slice by pid title: Products.Name subtitle: Products.Category
show slicetree "Products" a1b6 with
slice
show table "Selected product" c1f6 sliced with
Products.Name
Products.Category
Products.Price { unit: "$" }