An open source alternative to Tableau. Embeddable visual analytic
TypeScript bidatadata-analysisdata-miningdata-visualizationedak6skanarieslow-codepivot-tablereacttableautableau-alternativetypescriptvegavega-litevisualization
doc: teaser examples
Elwynn Chend2a889721f36
diff --git a/packages/playground/public/tersespec_v1.json b/packages/playground/public/tersespec_v1.jsonnew file mode 100644index 00000000..3c317427--- /dev/null+++ b/packages/playground/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 filediff --git a/packages/playground/src/examples/layout.tsx b/packages/playground/src/examples/layout.tsxindex 86194d4b..08b13aad 100644--- a/packages/playground/src/examples/layout.tsx+++ b/packages/playground/src/examples/layout.tsx@@ -1,22 +1,53 @@import { Fragment, useState } from 'react';-import { Link, Outlet } from 'react-router-dom';+import { Link, Outlet, useLocation } from 'react-router-dom';import { Dialog, Transition } from '@headlessui/react';import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline';import { themeContext } from './context';import { ThemeToggle } from './components/ThemeToggle';-import { pages } from './nav';+import { pageGroups } from './nav';++function NavList({ onNavigate }: { onNavigate?: () => void }) {+ const location = useLocation();++ return (+ <nav className="flex flex-col gap-5">+ {pageGroups.map((group) => (+ <div key={group.label}>+ <h3 className="mb-1.5 px-2 text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-500">+ {group.label}+ </h3>+ <ul className="space-y-0.5">+ {group.pages.map((page) => {+ const active = location.pathname === `/examples/${page.path}`;+ return (+ <li key={page.name}>+ <Link+ to={`/examples/${page.path}`}+ onClick={onNavigate}+ className={`block rounded-md px-2 py-1.5 text-sm transition-colors ${+ active+ ? 'bg-indigo-50 font-medium text-indigo-700 dark:bg-indigo-950/50 dark:text-indigo-300'+ : 'text-zinc-600 hover:bg-zinc-50 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800/50 dark:hover:text-white'+ }`}+ >+ {page.name}+ </Link>+ </li>+ );+ })}+ </ul>+ </div>+ ))}+ </nav>+ );+}export default function Layout() {const [sidebarOpen, setSidebarOpen] = useState(false);const [theme, setTheme] = useState<'light' | 'dark'>('light');return (- <themeContext.Provider- value={{- theme,- setTheme,- }}- >+ <themeContext.Provider value={{ theme, setTheme }}><div className={theme === 'dark' ? 'dark' : ''}><div><Transition.Root show={sidebarOpen} as={Fragment}>@@ -60,20 +91,9 @@ export default function Layout() {</button></div></Transition.Child>- <div className="flex grow flex-col gap-y-5 overflow-y-auto px-6 py-12 bg-white dark:bg-gray-950 text-gray-900 dark:text-white">- <span className="font-bold">Examples</span>- <ul>- {pages.map((page) => (- <li key={page.name}>- <Link- to={`/examples/${page.path}`}- className="block py-1 text-sm text-zinc-600 transition hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white"- >- {page.name}- </Link>- </li>- ))}- </ul>+ <div className="flex grow flex-col gap-y-5 overflow-y-auto px-4 py-8 bg-white dark:bg-gray-950 text-gray-900 dark:text-white">+ <span className="px-2 text-lg font-bold">Examples</span>+ <NavList onNavigate={() => setSidebarOpen(false)} /></div></Dialog.Panel></Transition.Child>@@ -81,38 +101,23 @@ export default function Layout() {</Dialog></Transition.Root>- <div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-72 lg:flex-col">- <nav className="flex grow flex-col gap-y-5 overflow-y-auto px-6 py-12 bg-white dark:bg-gray-950 text-gray-900 dark:text-white shadow-md">- <span className="font-bold">Examples</span>- <ul>- {pages.map((page) => (- <li key={page.name}>- <Link- to={`/examples/${page.path}`}- className="block py-1 text-sm text-zinc-600 transition hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white"- >- {page.name}- </Link>- </li>- ))}- </ul>- </nav>+ <div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-64 lg:flex-col">+ <div className="flex grow flex-col overflow-y-auto border-r border-zinc-200 bg-white px-4 py-8 dark:border-zinc-800 dark:bg-gray-950 text-gray-900 dark:text-white">+ <span className="mb-6 px-2 text-lg font-bold">Examples</span>+ <NavList />+ </div></div>- <div className="lg:pl-72">- <div className="sticky top-0 z-40 flex h-16 shrink-0 items-center gap-x-4 border-b bg-white dark:bg-gray-950 px-4 shadow-sm sm:gap-x-6 sm:px-6 lg:px-8">+ <div className="lg:pl-64">+ <div className="sticky top-0 z-40 flex h-14 shrink-0 items-center gap-x-4 border-b border-zinc-200 bg-white/80 backdrop-blur dark:border-zinc-800 dark:bg-gray-950/80 px-4 sm:gap-x-6 sm:px-6 lg:px-8"><button type="button" className="-m-2.5 p-2.5 text-gray-700 lg:hidden" onClick={() => setSidebarOpen(true)}><span className="sr-only">Open sidebar</span><Bars3Icon className="h-6 w-6" aria-hidden="true" /></button><div className="h-6 w-px bg-gray-950/10 dark:bg-white/10 lg:hidden" aria-hidden="true" />- <div className="flex flex-1 gap-x-4 items-center self-stretch justify-between lg:gap-x-6">- <div className="flex flex-col space-y-1 text-black dark:text-white">- <div className="text">Graphic Walker Examples</div>- </div>- <div>- <ThemeToggle />- </div>+ <div className="flex flex-1 items-center justify-between">+ <span className="text-sm font-medium text-zinc-900 dark:text-white">Graphic Walker Playground</span>+ <ThemeToggle /></div></div>diff --git a/packages/playground/src/examples/nav.tsx b/packages/playground/src/examples/nav.tsxindex 267d2883..fd06c778 100644--- a/packages/playground/src/examples/nav.tsx+++ b/packages/playground/src/examples/nav.tsx@@ -1,66 +1,69 @@-export const pages = [- {- comp: () => import('./pages/gw'),- name: 'GraphicWalker',- },- {- comp: () => import('./pages/pureRenderer'),- name: 'PureRenderer',- },- {- comp: () => import('./pages/inModal'),- name: 'Graphic Walker In a Modal',- },- {- comp: () => import('./pages/ds'),- name: 'DataSourceSegment',- },- {- comp: () => import('./pages/renderer'),- name: 'GraphicRenderer',- },- {- comp: () => import('./pages/cc'),- name: 'CustomColor',- },- {- comp: () => import('./pages/exportChart'),- name: 'Export Chart',- },- {- comp: () => import('./pages/table'),- name: 'TableWalker',- },- {- comp: () => import('./pages/tableSettings'),- name: 'TableWalker Settings',- },- {- comp: () => import('./pages/filterContext'),- name: 'Filter Context',- },- {- comp: () => import('./pages/defaultRenderer'),- name: 'Default Renderer',- },- {- comp: () => import('./pages/themeBuilder'),- name: 'ThemeBuilder',- },- {- comp: () => import('./pages/hideProfiling'),- name: 'HideProfiling',- },- {- comp: () => import('./pages/vlSpec'),- name: 'VlSpec',- },- {- comp: () => import('./pages/terseSpec'),- name: 'TerseSpec',+export interface PageItem {+ name: string;+ path: string;+ lazy: () => Promise<{ Component: React.ComponentType }>;+}++export interface PageGroup {+ label: string;+ pages: PageItem[];+}++const raw: { group: string; name: string; comp: () => Promise<{ default: React.ComponentType }> }[] = [+ // ── Teasers ──────────────────────────────────+ { group: 'Teasers', comp: () => import('./pages/teaserScatter'), name: 'Scatter: Horsepower vs Price' },+ { group: 'Teasers', comp: () => import('./pages/teaserTimeSeries'), name: 'Time Series: Bike Sharing' },+ { group: 'Teasers', comp: () => import('./pages/teaserStackedBar'), name: 'Stacked Bar: Titanic' },+ { group: 'Teasers', comp: () => import('./pages/teaserCollege'), name: 'Scatter: College Cost vs Earnings' },+ { group: 'Teasers', comp: () => import('./pages/teaserPie'), name: 'Pie: Car Sales' },++ // ── Core ─────────────────────────────────────+ { group: 'Core', comp: () => import('./pages/gw'), name: 'GraphicWalker' },+ { group: 'Core', comp: () => import('./pages/pureRenderer'), name: 'PureRenderer' },+ { group: 'Core', comp: () => import('./pages/renderer'), name: 'GraphicRenderer' },+ { group: 'Core', comp: () => import('./pages/defaultRenderer'), name: 'Default Renderer' },++ // ── Features ─────────────────────────────────+ { group: 'Features', comp: () => import('./pages/ds'), name: 'DataSourceSegment' },+ { group: 'Features', comp: () => import('./pages/inModal'), name: 'In a Modal' },+ { group: 'Features', comp: () => import('./pages/exportChart'), name: 'Export Chart' },+ { group: 'Features', comp: () => import('./pages/filterContext'), name: 'Filter Context' },+ { group: 'Features', comp: () => import('./pages/hideProfiling'), name: 'HideProfiling' },++ // ── Configuration ────────────────────────────+ { group: 'Configuration', comp: () => import('./pages/cc'), name: 'CustomColor' },+ { group: 'Configuration', comp: () => import('./pages/table'), name: 'TableWalker' },+ { group: 'Configuration', comp: () => import('./pages/tableSettings'), name: 'TableWalker Settings' },+ { group: 'Configuration', comp: () => import('./pages/themeBuilder'), name: 'ThemeBuilder' },++ // ── Spec / Grammar ───────────────────────────+ { group: 'Spec / Grammar', comp: () => import('./pages/vlSpec'), name: 'VlSpec' },+ { group: 'Spec / Grammar', comp: () => import('./pages/terseSpec'), name: 'TerseSpec' },+];++function toPage(item: (typeof raw)[number]): PageItem {+ return {+ name: item.name,+ path: item.name.replace(/\s/g, '_'),+ lazy: async () => item.comp().then((mod) => ({ Component: mod.default })),+ };+}++/** Flat page list for React Router */+export const pages: PageItem[] = raw.map(toPage);++/** Grouped page list for sidebar navigation */+export const pageGroups: PageGroup[] = (() => {+ const groups: PageGroup[] = [];+ const groupMap = new Map<string, PageGroup>();+ for (const item of raw) {+ let group = groupMap.get(item.group);+ if (!group) {+ group = { label: item.group, pages: [] };+ groupMap.set(item.group, group);+ groups.push(group);+ }+ group.pages.push(toPage(item));}-].map((Component) => ({- name: Component.name,- path: Component.name.replace(/\s/g, '_'),- lazy: async () => Component.comp().then((mod) => ({ Component: mod.default })),-}));+ return groups;+})();diff --git a/packages/playground/src/examples/pages/teaserCollege.stories.tsx b/packages/playground/src/examples/pages/teaserCollege.stories.tsxnew file mode 100644index 00000000..1c960ab4--- /dev/null+++ b/packages/playground/src/examples/pages/teaserCollege.stories.tsx@@ -0,0 +1,28 @@+import { useContext, useMemo } from 'react';+import { themeContext } from '../context';+import { GraphicRenderer, normalize } from '@kanaries/graphic-walker';+import type { TerseSpec } from '@kanaries/graphic-walker';+import { useFetch, IDataSource } from '../util';++const DATASET_URL = '/datasets/ds-collage-service.json';++const spec: TerseSpec = {+ mark: 'point',+ x: 'AverageCost',+ y: 'MedianEarnings',+ color: 'FundingModel',+ size: 'AdmissionRate',+ aggregate: false,+ filters: [+ { field: 'MedianEarnings', range: [10000, null] },+ { field: 'AverageCost', range: [1000, null] },+ ],+};++export default function TeaserCollege() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>(DATASET_URL);+ const chart = useMemo(() => [normalize(spec, fields)], [fields]);++ return <GraphicRenderer fields={fields} data={dataSource} chart={chart} appearance={theme} />;+}diff --git a/packages/playground/src/examples/pages/teaserCollege.tsx b/packages/playground/src/examples/pages/teaserCollege.tsxnew file mode 100644index 00000000..640d5282--- /dev/null+++ b/packages/playground/src/examples/pages/teaserCollege.tsx@@ -0,0 +1,15 @@+import Example from '../components/examplePage';+import code from './teaserCollege.stories?raw';+import Comp from './teaserCollege.stories';++export default function TeaserCollegePage() {+ return (+ <Example+ name="Scatter: College Cost vs Earnings"+ desc="Cost of attendance versus median earnings after graduation, colored by funding model and sized by admission rate."+ code={code}+ >+ <Comp />+ </Example>+ );+}diff --git a/packages/playground/src/examples/pages/teaserPie.stories.tsx b/packages/playground/src/examples/pages/teaserPie.stories.tsxnew file mode 100644index 00000000..d8746c46--- /dev/null+++ b/packages/playground/src/examples/pages/teaserPie.stories.tsx@@ -0,0 +1,23 @@+import { useContext, useMemo } from 'react';+import { themeContext } from '../context';+import { GraphicRenderer, normalize } from '@kanaries/graphic-walker';+import type { TerseSpec } from '@kanaries/graphic-walker';+import { useFetch, IDataSource } from '../util';++const DATASET_URL = '/datasets/ds-carsales-service.json';++const spec: TerseSpec = {+ mark: 'arc',+ theta: 'sum(Sales_in_thousands)',+ color: 'Manufacturer',+ filters: [{ field: 'Vehicle_type', oneOf: ['Passenger'] }],+ limit: 8,+};++export default function TeaserPie() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>(DATASET_URL);+ const chart = useMemo(() => [normalize(spec, fields)], [fields]);++ return <GraphicRenderer fields={fields} data={dataSource} chart={chart} appearance={theme} />;+}diff --git a/packages/playground/src/examples/pages/teaserPie.tsx b/packages/playground/src/examples/pages/teaserPie.tsxnew file mode 100644index 00000000..8e5d220e--- /dev/null+++ b/packages/playground/src/examples/pages/teaserPie.tsx@@ -0,0 +1,15 @@+import Example from '../components/examplePage';+import code from './teaserPie.stories?raw';+import Comp from './teaserPie.stories';++export default function TeaserPiePage() {+ return (+ <Example+ name="Pie: Car Sales by Manufacturer"+ desc="Top 8 passenger-car manufacturers by total sales volume."+ code={code}+ >+ <Comp />+ </Example>+ );+}diff --git a/packages/playground/src/examples/pages/teaserScatter.stories.tsx b/packages/playground/src/examples/pages/teaserScatter.stories.tsxnew file mode 100644index 00000000..7992fb6b--- /dev/null+++ b/packages/playground/src/examples/pages/teaserScatter.stories.tsx@@ -0,0 +1,24 @@+import { useContext, useMemo } from 'react';+import { themeContext } from '../context';+import { GraphicRenderer, normalize } from '@kanaries/graphic-walker';+import type { TerseSpec } from '@kanaries/graphic-walker';+import { useFetch, IDataSource } from '../util';++const DATASET_URL = '/datasets/ds-carsales-service.json';++const spec: TerseSpec = {+ mark: 'point',+ x: 'Horsepower',+ y: 'Price_in_thousands',+ color: 'Vehicle_type',+ size: 'Engine_size',+ aggregate: false,+};++export default function TeaserScatter() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>(DATASET_URL);+ const chart = useMemo(() => [normalize(spec, fields)], [fields]);++ return <GraphicRenderer fields={fields} data={dataSource} chart={chart} appearance={theme} />;+}diff --git a/packages/playground/src/examples/pages/teaserScatter.tsx b/packages/playground/src/examples/pages/teaserScatter.tsxnew file mode 100644index 00000000..5b8aa2aa--- /dev/null+++ b/packages/playground/src/examples/pages/teaserScatter.tsx@@ -0,0 +1,15 @@+import Example from '../components/examplePage';+import code from './teaserScatter.stories?raw';+import Comp from './teaserScatter.stories';++export default function TeaserScatterPage() {+ return (+ <Example+ name="Scatter: Horsepower vs Price"+ desc="A scatter plot of car horsepower against price, colored by vehicle type and sized by engine displacement."+ code={code}+ >+ <Comp />+ </Example>+ );+}diff --git a/packages/playground/src/examples/pages/teaserStackedBar.stories.tsx b/packages/playground/src/examples/pages/teaserStackedBar.stories.tsxnew file mode 100644index 00000000..08a5b41c--- /dev/null+++ b/packages/playground/src/examples/pages/teaserStackedBar.stories.tsx@@ -0,0 +1,24 @@+import { useContext, useMemo } from 'react';+import { themeContext } from '../context';+import { GraphicRenderer, normalize } from '@kanaries/graphic-walker';+import type { TerseSpec } from '@kanaries/graphic-walker';+import { useFetch, IDataSource } from '../util';++const DATASET_URL = '/datasets/ds-titanic-service.json';++const spec: TerseSpec = {+ mark: 'bar',+ x: 'Pclass',+ y: 'count()',+ color: 'Survived',+ stack: 'normalize',+ filters: [{ field: 'Embarked', notIn: [''] }],+};++export default function TeaserStackedBar() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>(DATASET_URL);+ const chart = useMemo(() => [normalize(spec, fields)], [fields]);++ return <GraphicRenderer fields={fields} data={dataSource} chart={chart} appearance={theme} />;+}diff --git a/packages/playground/src/examples/pages/teaserStackedBar.tsx b/packages/playground/src/examples/pages/teaserStackedBar.tsxnew file mode 100644index 00000000..84fb4b1a--- /dev/null+++ b/packages/playground/src/examples/pages/teaserStackedBar.tsx@@ -0,0 +1,15 @@+import Example from '../components/examplePage';+import code from './teaserStackedBar.stories?raw';+import Comp from './teaserStackedBar.stories';++export default function TeaserStackedBarPage() {+ return (+ <Example+ name="Stacked Bar: Titanic Survival"+ desc="Normalized stacked bar chart showing survival rate by passenger class on the Titanic."+ code={code}+ >+ <Comp />+ </Example>+ );+}diff --git a/packages/playground/src/examples/pages/teaserTimeSeries.stories.tsx b/packages/playground/src/examples/pages/teaserTimeSeries.stories.tsxnew file mode 100644index 00000000..80d2c41c--- /dev/null+++ b/packages/playground/src/examples/pages/teaserTimeSeries.stories.tsx@@ -0,0 +1,22 @@+import { useContext, useMemo } from 'react';+import { themeContext } from '../context';+import { GraphicRenderer, normalize } from '@kanaries/graphic-walker';+import type { TerseSpec } from '@kanaries/graphic-walker';+import { useFetch, IDataSource } from '../util';++const DATASET_URL = '/datasets/ds-bikesharing-service.json';++const spec: TerseSpec = {+ mark: 'line',+ x: { field: 'date', timeUnit: 'month' },+ y: 'mean(count)',+ color: 'workingday',+};++export default function TeaserTimeSeries() {+ const { theme } = useContext(themeContext);+ const { dataSource, fields } = useFetch<IDataSource>(DATASET_URL);+ const chart = useMemo(() => [normalize(spec, fields)], [fields]);++ return <GraphicRenderer fields={fields} data={dataSource} chart={chart} appearance={theme} />;+}diff --git a/packages/playground/src/examples/pages/teaserTimeSeries.tsx b/packages/playground/src/examples/pages/teaserTimeSeries.tsxnew file mode 100644index 00000000..27657834--- /dev/null+++ b/packages/playground/src/examples/pages/teaserTimeSeries.tsx@@ -0,0 +1,15 @@+import Example from '../components/examplePage';+import code from './teaserTimeSeries.stories?raw';+import Comp from './teaserTimeSeries.stories';++export default function TeaserTimeSeriesPage() {+ return (+ <Example+ name="Time Series: Bike Sharing"+ desc="Monthly bike sharing ridership trends, split by working day vs weekend/holiday."+ code={code}+ >+ <Comp />+ </Example>+ );+}