Skip to content

Commit

Permalink
fix: support expr in projections (#7060)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
domoritz and GitHub Actions Bot committed Nov 19, 2020
1 parent 2c81034 commit d35650b
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 60 deletions.
241 changes: 204 additions & 37 deletions build/vega-lite-schema.json
Expand Up @@ -20265,105 +20265,272 @@
"additionalProperties": false,
"properties": {
"center": {
"$ref": "#/definitions/Vector2<number>",
"description": "The projection's center, a two-element array of longitude and latitude in degrees.\n\n__Default value:__ `[0, 0]`"
"anyOf": [
{
"$ref": "#/definitions/Vector2<number>",
"description": "The projection's center, a two-element array of longitude and latitude in degrees.\n\n__Default value:__ `[0, 0]`"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"clipAngle": {
"description": "The projection's clipping circle radius to the specified angle in degrees. If `null`, switches to [antimeridian](http://bl.ocks.org/mbostock/3788999) cutting rather than small-circle clipping.",
"type": "number"
"anyOf": [
{
"description": "The projection's clipping circle radius to the specified angle in degrees. If `null`, switches to [antimeridian](http://bl.ocks.org/mbostock/3788999) cutting rather than small-circle clipping.",
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"clipExtent": {
"$ref": "#/definitions/Vector2<Vector2<number>>",
"description": "The projection's viewport clip extent to the specified bounds in pixels. The extent bounds are specified as an array `[[x0, y0], [x1, y1]]`, where `x0` is the left-side of the viewport, `y0` is the top, `x1` is the right and `y1` is the bottom. If `null`, no viewport clipping is performed."
"anyOf": [
{
"$ref": "#/definitions/Vector2<Vector2<number>>",
"description": "The projection's viewport clip extent to the specified bounds in pixels. The extent bounds are specified as an array `[[x0, y0], [x1, y1]]`, where `x0` is the left-side of the viewport, `y0` is the top, `x1` is the right and `y1` is the bottom. If `null`, no viewport clipping is performed."
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"coefficient": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"distance": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"extent": {
"$ref": "#/definitions/Vector2<Vector2<number>>"
"anyOf": [
{
"$ref": "#/definitions/Vector2<Vector2<number>>"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"fit": {
"anyOf": [
{
"$ref": "#/definitions/Fit"
"items": {
"$ref": "#/definitions/GeoJsonFeature"
},
"type": "array"
},
{
"items": {
"$ref": "#/definitions/Fit"
},
"type": "array"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"fraction": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"lobes": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"parallel": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"parallels": {
"description": "For conic projections, the [two standard parallels](https://en.wikipedia.org/wiki/Map_projection#Conic) that define the map layout. The default depends on the specific conic projection used.",
"items": {
"type": "number"
},
"type": "array"
"anyOf": [
{
"description": "For conic projections, the [two standard parallels](https://en.wikipedia.org/wiki/Map_projection#Conic) that define the map layout. The default depends on the specific conic projection used.",
"items": {
"type": "number"
},
"type": "array"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"pointRadius": {
"description": "The default radius (in pixels) to use when drawing GeoJSON `Point` and `MultiPoint` geometries. This parameter sets a constant default value. To modify the point radius in response to data, see the corresponding parameter of the GeoPath and GeoShape transforms.\n\n__Default value:__ `4.5`",
"type": "number"
"anyOf": [
{
"description": "The default radius (in pixels) to use when drawing GeoJSON `Point` and `MultiPoint` geometries. This parameter sets a constant default value. To modify the point radius in response to data, see the corresponding parameter of the GeoPath and GeoShape transforms.\n\n__Default value:__ `4.5`",
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"precision": {
"description": "The threshold for the projection's [adaptive resampling](http://bl.ocks.org/mbostock/3795544) to the specified value in pixels. This value corresponds to the [Douglas–Peucker distance](http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm). If precision is not specified, returns the projection's current resampling precision which defaults to `√0.5 ≅ 0.70710…`.",
"type": "number"
"anyOf": [
{
"description": "The threshold for the projection's [adaptive resampling](http://bl.ocks.org/mbostock/3795544) to the specified value in pixels. This value corresponds to the [Douglas–Peucker distance](http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm). If precision is not specified, returns the projection's current resampling precision which defaults to `√0.5 ≅ 0.70710…`.",
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"radius": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"ratio": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"reflectX": {
"type": "boolean"
"anyOf": [
{
"type": "boolean"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"reflectY": {
"type": "boolean"
"anyOf": [
{
"type": "boolean"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"rotate": {
"anyOf": [
{
"$ref": "#/definitions/Vector2<number>"
"anyOf": [
{
"$ref": "#/definitions/Vector2<number>"
},
{
"$ref": "#/definitions/Vector3<number>"
}
],
"description": "The projection's three-axis rotation to the specified angles, which must be a two- or three-element array of numbers [`lambda`, `phi`, `gamma`] specifying the rotation angles in degrees about each spherical axis. (These correspond to yaw, pitch and roll.)\n\n__Default value:__ `[0, 0, 0]`"
},
{
"$ref": "#/definitions/Vector3<number>"
"$ref": "#/definitions/ExprRef"
}
],
"description": "The projection's three-axis rotation to the specified angles, which must be a two- or three-element array of numbers [`lambda`, `phi`, `gamma`] specifying the rotation angles in degrees about each spherical axis. (These correspond to yaw, pitch and roll.)\n\n__Default value:__ `[0, 0, 0]`"
]
},
"scale": {
"description": "The projection’s scale (zoom) factor, overriding automatic fitting. The default scale is projection-specific. The scale factor corresponds linearly to the distance between projected points; however, scale factor values are not equivalent across projections.",
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "The projection’s scale (zoom) factor, overriding automatic fitting. The default scale is projection-specific. The scale factor corresponds linearly to the distance between projected points; however, scale factor values are not equivalent across projections."
},
"size": {
"$ref": "#/definitions/Vector2<number>"
"anyOf": [
{
"$ref": "#/definitions/Vector2<number>"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"spacing": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"tilt": {
"type": "number"
"anyOf": [
{
"type": "number"
},
{
"$ref": "#/definitions/ExprRef"
}
]
},
"translate": {
"$ref": "#/definitions/Vector2<number>",
"anyOf": [
{
"$ref": "#/definitions/Vector2<number>"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "The projection’s translation offset as a two-element array `[tx, ty]`."
},
"type": {
"$ref": "#/definitions/ProjectionType",
"anyOf": [
{
"$ref": "#/definitions/ProjectionType"
},
{
"$ref": "#/definitions/ExprRef"
}
],
"description": "The cartographic projection to use. This value is case-insensitive, for example `\"albers\"` and `\"Albers\"` indicate the same projection type. You can find all valid projection types [in the documentation](https://vega.github.io/vega-lite/docs/projection.html#projection-types).\n\n__Default value:__ `equalEarth`"
}
},
Expand Down
Binary file added examples/compiled/geo_params_projections.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/compiled/geo_params_projections.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions examples/compiled/geo_params_projections.vg.json
@@ -0,0 +1,65 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"width": 500,
"height": 300,
"style": "cell",
"data": [
{
"name": "source_0",
"url": "data/world-110m.json",
"format": {"type": "topojson", "feature": "countries"}
}
],
"projections": [
{
"name": "projection",
"size": {"signal": "[width, height]"},
"fit": {"signal": "data('source_0')"},
"type": {"signal": "projection"}
}
],
"signals": [
{
"name": "projection",
"value": "equalEarth",
"bind": {
"input": "select",
"options": [
"albers",
"albersUsa",
"azimuthalEqualArea",
"azimuthalEquidistant",
"conicConformal",
"conicEqualArea",
"conicEquidistant",
"equalEarth",
"equirectangular",
"gnomonic",
"mercator",
"naturalEarth1",
"orthographic",
"stereographic",
"transverseMercator"
]
}
}
],
"marks": [
{
"name": "marks",
"type": "shape",
"style": ["geoshape"],
"from": {"data": "source_0"},
"encode": {
"update": {
"fill": {"value": "lightgray"},
"stroke": {"value": "gray"},
"ariaRoleDescription": {"value": "geoshape"}
}
},
"transform": [{"type": "geoshape", "projection": "projection"}]
}
]
}

0 comments on commit d35650b

Please sign in to comment.