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

Add joinaggregate. Fixes #4121 #4554

Merged
merged 19 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
examples/specs/*.vl.json
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this rule in .prettierrc.json?

If we can, probably better to consolidate them in one place.

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 don't think it works yet. prettier/prettier#3460

2 changes: 1 addition & 1 deletion _data/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
"title": "Line Charts Showing Ranks Over Time"
},
{
"name": "window_sum_waterfall_chart",
"name": "waterfall_chart",
"title": "Waterfall Chart of Monthly Profit and Loss"
},
{
Expand Down
58 changes: 53 additions & 5 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
"op": {
"$ref": "#/definitions/AggregateOp",
"description": "The aggregation operations to apply to the fields, such as sum, average or count.\nSee the [full list of supported aggregation operations](https://vega.github.io/vega-lite/docs/aggregate.html#ops)\nfor more information."
"description": "The aggregation operation to apply to the fields (e.g., sum, average or count).\nSee the [full list of supported aggregation operations](https://vega.github.io/vega-lite/docs/aggregate.html#ops)\nfor more information."
}
},
"required": [
Expand Down Expand Up @@ -6087,6 +6087,51 @@
},
"type": "object"
},
"JoinAggregateDef": {
"additionalProperties": false,
"properties": {
"as": {
"description": "The output name for the join aggregate operation.",
"type": "string"
},
"field": {
"description": "The data field for which to compute the aggregate function. This can be omitted for functions that do not operate over a field such as `count`.",
"type": "string"
},
"op": {
"$ref": "#/definitions/AggregateOp",
"description": "The aggregation operation to apply (e.g., sum, average or count). See the list of all supported operations [here](https://vega.github.io/vega-lite/docs/aggregate.html#ops)."
}
},
"required": [
"op",
"as"
],
"type": "object"
},
"JoinAggregateTransform": {
"additionalProperties": false,
"properties": {
"groupby": {
"description": "The data fields for partitioning the data objects into separate groups. If unspecified, all data points will be in a single group.",
"items": {
"type": "string"
},
"type": "array"
},
"joinaggregate": {
"description": "The definition of the fields in the join aggregate, and what calculations to use.",
"items": {
"$ref": "#/definitions/JoinAggregateDef"
},
"type": "array"
}
},
"required": [
"joinaggregate"
],
"type": "object"
},
"JsonDataFormat": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -10989,6 +11034,9 @@
{
"$ref": "#/definitions/WindowTransform"
},
{
"$ref": "#/definitions/JoinAggregateTransform"
},
{
"$ref": "#/definitions/StackTransform"
},
Expand Down Expand Up @@ -11522,7 +11570,7 @@
"$ref": "#/definitions/WindowOnlyOp"
}
],
"description": "The window or aggregation operations to apply within a window, including `rank`, `lead`, `sum`, `average` or `count`. See the list of all supported operations [here](https://vega.github.io/vega-lite/docs/window.html#ops)."
"description": "The window or aggregation operation to apply within a window (e.g.,`rank`, `lead`, `sum`, `average` or `count`). See the list of all supported operations [here](https://vega.github.io/vega-lite/docs/window.html#ops)."
},
"param": {
"description": "Parameter values for the window functions. Parameter values can be omitted for operations that do not accept a parameter.\n\nSee the list of all supported operations and their parameters [here](https://vega.github.io/vega-lite/docs/transforms/window.html).",
Expand Down Expand Up @@ -11555,7 +11603,7 @@
"additionalProperties": false,
"properties": {
"frame": {
"description": "A frame specification as a two-element array indicating how the sliding window should proceed. The array entries should either be a number indicating the offset from the current data object, or null to indicate unbounded rows preceding or following the current data object. The default value is `[null, 0]`, indicating that the sliding window includes the current object and all preceding objects. The value `[-5, 5]` indicates that the window should include five objects preceding and five objects following the current object. Finally, `[null, null]` indicates that the window frame should always include all data objects. The only operators affected are the aggregation operations and the `first_value`, `last_value`, and `nth_value` window operations. The other window operations are not affected by this.\n\n__Default value:__: `[null, 0]` (includes the current object and all preceding objects)",
"description": "A frame specification as a two-element array indicating how the sliding window should proceed. The array entries should either be a number indicating the offset from the current data object, or null to indicate unbounded rows preceding or following the current data object. The default value is `[null, 0]`, indicating that the sliding window includes the current object and all preceding objects. The value `[-5, 5]` indicates that the window should include five objects preceding and five objects following the current object. Finally, `[null, null]` indicates that the window frame should always include all data objects. If you this frame and want to assign the same value to add objects, you can use the simpler [join aggregate transform](https://vega.github.io/vega-lite/docs/joinaggregate.html). The only operators affected are the aggregation operations and the `first_value`, `last_value`, and `nth_value` window operations. The other window operations are not affected by this.\n\n__Default value:__: `[null, 0]` (includes the current object and all preceding objects)",
"items": {
"type": [
"null",
Expand All @@ -11565,14 +11613,14 @@
"type": "array"
},
"groupby": {
"description": "The data fields for partitioning the data objects into separate windows. If unspecified, all data points will be in a single group.",
"description": "The data fields for partitioning the data objects into separate windows. If unspecified, all data points will be in a single window.",
"items": {
"type": "string"
},
"type": "array"
},
"ignorePeers": {
"description": "Indicates if the sliding window frame should ignore peer values. (Peer values are those considered identical by the sort criteria). The default is false, causing the window frame to expand to include all peer values. If set to true, the window frame will be defined by offset values only. This setting only affects those operations that depend on the window frame, namely aggregation operations and the first_value, last_value, and nth_value window operations.\n\n__Default value:__ `false`",
"description": "Indicates if the sliding window frame should ignore peer values (data that are considered identical by the sort criteria). The default is false, causing the window frame to expand to include all peer values. If set to true, the window frame will be defined by offset values only. This setting only affects those operations that depend on the window frame, namely aggregation operations and the first_value, last_value, and nth_value window operations.\n\n__Default value:__ `false`",
"type": "boolean"
},
"sort": {
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/bar_diverging_stack_transform.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,11 @@
"offset": "zero"
},
{
"type": "window",
"params": [null],
"type": "joinaggregate",
"as": ["offset"],
"ops": ["sum"],
"fields": ["signed_percentage"],
"sort": {"field": [], "order": []},
"groupby": ["question"],
"frame": [null, null]
"groupby": ["question"]
},
{"type": "formula", "expr": "datum.v1 - datum.offset", "as": "nx"},
{"type": "formula", "expr": "datum.v2 - datum.offset", "as": "nx2"}
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_1D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": [],
"frame": [null, null]
"groupby": []
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_1D_horizontal_custom_mark.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": [],
"frame": [null, null]
"groupby": []
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_1D_horizontal_explicit.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": [],
"frame": [null, null]
"groupby": []
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_1D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": [],
"frame": [null, null]
"groupby": []
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_2D_horizontal.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": ["age"],
"frame": [null, null]
"groupby": ["age"]
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_2D_horizontal_color_size.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": ["age"],
"frame": [null, null]
"groupby": ["age"]
},
{
"type": "filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": ["age"],
"frame": [null, null]
"groupby": ["age"]
},
{
"type": "filter",
Expand Down
7 changes: 2 additions & 5 deletions examples/compiled/boxplot_2D_vertical.vg.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,11 @@
"source": "source_0",
"transform": [
{
"type": "window",
"params": [null, null],
"type": "joinaggregate",
"as": ["lower_box_people", "upper_box_people"],
"ops": ["q1", "q3"],
"fields": ["people", "people"],
"sort": {"field": [], "order": []},
"groupby": ["age"],
"frame": [null, null]
"groupby": ["age"]
},
{
"type": "filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
"transform": [
{"type": "filter", "expr": "datum.IMDB_Rating != null"},
{
"type": "window",
"params": [null],
"type": "joinaggregate",
"as": ["AverageRating"],
"ops": ["mean"],
"fields": ["IMDB_Rating"],
"sort": {"field": [], "order": []},
"frame": [null, null]
"fields": ["IMDB_Rating"]
},
{
"type": "filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
"expr": "datetime(year(datum[\"Release_Date\"]), 0, 1, 0, 0, 0, 0)"
},
{
"type": "window",
"params": [null],
"type": "joinaggregate",
"as": ["AverageYearRating"],
"ops": ["mean"],
"fields": ["IMDB_Rating"],
"sort": {"field": [], "order": []},
"groupby": ["year"],
"frame": [null, null]
"groupby": ["year"]
},
{
"type": "filter",
Expand Down