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] Updates function reference docs #64741

Merged
merged 3 commits into from
May 4, 2020
Merged
Changes from 1 commit
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
273 changes: 257 additions & 16 deletions docs/canvas/canvas-function-reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ filters
| metric "Average uptime"
metricFont={
font size=48 family="'Open Sans', Helvetica, Arial, sans-serif"
color={
if {all {gte 0} {lt 0.8}} then="red" else="green"
}
align="center" lHeight=48
color={
if {all {gte 0} {lt 0.8}} then="red" else="green"
}
align="center" lHeight=48
}
| render
----
Expand Down Expand Up @@ -184,7 +184,7 @@ filters
----
`as` casts any primitive value (`string`, `number`, `date`, `null`) into a `datatable` with a single row and a single column with the given name (or defaults to `"value"` if no name is provided). This is useful when piping a primitive value into a function that only takes `datatable` as an input.

In the example, `ply` expects each `fn` subexpression to return a `datatable` in order to merge the results of each `fn` back into a `datatable`, but using a `math` aggregation in the subexpressions returns a single `math` value, which is then cast into a `datatable` using `as`.
In the example above, `ply` expects each `fn` subexpression to return a `datatable` in order to merge the results of each `fn` back into a `datatable`, but using a `math` aggregation in the subexpressions returns a single `math` value, which is then cast into a `datatable` using `as`.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `string`, `boolean`, `number`, `null`

