From d2491c8ed185c52f80c3289ef6896f0e5bd24b55 Mon Sep 17 00:00:00 2001 From: Stefan Binder Date: Fri, 5 May 2023 18:34:46 +0000 Subject: [PATCH 1/9] Add tile property and getTileOverlay --- build/vega-lite-schema.json | 1094 +++++++++++++++++++++++++++++----- src/mark.ts | 22 +- src/normalize/pathoverlay.ts | 54 +- 3 files changed, 1026 insertions(+), 144 deletions(-) diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 152f30f779..6ba3c6e9dd 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -144,6 +144,9 @@ }, { "$ref": "#/definitions/TickConfig" + }, + { + "$ref": "#/definitions/GeoshapeConfig" } ] }, @@ -7625,7 +7628,7 @@ "type": "string" }, "geoshape": { - "$ref": "#/definitions/MarkConfig", + "$ref": "#/definitions/GeoshapeConfig", "description": "Geoshape-Specific Config" }, "header": { @@ -11262,170 +11265,984 @@ "$ref": "#/definitions/Projection", "description": "An object defining properties of geographic projection, which will be applied to `shape` path for `\"geoshape\"` marks and to `latitude` and `\"longitude\"` channels for other marks." }, - "title": { + "title": { + "anyOf": [ + { + "$ref": "#/definitions/Text" + }, + { + "$ref": "#/definitions/TitleParams" + } + ], + "description": "Title for the plot." + }, + "transform": { + "description": "An array of data transformations such as filter and new field calculation.", + "items": { + "$ref": "#/definitions/Transform" + }, + "type": "array" + } + }, + "required": [ + "mark" + ], + "type": "object" + }, + "VConcatSpec": { + "additionalProperties": false, + "description": "Base interface for a vertical concatenation specification.", + "properties": { + "bounds": { + "description": "The bounds calculation method to use for determining the extent of a sub-plot. One of `full` (the default) or `flush`.\n\n- If set to `full`, the entire calculated bounds (including axes, title, and legend) will be used.\n- If set to `flush`, only the specified width and height values for the sub-view will be used. The `flush` setting can be useful when attempting to place sub-plots without axes or legends into a uniform grid structure.\n\n__Default value:__ `\"full\"`", + "enum": [ + "full", + "flush" + ], + "type": "string" + }, + "center": { + "description": "Boolean flag indicating if subviews should be centered relative to their respective rows or columns.\n\n__Default value:__ `false`", + "type": "boolean" + }, + "data": { + "anyOf": [ + { + "$ref": "#/definitions/Data" + }, + { + "type": "null" + } + ], + "description": "An object describing the data source. Set to `null` to ignore the parent's data source. If no data is set, it is derived from the parent." + }, + "description": { + "description": "Description of this mark for commenting purpose.", + "type": "string" + }, + "name": { + "description": "Name of the visualization for later reference.", + "type": "string" + }, + "resolve": { + "$ref": "#/definitions/Resolve", + "description": "Scale, axis, and legend resolutions for view composition specifications." + }, + "spacing": { + "description": "The spacing in pixels between sub-views of the concat operator.\n\n__Default value__: `10`", + "type": "number" + }, + "title": { + "anyOf": [ + { + "$ref": "#/definitions/Text" + }, + { + "$ref": "#/definitions/TitleParams" + } + ], + "description": "Title for the plot." + }, + "transform": { + "description": "An array of data transformations such as filter and new field calculation.", + "items": { + "$ref": "#/definitions/Transform" + }, + "type": "array" + }, + "vconcat": { + "description": "A list of views to be concatenated and put into a column.", + "items": { + "$ref": "#/definitions/Spec" + }, + "type": "array" + } + }, + "required": [ + "vconcat" + ], + "type": "object" + }, + "GeoJsonFeature": { + "$ref": "#/definitions/Feature" + }, + "GeoJsonFeatureCollection": { + "$ref": "#/definitions/FeatureCollection" + }, + "GeoJsonProperties": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "null" + } + ] + }, + "Geometry": { + "anyOf": [ + { + "$ref": "#/definitions/Point" + }, + { + "$ref": "#/definitions/MultiPoint" + }, + { + "$ref": "#/definitions/LineString" + }, + { + "$ref": "#/definitions/MultiLineString" + }, + { + "$ref": "#/definitions/Polygon" + }, + { + "$ref": "#/definitions/MultiPolygon" + }, + { + "$ref": "#/definitions/GeometryCollection" + } + ], + "description": "Union of geometry objects. https://tools.ietf.org/html/rfc7946#section-3" + }, + "GeometryCollection": { + "additionalProperties": false, + "description": "Geometry Collection https://tools.ietf.org/html/rfc7946#section-3.1.8", + "properties": { + "bbox": { + "$ref": "#/definitions/BBox", + "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. https://tools.ietf.org/html/rfc7946#section-5" + }, + "geometries": { + "items": { + "$ref": "#/definitions/Geometry" + }, + "type": "array" + }, + "type": { + "const": "GeometryCollection", + "description": "Specifies the type of GeoJSON object.", + "type": "string" + } + }, + "required": [ + "geometries", + "type" + ], + "type": "object" + }, + "GeoshapeConfig": { + "additionalProperties": false, + "properties": { + "align": { + "anyOf": [ + { + "$ref": "#/definitions/Align" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The horizontal alignment of the text or ranged marks (area, bar, image, rect, rule). One of `\"left\"`, `\"right\"`, `\"center\"`.\n\n__Note:__ Expression reference is *not* supported for range marks." + }, + "angle": { + "anyOf": [ + { + "description": "The rotation angle of the text, in degrees.", + "maximum": 360, + "minimum": 0, + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "aria": { + "anyOf": [ + { + "description": "A boolean flag indicating if [ARIA attributes](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) should be included (SVG output only). If `false`, the \"aria-hidden\" attribute will be set on the output SVG element, removing the mark item from the ARIA accessibility tree.", + "type": "boolean" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "ariaRole": { + "anyOf": [ + { + "description": "Sets the type of user interface element of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). If specified, this property determines the \"role\" attribute. Warning: this property is experimental and may be changed in the future.", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "ariaRoleDescription": { + "anyOf": [ + { + "description": "A human-readable, author-localized description for the role of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). If specified, this property determines the \"aria-roledescription\" attribute. Warning: this property is experimental and may be changed in the future.", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "aspect": { + "anyOf": [ + { + "description": "Whether to keep aspect ratio of image marks.", + "type": "boolean" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "baseline": { + "anyOf": [ + { + "$ref": "#/definitions/TextBaseline" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "For text marks, the vertical text baseline. One of `\"alphabetic\"` (default), `\"top\"`, `\"middle\"`, `\"bottom\"`, `\"line-top\"`, `\"line-bottom\"`, or an expression reference that provides one of the valid values. The `\"line-top\"` and `\"line-bottom\"` values operate similarly to `\"top\"` and `\"bottom\"`, but are calculated relative to the `lineHeight` rather than `fontSize` alone.\n\nFor range marks, the vertical alignment of the marks. One of `\"top\"`, `\"middle\"`, `\"bottom\"`.\n\n__Note:__ Expression reference is *not* supported for range marks." + }, + "blend": { + "anyOf": [ + { + "$ref": "#/definitions/Blend", + "description": "The color blend mode for drawing an item on its current background. Any valid [CSS mix-blend-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) value can be used.\n\n__Default value: `\"source-over\"`" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "color": { + "anyOf": [ + { + "$ref": "#/definitions/Color" + }, + { + "$ref": "#/definitions/Gradient" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Default color.\n\n__Default value:__ `\"#4682b4\"`\n\n__Note:__\n- This property cannot be used in a [style config](https://vega.github.io/vega-lite/docs/mark.html#style-config).\n- The `fill` and `stroke` properties have higher precedence than `color` and will override `color`." + }, + "cornerRadius": { + "anyOf": [ + { + "description": "The radius in pixels of rounded rectangles or arcs' corners.\n\n__Default value:__ `0`", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "cornerRadiusBottomLeft": { + "anyOf": [ + { + "description": "The radius in pixels of rounded rectangles' bottom left corner.\n\n__Default value:__ `0`", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "cornerRadiusBottomRight": { + "anyOf": [ + { + "description": "The radius in pixels of rounded rectangles' bottom right corner.\n\n__Default value:__ `0`", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "cornerRadiusTopLeft": { + "anyOf": [ + { + "description": "The radius in pixels of rounded rectangles' top right corner.\n\n__Default value:__ `0`", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "cornerRadiusTopRight": { + "anyOf": [ + { + "description": "The radius in pixels of rounded rectangles' top left corner.\n\n__Default value:__ `0`", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "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" + } + ] + }, + "description": { + "anyOf": [ + { + "description": "A text description of the mark item for [ARIA accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) (SVG output only). If specified, this property determines the [\"aria-label\" attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute).", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "dir": { + "anyOf": [ + { + "$ref": "#/definitions/TextDirection", + "description": "The direction of the text. One of `\"ltr\"` (left-to-right) or `\"rtl\"` (right-to-left). This property determines on which side is truncated in response to the limit parameter.\n\n__Default value:__ `\"ltr\"`" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "dx": { + "anyOf": [ + { + "description": "The horizontal offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by the _angle_ property.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "dy": { + "anyOf": [ + { + "description": "The vertical offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by the _angle_ property.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "ellipsis": { + "anyOf": [ + { + "description": "The ellipsis string for text truncated in response to the limit parameter.\n\n__Default value:__ `\"…\"`", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "endAngle": { + "anyOf": [ + { + "description": "The end angle in radians for arc marks. A value of `0` indicates up (north), increasing values proceed clockwise.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "fill": { + "anyOf": [ + { + "$ref": "#/definitions/Color" + }, + { + "$ref": "#/definitions/Gradient" + }, + { + "type": "null" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Default fill color. This property has higher precedence than `config.color`. Set to `null` to remove fill.\n\n__Default value:__ (None)" + }, + "fillOpacity": { + "anyOf": [ + { + "description": "The fill opacity (value between [0,1]).\n\n__Default value:__ `1`", + "maximum": 1, + "minimum": 0, + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "filled": { + "description": "Whether the mark's color should be used as fill color instead of stroke color.\n\n__Default value:__ `false` for all `point`, `line`, and `rule` marks as well as `geoshape` marks for [`graticule`](https://vega.github.io/vega-lite/docs/data.html#graticule) data sources; otherwise, `true`.\n\n__Note:__ This property cannot be used in a [style config](https://vega.github.io/vega-lite/docs/mark.html#style-config).", + "type": "boolean" + }, + "font": { + "anyOf": [ + { + "description": "The typeface to set the text in (e.g., `\"Helvetica Neue\"`).", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "fontSize": { + "anyOf": [ + { + "description": "The font size, in pixels.\n\n__Default value:__ `11`", + "minimum": 0, + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "fontStyle": { + "anyOf": [ + { + "$ref": "#/definitions/FontStyle", + "description": "The font style (e.g., `\"italic\"`)." + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "fontWeight": { + "anyOf": [ + { + "$ref": "#/definitions/FontWeight", + "description": "The font weight. This can be either a string (e.g `\"bold\"`, `\"normal\"`) or a number (`100`, `200`, `300`, ..., `900` where `\"normal\"` = `400` and `\"bold\"` = `700`)." + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "height": { + "anyOf": [ + { + "description": "Height of the marks.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "href": { + "anyOf": [ + { + "$ref": "#/definitions/URI", + "description": "A URL to load upon mouse click. If defined, the mark acts as a hyperlink." + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "innerRadius": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The inner radius in pixels of arc marks. `innerRadius` is an alias for `radius2`.\n\n__Default value:__ `0`", + "minimum": 0 + }, + "interpolate": { + "anyOf": [ + { + "$ref": "#/definitions/Interpolate", + "description": "The line interpolation method to use for line and area marks. One of the following:\n- `\"linear\"`: piecewise linear segments, as in a polyline.\n- `\"linear-closed\"`: close the linear segments to form a polygon.\n- `\"step\"`: alternate between horizontal and vertical segments, as in a step function.\n- `\"step-before\"`: alternate between vertical and horizontal segments, as in a step function.\n- `\"step-after\"`: alternate between horizontal and vertical segments, as in a step function.\n- `\"basis\"`: a B-spline, with control point duplication on the ends.\n- `\"basis-open\"`: an open B-spline; may not intersect the start or end.\n- `\"basis-closed\"`: a closed B-spline, as in a loop.\n- `\"cardinal\"`: a Cardinal spline, with control point duplication on the ends.\n- `\"cardinal-open\"`: an open Cardinal spline; may not intersect the start or end, but will intersect other control points.\n- `\"cardinal-closed\"`: a closed Cardinal spline, as in a loop.\n- `\"bundle\"`: equivalent to basis, except the tension parameter is used to straighten the spline.\n- `\"monotone\"`: cubic interpolation that preserves monotonicity in y." + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "invalid": { + "description": "Defines how Vega-Lite should handle marks for invalid values (`null` and `NaN`).\n- If set to `\"filter\"` (default), all data items with null values will be skipped (for line, trail, and area marks) or filtered (for other marks).\n- If `null`, all data items are included. In this case, invalid values will be interpreted as zeroes.", + "enum": [ + "filter", + null + ], + "type": [ + "string", + "null" + ] + }, + "limit": { + "anyOf": [ + { + "description": "The maximum length of the text mark in pixels. The text value will be automatically truncated if the rendered size exceeds the limit.\n\n__Default value:__ `0` -- indicating no limit", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "lineBreak": { + "anyOf": [ + { + "description": "A delimiter, such as a newline character, upon which to break text strings into multiple lines. This property is ignored if the text is array-valued.", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "lineHeight": { + "anyOf": [ + { + "description": "The line height in pixels (the spacing between subsequent lines of text) for multi-line text marks.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "opacity": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The overall opacity (value between [0,1]).\n\n__Default value:__ `0.7` for non-aggregate plots with `point`, `tick`, `circle`, or `square` marks or layered `bar` charts and `1` otherwise.", + "maximum": 1, + "minimum": 0 + }, + "order": { + "description": "For line and trail marks, this `order` property can be set to `null` or `false` to make the lines use the original order in the data sources.", + "type": [ + "null", + "boolean" + ] + }, + "orient": { + "$ref": "#/definitions/Orientation", + "description": "The orientation of a non-stacked bar, tick, area, and line charts. The value is either horizontal (default) or vertical.\n- For bar, rule and tick, this determines whether the size of the bar and tick should be applied to x or y dimension.\n- For area, this property determines the orient property of the Vega output.\n- For line and trail marks, this property determines the sort order of the points in the line if `config.sortLineBy` is not specified. For stacked charts, this is always determined by the orientation of the stack; therefore explicitly specified value will be ignored." + }, + "outerRadius": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The outer radius in pixels of arc marks. `outerRadius` is an alias for `radius`.\n\n__Default value:__ `0`", + "minimum": 0 + }, + "padAngle": { + "anyOf": [ + { + "description": "The angular padding applied to sides of the arc, in radians.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "radius": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "For arc mark, the primary (outer) radius in pixels.\n\nFor text marks, polar coordinate radial offset, in pixels, of the text from the origin determined by the `x` and `y` properties.\n\n__Default value:__ `min(plot_width, plot_height)/2`", + "minimum": 0 + }, + "radius2": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "The secondary (inner) radius in pixels of arc marks.\n\n__Default value:__ `0`", + "minimum": 0 + }, + "shape": { + "anyOf": [ + { + "anyOf": [ + { + "$ref": "#/definitions/SymbolShape" + }, + { + "type": "string" + } + ], + "description": "Shape of the point marks. Supported values include:\n- plotting shapes: `\"circle\"`, `\"square\"`, `\"cross\"`, `\"diamond\"`, `\"triangle-up\"`, `\"triangle-down\"`, `\"triangle-right\"`, or `\"triangle-left\"`.\n- the line symbol `\"stroke\"`\n- centered directional shapes `\"arrow\"`, `\"wedge\"`, or `\"triangle\"`\n- a custom [SVG path string](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)\n\n__Default value:__ `\"circle\"`" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "size": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Default size for marks.\n- For `point`/`circle`/`square`, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.\n- For `bar`, this represents the band size of the bar, in pixels.\n- For `text`, this represents the font size, in pixels.\n\n__Default value:__\n- `30` for point, circle, square marks; width/height's `step`\n- `2` for bar marks with discrete dimensions;\n- `5` for bar marks with continuous dimensions;\n- `11` for text marks.", + "minimum": 0 + }, + "smooth": { + "anyOf": [ + { + "description": "A boolean flag (default true) indicating if the image should be smoothed when resized. If false, individual pixels should be scaled directly rather than interpolated with smoothing. For SVG rendering, this option may not work in some browsers due to lack of standardization.", + "type": "boolean" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "startAngle": { + "anyOf": [ + { + "description": "The start angle in radians for arc marks. A value of `0` indicates up (north), increasing values proceed clockwise.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "stroke": { + "anyOf": [ + { + "$ref": "#/definitions/Color" + }, + { + "$ref": "#/definitions/Gradient" + }, + { + "type": "null" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Default stroke color. This property has higher precedence than `config.color`. Set to `null` to remove stroke.\n\n__Default value:__ (None)" + }, + "strokeCap": { + "anyOf": [ + { + "$ref": "#/definitions/StrokeCap", + "description": "The stroke cap for line ending style. One of `\"butt\"`, `\"round\"`, or `\"square\"`.\n\n__Default value:__ `\"butt\"`" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeDash": { + "anyOf": [ + { + "description": "An array of alternating stroke, space lengths for creating dashed or dotted lines.", + "items": { + "type": "number" + }, + "type": "array" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeDashOffset": { + "anyOf": [ + { + "description": "The offset (in pixels) into which to begin drawing with the stroke dash array.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeJoin": { + "anyOf": [ + { + "$ref": "#/definitions/StrokeJoin", + "description": "The stroke line join method. One of `\"miter\"`, `\"round\"` or `\"bevel\"`.\n\n__Default value:__ `\"miter\"`" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeMiterLimit": { + "anyOf": [ + { + "description": "The miter limit at which to bevel a line join.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeOffset": { + "anyOf": [ + { + "description": "The offset in pixels at which to draw the group stroke and fill. If unspecified, the default behavior is to dynamically offset stroked groups such that 1 pixel stroke widths align with the pixel grid.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeOpacity": { + "anyOf": [ + { + "description": "The stroke opacity (value between [0,1]).\n\n__Default value:__ `1`", + "maximum": 1, + "minimum": 0, + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "strokeWidth": { + "anyOf": [ + { + "description": "The stroke width, in pixels.", + "minimum": 0, + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "tension": { + "anyOf": [ + { + "description": "Depending on the interpolation type, sets the tension parameter (for line and area marks).", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "text": { + "anyOf": [ + { + "$ref": "#/definitions/Text", + "description": "Placeholder text if the `text` channel is not specified" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] + }, + "theta": { "anyOf": [ { - "$ref": "#/definitions/Text" + "type": "number" }, { - "$ref": "#/definitions/TitleParams" + "$ref": "#/definitions/ExprRef" } ], - "description": "Title for the plot." + "description": "- For arc marks, the arc length in radians if theta2 is not specified, otherwise the start arc angle. (A value of 0 indicates up or “north”, increasing values proceed clockwise.)\n\n- For text marks, polar coordinate angle in radians.", + "maximum": 360, + "minimum": 0 }, - "transform": { - "description": "An array of data transformations such as filter and new field calculation.", - "items": { - "$ref": "#/definitions/Transform" - }, - "type": "array" - } - }, - "required": [ - "mark" - ], - "type": "object" - }, - "VConcatSpec": { - "additionalProperties": false, - "description": "Base interface for a vertical concatenation specification.", - "properties": { - "bounds": { - "description": "The bounds calculation method to use for determining the extent of a sub-plot. One of `full` (the default) or `flush`.\n\n- If set to `full`, the entire calculated bounds (including axes, title, and legend) will be used.\n- If set to `flush`, only the specified width and height values for the sub-view will be used. The `flush` setting can be useful when attempting to place sub-plots without axes or legends into a uniform grid structure.\n\n__Default value:__ `\"full\"`", - "enum": [ - "full", - "flush" + "theta2": { + "anyOf": [ + { + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } ], - "type": "string" - }, - "center": { - "description": "Boolean flag indicating if subviews should be centered relative to their respective rows or columns.\n\n__Default value:__ `false`", - "type": "boolean" + "description": "The end angle of arc marks in radians. A value of 0 indicates up or “north”, increasing values proceed clockwise." }, - "data": { + "tile": { "anyOf": [ { - "$ref": "#/definitions/Data" + "type": "boolean" }, { - "type": "null" + "$ref": "#/definitions/OverlayMarkDef" } ], - "description": "An object describing the data source. Set to `null` to ignore the parent's data source. If no data is set, it is derived from the parent." - }, - "description": { - "description": "Description of this mark for commenting purpose.", - "type": "string" - }, - "name": { - "description": "Name of the visualization for later reference.", - "type": "string" + "description": "A flag for overlaying tiles on top of geoshape marks, or an object defining the properties of the overlayed tiles.\n\n- If this property is an empty object (`{}`) or `true`, tiles with default properties will be used.\n\n- If this property is `false`, no tiles would be automatically added to geoshape marks.\n\n__Default value:__ `false`." }, - "resolve": { - "$ref": "#/definitions/Resolve", - "description": "Scale, axis, and legend resolutions for view composition specifications." + "timeUnitBandPosition": { + "description": "Default relative band position for a time unit. If set to `0`, the marks will be positioned at the beginning of the time unit band step. If set to `0.5`, the marks will be positioned in the middle of the time unit band step.", + "type": "number" }, - "spacing": { - "description": "The spacing in pixels between sub-views of the concat operator.\n\n__Default value__: `10`", + "timeUnitBandSize": { + "description": "Default relative band size for a time unit. If set to `1`, the bandwidth of the marks will be equal to the time unit band step. If set to `0.5`, bandwidth of the marks will be half of the time unit band step.", "type": "number" }, - "title": { + "tooltip": { "anyOf": [ { - "$ref": "#/definitions/Text" + "type": "number" }, { - "$ref": "#/definitions/TitleParams" + "type": "string" + }, + { + "type": "boolean" + }, + { + "$ref": "#/definitions/TooltipContent" + }, + { + "$ref": "#/definitions/ExprRef" + }, + { + "type": "null" } ], - "description": "Title for the plot." - }, - "transform": { - "description": "An array of data transformations such as filter and new field calculation.", - "items": { - "$ref": "#/definitions/Transform" - }, - "type": "array" - }, - "vconcat": { - "description": "A list of views to be concatenated and put into a column.", - "items": { - "$ref": "#/definitions/Spec" - }, - "type": "array" - } - }, - "required": [ - "vconcat" - ], - "type": "object" - }, - "GeoJsonFeature": { - "$ref": "#/definitions/Feature" - }, - "GeoJsonFeatureCollection": { - "$ref": "#/definitions/FeatureCollection" - }, - "GeoJsonProperties": { - "anyOf": [ - { - "type": "object" - }, - { - "type": "null" - } - ] - }, - "Geometry": { - "anyOf": [ - { - "$ref": "#/definitions/Point" - }, - { - "$ref": "#/definitions/MultiPoint" - }, - { - "$ref": "#/definitions/LineString" + "description": "The tooltip text string to show upon mouse hover or an object defining which fields should the tooltip be derived from.\n\n- If `tooltip` is `true` or `{\"content\": \"encoding\"}`, then all fields from `encoding` will be used.\n- If `tooltip` is `{\"content\": \"data\"}`, then all fields that appear in the highlighted data point will be used.\n- If set to `null` or `false`, then no tooltip will be used.\n\nSee the [`tooltip`](https://vega.github.io/vega-lite/docs/tooltip.html) documentation for a detailed discussion about tooltip in Vega-Lite.\n\n__Default value:__ `null`" }, - { - "$ref": "#/definitions/MultiLineString" + "url": { + "anyOf": [ + { + "$ref": "#/definitions/URI", + "description": "The URL of the image file for image marks." + }, + { + "$ref": "#/definitions/ExprRef" + } + ] }, - { - "$ref": "#/definitions/Polygon" + "width": { + "anyOf": [ + { + "description": "Width of the marks.", + "type": "number" + }, + { + "$ref": "#/definitions/ExprRef" + } + ] }, - { - "$ref": "#/definitions/MultiPolygon" + "x": { + "anyOf": [ + { + "type": "number" + }, + { + "const": "width", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "X coordinates of the marks, or width of horizontal `\"bar\"` and `\"area\"` without specified `x2` or `width`.\n\nThe `value` of this channel can be a number or a string `\"width\"` for the width of the plot." }, - { - "$ref": "#/definitions/GeometryCollection" - } - ], - "description": "Union of geometry objects. https://tools.ietf.org/html/rfc7946#section-3" - }, - "GeometryCollection": { - "additionalProperties": false, - "description": "Geometry Collection https://tools.ietf.org/html/rfc7946#section-3.1.8", - "properties": { - "bbox": { - "$ref": "#/definitions/BBox", - "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. https://tools.ietf.org/html/rfc7946#section-5" + "x2": { + "anyOf": [ + { + "type": "number" + }, + { + "const": "width", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "X2 coordinates for ranged `\"area\"`, `\"bar\"`, `\"rect\"`, and `\"rule\"`.\n\nThe `value` of this channel can be a number or a string `\"width\"` for the width of the plot." }, - "geometries": { - "items": { - "$ref": "#/definitions/Geometry" - }, - "type": "array" + "y": { + "anyOf": [ + { + "type": "number" + }, + { + "const": "height", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Y coordinates of the marks, or height of vertical `\"bar\"` and `\"area\"` without specified `y2` or `height`.\n\nThe `value` of this channel can be a number or a string `\"height\"` for the height of the plot." }, - "type": { - "const": "GeometryCollection", - "description": "Specifies the type of GeoJSON object.", - "type": "string" + "y2": { + "anyOf": [ + { + "type": "number" + }, + { + "const": "height", + "type": "string" + }, + { + "$ref": "#/definitions/ExprRef" + } + ], + "description": "Y2 coordinates for ranged `\"area\"`, `\"bar\"`, `\"rect\"`, and `\"rule\"`.\n\nThe `value` of this channel can be a number or a string `\"height\"` for the height of the plot." } }, - "required": [ - "geometries", - "type" - ], "type": "object" }, "Gradient": { @@ -17286,6 +18103,17 @@ "minimum": 0, "type": "number" }, + "tile": { + "anyOf": [ + { + "type": "boolean" + }, + { + "$ref": "#/definitions/OverlayMarkDef" + } + ], + "description": "A flag for overlaying tiles on top of geoshape marks, or an object defining the properties of the overlayed tiles.\n\n- If this property is an empty object (`{}`) or `true`, tiles with default properties will be used.\n\n- If this property is `false`, no tiles would be automatically added to geoshape marks.\n\n__Default value:__ `false`." + }, "timeUnitBandPosition": { "description": "Default relative band position for a time unit. If set to `0`, the marks will be positioned at the beginning of the time unit band step. If set to `0.5`, the marks will be positioned in the middle of the time unit band step.", "type": "number" @@ -27281,7 +28109,7 @@ "description": "Circle-Specific Config" }, "geoshape": { - "$ref": "#/definitions/MarkConfig", + "$ref": "#/definitions/GeoshapeConfig", "description": "Geoshape-Specific Config" }, "group-subtitle": { diff --git a/src/mark.ts b/src/mark.ts index 5d53a2f646..919b1c2c3d 100644 --- a/src/mark.ts +++ b/src/mark.ts @@ -340,6 +340,7 @@ export const VL_ONLY_MARK_SPECIFIC_CONFIG_PROPERTY_INDEX: { bar: ['binSpacing', 'continuousBandSize', 'discreteBandSize'], rect: ['binSpacing', 'continuousBandSize', 'discreteBandSize'], line: ['point'], + geoshape: ['tile'], tick: ['bandSize', 'thickness'] }; @@ -356,7 +357,8 @@ export type AnyMarkConfig = | BarConfig | RectConfig | LineConfig - | TickConfig; + | TickConfig + | GeoshapeConfig; export interface MarkConfigMixins { /** Mark Config */ @@ -404,7 +406,7 @@ export interface MarkConfigMixins { trail?: LineConfig; /** Geoshape-Specific Config */ - geoshape?: MarkConfig; + geoshape?: GeoshapeConfig; } const MARK_CONFIG_INDEX: Flag> = { @@ -495,8 +497,23 @@ export interface PointOverlayMixins { point?: boolean | OverlayMarkDef | 'transparent'; } +export interface TileOverlayMixins { + /** + * A flag for overlaying tiles on top of geoshape marks, or an object defining the properties of the overlayed tiles. + * + * - If this property is an empty object (`{}`) or `true`, tiles with default properties will be used. + * + * - If this property is `false`, no tiles would be automatically added to geoshape marks. + * + * __Default value:__ `false`. + */ + tile?: boolean | OverlayMarkDef; +} + export interface LineConfig extends MarkConfig, PointOverlayMixins {} +export interface GeoshapeConfig extends MarkConfig, TileOverlayMixins {} + export interface LineOverlayMixins { /** * A flag for overlaying line on top of area marks, or an object defining the properties of the overlayed lines. @@ -608,6 +625,7 @@ export interface MarkDef & BarConfig & // always extends RectConfig LineConfig & + GeoshapeConfig & TickConfig, 'startAngle' | 'endAngle' | 'width' | 'height' >, diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index e5331c9422..89ff6cfc9e 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -3,7 +3,7 @@ import {isObject} from 'vega-util'; import {Config} from '../config'; import {Encoding, normalizeEncoding} from '../encoding'; import {ExprRef} from '../expr'; -import {AreaConfig, isMarkDef, LineConfig, Mark, MarkConfig, MarkDef} from '../mark'; +import {AreaConfig, isMarkDef, LineConfig, GeoshapeConfig, Mark, MarkConfig, MarkDef} from '../mark'; import {GenericUnitSpec, NormalizedUnitSpec} from '../spec'; import {isUnitSpec} from '../spec/unit'; import {stack} from '../stack'; @@ -12,19 +12,19 @@ import {NonFacetUnitNormalizer, NormalizeLayerOrUnit, NormalizerParams} from './ type UnitSpecWithPathOverlay = GenericUnitSpec, Mark | MarkDef<'line' | 'area' | 'rule' | 'trail'>>; -function dropLineAndPoint(markDef: MarkDef): MarkDef | Mark { - const {point: _point, line: _line, ...mark} = markDef; +function dropLineAndPointAndTile(markDef: MarkDef): MarkDef | Mark { + const {point: _point, line: _line, tile: _tile, ...mark} = markDef; return keys(mark).length > 1 ? mark : mark.type; } -function dropLineAndPointFromConfig(config: Config) { - for (const mark of ['line', 'area', 'rule', 'trail'] as const) { +function dropLineAndPointAndTileFromConfig(config: Config) { + for (const mark of ['line', 'area', 'rule', 'trail', 'geoshape'] as const) { if (config[mark]) { config = { ...config, // TODO: remove as any - [mark]: omit(config[mark], ['point', 'line'] as any) + [mark]: omit(config[mark], ['point', 'line', 'tile'] as any) }; } } @@ -55,6 +55,26 @@ function getPointOverlay( } } +function getTileOverlay( + markDef: MarkDef, + markConfig: GeoshapeConfig = {} +): MarkConfig { + if (markDef.tile) { + return isObject(markDef.tile) ? markDef.tile : {}; + } else if (markDef.tile !== undefined) { + // false or null + return null; + } else { + // undefined (not disabled) + if (markConfig.tile) { + // enable tile overlay if config[mark].tile is truthy + return isObject(markConfig.tile) ? markConfig.tile : {}; + } + // markDef.tile is defined as falsy + return undefined; + } +} + function getLineOverlay( markDef: MarkDef, markConfig: AreaConfig = {} @@ -88,6 +108,8 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Fri, 5 May 2023 19:24:45 +0000 Subject: [PATCH 2/9] Add parameters, encodings, data, and transform --- src/normalize/pathoverlay.ts | 111 ++++++++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 3 deletions(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index 89ff6cfc9e..f00d2c1b60 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -203,17 +203,122 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Fri, 5 May 2023 19:36:10 +0000 Subject: [PATCH 3/9] Move projection into geoshape layer --- src/normalize/pathoverlay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index f00d2c1b60..9fc5268f95 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -140,6 +140,7 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Fri, 5 May 2023 19:43:33 +0000 Subject: [PATCH 4/9] Push down data into geoshape layer --- src/normalize/pathoverlay.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index 9fc5268f95..ce8a8ff622 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -136,11 +136,15 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Sat, 6 May 2023 08:25:07 +0000 Subject: [PATCH 5/9] Move definition of parameters into tileOverlay if statement --- src/normalize/pathoverlay.ts | 155 ++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index ce8a8ff622..2aeb9800e5 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -136,14 +136,16 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Sat, 6 May 2023 09:31:47 +0000 Subject: [PATCH 6/9] Calculate zoom level based on scale. Minor fixes --- src/normalize/pathoverlay.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index 2aeb9800e5..3c56d4ff1e 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -208,6 +208,9 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Sat, 6 May 2023 09:54:58 +0000 Subject: [PATCH 7/9] Fix calculation of tile_count --- src/normalize/pathoverlay.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index 3c56d4ff1e..d189eaa2fa 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -211,7 +211,9 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Sat, 6 May 2023 10:32:09 +0000 Subject: [PATCH 8/9] Fix wrong parentheses in dy --- src/normalize/pathoverlay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index d189eaa2fa..e66a59eba9 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -308,7 +308,7 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer Date: Sat, 6 May 2023 14:49:54 +0000 Subject: [PATCH 9/9] Fix prScale type --- src/normalize/pathoverlay.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index e66a59eba9..bb7b231389 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -264,7 +264,9 @@ export class PathOverlayNormalizer implements NonFacetUnitNormalizer