Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Canvas][Docs] Updates Canvas function reference #37614

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 127 additions & 27 deletions docs/canvas/canvas-client-functions.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,171 @@ or interact with the workpad to read filters.

A *** denotes a required argument.

A *†* denotes an argument can be passed multiple times.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

[float]
=== asset
[[asset_fn]]
=== `asset`

Uses Canvas workpad asset objects to provide argument values. Usually images.

*Accepts:* null
*Accepts:* `null`

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_*
|string
|_Unnamed_ ***
|`string`
|The ID of the asset value to return
|===

*Returns:* string
*Returns:* `string`


[float]
=== browser
[[filters_fn]]
=== `filters`

Forces the interpreter to return to the browser.
Collects element filters on the workpad, usually to provide them to a data source.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* Anything or nothing
*Accepts:* `null`

*Returns:* Depends on your input and arguments
*Returns:* `filter`

[float]
=== filters
[[location_fn]]
=== `location`

Collects element filters on the workpad, usually to provide them to a data source.
Uses the browser's location functionality to get your current location. Usually
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved
quite slow, but fairly accurate.

*Accepts:* null
*Accepts:* `null`

*Returns:* filter
*Returns:* `datatable`

[float]
=== location
[[markdown_fn]]
=== `markdown`

Uses the browser's location functionality to get your current location. Usually
quite slow, but fairly accurate.
Adds an element for rendering Markdown text. Great for single numbers, metrics, or paragraphs of text.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `datatable`, `null`

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_ *†*

*Accepts:* null
Alias: `expression`, `content`
|`string`
|A `string` containing Markdown. You can pass this multiple
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved
times to achieve concatenation

*Returns:* datatable
Default: `""`

|`font`
|`style`
|Font settings. Technically, you can put other styles in here too
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `{<<font_fn>>}`
|===

*Returns:* `render`

[float]
=== urlparam
[[timelion_fn]]
=== `timelion`

Accesses URL parameters and use them in expressions. This will always return a string.
Uses Timelion to extract one or more time series from many sources.

*Accepts:* null
*Accepts:* `filter`

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_* (Aliases: `var`, `variable`)
|string
|_Unnamed_

Aliases: `q`, `query`
|`string`
|A Timelion query

Default: `".es(*)"`

|`interval`
|`string`
|Bucket interval for the time series
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `"auto"`

|`from`
|`string`
|{es} `datemath` string for the start of the time range
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `"now-1y"`

|`to`
|`string`
|{es} date math `string` for the end of the time range
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `"now"`

|`timezone`
|`string`
|Time zone for the time range
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `"UTC"`
|===

*Returns:* `datatable`

[float]
[[to_fn]]
=== `to`

Explicitly casts from one type to another.

*Accepts:* `any`

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_ ***

Alias: `type`
|`string`
|A known type
|===

*Returns:* Depends on your input and arguments

[float]
[[urlparam_fn]]
=== `urlparam`

Accesses URL parameters and use them in expressions. This will always return a `string`.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `null`

[cols="3*^<"]
|===
|Argument |Type |Description

|_Unnamed_ ***

Aliases: `var`, `variable`
|`string`
|The URL hash parameter to access

|default
|string
|Return this string if the url parameter is not defined (default: `""`)
|`default`
|`string`
|Return this `string` if the url parameter is not defined
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `""`
|===

*Returns:* string
*Returns:* `string`

Loading