diff --git a/CHANGELOG.md b/CHANGELOG.md index 35fa50e3c0..f52f4da12f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -364,4 +364,4 @@ Thanks for all your work! - GitHub Actions Bot (vega-actions-bot@users.noreply.github.com) - Jon Mease ([@jonmmease](https://github.com/jonmmease)) - Kanit Wongsuphasawat ([@kanitw](https://github.com/kanitw)) -- Lukas Hermann ([@lsh](https://github.com/lsh)) \ No newline at end of file +- Lukas Hermann ([@lsh](https://github.com/lsh)) diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 104d8bb29c..c8be9c8935 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -310,15 +310,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -3168,15 +3161,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -4962,6 +4948,26 @@ "$ref": "#/definitions/ColorDef", "description": "Color of the marks – either fill or stroke color based on the `filled` property of mark definition. By default, `color` represents fill color for `\"area\"`, `\"bar\"`, `\"tick\"`, `\"text\"`, `\"trail\"`, `\"circle\"`, and `\"square\"` / stroke color for `\"line\"` and `\"point\"`.\n\n__Default value:__ If undefined, the default color depends on [mark config](https://vega.github.io/vega-lite/docs/config.html#mark-config)'s `color` property.\n\n_Note:_ 1) For fine-grained control over both fill and stroke colors of the marks, please use the `fill` and `stroke` channels. The `fill` or `stroke` encodings have higher precedence than `color`, thus may override the `color` encoding if conflicting encodings are specified. 2) See the scale documentation for more information about customizing [color scheme](https://vega.github.io/vega-lite/docs/scale.html#scheme)." }, + "cursor": { + "anyOf": [ + { + "$ref": "#/definitions/StringFieldDefWithCondition" + }, + { + "$ref": "#/definitions/StringValueDefWithCondition" + }, + { + "items": { + "$ref": "#/definitions/StringFieldDef" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "description": "TODO: Add description" + }, "description": { "anyOf": [ { @@ -9085,6 +9091,26 @@ "$ref": "#/definitions/RowColumnEncodingFieldDef", "description": "A field definition for the horizontal facet of trellis plots." }, + "cursor": { + "anyOf": [ + { + "$ref": "#/definitions/StringFieldDefWithCondition" + }, + { + "$ref": "#/definitions/StringValueDefWithCondition" + }, + { + "items": { + "$ref": "#/definitions/StringFieldDef" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "description": "TODO: Add description" + }, "description": { "anyOf": [ { @@ -14636,6 +14662,9 @@ "color": { "$ref": "#/definitions/ResolveMode" }, + "cursor": { + "$ref": "#/definitions/ResolveMode" + }, "fill": { "$ref": "#/definitions/ResolveMode" }, @@ -14848,15 +14877,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -16003,15 +16025,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -16836,15 +16851,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -18369,15 +18377,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -20653,15 +20654,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -22394,6 +22388,9 @@ "color": { "$ref": "#/definitions/ResolveMode" }, + "cursor": { + "$ref": "#/definitions/ResolveMode" + }, "fill": { "$ref": "#/definitions/ResolveMode" }, @@ -23269,6 +23266,138 @@ }, "type": "object" }, + "cursor": { + "additionalProperties": false, + "properties": { + "aggregate": { + "$ref": "#/definitions/Aggregate", + "description": "Aggregation function for the field (e.g., `\"mean\"`, `\"sum\"`, `\"median\"`, `\"min\"`, `\"max\"`, `\"count\"`).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html) documentation." + }, + "bandPosition": { + "description": "Relative position on a band of a stacked, binned, time unit, or band scale. For example, the marks will be positioned at the beginning of the band if set to `0`, and at the middle of the band if set to `0.5`.", + "maximum": 1, + "minimum": 0, + "type": "number" + }, + "bin": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/BinParams" + }, + { + "const": "binned", + "type": "string" + }, + { + "type": "null" + } + ], + "description": "A flag for binning a `quantitative` field, [an object defining binning parameters](https://vega.github.io/vega-lite/docs/bin.html#bin-parameters), or indicating that the data for `x` or `y` channel are binned before they are imported into Vega-Lite (`\"binned\"`).\n\n- If `true`, default [binning parameters](https://vega.github.io/vega-lite/docs/bin.html#bin-parameters) will be applied.\n\n- If `\"binned\"`, this indicates that the data for the `x` (or `y`) channel are already binned. You can map the bin-start field to `x` (or `y`) and the bin-end field to `x2` (or `y2`). The scale and axis will be formatted similar to binning in Vega-Lite. To adjust the axis ticks based on the bin step, you can also set the axis's [`tickMinStep`](https://vega.github.io/vega-lite/docs/axis.html#ticks) property.\n\n__Default value:__ `false`\n\n__See also:__ [`bin`](https://vega.github.io/vega-lite/docs/bin.html) documentation." + }, + "condition": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/ConditionalValueDef<(string|ExprRef)>" + }, + { + "items": { + "$ref": "#/definitions/ConditionalValueDef<(string|ExprRef)>" + }, + "type": "array" + } + ], + "description": "One or more value definition(s) with [a parameter or a test predicate](https://vega.github.io/vega-lite/docs/condition.html).\n\n__Note:__ A field definition's `condition` property can only contain [conditional value definitions](https://vega.github.io/vega-lite/docs/condition.html#value) since Vega-Lite only allows at most one encoded field per encoding channel." + }, + { + "anyOf": [ + { + "$ref": "#/definitions/ConditionalMarkPropFieldOrDatumDef" + }, + { + "$ref": "#/definitions/ConditionalValueDef<(string|null|ExprRef)>" + }, + { + "items": { + "$ref": "#/definitions/ConditionalValueDef<(string|null|ExprRef)>" + }, + "type": "array" + } + ], + "description": "A field definition or one or more value definition(s) with a parameter predicate." + } + ], + "description": "One or more value definition(s) with [a parameter or a test predicate](https://vega.github.io/vega-lite/docs/condition.html).\n\n__Note:__ A field definition's `condition` property can only contain [conditional value definitions](https://vega.github.io/vega-lite/docs/condition.html#value) since Vega-Lite only allows at most one encoded field per encoding channel." + }, + "field": { + "$ref": "#/definitions/Field", + "description": "__Required.__ A string defining the name of the field from which to pull a data value or an object defining iterated values from the [`repeat`](https://vega.github.io/vega-lite/docs/repeat.html) operator.\n\n__See also:__ [`field`](https://vega.github.io/vega-lite/docs/field.html) documentation.\n\n__Notes:__ 1) Dots (`.`) and brackets (`[` and `]`) can be used to access nested objects (e.g., `\"field\": \"foo.bar\"` and `\"field\": \"foo['bar']\"`). If field names contain dots or brackets but are not nested, you can use `\\\\` to escape dots and brackets (e.g., `\"a\\\\.b\"` and `\"a\\\\[0\\\\]\"`). See more details about escaping in the [field documentation](https://vega.github.io/vega-lite/docs/field.html). 2) `field` is not required if `aggregate` is `count`." + }, + "format": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/Dict" + } + ], + "description": "When used with the default `\"number\"` and `\"time\"` format type, the text formatting pattern for labels of guides (axes, legends, headers) and text marks.\n\n- If the format type is `\"number\"` (e.g., for quantitative fields), this is D3's [number format pattern](https://github.com/d3/d3-format#locale_format).\n- If the format type is `\"time\"` (e.g., for temporal fields), this is D3's [time format pattern](https://github.com/d3/d3-time-format#locale_format).\n\nSee the [format documentation](https://vega.github.io/vega-lite/docs/format.html) for more examples.\n\nWhen used with a [custom `formatType`](https://vega.github.io/vega-lite/docs/config.html#custom-format-type), this value will be passed as `format` alongside `datum.value` to the registered function.\n\n__Default value:__ Derived from [numberFormat](https://vega.github.io/vega-lite/docs/config.html#format) config for number format and from [timeFormat](https://vega.github.io/vega-lite/docs/config.html#format) config for time format." + }, + "formatType": { + "description": "The format type for labels. One of `\"number\"`, `\"time\"`, or a [registered custom format type](https://vega.github.io/vega-lite/docs/config.html#custom-format-type).\n\n__Default value:__\n- `\"time\"` for temporal fields and ordinal and nominal fields with `timeUnit`.\n- `\"number\"` for quantitative fields as well as ordinal and nominal fields without `timeUnit`.", + "type": "string" + }, + "timeUnit": { + "anyOf": [ + { + "$ref": "#/definitions/TimeUnit" + }, + { + "$ref": "#/definitions/BinnedTimeUnit" + }, + { + "$ref": "#/definitions/TimeUnitParams" + } + ], + "description": "Time unit (e.g., `year`, `yearmonth`, `month`, `hours`) for a temporal field. or [a temporal field that gets casted as ordinal](https://vega.github.io/vega-lite/docs/type.html#cast).\n\n__Default value:__ `undefined` (None)\n\n__See also:__ [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html) documentation." + }, + "title": { + "anyOf": [ + { + "$ref": "#/definitions/Text" + }, + { + "type": "null" + } + ], + "description": "A title for the field. If `null`, the title will be removed.\n\n__Default value:__ derived from the field's name and transformation function (`aggregate`, `bin` and `timeUnit`). If the field has an aggregate function, the function is displayed as part of the title (e.g., `\"Sum of Profit\"`). If the field is binned or has a time unit applied, the applied function is shown in parentheses (e.g., `\"Profit (binned)\"`, `\"Transaction Date (year-month)\"`). Otherwise, the title is simply the field name.\n\n__Notes__:\n\n1) You can customize the default field title format by providing the [`fieldTitle`](https://vega.github.io/vega-lite/docs/config.html#top-level-config) property in the [config](https://vega.github.io/vega-lite/docs/config.html) or [`fieldTitle` function via the `compile` function's options](https://vega.github.io/vega-lite/usage/compile.html#field-title).\n\n2) If both field definition's `title` and axis, header, or legend `title` are defined, axis/header/legend title will be used." + }, + "type": { + "$ref": "#/definitions/StandardType", + "description": "The type of measurement (`\"quantitative\"`, `\"temporal\"`, `\"ordinal\"`, or `\"nominal\"`) for the encoded field or constant value (`datum`). It can also be a `\"geojson\"` type for encoding ['geoshape'](https://vega.github.io/vega-lite/docs/geoshape.html).\n\nVega-Lite automatically infers data types in many cases as discussed below. However, type is required for a field if: (1) the field is not nominal and the field encoding has no specified `aggregate` (except `argmin` and `argmax`), `bin`, scale type, custom `sort` order, nor `timeUnit` or (2) if you wish to use an ordinal scale for a field with `bin` or `timeUnit`.\n\n__Default value:__\n\n1) For a data `field`, `\"nominal\"` is the default data type unless the field encoding has `aggregate`, `channel`, `bin`, scale type, `sort`, or `timeUnit` that satisfies the following criteria:\n- `\"quantitative\"` is the default type if (1) the encoded field contains `bin` or `aggregate` except `\"argmin\"` and `\"argmax\"`, (2) the encoding channel is `latitude` or `longitude` channel or (3) if the specified scale type is [a quantitative scale](https://vega.github.io/vega-lite/docs/scale.html#type).\n- `\"temporal\"` is the default type if (1) the encoded field contains `timeUnit` or (2) the specified scale type is a time or utc scale\n- `\"ordinal\"` is the default type if (1) the encoded field contains a [custom `sort` order](https://vega.github.io/vega-lite/docs/sort.html#specifying-custom-sort-order), (2) the specified scale type is an ordinal/point/band scale, or (3) the encoding channel is `order`.\n\n2) For a constant value in data domain (`datum`):\n- `\"quantitative\"` if the datum is a number\n- `\"nominal\"` if the datum is a string\n- `\"temporal\"` if the datum is [a date time object](https://vega.github.io/vega-lite/docs/datetime.html)\n\n__Note:__\n- Data `type` describes the semantics of the data rather than the primitive data types (number, string, etc.). The same primitive data type can have different types of measurement. For example, numeric data can represent quantitative, ordinal, or nominal data.\n- Data values for a temporal field can be either a date-time string (e.g., `\"2015-03-07 12:32:17\"`, `\"17:01\"`, `\"2015-03-16\"`. `\"2015\"`) or a timestamp number (e.g., `1552199579097`).\n- When using with [`bin`](https://vega.github.io/vega-lite/docs/bin.html), the `type` property can be either `\"quantitative\"` (for using a linear bin scale) or [`\"ordinal\"` (for using an ordinal bin scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).\n- When using with [`timeUnit`](https://vega.github.io/vega-lite/docs/timeunit.html), the `type` property can be either `\"temporal\"` (default, for using a temporal scale) or [`\"ordinal\"` (for using an ordinal scale)](https://vega.github.io/vega-lite/docs/type.html#cast-bin).\n- When using with [`aggregate`](https://vega.github.io/vega-lite/docs/aggregate.html), the `type` property refers to the post-aggregation data type. For example, we can calculate count `distinct` of a categorical field `\"cat\"` using `{\"aggregate\": \"distinct\", \"field\": \"cat\"}`. The `\"type\"` of the aggregate output is `\"quantitative\"`.\n- Secondary channels (e.g., `x2`, `y2`, `xError`, `yError`) do not have `type` as they must have exactly the same type as their primary channels (e.g., `x`, `y`).\n\n__See also:__ [`type`](https://vega.github.io/vega-lite/docs/type.html) documentation." + }, + "value": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "A constant value in visual domain (e.g., `\"red\"` / `\"#0099ff\"` / [gradient definition](https://vega.github.io/vega-lite/docs/types.html#gradient) for color, values between `0` to `1` for opacity)." + } + }, + "type": "object" + }, "description": { "additionalProperties": false, "properties": { @@ -27181,7 +27310,8 @@ "text", "href", "url", - "description" + "description", + "cursor" ], "type": "string" }, @@ -27884,15 +28014,8 @@ ] }, "cursor": { - "anyOf": [ - { - "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." - }, - { - "$ref": "#/definitions/ExprRef" - } - ] + "$ref": "#/definitions/Cursor", + "description": "The mouse cursor used over the mark. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "description": { "anyOf": [ @@ -31208,7 +31331,7 @@ }, "cursor": { "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." + "description": "The cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "fill": { "anyOf": [ @@ -31392,7 +31515,7 @@ }, "cursor": { "$ref": "#/definitions/Cursor", - "description": "The mouse cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." + "description": "The cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used." }, "discreteHeight": { "anyOf": [ diff --git a/examples/specs/airport_connections.vl.json b/examples/specs/airport_connections.vl.json index 32ccb4ec23..12297420e0 100644 --- a/examples/specs/airport_connections.vl.json +++ b/examples/specs/airport_connections.vl.json @@ -11,50 +11,105 @@ }, "data": { "url": "data/us-10m.json", - "format": {"type": "topojson", "feature": "states"} + "format": { + "type": "topojson", + "feature": "states" + } } }, { - "mark": {"type": "rule", "color": "#000", "opacity": 0.35}, - "data": {"url": "data/flights-airport.csv"}, + "mark": { + "type": "rule", + "color": "#000", + "opacity": 0.35 + }, + "data": { + "url": "data/flights-airport.csv" + }, "transform": [ - {"filter": {"param": "org", "empty": false}}, + { + "filter": { + "param": "org", + "empty": false + } + }, { "lookup": "origin", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["latitude", "longitude"] + "fields": [ + "latitude", + "longitude" + ] } }, { "lookup": "destination", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["latitude", "longitude"] + "fields": [ + "latitude", + "longitude" + ] }, - "as": ["lat2", "lon2"] + "as": [ + "lat2", + "lon2" + ] } ], "encoding": { - "latitude": {"field": "latitude"}, - "longitude": {"field": "longitude"}, - "latitude2": {"field": "lat2"}, - "longitude2": {"field": "lon2"} + "latitude": { + "field": "latitude" + }, + "longitude": { + "field": "longitude" + }, + "latitude2": { + "field": "lat2" + }, + "longitude2": { + "field": "lon2" + } } }, { - "mark": {"type": "circle"}, - "data": {"url": "data/flights-airport.csv"}, + "mark": { + "type": "circle" + }, + "data": { + "url": "data/flights-airport.csv" + }, "transform": [ - {"aggregate": [{"op": "count", "as": "routes"}], "groupby": ["origin"]}, + { + "aggregate": [ + { + "op": "count", + "as": "routes" + } + ], + "groupby": [ + "origin" + ] + }, { "lookup": "origin", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["state", "latitude", "longitude"] + "fields": [ + "state", + "latitude", + "longitude" + ] } }, {"filter": "datum.state !== 'PR' && datum.state !== 'VI'"} @@ -67,14 +122,33 @@ "nearest": true, "fields": ["origin"] } - }], + ], + "params": [ + { + "name": "org", + "select": { + "type": "point", + "on": "pointerover", + "nearest": true, + "fields": [ + "origin" + ] + } + } + ], "encoding": { - "latitude": {"field": "latitude"}, - "longitude": {"field": "longitude"}, + "latitude": { + "field": "latitude" + }, + "longitude": { + "field": "longitude" + }, "size": { "field": "routes", "type": "quantitative", - "scale": {"rangeMax": 1000}, + "scale": { + "rangeMax": 1000 + }, "legend": null }, "order": { @@ -84,7 +158,9 @@ } } ], - "projection": {"type": "albersUsa"}, + "projection": { + "type": "albersUsa" + }, "width": 900, "height": 500 } diff --git a/examples/specs/concat_hover.vl.json b/examples/specs/concat_hover.vl.json index 15dff37cda..f6308b1f2d 100644 --- a/examples/specs/concat_hover.vl.json +++ b/examples/specs/concat_hover.vl.json @@ -16,7 +16,50 @@ "param": "hover", "empty": false, "field": "Cylinders", "type": "ordinal" }, - "value": "grey" + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, + "color": { + "condition": { + "param": "hover", + "empty": false, + "field": "Cylinders", + "type": "ordinal" + }, + "value": "grey" + } + } + }, + { + "params": [ + { + "name": "hover", + "select": { + "type": "point", + "on": "pointerover" + } + } + ], + "mark": "point", + "encoding": { + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Acceleration", + "type": "quantitative" + }, + "color": { + "condition": { + "param": "hover", + "empty": false, + "field": "Cylinders", + "type": "ordinal" + }, + "value": "grey" + } } } },{ diff --git a/examples/specs/concat_hover_filter.vl.json b/examples/specs/concat_hover_filter.vl.json index d88b2ab328..4b17da25b7 100644 --- a/examples/specs/concat_hover_filter.vl.json +++ b/examples/specs/concat_hover_filter.vl.json @@ -15,17 +15,34 @@ }], "mark": "point" }, - { - "mark": {"type": "point", "color": "goldenrod"}, - "transform": [ - {"filter": {"param": "hover", "empty": false}} - ] - } - ] - }, { - "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Acceleration", "type": "quantitative"} + "layer": [ + { + "params": [ + { + "name": "hover", + "select": { + "type": "point", + "on": "pointerover" + } + } + ], + "mark": "point" + }, + { + "mark": { + "type": "point", + "color": "goldenrod" + }, + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ] + } + ] }, "layer": [ { @@ -36,12 +53,34 @@ }], "mark": "point" }, - { - "mark": {"type": "point", "color": "goldenrod"}, - "transform": [ - {"filter": {"param": "hover", "empty": false}} - ] - } - ] - }] + "layer": [ + { + "params": [ + { + "name": "hover", + "select": { + "type": "point", + "on": "pointerover" + } + } + ], + "mark": "point" + }, + { + "mark": { + "type": "point", + "color": "goldenrod" + }, + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ] + } + ] + } + ] } diff --git a/examples/specs/interactive_bar_select_highlight.vl.json b/examples/specs/interactive_bar_select_highlight.vl.json index 81ad0a99c4..ea85355bf5 100644 --- a/examples/specs/interactive_bar_select_highlight.vl.json +++ b/examples/specs/interactive_bar_select_highlight.vl.json @@ -3,9 +3,42 @@ "description": "A bar chart with highlighting on hover and selecting on click. (Inspired by Tableau's interaction style.)", "data": { "values": [ - {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43}, - {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53}, - {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52} + { + "a": "A", + "b": 28 + }, + { + "a": "B", + "b": 55 + }, + { + "a": "C", + "b": 43 + }, + { + "a": "D", + "b": 91 + }, + { + "a": "E", + "b": 81 + }, + { + "a": "F", + "b": 53 + }, + { + "a": "G", + "b": 19 + }, + { + "a": "H", + "b": 87 + }, + { + "a": "I", + "b": 52 + } ] }, "params": [ @@ -13,7 +46,10 @@ "name": "highlight", "select": {"type": "point", "on": "pointerover"} }, - {"name": "select", "select": "point"} + { + "name": "select", + "select": "point" + } ], "mark": { "type": "bar", @@ -22,10 +58,19 @@ "cursor": "pointer" }, "encoding": { - "x": {"field": "a", "type": "ordinal"}, - "y": {"field": "b", "type": "quantitative"}, + "x": { + "field": "a", + "type": "ordinal" + }, + "y": { + "field": "b", + "type": "quantitative" + }, "fillOpacity": { - "condition": {"param": "select", "value": 1}, + "condition": { + "param": "select", + "value": 1 + }, "value": 0.3 }, "strokeWidth": { diff --git a/examples/specs/interactive_global_development.vl.json b/examples/specs/interactive_global_development.vl.json index 9a9243ccde..c8e7af7ff0 100644 --- a/examples/specs/interactive_global_development.vl.json +++ b/examples/specs/interactive_global_development.vl.json @@ -1,14 +1,25 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "An interactive scatter plot of global health statistics by country and year.", - "data": {"url": "data/gapminder.json"}, + "data": { + "url": "data/gapminder.json" + }, "width": 800, "height": 500, "layer": [ { "transform": [ - {"filter": {"field": "country", "equal": "Afghanistan"}}, - {"filter": {"param": "year"}} + { + "filter": { + "field": "country", + "equal": "Afghanistan" + } + }, + { + "filter": { + "param": "year" + } + } ], "mark": { "type": "text", @@ -17,7 +28,11 @@ "y": 250, "opacity": 0.06 }, - "encoding": {"text": {"field": "year"}} + "encoding": { + "text": { + "field": "year" + } + } }, { "transform": [ @@ -25,15 +40,35 @@ "lookup": "cluster", "from": { "key": "id", - "fields": ["name"], + "fields": [ + "name" + ], "data": { "values": [ - {"id": 0, "name": "South Asia"}, - {"id": 1, "name": "Europe & Central Asia"}, - {"id": 2, "name": "Sub-Saharan Africa"}, - {"id": 3, "name": "America"}, - {"id": 4, "name": "East Asia & Pacific"}, - {"id": 5, "name": "Middle East & North Africa"} + { + "id": 0, + "name": "South Asia" + }, + { + "id": 1, + "name": "Europe & Central Asia" + }, + { + "id": 2, + "name": "Sub-Saharan Africa" + }, + { + "id": 3, + "name": "America" + }, + { + "id": 4, + "name": "East Asia & Pacific" + }, + { + "id": 5, + "name": "Middle East & North Africa" + } ] } } @@ -43,14 +78,30 @@ "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } } }, "layer": [ @@ -62,14 +113,26 @@ "strokeCap": "round" }, "encoding": { - "detail": {"field": "country"}, - "order": {"field": "year"}, + "detail": { + "field": "country" + }, + "order": { + "field": "year" + }, "opacity": { "condition": { - "test": {"or": [ - {"param": "hovered", "empty": false}, - {"param": "clicked", "empty": false} - ]}, + "test": { + "or": [ + { + "param": "hovered", + "empty": false + }, + { + "param": "clicked", + "empty": false + } + ] + }, "value": 0.8 }, "value": 0 @@ -80,45 +143,85 @@ "params": [ { "name": "year", - "value": [{"year": 1955}], + "value": [ + { + "year": 1955 + } + ], "select": { "type": "point", - "fields": ["year"] + "fields": [ + "year" + ] }, "bind": { "name": "Year", "input": "range", - "min": 1955, "max": 2005, "step": 5 + "min": 1955, + "max": 2005, + "step": 5 } }, { "name": "hovered", "select": { "type": "point", - "fields": ["country"], + "fields": [ + "country" + ], "toggle": false, "on": "pointerover" } }, { "name": "clicked", - "select": {"type": "point", "fields": ["country"]} + "select": { + "type": "point", + "fields": [ + "country" + ] + } + } + ], + "transform": [ + { + "filter": { + "param": "year" + } } ], - "transform": [{"filter": {"param": "year"}}], - "mark": {"type": "circle", "size": 100, "opacity": 0.9}, - "encoding": {"color": {"field": "name", "title": "Region"}} + "mark": { + "type": "circle", + "size": 100, + "opacity": 0.9 + }, + "encoding": { + "color": { + "field": "name", + "title": "Region" + } + } }, { "transform": [ { "filter": { "and": [ - {"param": "year"}, - {"or": [ - {"param": "clicked", "empty": false}, - {"param": "hovered", "empty": false} - ]} + { + "param": "year" + }, + { + "or": [ + { + "param": "clicked", + "empty": false + }, + { + "param": "hovered", + "empty": false + } + ] + } ] } } @@ -130,14 +233,30 @@ "fontWeight": "bold" }, "encoding": { - "text": {"field": "country"}, - "color": {"field": "name", "title": "Region"} + "text": { + "field": "country" + }, + "color": { + "field": "name", + "title": "Region" + } } }, { "transform": [ - {"filter": {"param": "hovered", "empty": false}}, - {"filter": {"not": {"param": "year"}}} + { + "filter": { + "param": "hovered", + "empty": false + } + }, + { + "filter": { + "not": { + "param": "year" + } + } + } ], "layer": [ { @@ -147,9 +266,18 @@ "fontSize": 12, "color": "gray" }, - "encoding": {"text": {"field": "year"}} + "encoding": { + "text": { + "field": "year" + } + } }, - {"mark": {"type": "circle", "color": "gray"}} + { + "mark": { + "type": "circle", + "color": "gray" + } + } ] } ] diff --git a/examples/specs/interactive_histogram_full_height_hover.vl.json b/examples/specs/interactive_histogram_full_height_hover.vl.json index ef361cce41..7bda075a8e 100644 --- a/examples/specs/interactive_histogram_full_height_hover.vl.json +++ b/examples/specs/interactive_histogram_full_height_hover.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/movies.json"}, + "data": { + "url": "data/movies.json" + }, "layer": [ { "params": [ @@ -9,21 +11,43 @@ "select": {"type": "point", "on": "pointerover", "clear": "pointerout"} } ], - "mark": {"type": "bar", "color": "#eee", "tooltip": true}, + "mark": { + "type": "bar", + "color": "#eee", + "tooltip": true + }, "encoding": { - "x": {"bin": true, "field": "IMDB Rating"}, + "x": { + "bin": true, + "field": "IMDB Rating" + }, "opacity": { - "condition": {"test": {"param": "hover", "empty": false}, "value": 0.5}, + "condition": { + "test": { + "param": "hover", + "empty": false + }, + "value": 0.5 + }, "value": 0 }, - "detail": [{"aggregate": "count"}] + "detail": [ + { + "aggregate": "count" + } + ] } }, { "mark": "bar", "encoding": { - "x": {"bin": true, "field": "IMDB Rating"}, - "y": {"aggregate": "count"} + "x": { + "bin": true, + "field": "IMDB Rating" + }, + "y": { + "aggregate": "count" + } } } ] diff --git a/examples/specs/interactive_index_chart.vl.json b/examples/specs/interactive_index_chart.vl.json index db9f872a26..2ad363031f 100644 --- a/examples/specs/interactive_index_chart.vl.json +++ b/examples/specs/interactive_index_chart.vl.json @@ -2,7 +2,11 @@ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": { "url": "data/stocks.csv", - "format": {"parse": {"date": "date"}} + "format": { + "parse": { + "date": "date" + } + } }, "width": 650, "height": 300, @@ -17,18 +21,27 @@ "on": "pointerover", "nearest": true } - }], + ], "mark": "point", "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, - "opacity": {"value": 0} + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, + "opacity": { + "value": 0 + } } }, { "transform": [ { "lookup": "symbol", - "from": {"param": "index", "key": "symbol"} + "from": { + "param": "index", + "key": "symbol" + } }, { "calculate": "datum.index && datum.index.price > 0 ? (datum.price - datum.index.price)/datum.index.price : 0", @@ -37,27 +50,63 @@ ], "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, "y": { - "field": "indexed_price", "type": "quantitative", - "axis": {"format": "%"} + "field": "indexed_price", + "type": "quantitative", + "axis": { + "format": "%" + } }, - "color": {"field": "symbol", "type": "nominal"} + "color": { + "field": "symbol", + "type": "nominal" + } } }, { - "transform": [{"filter": {"param": "index"}}], + "transform": [ + { + "filter": { + "param": "index" + } + } + ], "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, - "color": {"value": "firebrick"} + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, + "color": { + "value": "firebrick" + } }, "layer": [ - {"mark": {"type": "rule", "strokeWidth": 0.5}}, { - "mark": {"type": "text", "align": "center", "fontWeight": 100}, + "mark": { + "type": "rule", + "strokeWidth": 0.5 + } + }, + { + "mark": { + "type": "text", + "align": "center", + "fontWeight": 100 + }, "encoding": { - "text": {"field": "date", "timeUnit": "yearmonth"}, - "y": {"value": 310} + "text": { + "field": "date", + "timeUnit": "yearmonth" + }, + "y": { + "value": 310 + } } } ] diff --git a/examples/specs/interactive_line_hover.vl.json b/examples/specs/interactive_line_hover.vl.json index cb548ad2cf..b3281d18bf 100644 --- a/examples/specs/interactive_line_hover.vl.json +++ b/examples/specs/interactive_line_hover.vl.json @@ -1,16 +1,30 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Multi-series line chart with labels and interactive highlight on hover. We also set the selection's initial value to provide a better screenshot", - "data": {"url": "data/stocks.csv"}, - "transform": [{"filter": "datum.symbol!=='IBM'"}], + "data": { + "url": "data/stocks.csv" + }, + "transform": [ + { + "filter": "datum.symbol!=='IBM'" + } + ], "encoding": { - "x": {"field": "date", "type": "temporal", "title": "date"}, - "y": {"field": "price", "type": "quantitative", "title": "price"}, + "x": { + "field": "date", + "type": "temporal", + "title": "date" + }, + "y": { + "field": "price", + "type": "quantitative", + "title": "price" + }, "color": { "condition": { "param": "hover", - "field":"symbol", - "type":"nominal", + "field": "symbol", + "type": "nominal", "legend": null }, "value": "grey" @@ -33,21 +47,48 @@ "fields": ["symbol"], "on": "pointerover" } - }], - "mark": {"type": "line", "strokeWidth": 8, "stroke": "transparent"} - }, { - "mark": "line" - }, { - "encoding": { - "x": {"aggregate": "max", "field": "date"}, - "y": {"aggregate": {"argmax": "date"}, "field": "price"} }, - "layer": [{ - "mark": {"type": "circle"} - }, { - "mark": {"type": "text", "align": "left", "dx": 4}, - "encoding": {"text": {"field":"symbol", "type": "nominal"}} - }] - }], - "config": {"view": {"stroke": null}} + { + "mark": "line" + }, + { + "encoding": { + "x": { + "aggregate": "max", + "field": "date" + }, + "y": { + "aggregate": { + "argmax": "date" + }, + "field": "price" + } + }, + "layer": [ + { + "mark": { + "type": "circle" + } + }, + { + "mark": { + "type": "text", + "align": "left", + "dx": 4 + }, + "encoding": { + "text": { + "field": "symbol", + "type": "nominal" + } + } + } + ] + } + ], + "config": { + "view": { + "stroke": null + } + } } diff --git a/examples/specs/interactive_line_point_hover.vl.json b/examples/specs/interactive_line_point_hover.vl.json index ef00f44197..e3fdcc7a61 100644 --- a/examples/specs/interactive_line_point_hover.vl.json +++ b/examples/specs/interactive_line_point_hover.vl.json @@ -1,11 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Stock prices of 5 Tech Companies over Time, with a point marker on hover. Note that the hidden markers are intentionally bigger to make it easier for readers to hover.", - "data": {"url": "data/stocks.csv"}, - "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "data": { + "url": "data/stocks.csv" }, "layer": [{ "mark": "line" diff --git a/examples/specs/interactive_multi_line_label.vl.json b/examples/specs/interactive_multi_line_label.vl.json index c93b05980e..b6a8a4ab95 100644 --- a/examples/specs/interactive_multi_line_label.vl.json +++ b/examples/specs/interactive_multi_line_label.vl.json @@ -8,12 +8,20 @@ "layer": [ { "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } }, "layer": [ - {"mark": "line"}, { "params": [{ "name": "label", @@ -23,7 +31,7 @@ "nearest": true, "on": "pointerover" } - }], + ], "mark": "point", "encoding": { "opacity": { @@ -39,19 +47,42 @@ ] }, { - "transform": [{"filter": {"param": "label", "empty": false}}], + "transform": [ + { + "filter": { + "param": "label", + "empty": false + } + } + ], "layer": [ { - "mark": {"type": "rule", "color": "gray"}, + "mark": { + "type": "rule", + "color": "gray" + }, "encoding": { - "x": {"type": "temporal", "field": "date", "aggregate": "min"} + "x": { + "type": "temporal", + "field": "date", + "aggregate": "min" + } } }, { "encoding": { - "text": {"type": "quantitative", "field": "price"}, - "x": {"type": "temporal", "field": "date"}, - "y": {"type": "quantitative", "field": "price"} + "text": { + "type": "quantitative", + "field": "price" + }, + "x": { + "type": "temporal", + "field": "date" + }, + "y": { + "type": "quantitative", + "field": "price" + } }, "layer": [ { @@ -65,9 +96,17 @@ } }, { - "mark": {"type": "text", "align": "left", "dx": 5, "dy": -5}, + "mark": { + "type": "text", + "align": "left", + "dx": 5, + "dy": -5 + }, "encoding": { - "color": {"type": "nominal", "field": "symbol"} + "color": { + "type": "nominal", + "field": "symbol" + } } } ] diff --git a/examples/specs/interactive_multi_line_pivot_tooltip.vl.json b/examples/specs/interactive_multi_line_pivot_tooltip.vl.json index 32fd991b85..0ca9ba8159 100644 --- a/examples/specs/interactive_multi_line_pivot_tooltip.vl.json +++ b/examples/specs/interactive_multi_line_pivot_tooltip.vl.json @@ -1,34 +1,86 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "width": 400, "height": 300, - "encoding": {"x": {"field": "date", "type": "temporal"}}, + "encoding": { + "x": { + "field": "date", + "type": "temporal" + } + }, "layer": [ { "encoding": { - "color": {"field": "symbol", "type": "nominal"}, - "y": {"field": "price", "type": "quantitative"} + "color": { + "field": "symbol", + "type": "nominal" + }, + "y": { + "field": "price", + "type": "quantitative" + } }, "layer": [ - {"mark": "line"}, - {"transform": [{"filter": {"param": "hover", "empty": false}}], "mark": "point"} + { + "mark": "line" + }, + { + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ], + "mark": "point" + } ] }, { - "transform": [{"pivot": "symbol", "value": "price", "groupby": ["date"]}], + "transform": [ + { + "pivot": "symbol", + "value": "price", + "groupby": [ + "date" + ] + } + ], "mark": "rule", "encoding": { "opacity": { - "condition": {"value": 0.3, "param": "hover", "empty": false}, + "condition": { + "value": 0.3, + "param": "hover", + "empty": false + }, "value": 0 }, "tooltip": [ - {"field": "AAPL", "type": "quantitative"}, - {"field": "AMZN", "type": "quantitative"}, - {"field": "GOOG", "type": "quantitative"}, - {"field": "IBM", "type": "quantitative"}, - {"field": "MSFT", "type": "quantitative"} + { + "field": "AAPL", + "type": "quantitative" + }, + { + "field": "AMZN", + "type": "quantitative" + }, + { + "field": "GOOG", + "type": "quantitative" + }, + { + "field": "IBM", + "type": "quantitative" + }, + { + "field": "MSFT", + "type": "quantitative" + } ] }, "params": [{ @@ -40,7 +92,7 @@ "on": "pointerover", "clear": "pointerout" } - }] + ] } ] } diff --git a/examples/specs/interactive_multi_line_tooltip.vl.json b/examples/specs/interactive_multi_line_tooltip.vl.json index 89400a15e6..55e931e840 100644 --- a/examples/specs/interactive_multi_line_tooltip.vl.json +++ b/examples/specs/interactive_multi_line_tooltip.vl.json @@ -1,12 +1,26 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/seattle-weather.csv"}, + "data": { + "url": "data/seattle-weather.csv" + }, "encoding": { - "x": {"timeUnit": "yearmonthdate", "field": "date"}, + "x": { + "timeUnit": "yearmonthdate", + "field": "date" + }, "tooltip": [ - {"timeUnit": "yearmonthdate", "field": "date"}, - {"field": "temp_max", "type": "quantitative"}, - {"field": "temp_min", "type": "quantitative"} + { + "timeUnit": "yearmonthdate", + "field": "date" + }, + { + "field": "temp_max", + "type": "quantitative" + }, + { + "field": "temp_min", + "type": "quantitative" + } ] }, "layer": [{ @@ -35,6 +49,10 @@ "value": "transparent" } } - }], - "config": {"axisY": {"minExtent": 30}} + ], + "config": { + "axisY": { + "minExtent": 30 + } + } } diff --git a/examples/specs/interactive_paintbrush.vl.json b/examples/specs/interactive_paintbrush.vl.json index 4971a67a0b..dc0108c25f 100644 --- a/examples/specs/interactive_paintbrush.vl.json +++ b/examples/specs/interactive_paintbrush.vl.json @@ -8,10 +8,19 @@ }], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "size": { - "condition": {"param": "paintbrush", "value": 300}, + "condition": { + "param": "paintbrush", + "value": 300 + }, "value": 50 } } diff --git a/examples/specs/interactive_paintbrush_color.vl.json b/examples/specs/interactive_paintbrush_color.vl.json index 4694cb3007..c8996b92fe 100644 --- a/examples/specs/interactive_paintbrush_color.vl.json +++ b/examples/specs/interactive_paintbrush_color.vl.json @@ -8,18 +8,27 @@ "type": "point", "on": "pointerover" } - }], + ], "mark": "circle", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { "condition": { "param": "paintbrush", - "field": "Cylinders", "type": "ordinal" + "field": "Cylinders", + "type": "ordinal" }, "value": "grey" }, - "size": {"value": 75} + "size": { + "value": 75 + } } } diff --git a/examples/specs/interactive_paintbrush_color_nearest.vl.json b/examples/specs/interactive_paintbrush_color_nearest.vl.json index 0b2818c4f5..b9ee1f84d0 100644 --- a/examples/specs/interactive_paintbrush_color_nearest.vl.json +++ b/examples/specs/interactive_paintbrush_color_nearest.vl.json @@ -9,18 +9,27 @@ "on": "pointerover", "nearest": true } - }], + ], "mark": "circle", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { "condition": { "param": "paintbrush", - "field": "Cylinders", "type": "ordinal" + "field": "Cylinders", + "type": "ordinal" }, "value": "grey" }, - "size": {"value": 75} + "size": { + "value": 75 + } } } diff --git a/examples/specs/interactive_paintbrush_simple_false.vl.json b/examples/specs/interactive_paintbrush_simple_false.vl.json index 5745cd40ad..7ab120d157 100644 --- a/examples/specs/interactive_paintbrush_simple_false.vl.json +++ b/examples/specs/interactive_paintbrush_simple_false.vl.json @@ -1,10 +1,14 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ { "name": "toggleOrigin", - "bind": {"input": "checkbox"} + "bind": { + "input": "checkbox" + } }, { "name": "paintbrush", @@ -13,8 +17,14 @@ ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { "condition": { "param": "toggleOrigin", diff --git a/examples/specs/interactive_paintbrush_simple_true.vl.json b/examples/specs/interactive_paintbrush_simple_true.vl.json index c84add42ae..bfbcfdcb72 100644 --- a/examples/specs/interactive_paintbrush_simple_true.vl.json +++ b/examples/specs/interactive_paintbrush_simple_true.vl.json @@ -1,10 +1,14 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ { "name": "toggleOrigin", - "bind": {"input": "checkbox"} + "bind": { + "input": "checkbox" + } }, { "name": "paintbrush", @@ -13,8 +17,14 @@ ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { "condition": { "param": "toggleOrigin", diff --git a/examples/specs/interactive_splom.vl.json b/examples/specs/interactive_splom.vl.json index d04683426b..843dfa58f2 100644 --- a/examples/specs/interactive_splom.vl.json +++ b/examples/specs/interactive_splom.vl.json @@ -1,11 +1,21 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "repeat": { - "row": ["Horsepower", "Acceleration", "Miles_per_Gallon"], - "column": ["Miles_per_Gallon", "Acceleration", "Horsepower"] + "row": [ + "Horsepower", + "Acceleration", + "Miles_per_Gallon" + ], + "column": [ + "Miles_per_Gallon", + "Acceleration", + "Horsepower" + ] }, "spec": { - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "mark": "point", "params": [ { @@ -30,11 +40,20 @@ } ], "encoding": { - "x": {"field": {"repeat": "column"}, "type": "quantitative"}, + "x": { + "field": { + "repeat": "column" + }, + "type": "quantitative" + }, "y": { - "field": {"repeat": "row"}, + "field": { + "repeat": "row" + }, "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { "condition": { diff --git a/examples/specs/interactive_stocks_nearest_index.vl.json b/examples/specs/interactive_stocks_nearest_index.vl.json index e3143105b1..7f341ce564 100644 --- a/examples/specs/interactive_stocks_nearest_index.vl.json +++ b/examples/specs/interactive_stocks_nearest_index.vl.json @@ -2,16 +2,27 @@ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "width": 600, "height": 300, - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "encoding": { - "x": {"field": "date", "type": "temporal"} + "x": { + "field": "date", + "type": "temporal" + } }, "layer": [ { "mark": "line", "encoding": { - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } } }, { @@ -23,33 +34,65 @@ "on": "pointermove", "nearest": true } - }], - "mark": {"type": "point"}, + ], + "mark": { + "type": "point" + }, "encoding": { - "y": {"field": "price", "type": "quantitative"}, - "opacity": {"value": 0} + "y": { + "field": "price", + "type": "quantitative" + }, + "opacity": { + "value": 0 + } } }, { "transform": [ - {"filter": { - "and": ["index.date", {"param": "index"}] - }} + { + "filter": { + "and": [ + "index.date", + { + "param": "index" + } + ] + } + } ], "mark": "rule" }, { "transform": [ - {"filter": { - "and": ["index.date", {"param": "index"}] - }} + { + "filter": { + "and": [ + "index.date", + { + "param": "index" + } + ] + } + } ], "mark": "text", "encoding": { - "y": {"value": 10}, - "text": {"field": "date", "type": "temporal"} + "y": { + "value": 10 + }, + "text": { + "field": "date", + "type": "temporal" + } } } ], - "config": {"text": {"align": "right", "dx": -5, "dy": 5}} + "config": { + "text": { + "align": "right", + "dx": -5, + "dy": 5 + } + } } diff --git a/examples/specs/normalized/airport_connections_normalized.vl.json b/examples/specs/normalized/airport_connections_normalized.vl.json index 731a599ae4..584a2de932 100644 --- a/examples/specs/normalized/airport_connections_normalized.vl.json +++ b/examples/specs/normalized/airport_connections_normalized.vl.json @@ -11,44 +11,87 @@ }, "data": { "url": "data/us-10m.json", - "format": {"type": "topojson", "feature": "states"} + "format": { + "type": "topojson", + "feature": "states" + } }, - "projection": {"type": "albersUsa"} + "projection": { + "type": "albersUsa" + } }, { - "mark": {"type": "rule", "color": "#000", "opacity": 0.35}, - "data": {"url": "data/flights-airport.csv"}, + "mark": { + "type": "rule", + "color": "#000", + "opacity": 0.35 + }, + "data": { + "url": "data/flights-airport.csv" + }, "encoding": { - "latitude": {"field": "latitude"}, - "longitude": {"field": "longitude"}, - "latitude2": {"field": "lat2"}, - "longitude2": {"field": "lon2"} + "latitude": { + "field": "latitude" + }, + "longitude": { + "field": "longitude" + }, + "latitude2": { + "field": "lat2" + }, + "longitude2": { + "field": "lon2" + } }, "transform": [ - {"filter": {"param": "org", "empty": false}}, + { + "filter": { + "param": "org", + "empty": false + } + }, { "lookup": "origin", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["latitude", "longitude"] + "fields": [ + "latitude", + "longitude" + ] } }, { "lookup": "destination", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["latitude", "longitude"] + "fields": [ + "latitude", + "longitude" + ] }, - "as": ["lat2", "lon2"] + "as": [ + "lat2", + "lon2" + ] } ], - "projection": {"type": "albersUsa"} + "projection": { + "type": "albersUsa" + } }, { - "mark": {"type": "circle"}, - "data": {"url": "data/flights-airport.csv"}, + "mark": { + "type": "circle" + }, + "data": { + "url": "data/flights-airport.csv" + }, "params": [ { "name": "org", @@ -56,36 +99,67 @@ "type": "point", "on": "pointerover", "nearest": true, - "fields": ["origin"] + "fields": [ + "origin" + ] } } ], "encoding": { - "latitude": {"field": "latitude"}, - "longitude": {"field": "longitude"}, + "latitude": { + "field": "latitude" + }, + "longitude": { + "field": "longitude" + }, "size": { "field": "routes", "type": "quantitative", - "scale": {"rangeMax": 1000}, + "scale": { + "rangeMax": 1000 + }, "legend": null }, - "order": {"field": "routes", "sort": "descending"} + "order": { + "field": "routes", + "sort": "descending" + } }, "transform": [ - {"aggregate": [{"op": "count", "as": "routes"}], "groupby": ["origin"]}, + { + "aggregate": [ + { + "op": "count", + "as": "routes" + } + ], + "groupby": [ + "origin" + ] + }, { "lookup": "origin", "from": { - "data": {"url": "data/airports.csv"}, + "data": { + "url": "data/airports.csv" + }, "key": "iata", - "fields": ["state", "latitude", "longitude"] + "fields": [ + "state", + "latitude", + "longitude" + ] } }, - {"filter": "datum.state !== 'PR' && datum.state !== 'VI'"} + { + "filter": "datum.state !== 'PR' && datum.state !== 'VI'" + } ], - "projection": {"type": "albersUsa"} + "projection": { + "type": "albersUsa" + } } ], "width": 900, "height": 500 -} \ No newline at end of file +} diff --git a/examples/specs/normalized/concat_hover_filter_normalized.vl.json b/examples/specs/normalized/concat_hover_filter_normalized.vl.json index 94ebea2af3..6c104722f6 100644 --- a/examples/specs/normalized/concat_hover_filter_normalized.vl.json +++ b/examples/specs/normalized/concat_hover_filter_normalized.vl.json @@ -1,7 +1,9 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Drag out a rectangular brush to highlight points.", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "hconcat": [ { "layer": [ @@ -11,16 +13,38 @@ ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"} + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + } } }, { - "mark": {"type": "point", "color": "goldenrod"}, - "transform": [{"filter": {"param": "hover", "empty": false}}], + "mark": { + "type": "point", + "color": "goldenrod" + }, + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"} + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + } } } ] @@ -33,19 +57,41 @@ ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Acceleration", "type": "quantitative"} + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Acceleration", + "type": "quantitative" + } } }, { - "mark": {"type": "point", "color": "goldenrod"}, - "transform": [{"filter": {"param": "hover", "empty": false}}], + "mark": { + "type": "point", + "color": "goldenrod" + }, + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Acceleration", "type": "quantitative"} + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Acceleration", + "type": "quantitative" + } } } ] } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_global_development_normalized.vl.json b/examples/specs/normalized/interactive_global_development_normalized.vl.json index 9338c9f947..8bd7f9b5e6 100644 --- a/examples/specs/normalized/interactive_global_development_normalized.vl.json +++ b/examples/specs/normalized/interactive_global_development_normalized.vl.json @@ -1,7 +1,9 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "An interactive scatter plot of global health statistics by country and year.", - "data": {"url": "data/gapminder.json"}, + "data": { + "url": "data/gapminder.json" + }, "width": 800, "height": 500, "layer": [ @@ -13,10 +15,23 @@ "y": 250, "opacity": 0.06 }, - "encoding": {"text": {"field": "year"}}, + "encoding": { + "text": { + "field": "year" + } + }, "transform": [ - {"filter": {"field": "country", "equal": "Afghanistan"}}, - {"filter": {"param": "year"}} + { + "filter": { + "field": "country", + "equal": "Afghanistan" + } + }, + { + "filter": { + "param": "year" + } + } ] }, { @@ -32,24 +47,50 @@ "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } + }, + "detail": { + "field": "country" + }, + "order": { + "field": "year" }, - "detail": {"field": "country"}, - "order": {"field": "year"}, "opacity": { "condition": { "value": 0.8, "test": { "or": [ - {"param": "hovered", "empty": false}, - {"param": "clicked", "empty": false} + { + "param": "hovered", + "empty": false + }, + { + "param": "clicked", + "empty": false + } ] } }, @@ -61,8 +102,17 @@ "params": [ { "name": "year", - "value": [{"year": 1955}], - "select": {"type": "point", "fields": ["year"]}, + "value": [ + { + "year": 1955 + } + ], + "select": { + "type": "point", + "fields": [ + "year" + ] + }, "bind": { "name": "Year", "input": "range", @@ -75,33 +125,69 @@ "name": "hovered", "select": { "type": "point", - "fields": ["country"], + "fields": [ + "country" + ], "toggle": false, "on": "pointerover" } }, { "name": "clicked", - "select": {"type": "point", "fields": ["country"]} + "select": { + "type": "point", + "fields": [ + "country" + ] + } } ], - "mark": {"type": "circle", "size": 100, "opacity": 0.9}, + "mark": { + "type": "circle", + "size": 100, + "opacity": 0.9 + }, "encoding": { "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } }, - "color": {"field": "name", "title": "Region"} + "color": { + "field": "name", + "title": "Region" + } }, - "transform": [{"filter": {"param": "year"}}] + "transform": [ + { + "filter": { + "param": "year" + } + } + ] }, { "mark": { @@ -114,27 +200,56 @@ "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } }, - "text": {"field": "country"}, - "color": {"field": "name", "title": "Region"} + "text": { + "field": "country" + }, + "color": { + "field": "name", + "title": "Region" + } }, "transform": [ { "filter": { "and": [ - {"param": "year"}, + { + "param": "year" + }, { "or": [ - {"param": "clicked", "empty": false}, - {"param": "hovered", "empty": false} + { + "param": "clicked", + "empty": false + }, + { + "param": "hovered", + "empty": false + } ] } ] @@ -155,39 +270,87 @@ "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } }, - "text": {"field": "year"} + "text": { + "field": "year" + } } }, { - "mark": {"type": "circle", "color": "gray"}, + "mark": { + "type": "circle", + "color": "gray" + }, "encoding": { "x": { "field": "fertility", "type": "quantitative", - "scale": {"domain": [0, 9]}, - "axis": {"tickCount": 5, "title": "Fertility"} + "scale": { + "domain": [ + 0, + 9 + ] + }, + "axis": { + "tickCount": 5, + "title": "Fertility" + } }, "y": { "field": "life_expect", "type": "quantitative", - "scale": {"domain": [20, 85]}, - "axis": {"tickCount": 5, "title": "Life Expectancy"} + "scale": { + "domain": [ + 20, + 85 + ] + }, + "axis": { + "tickCount": 5, + "title": "Life Expectancy" + } } } } ], "transform": [ - {"filter": {"param": "hovered", "empty": false}}, - {"filter": {"not": {"param": "year"}}} + { + "filter": { + "param": "hovered", + "empty": false + } + }, + { + "filter": { + "not": { + "param": "year" + } + } + } ] } ], @@ -196,15 +359,35 @@ "lookup": "cluster", "from": { "key": "id", - "fields": ["name"], + "fields": [ + "name" + ], "data": { "values": [ - {"id": 0, "name": "South Asia"}, - {"id": 1, "name": "Europe & Central Asia"}, - {"id": 2, "name": "Sub-Saharan Africa"}, - {"id": 3, "name": "America"}, - {"id": 4, "name": "East Asia & Pacific"}, - {"id": 5, "name": "Middle East & North Africa"} + { + "id": 0, + "name": "South Asia" + }, + { + "id": 1, + "name": "Europe & Central Asia" + }, + { + "id": 2, + "name": "Sub-Saharan Africa" + }, + { + "id": 3, + "name": "America" + }, + { + "id": 4, + "name": "East Asia & Pacific" + }, + { + "id": 5, + "name": "Middle East & North Africa" + } ] } } @@ -212,4 +395,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_index_chart_normalized.vl.json b/examples/specs/normalized/interactive_index_chart_normalized.vl.json index 58f2a560ef..a37968ef8d 100644 --- a/examples/specs/normalized/interactive_index_chart_normalized.vl.json +++ b/examples/specs/normalized/interactive_index_chart_normalized.vl.json @@ -1,6 +1,13 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/stocks.csv", "format": {"parse": {"date": "date"}}}, + "data": { + "url": "data/stocks.csv", + "format": { + "parse": { + "date": "date" + } + } + }, "width": 650, "height": 300, "layer": [ @@ -8,7 +15,15 @@ "params": [ { "name": "index", - "value": [{"x": {"year": 2005, "month": 1, "date": 1}}], + "value": [ + { + "x": { + "year": 2005, + "month": 1, + "date": 1 + } + } + ], "select": { "type": "point", "encodings": ["x"], @@ -19,23 +34,44 @@ ], "mark": "point", "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, - "opacity": {"value": 0} + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, + "opacity": { + "value": 0 + } } }, { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, "y": { "field": "indexed_price", "type": "quantitative", - "axis": {"format": "%"} + "axis": { + "format": "%" + } }, - "color": {"field": "symbol", "type": "nominal"} + "color": { + "field": "symbol", + "type": "nominal" + } }, "transform": [ - {"lookup": "symbol", "from": {"param": "index", "key": "symbol"}}, + { + "lookup": "symbol", + "from": { + "param": "index", + "key": "symbol" + } + }, { "calculate": "datum.index && datum.index.price > 0 ? (datum.price - datum.index.price)/datum.index.price : 0", "as": "indexed_price" @@ -45,23 +81,53 @@ { "layer": [ { - "mark": {"type": "rule", "strokeWidth": 0.5}, + "mark": { + "type": "rule", + "strokeWidth": 0.5 + }, "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, - "color": {"value": "firebrick"} + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, + "color": { + "value": "firebrick" + } } }, { - "mark": {"type": "text", "align": "center", "fontWeight": 100}, + "mark": { + "type": "text", + "align": "center", + "fontWeight": 100 + }, "encoding": { - "x": {"field": "date", "type": "temporal", "axis": null}, - "color": {"value": "firebrick"}, - "text": {"field": "date", "timeUnit": "yearmonth"}, - "y": {"value": 310} + "x": { + "field": "date", + "type": "temporal", + "axis": null + }, + "color": { + "value": "firebrick" + }, + "text": { + "field": "date", + "timeUnit": "yearmonth" + }, + "y": { + "value": 310 + } } } ], - "transform": [{"filter": {"param": "index"}}] + "transform": [ + { + "filter": { + "param": "index" + } + } + ] } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_line_hover_normalized.vl.json b/examples/specs/normalized/interactive_line_hover_normalized.vl.json index f1ef97fbf6..648526b2c1 100644 --- a/examples/specs/normalized/interactive_line_hover_normalized.vl.json +++ b/examples/specs/normalized/interactive_line_hover_normalized.vl.json @@ -1,7 +1,9 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Multi-series line chart with labels and interactive highlight on hover. We also set the selection's initial value to provide a better screenshot", - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "layer": [ { "description": "transparent layer to make it easier to trigger selection", @@ -12,10 +14,22 @@ "select": {"type": "point", "fields": ["symbol"], "on": "pointerover"} } ], - "mark": {"type": "line", "strokeWidth": 8, "stroke": "transparent"}, + "mark": { + "type": "line", + "strokeWidth": 8, + "stroke": "transparent" + }, "encoding": { - "x": {"field": "date", "type": "temporal", "title": "date"}, - "y": {"field": "price", "type": "quantitative", "title": "price"}, + "x": { + "field": "date", + "type": "temporal", + "title": "date" + }, + "y": { + "field": "price", + "type": "quantitative", + "title": "price" + }, "color": { "condition": { "param": "hover", @@ -25,14 +39,28 @@ }, "value": "grey" }, - "opacity": {"condition": {"param": "hover", "value": 1}, "value": 0.2} + "opacity": { + "condition": { + "param": "hover", + "value": 1 + }, + "value": 0.2 + } } }, { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal", "title": "date"}, - "y": {"field": "price", "type": "quantitative", "title": "price"}, + "x": { + "field": "date", + "type": "temporal", + "title": "date" + }, + "y": { + "field": "price", + "type": "quantitative", + "title": "price" + }, "color": { "condition": { "param": "hover", @@ -42,13 +70,21 @@ }, "value": "grey" }, - "opacity": {"condition": {"param": "hover", "value": 1}, "value": 0.2} + "opacity": { + "condition": { + "param": "hover", + "value": 1 + }, + "value": 0.2 + } } }, { "layer": [ { - "mark": {"type": "circle"}, + "mark": { + "type": "circle" + }, "encoding": { "x": { "field": "date", @@ -60,7 +96,9 @@ "field": "price", "type": "quantitative", "title": "price", - "aggregate": {"argmax": "date"} + "aggregate": { + "argmax": "date" + } }, "color": { "condition": { @@ -72,13 +110,20 @@ "value": "grey" }, "opacity": { - "condition": {"param": "hover", "value": 1}, + "condition": { + "param": "hover", + "value": 1 + }, "value": 0.2 } } }, { - "mark": {"type": "text", "align": "left", "dx": 4}, + "mark": { + "type": "text", + "align": "left", + "dx": 4 + }, "encoding": { "x": { "field": "date", @@ -90,7 +135,9 @@ "field": "price", "type": "quantitative", "title": "price", - "aggregate": {"argmax": "date"} + "aggregate": { + "argmax": "date" + } }, "color": { "condition": { @@ -102,15 +149,29 @@ "value": "grey" }, "opacity": { - "condition": {"param": "hover", "value": 1}, + "condition": { + "param": "hover", + "value": 1 + }, "value": 0.2 }, - "text": {"field": "symbol", "type": "nominal"} + "text": { + "field": "symbol", + "type": "nominal" + } } } ] } ], - "config": {"view": {"stroke": null}}, - "transform": [{"filter": "datum.symbol!=='IBM'"}] -} \ No newline at end of file + "config": { + "view": { + "stroke": null + } + }, + "transform": [ + { + "filter": "datum.symbol!=='IBM'" + } + ] +} diff --git a/examples/specs/normalized/interactive_line_point_hover_normalized.vl.json b/examples/specs/normalized/interactive_line_point_hover_normalized.vl.json index e20f6158be..4bb5d0ea93 100644 --- a/examples/specs/normalized/interactive_line_point_hover_normalized.vl.json +++ b/examples/specs/normalized/interactive_line_point_hover_normalized.vl.json @@ -1,14 +1,25 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Stock prices of 5 Tech Companies over Time, with a point marker on hover. Note that the hidden markers are intentionally bigger to make it easier for readers to hover.", - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "layer": [ { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } } }, { @@ -22,23 +33,44 @@ } } ], - "mark": {"type": "circle", "tooltip": true}, + "mark": { + "type": "circle", + "tooltip": true + }, "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"}, + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + }, "opacity": { - "condition": {"value": 1, "test": {"param": "hover", "empty": false}}, + "condition": { + "value": 1, + "test": { + "param": "hover", + "empty": false + } + }, "value": 0 }, "size": { "condition": { "value": 48, - "test": {"param": "hover", "empty": false} + "test": { + "param": "hover", + "empty": false + } }, "value": 100 } } } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_multi_line_label_normalized.vl.json b/examples/specs/normalized/interactive_multi_line_label_normalized.vl.json index 67a5af7496..591bf4e423 100644 --- a/examples/specs/normalized/interactive_multi_line_label_normalized.vl.json +++ b/examples/specs/normalized/interactive_multi_line_label_normalized.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "width": 400, "height": 300, "layer": [ @@ -9,9 +11,18 @@ { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } } }, { @@ -20,7 +31,9 @@ "name": "label", "select": { "type": "point", - "encodings": ["x"], + "encodings": [ + "x" + ], "nearest": true, "on": "pointerover" } @@ -28,11 +41,24 @@ ], "mark": "point", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"}, + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + }, "opacity": { - "condition": {"param": "label", "empty": false, "value": 1}, + "condition": { + "param": "label", + "empty": false, + "value": 1 + }, "value": 0 } } @@ -42,9 +68,16 @@ { "layer": [ { - "mark": {"type": "rule", "color": "gray"}, + "mark": { + "type": "rule", + "color": "gray" + }, "encoding": { - "x": {"type": "temporal", "field": "date", "aggregate": "min"} + "x": { + "type": "temporal", + "field": "date", + "aggregate": "min" + } } }, { @@ -59,24 +92,57 @@ "dy": -5 }, "encoding": { - "text": {"type": "quantitative", "field": "price"}, - "x": {"type": "temporal", "field": "date"}, - "y": {"type": "quantitative", "field": "price"} + "text": { + "type": "quantitative", + "field": "price" + }, + "x": { + "type": "temporal", + "field": "date" + }, + "y": { + "type": "quantitative", + "field": "price" + } } }, { - "mark": {"type": "text", "align": "left", "dx": 5, "dy": -5}, + "mark": { + "type": "text", + "align": "left", + "dx": 5, + "dy": -5 + }, "encoding": { - "text": {"type": "quantitative", "field": "price"}, - "x": {"type": "temporal", "field": "date"}, - "y": {"type": "quantitative", "field": "price"}, - "color": {"type": "nominal", "field": "symbol"} + "text": { + "type": "quantitative", + "field": "price" + }, + "x": { + "type": "temporal", + "field": "date" + }, + "y": { + "type": "quantitative", + "field": "price" + }, + "color": { + "type": "nominal", + "field": "symbol" + } } } ] } ], - "transform": [{"filter": {"param": "label", "empty": false}}] + "transform": [ + { + "filter": { + "param": "label", + "empty": false + } + } + ] } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_multi_line_pivot_tooltip_normalized.vl.json b/examples/specs/normalized/interactive_multi_line_pivot_tooltip_normalized.vl.json index 0f61fff482..0fa4a618b5 100644 --- a/examples/specs/normalized/interactive_multi_line_pivot_tooltip_normalized.vl.json +++ b/examples/specs/normalized/interactive_multi_line_pivot_tooltip_normalized.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "width": 400, "height": 300, "layer": [ @@ -9,18 +11,43 @@ { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "color": {"field": "symbol", "type": "nominal"}, - "y": {"field": "price", "type": "quantitative"} + "x": { + "field": "date", + "type": "temporal" + }, + "color": { + "field": "symbol", + "type": "nominal" + }, + "y": { + "field": "price", + "type": "quantitative" + } } }, { "mark": "point", - "transform": [{"filter": {"param": "hover", "empty": false}}], + "transform": [ + { + "filter": { + "param": "hover", + "empty": false + } + } + ], "encoding": { - "x": {"field": "date", "type": "temporal"}, - "color": {"field": "symbol", "type": "nominal"}, - "y": {"field": "price", "type": "quantitative"} + "x": { + "field": "date", + "type": "temporal" + }, + "color": { + "field": "symbol", + "type": "nominal" + }, + "y": { + "field": "price", + "type": "quantitative" + } } } ] @@ -28,17 +55,39 @@ { "mark": "rule", "encoding": { - "x": {"field": "date", "type": "temporal"}, + "x": { + "field": "date", + "type": "temporal" + }, "opacity": { - "condition": {"value": 0.3, "param": "hover", "empty": false}, + "condition": { + "value": 0.3, + "param": "hover", + "empty": false + }, "value": 0 }, "tooltip": [ - {"field": "AAPL", "type": "quantitative"}, - {"field": "AMZN", "type": "quantitative"}, - {"field": "GOOG", "type": "quantitative"}, - {"field": "IBM", "type": "quantitative"}, - {"field": "MSFT", "type": "quantitative"} + { + "field": "AAPL", + "type": "quantitative" + }, + { + "field": "AMZN", + "type": "quantitative" + }, + { + "field": "GOOG", + "type": "quantitative" + }, + { + "field": "IBM", + "type": "quantitative" + }, + { + "field": "MSFT", + "type": "quantitative" + } ] }, "params": [ @@ -46,14 +95,24 @@ "name": "hover", "select": { "type": "point", - "fields": ["date"], + "fields": [ + "date" + ], "nearest": true, "on": "pointerover", "clear": "pointerout" } } ], - "transform": [{"pivot": "symbol", "value": "price", "groupby": ["date"]}] + "transform": [ + { + "pivot": "symbol", + "value": "price", + "groupby": [ + "date" + ] + } + ] } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_multi_line_tooltip_normalized.vl.json b/examples/specs/normalized/interactive_multi_line_tooltip_normalized.vl.json index d2dd6225ac..c10f13fed3 100644 --- a/examples/specs/normalized/interactive_multi_line_tooltip_normalized.vl.json +++ b/examples/specs/normalized/interactive_multi_line_tooltip_normalized.vl.json @@ -1,29 +1,67 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/seattle-weather.csv"}, + "data": { + "url": "data/seattle-weather.csv" + }, "layer": [ { - "mark": {"type": "line", "color": "orange"}, + "mark": { + "type": "line", + "color": "orange" + }, "encoding": { - "x": {"timeUnit": "yearmonthdate", "field": "date"}, + "x": { + "timeUnit": "yearmonthdate", + "field": "date" + }, "tooltip": [ - {"timeUnit": "yearmonthdate", "field": "date"}, - {"field": "temp_max", "type": "quantitative"}, - {"field": "temp_min", "type": "quantitative"} + { + "timeUnit": "yearmonthdate", + "field": "date" + }, + { + "field": "temp_max", + "type": "quantitative" + }, + { + "field": "temp_min", + "type": "quantitative" + } ], - "y": {"field": "temp_max", "type": "quantitative"} + "y": { + "field": "temp_max", + "type": "quantitative" + } } }, { - "mark": {"type": "line", "color": "red"}, + "mark": { + "type": "line", + "color": "red" + }, "encoding": { - "x": {"timeUnit": "yearmonthdate", "field": "date"}, + "x": { + "timeUnit": "yearmonthdate", + "field": "date" + }, "tooltip": [ - {"timeUnit": "yearmonthdate", "field": "date"}, - {"field": "temp_max", "type": "quantitative"}, - {"field": "temp_min", "type": "quantitative"} + { + "timeUnit": "yearmonthdate", + "field": "date" + }, + { + "field": "temp_max", + "type": "quantitative" + }, + { + "field": "temp_min", + "type": "quantitative" + } ], - "y": {"field": "temp_min", "type": "quantitative"} + "y": { + "field": "temp_min", + "type": "quantitative" + } } }, { @@ -32,18 +70,38 @@ {"name": "hover", "select": {"type": "point", "on": "pointerover"}} ], "encoding": { - "x": {"timeUnit": "yearmonthdate", "field": "date"}, + "x": { + "timeUnit": "yearmonthdate", + "field": "date" + }, "tooltip": [ - {"timeUnit": "yearmonthdate", "field": "date"}, - {"field": "temp_max", "type": "quantitative"}, - {"field": "temp_min", "type": "quantitative"} + { + "timeUnit": "yearmonthdate", + "field": "date" + }, + { + "field": "temp_max", + "type": "quantitative" + }, + { + "field": "temp_min", + "type": "quantitative" + } ], "color": { - "condition": {"param": "hover", "empty": false, "value": "black"}, + "condition": { + "param": "hover", + "empty": false, + "value": "black" + }, "value": "transparent" } } } ], - "config": {"axisY": {"minExtent": 30}} -} \ No newline at end of file + "config": { + "axisY": { + "minExtent": 30 + } + } +} diff --git a/examples/specs/normalized/interactive_splom_normalized.vl.json b/examples/specs/normalized/interactive_splom_normalized.vl.json index 07b31425bf..58b65eff67 100644 --- a/examples/specs/normalized/interactive_splom_normalized.vl.json +++ b/examples/specs/normalized/interactive_splom_normalized.vl.json @@ -1,5 +1,7 @@ { - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "align": "all", "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "columns": 3, @@ -29,14 +31,23 @@ } ], "encoding": { - "x": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "y": { "field": "Horsepower", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -67,14 +78,23 @@ } ], "encoding": { - "x": {"field": "Acceleration", "type": "quantitative"}, + "x": { + "field": "Acceleration", + "type": "quantitative" + }, "y": { "field": "Horsepower", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -105,14 +125,23 @@ } ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, "y": { "field": "Horsepower", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -143,14 +172,23 @@ } ], "encoding": { - "x": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "y": { "field": "Acceleration", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -181,14 +219,23 @@ } ], "encoding": { - "x": {"field": "Acceleration", "type": "quantitative"}, + "x": { + "field": "Acceleration", + "type": "quantitative" + }, "y": { "field": "Acceleration", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -219,14 +266,23 @@ } ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, "y": { "field": "Acceleration", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -257,14 +313,23 @@ } ], "encoding": { - "x": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "y": { "field": "Miles_per_Gallon", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -295,14 +360,23 @@ } ], "encoding": { - "x": {"field": "Acceleration", "type": "quantitative"}, + "x": { + "field": "Acceleration", + "type": "quantitative" + }, "y": { "field": "Miles_per_Gallon", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, @@ -333,18 +407,27 @@ } ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, "y": { "field": "Miles_per_Gallon", "type": "quantitative", - "axis": {"minExtent": 30} + "axis": { + "minExtent": 30 + } }, "color": { - "condition": {"param": "brush", "field": "Origin", "type": "nominal"}, + "condition": { + "param": "brush", + "field": "Origin", + "type": "nominal" + }, "value": "grey" } }, "name": "child__row_Miles_per_Galloncolumn_Horsepower" } ] -} \ No newline at end of file +} diff --git a/examples/specs/normalized/interactive_stocks_nearest_index_normalized.vl.json b/examples/specs/normalized/interactive_stocks_nearest_index_normalized.vl.json index 37ad5678fb..9450c8262f 100644 --- a/examples/specs/normalized/interactive_stocks_nearest_index_normalized.vl.json +++ b/examples/specs/normalized/interactive_stocks_nearest_index_normalized.vl.json @@ -2,14 +2,25 @@ "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "width": 600, "height": 300, - "data": {"url": "data/stocks.csv"}, + "data": { + "url": "data/stocks.csv" + }, "layer": [ { "mark": "line", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "color": {"field": "symbol", "type": "nominal"} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "color": { + "field": "symbol", + "type": "nominal" + } } }, { @@ -24,27 +35,78 @@ } } ], - "mark": {"type": "point"}, + "mark": { + "type": "point" + }, "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"field": "price", "type": "quantitative"}, - "opacity": {"value": 0} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "field": "price", + "type": "quantitative" + }, + "opacity": { + "value": 0 + } } }, { "mark": "rule", - "transform": [{"filter": {"and": ["index.date", {"param": "index"}]}}], - "encoding": {"x": {"field": "date", "type": "temporal"}} + "transform": [ + { + "filter": { + "and": [ + "index.date", + { + "param": "index" + } + ] + } + } + ], + "encoding": { + "x": { + "field": "date", + "type": "temporal" + } + } }, { "mark": "text", "encoding": { - "x": {"field": "date", "type": "temporal"}, - "y": {"value": 10}, - "text": {"field": "date", "type": "temporal"} + "x": { + "field": "date", + "type": "temporal" + }, + "y": { + "value": 10 + }, + "text": { + "field": "date", + "type": "temporal" + } }, - "transform": [{"filter": {"and": ["index.date", {"param": "index"}]}}] + "transform": [ + { + "filter": { + "and": [ + "index.date", + { + "param": "index" + } + ] + } + } + ] } ], - "config": {"text": {"align": "right", "dx": -5, "dy": 5}} -} \ No newline at end of file + "config": { + "text": { + "align": "right", + "dx": -5, + "dy": 5 + } + } +} diff --git a/examples/specs/normalized/trellis_selections_normalized.vl.json b/examples/specs/normalized/trellis_selections_normalized.vl.json index 05e1afc7a5..aa443bb942 100644 --- a/examples/specs/normalized/trellis_selections_normalized.vl.json +++ b/examples/specs/normalized/trellis_selections_normalized.vl.json @@ -1,26 +1,57 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Anscombe's Quartet", - "data": {"url": "data/anscombe.json"}, - "facet": {"column": {"field": "Series"}}, + "data": { + "url": "data/anscombe.json" + }, + "facet": { + "column": { + "field": "Series" + } + }, "spec": { "mark": "circle", "encoding": { - "x": {"field": "X", "type": "quantitative", "scale": {"zero": false}}, - "y": {"field": "Y", "type": "quantitative", "scale": {"zero": false}}, - "size": {"value": 100, "condition": {"param": "brush", "value": 250}}, + "x": { + "field": "X", + "type": "quantitative", + "scale": { + "zero": false + } + }, + "y": { + "field": "Y", + "type": "quantitative", + "scale": { + "zero": false + } + }, + "size": { + "value": 100, + "condition": { + "param": "brush", + "value": 250 + } + }, "color": { "value": "steelblue", - "condition": {"param": "xenc", "value": "red"} + "condition": { + "param": "xenc", + "value": "red" + } }, - "opacity": {"value": 1} + "opacity": { + "value": 1 + } }, "params": [ { "name": "brush", "select": { "type": "interval", - "encodings": ["x"], + "encodings": [ + "x" + ], "resolve": "intersect", "on": "[pointerdown[event.shiftKey], pointerup] > pointermove", "translate": "[pointerdown[event.shiftKey], pointerup] > pointermove" @@ -39,13 +70,17 @@ "name": "xenc", "select": { "type": "point", - "fields": ["X"], + "fields": [ + "X" + ], "resolve": "global", "on": "pointerover", "nearest": true }, - "bind": {"input": "number"} + "bind": { + "input": "number" + } } ] } -} \ No newline at end of file +} diff --git a/examples/specs/selection_clear_brush.vl.json b/examples/specs/selection_clear_brush.vl.json index c4ad9e7889..fccd974184 100644 --- a/examples/specs/selection_clear_brush.vl.json +++ b/examples/specs/selection_clear_brush.vl.json @@ -8,10 +8,20 @@ }], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { - "condition": {"param": "brush", "field": "Cylinders", "type": "ordinal"}, + "condition": { + "param": "brush", + "field": "Cylinders", + "type": "ordinal" + }, "value": "grey" } } diff --git a/examples/specs/selection_composition_and.vl.json b/examples/specs/selection_composition_and.vl.json index b0f96323ad..d4fa0deb4a 100644 --- a/examples/specs/selection_composition_and.vl.json +++ b/examples/specs/selection_composition_and.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ { "name": "alex", @@ -22,14 +24,26 @@ ], "mark": "rect", "encoding": { - "y": {"field": "Origin", "type": "ordinal"}, - "x": {"field": "Cylinders", "type": "ordinal"}, + "y": { + "field": "Origin", + "type": "ordinal" + }, + "x": { + "field": "Cylinders", + "type": "ordinal" + }, "color": { "condition": { - "test": {"and": [ - {"param": "alex"}, - {"param": "morgan"} - ]}, + "test": { + "and": [ + { + "param": "alex" + }, + { + "param": "morgan" + } + ] + }, "aggregate": "count" }, "value": "grey" diff --git a/examples/specs/selection_composition_or.vl.json b/examples/specs/selection_composition_or.vl.json index 229401a885..f4c8b0514a 100644 --- a/examples/specs/selection_composition_or.vl.json +++ b/examples/specs/selection_composition_or.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ { "name": "alex", @@ -22,14 +24,26 @@ ], "mark": "rect", "encoding": { - "y": {"field": "Origin", "type": "ordinal"}, - "x": {"field": "Cylinders", "type": "ordinal"}, + "y": { + "field": "Origin", + "type": "ordinal" + }, + "x": { + "field": "Cylinders", + "type": "ordinal" + }, "color": { "condition": { - "test": {"or": [ - {"param": "alex"}, - {"param": "morgan"} - ]}, + "test": { + "or": [ + { + "param": "alex" + }, + { + "param": "morgan" + } + ] + }, "aggregate": "count" }, "value": "grey" diff --git a/examples/specs/selection_interval_mark_style.vl.json b/examples/specs/selection_interval_mark_style.vl.json index 2d3602652a..d5b79897f5 100644 --- a/examples/specs/selection_interval_mark_style.vl.json +++ b/examples/specs/selection_interval_mark_style.vl.json @@ -1,6 +1,8 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ { "name": "alex", @@ -22,8 +24,14 @@ ], "mark": "rect", "encoding": { - "y": {"field": "Origin"}, - "x": {"field": "Cylinders"}, - "color": {"aggregate": "count"} + "y": { + "field": "Origin" + }, + "x": { + "field": "Cylinders" + }, + "color": { + "aggregate": "count" + } } } diff --git a/examples/specs/selection_layer.json b/examples/specs/selection_layer.json index c26ebe3dbc..1ede44fc89 100644 --- a/examples/specs/selection_layer.json +++ b/examples/specs/selection_layer.json @@ -1,7 +1,9 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Drag out a rectangular brush to highlight points.", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "layer": [ { "params": [ @@ -15,20 +17,41 @@ }, { "name": "cyl", - "select": {"type": "point", "fields": ["Cylinders"]}, - "bind": {"input": "range", "min": 3, "max": 8, "step": 1} + "select": { + "type": "point", + "fields": [ + "Cylinders" + ] + }, + "bind": { + "input": "range", + "min": 3, + "max": 8, + "step": 1 + } } ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { - "condition": {"param": "brush", "value": "grey"}, + "condition": { + "param": "brush", + "value": "grey" + }, "field": "Cylinders", "type": "ordinal" }, - "size": {"value": 100} + "size": { + "value": 100 + } } }, { @@ -44,10 +67,20 @@ } ], "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { - "condition": {"param": "brush", "field": "Cylinders", "type": "ordinal"}, + "condition": { + "param": "brush", + "field": "Cylinders", + "type": "ordinal" + }, "value": "grey" }, "size": { diff --git a/examples/specs/selection_multi_condition.vl.json b/examples/specs/selection_multi_condition.vl.json index 98334d62cd..aa8b057df5 100644 --- a/examples/specs/selection_multi_condition.vl.json +++ b/examples/specs/selection_multi_condition.vl.json @@ -1,9 +1,14 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Drag out a rectangular brush to highlight points.", - "data": {"url": "data/cars.json"}, + "data": { + "url": "data/cars.json" + }, "params": [ - {"name": "brush", "select": "interval"}, + { + "name": "brush", + "select": "interval" + }, { "name": "hoverbrush", "select": { @@ -14,12 +19,24 @@ ], "mark": "point", "encoding": { - "x": {"field": "Horsepower", "type": "quantitative"}, - "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, + "x": { + "field": "Horsepower", + "type": "quantitative" + }, + "y": { + "field": "Miles_per_Gallon", + "type": "quantitative" + }, "color": { "condition": [ - {"param": "hoverbrush", "value": "teal"}, - {"param": "brush", "value": "skyblue"} + { + "param": "hoverbrush", + "value": "teal" + }, + { + "param": "brush", + "value": "skyblue" + } ], "value": "grey" } diff --git a/examples/specs/selection_translate_brush_shift-drag.vl.json b/examples/specs/selection_translate_brush_shift-drag.vl.json index f94e82f27e..71231bff6a 100644 --- a/examples/specs/selection_translate_brush_shift-drag.vl.json +++ b/examples/specs/selection_translate_brush_shift-drag.vl.json @@ -7,22 +7,41 @@ "type": "interval", "translate": "[pointerdown[event.shiftKey], window:pointerup] > window:pointermove!" } - }], - "mark": {"type": "circle", "clip": true}, + ], + "mark": { + "type": "circle", + "clip": true + }, "encoding": { "x": { - "field": "Horsepower", "type": "quantitative", - "scale": {"domain": [75, 150]} + "field": "Horsepower", + "type": "quantitative", + "scale": { + "domain": [ + 75, + 150 + ] + } }, "y": { - "field": "Miles_per_Gallon", "type": "quantitative", - "scale": {"domain": [20, 40]} + "field": "Miles_per_Gallon", + "type": "quantitative", + "scale": { + "domain": [ + 20, + 40 + ] + } + }, + "size": { + "field": "Cylinders", + "type": "quantitative" }, - "size": {"field": "Cylinders", "type": "quantitative"}, "color": { "condition": { "param": "brush", - "field": "Origin", "type": "nominal" + "field": "Origin", + "type": "nominal" }, "value": "grey" } diff --git a/examples/specs/selection_translate_scatterplot_shift-drag.vl.json b/examples/specs/selection_translate_scatterplot_shift-drag.vl.json index 406b413233..e919d8facd 100644 --- a/examples/specs/selection_translate_scatterplot_shift-drag.vl.json +++ b/examples/specs/selection_translate_scatterplot_shift-drag.vl.json @@ -12,13 +12,28 @@ "mark": "circle", "encoding": { "x": { - "field": "Horsepower", "type": "quantitative", - "scale": {"domain": [75, 150]} + "field": "Horsepower", + "type": "quantitative", + "scale": { + "domain": [ + 75, + 150 + ] + } }, "y": { - "field": "Miles_per_Gallon", "type": "quantitative", - "scale": {"domain": [20, 40]} + "field": "Miles_per_Gallon", + "type": "quantitative", + "scale": { + "domain": [ + 20, + 40 + ] + } }, - "size": {"field": "Cylinders", "type": "quantitative"} + "size": { + "field": "Cylinders", + "type": "quantitative" + } } } diff --git a/examples/specs/selection_type_single_pointerover.vl.json b/examples/specs/selection_type_single_pointerover.vl.json index 67b0328d28..14fb0e12b3 100644 --- a/examples/specs/selection_type_single_pointerover.vl.json +++ b/examples/specs/selection_type_single_pointerover.vl.json @@ -7,8 +7,12 @@ }], "mark": "rect", "encoding": { - "y": {"field": "Origin"}, - "x": {"field": "Cylinders"}, + "y": { + "field": "Origin" + }, + "x": { + "field": "Cylinders" + }, "color": { "condition": { "param": "pts", diff --git a/examples/specs/trellis_selections.vl.json b/examples/specs/trellis_selections.vl.json index adcea7a106..e66afe2dea 100644 --- a/examples/specs/trellis_selections.vl.json +++ b/examples/specs/trellis_selections.vl.json @@ -1,14 +1,18 @@ { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "description": "Anscombe's Quartet", - "data": {"url": "data/anscombe.json"}, + "data": { + "url": "data/anscombe.json" + }, "mark": "circle", "params": [ { "name": "brush", "select": { "type": "interval", - "encodings": ["x"], + "encodings": [ + "x" + ], "resolve": "intersect", "on": "[pointerdown[event.shiftKey], pointerup] > pointermove", "translate": "[pointerdown[event.shiftKey], pointerup] > pointermove" @@ -27,29 +31,42 @@ "name": "xenc", "select": { "type": "point", - "fields": ["X"], + "fields": [ + "X" + ], "resolve": "global", "on": "pointerover", "nearest": true }, - "bind": {"input": "number"} + "bind": { + "input": "number" + } } ], "encoding": { - "column": {"field": "Series"}, + "column": { + "field": "Series" + }, "x": { "field": "X", "type": "quantitative", - "scale": {"zero": false} + "scale": { + "zero": false + } }, "y": { "field": "Y", "type": "quantitative", - "scale": {"zero": false} + "scale": { + "zero": false + } }, "size": { "value": 100, - "condition": {"param": "brush", "value": 250} + "condition": { + "param": "brush", + "value": 250 + } }, "color": { "value": "steelblue", @@ -58,6 +75,8 @@ "value": "red" } }, - "opacity": {"value": 1} + "opacity": { + "value": 1 + } } } diff --git a/site/.ruby-version b/site/.ruby-version new file mode 100644 index 0000000000..be94e6f53d --- /dev/null +++ b/site/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/site/= b/site/= new file mode 100644 index 0000000000..e69de29bb2 diff --git a/site/Gemfile.lock b/site/Gemfile.lock index bc614a8f52..f080d78ddf 100644 --- a/site/Gemfile.lock +++ b/site/Gemfile.lock @@ -261,6 +261,7 @@ PLATFORMS arm64-darwin-22 x86_64-darwin-19 x86_64-darwin-20 + x86_64-darwin-22 x86_64-linux DEPENDENCIES diff --git a/site/_data/versions.yml b/site/_data/versions.yml new file mode 100644 index 0000000000..51bb3e262a --- /dev/null +++ b/site/_data/versions.yml @@ -0,0 +1,4 @@ +vega: 5.25.0 +vega-lite: 5.15.0 +vega-embed: 6.22.2 +vega-tooltip: 0.33.0 diff --git a/src/channel.ts b/src/channel.ts index 289cc693c3..c0002bcc96 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -39,6 +39,7 @@ export const LATITUDE = 'latitude' as const; export const LONGITUDE = 'longitude' as const; export const LATITUDE2 = 'latitude2' as const; export const LONGITUDE2 = 'longitude2' as const; +export const CURSOR = 'cursor' as const; // Mark property with scale export const COLOR = 'color' as const; diff --git a/src/channeldef.ts b/src/channeldef.ts index 7f2ccb8eb7..69c540052b 100644 --- a/src/channeldef.ts +++ b/src/channeldef.ts @@ -8,6 +8,7 @@ import { Channel, COLOR, COLUMN, + // CURSOR, DESCRIPTION, DETAIL, ExtendedChannel, diff --git a/src/compile/mark/init.ts b/src/compile/mark/init.ts index 3f7379cfc9..ac7878ae29 100644 --- a/src/compile/mark/init.ts +++ b/src/compile/mark/init.ts @@ -68,7 +68,7 @@ export function initMarkdef(originalMarkDef: MarkDef, encoding: Encoding return markDef; } - +// TODO: ALLIE function cursor(markDef: MarkDef, encoding: Encoding, config: Config) { if (encoding.href || markDef.href || getMarkPropOrConfig('href', markDef, config)) { return 'pointer'; diff --git a/src/compile/selection/interval.ts b/src/compile/selection/interval.ts index cda65f2b39..27a977ad8b 100644 --- a/src/compile/selection/interval.ts +++ b/src/compile/selection/interval.ts @@ -51,6 +51,7 @@ const interval: SelectionCompiler<'interval'> = { filters.push(filterExpr); } } + selCmpt.mark.cursor = 'move'; } }, @@ -233,7 +234,7 @@ const interval: SelectionCompiler<'interval'> = { // Two brush marks ensure that fill colors and other aesthetic choices do // not interefere with the core marks, but that the brushed region can still - // be interacted with (e.g., dragging it around). + // be interacted with (e.g., ging it around). const {fill, fillOpacity, cursor, ...stroke} = selCmpt.mark; const vgStroke = keys(stroke).reduce((def, k) => { def[k] = [ diff --git a/src/encoding.ts b/src/encoding.ts index 0dafbc975e..899c815ae2 100644 --- a/src/encoding.ts +++ b/src/encoding.ts @@ -7,6 +7,7 @@ import { Channel, CHANNELS, COLOR, + // CURSOR, DESCRIPTION, DETAIL, FILL, @@ -325,6 +326,11 @@ export interface Encoding { * __Note__: In aggregate plots, `order` field should be `aggregate`d to avoid creating additional aggregation grouping. */ order?: OrderFieldDef | OrderFieldDef[] | OrderValueDef | OrderOnlyDef; + + /** + * TODO: Add description + */ + // cursor?: StringFieldDefWithCondition | StringValueDefWithCondition | StringFieldDef[] | null; } export interface EncodingWithFacet extends Encoding, EncodingFacetMapping {} diff --git a/src/selection.ts b/src/selection.ts index e607590b7c..137fb67798 100644 --- a/src/selection.ts +++ b/src/selection.ts @@ -220,10 +220,10 @@ export interface SelectionParameter { * __See also:__ [`init`](https://vega.github.io/vega-lite/docs/value.html) documentation. */ value?: T extends 'point' - ? SelectionInit | SelectionInitMapping[] - : T extends 'interval' - ? SelectionInitIntervalMapping - : never; + ? SelectionInit | SelectionInitMapping[] + : T extends 'interval' + ? SelectionInitIntervalMapping + : never; /** * When set, a selection is populated by input elements (also known as dynamic query widgets) @@ -238,10 +238,10 @@ export interface SelectionParameter { * __See also:__ [`bind`](https://vega.github.io/vega-lite/docs/bind.html) documentation. */ bind?: T extends 'point' - ? Binding | Record | LegendBinding - : T extends 'interval' - ? 'scales' - : never; + ? Binding | Record | LegendBinding + : T extends 'interval' + ? 'scales' + : never; } export type TopLevelSelectionParameter = SelectionParameter & { @@ -254,29 +254,29 @@ export type TopLevelSelectionParameter = SelectionParameter & { export type ParameterExtent = | { - /** - * The name of a parameter. - */ - param: ParameterName; - - /** - * If a selection parameter is specified, the field name to extract selected values for - * when the selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings. - */ - field?: FieldName; - } + /** + * The name of a parameter. + */ + param: ParameterName; + + /** + * If a selection parameter is specified, the field name to extract selected values for + * when the selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings. + */ + field?: FieldName; + } | { - /** - * The name of a parameter. - */ - param: ParameterName; - - /** - * If a selection parameter is specified, the encoding channel to extract selected values for - * when a selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings. - */ - encoding?: SingleDefUnitChannel; - }; + /** + * The name of a parameter. + */ + param: ParameterName; + + /** + * If a selection parameter is specified, the encoding channel to extract selected values for + * when a selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings. + */ + encoding?: SingleDefUnitChannel; + }; export type PointSelectionConfigWithoutType = Omit; diff --git a/src/spec/base.ts b/src/spec/base.ts index 578542719a..d9477e94f0 100644 --- a/src/spec/base.ts +++ b/src/spec/base.ts @@ -166,7 +166,7 @@ export interface BaseViewBackground stroke?: Color | null | ES; /** - * The mouse cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used. + * The cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used. */ cursor?: Cursor; } diff --git a/test-runtime/index.html b/test-runtime/index.html index 5b6ee43a4d..83e13bd5be 100644 --- a/test-runtime/index.html +++ b/test-runtime/index.html @@ -1,20 +1,13 @@ - - - - - -
- - + + + + +
const vgSpec = vegaLite.compile(vlSpec).spec; view = new vega.View(vega.parse(vgSpec)).renderer('svg').initialize('#vis').run(); @@ -38,18 +31,19 @@ ); } - function mark(id, parent) { - return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`); - } + target.dispatchEvent( + new PointerEvent('pointermove', { ...opts, clientX: opts.clientX + 5, clientY: opts.clientY + 5 }) + ); + } - function coords(el) { - const rect = el.getBoundingClientRect(); - return [Math.ceil(rect.left + rect.width / 2), Math.ceil(rect.top + rect.height / 2)]; - } + function mark(id, parent) { + return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`); + } - function brushOrEl(el, parent, _) { - return !_ ? el : document.querySelector((parent ? `g.${parent} ` : '') + 'g.sel_brush > path'); - } + function coords(el) { + const rect = el.getBoundingClientRect(); + return [Math.ceil(rect.left + rect.width / 2), Math.ceil(rect.top + rect.height / 2)]; + } function click(el, evt) { pointerEvt('pointerdown', el, evt); @@ -67,22 +61,54 @@ return (await view.runAsync()).data('sel_store'); } - async function pt(id, parent, shiftKey) { - const el = mark(id, parent); - const [clientX, clientY] = coords(el); - click(el, {clientX, clientY, shiftKey}); - return (await view.runAsync()).data('sel_store'); - } - - async function clear(id, parent, shiftKey) { - const bg = document.querySelector((parent ? `g.${parent} ` : '') + 'path.background'); - const el = mark(id, parent); - let [clientX, clientY] = coords(el); - clientX += 10; - clientY -= 10; - click(bg, {clientX, clientY, shiftKey}); - return (await view.runAsync()).data('sel_store'); - } + async function brush(id0, id1, parent, targetBrush) { + const el0 = mark(id0, parent); + const el1 = mark(id1, parent); + const [mdX, mdY] = coords(el0); + const [muX, muY] = coords(el1); + pointerEvt('pointerdown', brushOrEl(el0, parent, targetBrush), { clientX: mdX, clientY: mdY }); + pointerEvt('pointerup', window, { clientX: muX, clientY: muY }); + return (await view.runAsync()).data('sel_store'); + } + + async function pt(id, parent, shiftKey) { + const el = mark(id, parent); + const [clientX, clientY] = coords(el); + click(el, { clientX, clientY, shiftKey }); + return (await view.runAsync()).data('sel_store'); + } + + async function clear(id, parent, shiftKey) { + const bg = document.querySelector((parent ? `g.${parent} ` : '') + 'path.background'); + const el = mark(id, parent); + let [clientX, clientY] = coords(el); + clientX += 10; + clientY -= 10; + click(bg, { clientX, clientY, shiftKey }); + return (await view.runAsync()).data('sel_store'); + } + + async function zoom(id, delta, parent, targetBrush) { + const el = mark(id, parent); + const [clientX, clientY] = coords(el); + pointerEvt('wheel', brushOrEl(el, parent, targetBrush), { + clientX, + clientY, + deltaX: delta, + deltaY: delta, + deltaZ: delta + }); + pointerEvt('wheel', brushOrEl(el, parent, targetBrush), { + clientX, + clientY, + deltaX: Math.sign(delta), + deltaY: Math.sign(delta), + deltaZ: Math.sign(delta) + }); + return (await view.runAsync()).data('sel_store'); + } + + async function zoom(id, delta, parent, targetBrush) { const el = mark(id, parent); diff --git a/test/compile/selection/interval.test.ts b/test/compile/selection/interval.test.ts index 17a0988f9b..0f560a6129 100644 --- a/test/compile/selection/interval.test.ts +++ b/test/compile/selection/interval.test.ts @@ -580,6 +580,7 @@ describe('Interval Selections', () => { clip: true, encode: { enter: { + cursor: {value: 'move'}, fill: {value: 'transparent'} }, update: { @@ -671,6 +672,7 @@ describe('Interval Selections', () => { clip: true, encode: { enter: { + cursor: {value: 'move'}, fill: {value: 'transparent'} }, update: { @@ -794,7 +796,7 @@ describe('Interval Selections', () => { type: 'rect', clip: true, encode: { - enter: {fill: {value: 'transparent'}}, + enter: {cursor: {value: 'move'}, fill: {value: 'transparent'}}, update: { x: [ { diff --git a/test/compile/selection/layers.test.ts b/test/compile/selection/layers.test.ts index f3c0e87f6c..050b085935 100644 --- a/test/compile/selection/layers.test.ts +++ b/test/compile/selection/layers.test.ts @@ -276,6 +276,7 @@ describe('Layered Selections', () => { clip: true, encode: { enter: { + cursor: {value: 'move'}, fill: {value: 'transparent'} }, update: {