Tags are metadata that can be added to Squiggle variables. They are used to add additional information to variables, such as names, descriptions, and visualization options. While tags can be accessed at runtime, they are primarily meant for use with the Squiggle Playground and other visualizations.
Tags can be added to variables either by using their name
Tag.get[Name] or by using decorators.
|Change the default display name for the variable, in the playground.
|Adds documentation to the variable in the playground.
|Change the default view for the value when displayed.
|Format a number, date, or duration when displayed.
|Formats lists as notebooks.
|Don't show the variable in the playground
Adds a user-facing name to a value. This is useful for documenting what a value represents, or how it was calculated.
Note: While names are shown in the sidebar, you still need to call variables by their regular variable names in code.
Adds text documentation to a value. This is useful for documenting what a value represents or how it was calculated.
Overrides the default visualization for a value.
showAs() can take either a visualization, or a function that calls the value and returns a visualization.
Different types of values can be displayed in different ways. The following table shows the potential visualization types for each input type. In this table,
Number can be used with Dates and Durations as well.
(Number -> Number) Function
(Number -> Dist) Function
Set the display format for a number, distribution, duration, or date. Uses the d3-format (opens in a new tab) syntax on numbers and distributions, and the d3-time-format (opens in a new tab) syntax for dates.
Hides a value when displayed under Variables. This is useful for hiding intermediate values or helper functions that are used in calculations, but are not directly relevant to the user. Only hides top-level variables.
When the value is first displayed, it will begin open in the viewer. Refresh the page to reset.
When the value is first displayed, it will begin collapsed in the viewer. Refresh the page to reset.
Returns the startOpenState of a value, which can be "open", "closed", or "" if no startOpenState is set. Set using
Displays the list of values as a notebook. This means that element indices are hidden, and the values are displayed in a vertical list. Useful for displaying combinations of text and values.
Saves the location of a value. Note that this must be called at the point where the location is to be saved. If you use it in a helper function, it will save the location of the helper function, not the location where the helper function is called.
Returns a dictionary of all tags on a value.
Returns a copy of the value with the specified tags removed.
Returns a copy of the value with all tags removed.