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

Move expressions to types and correct links #3288

Merged
merged 1 commit into from
Jan 21, 2018
Merged
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
4 changes: 3 additions & 1 deletion _data/link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ VgEventStream:
SelectionResolution:
link: "selection.html#resolve"

# Others
# Types
DateTime:
link: "types.html#datetime"

# Others
HorizontalAlign:
name: String
VerticalAlign:
Expand Down
4 changes: 2 additions & 2 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
"type": "string"
},
"calculate": {
"description": "A string containing a Vega Expression. Use the variable `datum` to refer to the current data object.",
"description": "A [expression](types.html#expression) string. Use the variable `datum` to refer to the current data object.",
"type": "string"
}
},
Expand Down Expand Up @@ -2078,7 +2078,7 @@
"properties": {
"filter": {
"$ref": "#/definitions/LogicalOperand<Predicate>",
"description": "The `filter` property must be one of the predicate definitions:\n(1) a [Vega Expression](filter.html#expression) string,\nwhere `datum` can be used to refer to the current data object;\n(2) one of the field predicates: [equal predicate](filter.html#equal-predicate);\n[range precidate](filter.html#range-predicate), [one-of predicate](filter.html#one-of-predicate);\n(3) a [selection predicate](filter.html#selection-predicate);\nor (4) a logical operand that combines (1), (2), or (3)."
"description": "The `filter` property must be one of the predicate definitions:\n(1) an [expression](types.html#expression) string,\nwhere `datum` can be used to refer to the current data object;\n(2) one of the field predicates: [equal predicate](filter.html#equal-predicate);\n[range precidate](filter.html#range-predicate), [one-of predicate](filter.html#one-of-predicate);\n(3) a [selection predicate](filter.html#selection-predicate);\nor (4) a logical operand that combines (1), (2), or (3)."
}
},
"required": [
Expand Down
4 changes: 2 additions & 2 deletions site/docs/transform/calculate.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Calculate Transform
permalink: /docs/calculate.html
---

The formula transform extends data objects with new fields (columns) according to a calculation formula.
The formula transform extends data objects with new fields (columns) according to an [expression](types.html#expression).

{: .suppress-error}
```json
Expand All @@ -23,6 +23,6 @@ The formula transform extends data objects with new fields (columns) according t

## Example

This example use `calculate` to derive a new field, then `filter` data based on the new field.
This example uses `calculate` to derive a new field, and then `filter`s the data based on the new field.

<span class="vl-example" data-name="bar_filter_calc"></span>
2 changes: 1 addition & 1 deletion site/docs/transform/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Vega-Lite filter transforms must have the `filter` property describing the predi
{:#expression}
## Filter Expression

For a [Vega Expression](https://vega.github.io/vega/docs/expressions/) string, each datum object can be referred using bound variable `datum`. For example, setting `filter` to `"datum.b2 > 60"` would make the output data includes only items that have values in the field `b2` over 60.
For an [expression](types.html#expression) string, each datum object can be referred using bound variable `datum`. For example, setting `filter` to `"datum.b2 > 60"` would make the output data includes only items that have values in the field `b2` over 60.


## Field Predicate
Expand Down
73 changes: 37 additions & 36 deletions site/docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,82 @@ title: Parameter Types
permalink: /docs/types.html
---

Reference documentation for common parameter **types** expected by Vega specification properties.
Reference documentation for common parameter **types** expected by Vega-Lite specification properties.

{:#reference}
## Parameter Type Reference

- [Any](#Any)
- [Array](#Array)
- [Boolean](#Boolean)
- [Color](#Color)
- [Number](#Number)
- [Object](#Object)
- [String](#String)
- [URL](#URL)
- [DateTime](#DateTime)
- [Field](#Field)
- [Signal](#Signal)
- [Compare](#Compare)
- [Expr](#Expr)
- [Value](#Value)
- [ColorValue](#ColorValue)
- [FieldValue](#FieldValue)
- [Any](#any)
- [Array](#array)
- [Boolean](#boolean)
- [Color](#color)
- [DateTime](#datetime)
- [Expressions](#expression)
- [Number](#number)
- [Object](#object)
- [String](#string)
- [URL](#url)
{: .column-list }

## Literal Values

<a name="*"></a><a name="Any" href="#Any">#</a>
<a name="*"></a><a name="any" href="#any">#</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please search and make sure we don't refer to these anchor names with Titlecase from other pages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I searched for types.html.

**Any** or **\***

Accepts any literal value, including a string, number, boolean, or `null`.

<br/><a name="Array" href="#Array">#</a>
<br/><a name="array" href="#array">#</a>
**Array** or **Type[]**

Accepts array values. For example: `[]`, `[1, 2, 3]`, `["foo", "bar"]`. If individual array items must adhere to a specific type, bracket notation &ndash; such as Number[] or String[] &ndash; is used to indicate the item type.
Accepts array values. For example: `[]`, `[1, 2, 3]`, `["foo", "bar"]`. If individual array items must adhere to a specific type, bracket notation &ndash; such as `Number[]` or `String[]` &ndash; is used to indicate the item type.

In most cases, arrays may also have [signal references](#Signal) as items. For example: `[{"signal": "width"}, {"signal": "height"}]`.

<br/><a name="Boolean" href="#Boolean">#</a>
<br/><a name="boolean" href="#boolean">#</a>
**Boolean**

Accepts boolean values. For example: `true`, `false`.

<br/><a name="Color" href="#Color">#</a>
<br/><a name="color" href="#color">#</a>
**Color**

Accepts a valid CSS color string. For example: `#f304d3`, `#ccc`, `rgb(253, 12, 134)`, `steelblue`.

<br/><a name="Number" href="#Number">#</a>
<br/><a name="datetime" href="#datetime">#</a>
**DateTime**

A DateTime object (in [filter transform](filter.html), [scale domain](scale.html#domain), and [axis](axis.html#ticks)/[legend](legend.html#properties) values) must have at least one of the following properties:

{% include table.html props="year,quarter,month,date,day,hours,minutes,seconds,milliseconds" source="DateTime" %}

For example `{"year": 2006, "month": "jan", "date": 1}` represents _Jan 1, 2006_.

<br/><a name="expression" href="#expression">#</a>
**Expression**

To enable custom calculations, Vega-Lite uses Vega's expression language for writing basic formulas. Each datum object can be referred using bound variable `datum`.

Please read the [Vega documentation for expressions](https://vega.github.io/vega/docs/expressions/) for details.


<br/><a name="number" href="#number">#</a>
**Number**

Accepts number values. For example: `1`, `3.14`, `1e5`.

<br/><a name="Object" href="#Object">#</a>
<br/><a name="object" href="#object">#</a>
**Object**

Accepts object literals. For example: `{"left":5, "right":30, "top":5, "bottom":50}`. The valid object property names and types will vary across parameters; read the individual parameter descriptions for more information.


<br/><a name="String" href="#String">#</a>
<br/><a name="string" href="#string">#</a>
**String**

Accepts string values. For example: `"bold"`, `"step-before"`, `""`.


<br/><a name="URL" href="#URL">#</a>
<br/><a name="url" href="#url">#</a>
**URL**

Accepts a valid URL string linking to external site or resource. For example: `"data/stocks.csv"`, `"images/logo.png"`, `"https://vega.github.io/"`.


<br/><a name="datetime" href="#datetime">#</a>
**DateTime**

A DateTime object (in [filter transform](filter.html), [scale domain](scale.html#domain), and [axis](axis.html#ticks)/[legend](legend.html#properties) values) must have at least one of the following properties:

{% include table.html props="year,quarter,month,date,day,hours,minutes,seconds,milliseconds" source="DateTime" %}

For example `{"year": 2006, "month": "jan", "date": 1}` represents _Jan 1, 2006_.
6 changes: 3 additions & 3 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {TimeUnit} from './timeunit';
export interface FilterTransform {
/**
* The `filter` property must be one of the predicate definitions:
* (1) a [Vega Expression](filter.html#expression) string,
* (1) an [expression](types.html#expression) string,
* where `datum` can be used to refer to the current data object;
* (2) one of the field predicates: [equal predicate](filter.html#equal-predicate);
* [range precidate](filter.html#range-predicate), [one-of predicate](filter.html#one-of-predicate);
Expand All @@ -24,12 +24,12 @@ export function isFilter(t: Transform): t is FilterTransform {
return t['filter'] !== undefined;
}


export interface CalculateTransform {
/**
* A string containing a Vega Expression. Use the variable `datum` to refer to the current data object.
* A [expression](types.html#expression) string. Use the variable `datum` to refer to the current data object.
*/
calculate: string;

/**
* The field for storing the computed formula value.
*/
Expand Down