dash

dash, keyword

The dash keyword marks assignments evaluated during the interactive phase. Dash variables exist only in the browser, and are recomputed when the user changes inputs.

Example

read upload "values" as Submitted with
  Id : text
  Value : number

table T[id] = with
  [| as id, as Min, as Max |]
  [| "A", 1, 5 |]
  [| "B", 0, 10 |]

mutable T.Value = single(Submitted.Value) by Submitted.Id at T.id default 0

dash T.IsValid = T.Min <= T.Value and T.Value <= T.Max
dash T.Color = if T.IsValid then "default" else "red"

show table "Values" editable: "values" with
  T.id { columnReadOnly: true }
  T.Value mutable { cellBackground: #[T.Color] }
  T.Min { columnReadOnly: true }
  T.Max { columnReadOnly: true }

Dash-sized tables

A vector-valued dash expression can broadcast from one table to another when the source and destination tables are declared as dash-sized. Put dash and a maximum size after the table name:

read upload "values" as T dash 5k with
  Label : text
  Count : number
  Enabled : boolean

table Details dash 5k = extend.range(T.Count)

mutable T.IsEnabled = T.Enabled
dash Details.Color = if T.IsEnabled then "green" else "red"

show table "Details" with
  Details.N { cellBackground: #[Details.Color] }
  T.Label

The maximum size of a dash-sized table is 5,000 lines. Declaring dash without a compatible maximum fails when the inferred table maximum is larger. Scalar dash values can broadcast to a dash-sized table without a dash-sized source table.

The in operator can check a mutable value against all values in a dash-sized table. For example, dash Items.IsValid = Items.Value in ValidValues.Value updates the check when the user edits Items.Value. The result can drive conditional cell styling, as in the example above.

The right-hand table must fit within the 5,000-line limit so that the full set is available in the browser. Declare it with dash 5k, or use a table whose inferred maximum already satisfies that limit, such as a short comprehension. This interactive form compares individual values, not tuples.

Remarks

Dash expressions can use number, boolean, text, date, week, month, markdown, any enum, and tuples of those types. They support comparisons, arithmetic, boolean logic, if then else, match, in, interpolation, broadcasting, and pure functions marked as dash.

A dash assignment cannot depend on itself, directly or indirectly. This also applies when the expression is evaluated over slices.

Dash variables are rejected in non-dash contexts such as write, where, and non-dash assignments, except for system-defined tiny tables.

Dash expressions can be displayed by browser-evaluated tiles such as gauge. Tiles that still use server-side matrix evaluation reject dash expressions in their with columns. The current rejecting tile types are assert, histogram, menu, plot, scatter, slicepicker, slicetree, treemap, and upload.

When a tile rejects such an expression, compilation fails with a message of the form:

'dash' expressions are not supported as columns in 'show upload'.
User Contributed Notes
0 notes + add a note