Skip to content

An open source alternative to Tableau. Embeddable visual analytic

doc: json schema

Elwynn Chenfb8c172b0e8a
diff --git a/.gitignore b/.gitignore
index b2fd46e4..36492bf7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,5 @@ app-dist
.vercel
chartinfo.json
stoinfo_v2.json
+
+internal_docs
\ No newline at end of file
diff --git a/packages/graphic-walker/public/tersespec_v1.json b/packages/graphic-walker/public/tersespec_v1.json
new file mode 100644
index 00000000..3c317427
--- /dev/null
+++ b/packages/graphic-walker/public/tersespec_v1.json
@@ -0,0 +1,888 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "properties": {
+ "$schema": {
+ "type": "string"
+ },
+ "mark": {
+ "type": "string",
+ "description": "chart type; maps to config.geoms[0], defaults to 'auto'"
+ },
+ "name": {
+ "type": "string"
+ },
+ "x": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TerseFieldRef"
+ }
+ }
+ ]
+ },
+ "y": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TerseFieldRef"
+ }
+ }
+ ]
+ },
+ "color": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "opacity": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "size": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "shape": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "text": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "details": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TerseFieldRef"
+ }
+ }
+ ]
+ },
+ "theta": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "radius": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "longitude": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "latitude": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "geoId": {
+ "$ref": "#/definitions/TerseFieldRef"
+ },
+ "filters": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TerseFilter"
+ }
+ },
+ "computed": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/TerseComputedField"
+ }
+ },
+ "aggregate": {
+ "type": "boolean",
+ "description": "→ config.defaultAggregated, defaults to true"
+ },
+ "stack": {
+ "$ref": "#/definitions/IStackMode",
+ "description": "→ layout.stack"
+ },
+ "limit": {
+ "type": "number",
+ "description": "→ config.limit"
+ },
+ "sort": {
+ "type": "string",
+ "enum": [
+ "ascending",
+ "descending"
+ ],
+ "description": "applied to the last y measure"
+ },
+ "config": {
+ "type": "object",
+ "properties": {
+ "defaultAggregated": {
+ "type": "boolean"
+ },
+ "geoms": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "coordSystem": {
+ "$ref": "#/definitions/ICoordMode",
+ "default": "generic"
+ },
+ "limit": {
+ "type": "number"
+ },
+ "folds": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "timezoneDisplayOffset": {
+ "type": "number"
+ }
+ },
+ "additionalProperties": false,
+ "description": "canonical escape hatch, shallow-merged last (highest priority)"
+ },
+ "layout": {
+ "type": "object",
+ "properties": {
+ "showTableSummary": {
+ "type": "boolean"
+ },
+ "format": {
+ "type": "object",
+ "properties": {
+ "numberFormat": {
+ "type": "string"
+ },
+ "timeFormat": {
+ "type": "string"
+ },
+ "normalizedNumberFormat": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ },
+ "primaryColor": {
+ "type": "string"
+ },
+ "colorPalette": {
+ "type": "string"
+ },
+ "scale": {
+ "$ref": "#/definitions/IConfigScaleSet"
+ },
+ "resolve": {
+ "type": "object",
+ "properties": {
+ "x": {
+ "type": "boolean"
+ },
+ "y": {
+ "type": "boolean"
+ },
+ "color": {
+ "type": "boolean"
+ },
+ "opacity": {
+ "type": "boolean"
+ },
+ "shape": {
+ "type": "boolean"
+ },
+ "size": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false
+ },
+ "size": {
+ "type": "object",
+ "properties": {
+ "mode": {
+ "type": "string",
+ "enum": [
+ "auto",
+ "fixed",
+ "full"
+ ]
+ },
+ "width": {
+ "type": "number"
+ },
+ "height": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "mode",
+ "width",
+ "height"
+ ],
+ "additionalProperties": false
+ },
+ "useSvg": {
+ "type": "boolean"
+ },
+ "geojson": {
+ "$ref": "#/definitions/FeatureCollection%3CGeometry%2CGeoJsonProperties%3E"
+ },
+ "geoKey": {
+ "type": "string"
+ },
+ "geoUrl": {
+ "$ref": "#/definitions/IGeoUrl"
+ },
+ "geoMapTileUrl": {
+ "type": "string"
+ },
+ "interactiveScale": {
+ "type": "boolean"
+ },
+ "stack": {
+ "$ref": "#/definitions/IStackMode"
+ },
+ "showActions": {
+ "type": "boolean"
+ },
+ "zeroScale": {
+ "type": "boolean"
+ },
+ "background": {
+ "type": "string"
+ },
+ "scaleIncludeUnmatchedChoropleth": {
+ "type": "boolean",
+ "default": false
+ },
+ "showAllGeoshapeInChoropleth": {
+ "type": "boolean"
+ },
+ "renderer": {
+ "type": "string",
+ "enum": [
+ "vega-lite",
+ "observable-plot"
+ ],
+ "default": "vega-lite"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "additionalProperties": false,
+ "description": "The human-authored terse spec (authoring format). Expanded into a canonical IChart by `normalize()`; never used for persistence. See docs/terse-spec-design.md.",
+ "definitions": {
+ "TerseFieldRef": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "aggregate": {
+ "type": "string",
+ "enum": [
+ "sum",
+ "count",
+ "max",
+ "min",
+ "mean",
+ "median",
+ "variance",
+ "stdev",
+ "distinctCount"
+ ]
+ },
+ "sort": {
+ "type": "string",
+ "enum": [
+ "ascending",
+ "descending"
+ ]
+ },
+ "timeUnit": {
+ "type": "string",
+ "enum": [
+ "year",
+ "quarter",
+ "month",
+ "week",
+ "day",
+ "hour",
+ "minute",
+ "second",
+ "iso_year",
+ "iso_week"
+ ]
+ }
+ },
+ "required": [
+ "field"
+ ],
+ "additionalProperties": false
+ }
+ ],
+ "description": "A field reference inside a TerseSpec. A plain string is resolved by name, with optional aggregate shorthand like `'sum(Sales)'` or a `'fid:'` prefix to bypass name resolution. The object form carries per-channel overrides; its `field` string accepts the same syntax (name / shorthand / `fid:` prefix), and setting `aggregate` alongside a shorthand is an error. `timeUnit` expands to a dateTimeDrill computed field — a query-level drill identical to the UI's drill, not just axis formatting."
+ },
+ "TerseFilter": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "oneOf": {
+ "type": "array",
+ "items": {}
+ }
+ },
+ "required": [
+ "field",
+ "oneOf"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "notIn": {
+ "type": "array",
+ "items": {}
+ }
+ },
+ "required": [
+ "field",
+ "notIn"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "range": {
+ "type": "array",
+ "items": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "minItems": 2,
+ "maxItems": 2
+ }
+ },
+ "required": [
+ "field",
+ "range"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "timeRange": {
+ "type": "array",
+ "items": {
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "minItems": 2,
+ "maxItems": 2
+ }
+ },
+ "required": [
+ "field",
+ "timeRange"
+ ],
+ "additionalProperties": false
+ }
+ ],
+ "description": "Filter literals. `timeRange` takes epoch milliseconds only, word-for-word aligned with the `temporal range` rule in computation.md."
+ },
+ "TerseComputedField": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "expr": {
+ "type": "string"
+ },
+ "bin": {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "count": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "field"
+ ],
+ "additionalProperties": false
+ },
+ "log": {
+ "type": "object",
+ "properties": {
+ "field": {
+ "type": "string"
+ },
+ "base": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "field"
+ ],
+ "additionalProperties": false
+ },
+ "analyticType": {
+ "$ref": "#/definitions/IAnalyticType"
+ }
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false,
+ "description": "An inline computed-field definition; exactly one of `expr` / `bin` / `log` must be set."
+ },
+ "IAnalyticType": {
+ "type": "string",
+ "enum": [
+ "dimension",
+ "measure"
+ ]
+ },
+ "IStackMode": {
+ "type": "string",
+ "enum": [
+ "none",
+ "stack",
+ "normalize",
+ "zero",
+ "center"
+ ]
+ },
+ "ICoordMode": {
+ "type": "string",
+ "enum": [
+ "generic",
+ "geographic"
+ ]
+ },
+ "IConfigScaleSet": {
+ "type": "object",
+ "properties": {
+ "row": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "column": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "color": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "opacity": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "size": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "radius": {
+ "$ref": "#/definitions/IConfigScale"
+ },
+ "theta": {
+ "$ref": "#/definitions/IConfigScale"
+ }
+ },
+ "additionalProperties": false
+ },
+ "IConfigScale": {
+ "type": "object",
+ "properties": {
+ "rangeMax": {
+ "type": "number"
+ },
+ "rangeMin": {
+ "type": "number"
+ },
+ "domainMin": {
+ "type": "number"
+ },
+ "domainMax": {
+ "type": "number"
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "linear",
+ "log",
+ "pow",
+ "sqrt",
+ "symlog"
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
+ "FeatureCollection<Geometry,GeoJsonProperties>": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "FeatureCollection",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "features": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Feature%3CGeometry%2CGeoJsonProperties%3E"
+ }
+ }
+ },
+ "required": [
+ "features",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "A collection of feature objects. https://tools.ietf.org/html/rfc7946#section-3.3"
+ },
+ "BBox": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "number"
+ },
+ "minItems": 4,
+ "maxItems": 4
+ },
+ {
+ "type": "array",
+ "items": {
+ "type": "number"
+ },
+ "minItems": 6,
+ "maxItems": 6
+ }
+ ],
+ "description": "Bounding box https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "Feature<Geometry,GeoJsonProperties>": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "Feature",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "geometry": {
+ "$ref": "#/definitions/Geometry",
+ "description": "The feature's geometry"
+ },
+ "id": {
+ "type": [
+ "string",
+ "number"
+ ],
+ "description": "A value that uniquely identifies this feature in a https://tools.ietf.org/html/rfc7946#section-3.2."
+ },
+ "properties": {
+ "$ref": "#/definitions/GeoJsonProperties",
+ "description": "Properties associated with this feature."
+ }
+ },
+ "required": [
+ "geometry",
+ "properties",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "A feature object which contains a geometry and associated properties. https://tools.ietf.org/html/rfc7946#section-3.2"
+ },
+ "Geometry": {
+ "anyOf": [
+ {
+ "$ref": "#/definitions/Point"
+ },
+ {
+ "$ref": "#/definitions/MultiPoint"
+ },
+ {
+ "$ref": "#/definitions/LineString"
+ },
+ {
+ "$ref": "#/definitions/MultiLineString"
+ },
+ {
+ "$ref": "#/definitions/Polygon"
+ },
+ {
+ "$ref": "#/definitions/MultiPolygon"
+ },
+ {
+ "$ref": "#/definitions/GeometryCollection"
+ }
+ ],
+ "description": "Geometry object. https://tools.ietf.org/html/rfc7946#section-3"
+ },
+ "Point": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "Point",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "$ref": "#/definitions/Position"
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "Point geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.2"
+ },
+ "Position": {
+ "type": "array",
+ "items": {
+ "type": "number"
+ },
+ "description": "A Position is an array of coordinates. https://tools.ietf.org/html/rfc7946#section-3.1.1 Array should contain between two and three elements. The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values), but the current specification only allows X, Y, and (optionally) Z to be defined."
+ },
+ "MultiPoint": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "MultiPoint",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Position"
+ }
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "MultiPoint geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.3"
+ },
+ "LineString": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "LineString",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Position"
+ }
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "LineString geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.4"
+ },
+ "MultiLineString": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "MultiLineString",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Position"
+ }
+ }
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "MultiLineString geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.5"
+ },
+ "Polygon": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "Polygon",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Position"
+ }
+ }
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "Polygon geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.6"
+ },
+ "MultiPolygon": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "MultiPolygon",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "coordinates": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Position"
+ }
+ }
+ }
+ }
+ },
+ "required": [
+ "coordinates",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "MultiPolygon geometry object. https://tools.ietf.org/html/rfc7946#section-3.1.7"
+ },
+ "GeometryCollection": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "GeometryCollection",
+ "description": "Specifies the type of GeoJSON object."
+ },
+ "bbox": {
+ "$ref": "#/definitions/BBox",
+ "description": "Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections. The value of the bbox member is an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. https://tools.ietf.org/html/rfc7946#section-5"
+ },
+ "geometries": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Geometry"
+ }
+ }
+ },
+ "required": [
+ "geometries",
+ "type"
+ ],
+ "additionalProperties": false,
+ "description": "Geometry Collection https://tools.ietf.org/html/rfc7946#section-3.1.8"
+ },
+ "GeoJsonProperties": {
+ "anyOf": [
+ {
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "IGeoUrl": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "GeoJSON",
+ "TopoJSON"
+ ]
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "url"
+ ],
+ "additionalProperties": false
+ }
+ }
+}
\ No newline at end of file