GizStack
View .mdOpen in ChatGPTOpen in Claude

gizapp/visual

Presentation declarations reference typed result fields. They carry no SQL, aggregation formula, storage mapping or independent Live state.

gizlang
import * as Visual from "gizapp/visual";

Types

Mark

gizlang
type Mark = | { kind: "bar"; } | { kind: "line"; } | { kind: "scatter"; } | { kind: "pie"; }

How a chart draws its points.

  • bar
  • line
  • scatter
  • pie

Chart

gizlang
type Chart = { mark: Mark; x: string; y: string; series: string; }

A chart: its mark and the fields of its x, y and series.

  • mark: M125.Mark
  • x: string
  • y: string
  • series: string

Place

gizlang
type Place = { column: i64; row: i64; width: i64; height: i64; }

The area of a dashboard panel: zero-based column and row, and its span.

  • column: i64
  • row: i64
  • width: i64
  • height: i64

Functions

figure

gizlang
function figure(spec: Chart, names: Vec<string>, rows: Vec<Vec<Option<string>>>): bytes throws DbError

The chart as a page shows it: a <giz-chart> element that holds the SVG of svg and the rows as a table (exact text; the x cell is the row header; a NULL cell has data-null). Without script the SVG is the chart. With the giz-chart enhancement (app/components/src/chart.js), ECharts draws the same table in the element's shadow root. The table is what assistive technology reads in both cases.

Effects: fail, alloc.

svg

gizlang
function svg(spec: Chart, names: Vec<string>, rows: Vec<Vec<Option<string>>>): bytes throws DbError

The chart drawn on the server as SVG: no script, so it shows at first paint, prints, and is the form of a chart without JavaScript. names and rows are a text result (none for NULL); y, and x of a scatter, must be decimal text. A row with a NULL y is not drawn. At most 4096 rows.

Effects: fail, alloc.

pivotTable

gizlang
function pivotTable(view: Semantic.Crosstab, title: string): bytes

The pivot as an HTML table: it reads without JavaScript and CSS. Values are exact text (Value.show). A NULL key or measure has data-null; a pair without a result row is an empty cell with data-empty.

Effects: fail, alloc.

readPivot

gizlang
function readPivot(value: Json.Json): Semantic.Pivot throws DbError

A pivot spec in a saved workbook. Semantic.pivot checks it against its metric.

Effects: fail, alloc.

pivotJson

gizlang
function pivotJson(spec: Semantic.Pivot): string

The pivot spec as JSON.

Effects: fail, alloc.

layout

gizlang
function layout(places: Vec<Place>, cells: Vec<i64>): bool throws DbError

A dashboard layout: 1 to PANELS panels in a grid of GRID_COLUMNS by GRID_ROWS, without overlap. cells[i] is the cell limit of panel i (for a pivot, its cells). Their sum is at most CELL_BUDGET.

Effects: fail, alloc.

area

gizlang
function area(place: Place): string

The CSS grid area of a panel, for its style attribute. The dashboard element declares display:grid;grid-template-columns:repeat(12,minmax(0,1fr)).

Effects: fail, alloc.

readPlace

gizlang
function readPlace(value: Json.Json): Place throws DbError

The Place in JSON value, or why it is not one.

Effects: fail, alloc.

placeJson

gizlang
function placeJson(place: Place): string

The Place place as JSON.

Effects: fail, alloc.