Expand Down Expand Up @@ -324,12 +324,14 @@ case if={lte 50} then="green"
----
math "random()"
| progress shape="gauge" label={formatnumber "0%"}
font={font size=24 family="'Open Sans', Helvetica, Arial, sans-serif" align="center"
color={
switch {case if={lte 0.5} then="green"}
{case if={all {gt 0.5} {lte 0.75}} then="orange"}
default="red"
}}
font={
font size=24 family="'Open Sans', Helvetica, Arial, sans-serif" align="center"
color={
switch {case if={lte 0.5} then="green"}
{case if={all {gt 0.5} {lte 0.75}} then="orange"}
default="red"
}
}
valueColor={
switch {case if={lte 0.5} then="green"}
{case if={all {gt 0.5} {lte 0.75}} then="orange"}
Expand Down Expand Up @@ -693,7 +695,25 @@ Alias: `value`
[[demodata_fn]]
=== `demodata`

A mock data set that includes project CI times with usernames, countries, and run phases.
A sample data set that includes project CI times with usernames, countries, and run phases.

*Expression syntax*
[source,js]
----
demodata
demodata "ci"
demodata type="shirts"
----

*Code example*
[source,text]
----
filters
| demodata
| table
| render
----
`demodata` is a mock data set that you can use to start playing around in Canvas.

*Accepts:* `filter`

Expand Down Expand Up @@ -837,6 +857,28 @@ Alias: `value`

Query Elasticsearch for the number of hits matching the specified query.

*Expression syntax*
[source,js]
----
escount index="logstash-*"
escount "currency:"EUR"" index="kibana_sample_data_ecommerce"
escount query="response:404" index="kibana_sample_data_logs"
----

*Code example*
[source,text]
----
filters
| escount "Cancelled:true" index="kibana_sample_data_flights"
| math "value"
| progress shape="semicircle"
label={formatnumber 0,0}
font={font size=24 family="'Open Sans', Helvetica, Arial, sans-serif" color="#000000" align=center}
max={filters | escount index="kibana_sample_data_flights"}
| render
----
The first `escount` expression retrieves the number of flights that were cancelled. The second `escount` expression retrieves the total number of flights.

*Accepts:* `filter`

[cols="3*^<"]
Expand Down Expand Up @@ -867,6 +909,34 @@ Default: `_all`

Query Elasticsearch for raw documents. Specify the fields you want to retrieve, especially if you are asking for a lot of rows.

*Expression syntax*
[source,js]
----
esdocs index="logstash-*"
esdocs "currency:"EUR"" index="kibana_sample_data_ecommerce"
esdocs query="response:404" index="kibana_sample_data_logs"
esdocs index="kibana_sample_data_flights" count=100
esdocs index="kibana_sample_data_flights" sort="AvgTicketPrice, asc"
----

*Code example*
[source,text]
----
filters
| esdocs index="kibana_sample_data_ecommerce"
fields="customer_gender, taxful_total_price, order_date"
sort="order_date, asc"
count=10000
| mapColumn "order_date"
fn={getCell "order_date" | date {context} | rounddate "YYYY-MM-DD"}
| alterColumn "order_date" type="date"
| pointseries x="order_date" y="sum(taxful_total_price)" color="customer_gender"
| plot defaultStyle={seriesStyle lines=3}
palette={palette "#7ECAE3" "#003A4D" gradient=true}
| render
----
This retrieves the first 10000 documents data from the `kibana_sample_data_ecommerce` index sorted by `order_date` in ascending order and only requests the `customer_gender`, `taxful_total_price`, and `order_date` fields.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `filter`

[cols="3*^<"]
Expand Down Expand Up @@ -915,6 +985,23 @@ Default: `_all`

Queries Elasticsearch using Elasticsearch SQL.

*Expression syntax*
[source,js]
----
essql query="SELECT * FROM "logstash*""
essql "SELECT * FROM "apm*"" count=10000
----

*Code example*
[source,text]
----
filters
| essql query="SELECT Carrier, FlightDelayMin, AvgTicketPrice FROM "kibana_sample_data_flights""
| table
| render
----
This retrieves the `Carrier`, `FlightDelayMin`, and `AvgTicketPrice` fields from the "kibana_sample_data_flights" index.

*Accepts:* `filter`

[cols="3*^<"]
Expand Down Expand Up @@ -1107,7 +1194,7 @@ Default: `false`
[[font_fn]]
=== `font`

Creates a font style.
Create a font style.

*Expression syntax*
[source,js]
Expand Down Expand Up @@ -1244,7 +1331,7 @@ Alias: `format`
[[formatnumber_fn]]
=== `formatnumber`

Formats a number into a formatted number string using the <<numeral, numeral pattern syntax>>.
Formats a number into a formatted number string using Numeral pattern.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Expression syntax*
[source,js]
Expand Down Expand Up @@ -1276,7 +1363,7 @@ The `formatnumber` subexpression receives the same `context` as the `progress` f

Alias: `format`
|`string`
|A <<numeral, numeral pattern>> string. For example, `"0.0a"` or `"0%"`.
|A Numeral pattern format string. For example, `"0.0a"` or `"0%"`.
|===

*Returns:* `string`
Expand Down Expand Up @@ -1559,6 +1646,34 @@ Alias: `value`
[[m_fns]]
== M

[float]
[[mapCenter_fn]]
=== `mapCenter`

Returns an object with the center coordinates and zoom level of the map
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `null`

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

|`lat` ***
|`number`
|Latitude for the center of the map

|`lon` ***
|`number`
|Longitude for the center of the map

|`zoom` ***
|`number`
|The zoom level of the map
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved
|===

*Returns:* `mapCenter`


[float]
[[mapColumn_fn]]
=== `mapColumn`
Expand Down Expand Up @@ -1612,6 +1727,12 @@ Default: `""`
|The CSS font properties for the content. For example, "font-family" or "font-weight".

Default: `${font}`

|`openLinksInNewTab`
|`boolean`
|A true/false value for opening links in a new tab. Default value is false. Setting to true will open all links in a new tab.
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

Default: `false`
|===

*Returns:* `render`
Expand Down Expand Up @@ -1675,7 +1796,7 @@ Default: `${font size=48 family="'Open Sans', Helvetica, Arial, sans-serif" colo

Alias: `format`
|`string`
|A <<numeral, numeral pattern>> string. For example, `"0.0a"` or `"0%"`.
|A Numeral pattern format string. For example, `"0.0a"` or `"0%"`.
|===

*Returns:* `render`
Expand Down Expand Up @@ -2184,6 +2305,102 @@ Returns the number of rows. Pairs with <<ply_fn>> to get the count of unique col
[[s_fns]]
== S

[float]
[[savedLens_fn]]
=== `savedLens`

Returns an embeddable for a saved lens object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `any`

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

|`id`
|`string`
|The ID of the Saved Lens Object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

|`timerange`
|`timerange`
|The timerange of data that should be included

|`title`
|`string`
|The title for the lens emebeddable
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved
|===

*Returns:* `embeddable`


[float]
[[savedMap_fn]]
=== `savedMap`

Returns an embeddable for a saved map object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `any`

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

|`center`
|`mapCenter`
|The center and zoom level the map should have

|`hideLayer` †
|`string`
|The IDs of map layers that should be hidden

|`id`
|`string`
|The ID of the Saved Map Object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

|`timerange`
|`timerange`
|The timerange of data that should be included

|`title`
|`string`
|The title for the map
|===

*Returns:* `embeddable`


[float]
[[savedVisualization_fn]]
=== `savedVisualization`

Returns an embeddable for a saved visualization object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `any`

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

|`colors` †
|`seriesStyle`
|Define the color to use for a specific series
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

|`hideLegend`
|`boolean`
|Should the legend be hidden
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

|`id`
|`string`
|The ID of the Saved Visualization Object
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

|`timerange`
|`timerange`
|The timerange of data that should be included
|===

*Returns:* `embeddable`


[float]
[[seriesStyle_fn]]
=== `seriesStyle`
Expand Down Expand Up @@ -2579,6 +2796,30 @@ Default: `"now"`
*Returns:* `datatable`


[float]
[[timerange_fn]]
=== `timerange`

An object that represents a span of time
cqliu1 marked this conversation as resolved.
Show resolved Hide resolved

*Accepts:* `null`

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

|`from` ***
|`string`
|The start of the time range

|`to` ***
|`string`
|The end of the time range
|===

*Returns:* `timerange`


[float]
[[to_fn]]
=== `to`
Expand Down