@silverpoint/core 0.3.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/catalog.d.ts +97 -0
- package/dist/catalog.js +8004 -0
- package/dist/catalog.js.map +1 -0
- package/dist/{chunk-I6BAZ7MJ.js → chunk-46QELMCG.js} +41 -236
- package/dist/chunk-46QELMCG.js.map +1 -0
- package/dist/chunk-5MP3BLZK.js +48 -0
- package/dist/chunk-5MP3BLZK.js.map +1 -0
- package/dist/chunk-6YFO7OP3.js +84 -0
- package/dist/chunk-6YFO7OP3.js.map +1 -0
- package/dist/chunk-ANJSW5JX.js +93 -0
- package/dist/chunk-ANJSW5JX.js.map +1 -0
- package/dist/chunk-E5CC2NNQ.js +172 -0
- package/dist/chunk-E5CC2NNQ.js.map +1 -0
- package/dist/chunk-G7N4X5XD.js +12 -0
- package/dist/chunk-G7N4X5XD.js.map +1 -0
- package/dist/chunk-KFBSQH5G.js +34 -0
- package/dist/chunk-KFBSQH5G.js.map +1 -0
- package/dist/chunk-NI7B6UEO.js +24 -0
- package/dist/chunk-NI7B6UEO.js.map +1 -0
- package/dist/chunk-WYFRHI4S.js +179 -0
- package/dist/chunk-WYFRHI4S.js.map +1 -0
- package/dist/contrast-siWF_R5o.d.ts +30 -0
- package/dist/dashboard-demos.d.ts +2 -2
- package/dist/index.d.ts +16 -60
- package/dist/index.js +34 -179
- package/dist/index.js.map +1 -1
- package/dist/model-DVVt59AB.d.ts +53 -0
- package/dist/palettes.d.ts +29 -0
- package/dist/palettes.js +79 -0
- package/dist/palettes.js.map +1 -0
- package/dist/{props-3G1XYd-r.d.ts → props-BZ9CcrGv.d.ts} +394 -2
- package/dist/timeline.d.ts +90 -0
- package/dist/timeline.js +125 -0
- package/dist/timeline.js.map +1 -0
- package/dist/{types-CbVMKvyQ.d.ts → types-BT3Xm7fP.d.ts} +3 -1
- package/dist/types-D5ys35fF.d.ts +576 -0
- package/dist/types-DHBJ0PzV.d.ts +57 -0
- package/dist/ui-demos.d.ts +14 -3
- package/dist/ui-demos.js +163 -1
- package/dist/ui-demos.js.map +1 -1
- package/dist/ui.d.ts +346 -325
- package/dist/ui.js +933 -118
- package/dist/ui.js.map +1 -1
- package/dist/view-DteS9glE.d.ts +82 -0
- package/package.json +19 -1
- package/dist/chunk-I6BAZ7MJ.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { au as Palette } from './props-BZ9CcrGv.js';
|
|
2
|
+
|
|
3
|
+
/** One pair of a palette below its threshold (REQ-465). */
|
|
4
|
+
interface PaletteFinding {
|
|
5
|
+
/** The pair's name in Data Model §3.9. */
|
|
6
|
+
readonly pair: string;
|
|
7
|
+
readonly foreground: string;
|
|
8
|
+
readonly background: string;
|
|
9
|
+
/** 2 decimals. */
|
|
10
|
+
readonly ratio: number;
|
|
11
|
+
readonly threshold: number;
|
|
12
|
+
}
|
|
13
|
+
interface Pair {
|
|
14
|
+
readonly pair: string;
|
|
15
|
+
readonly threshold: number;
|
|
16
|
+
readonly foreground: (p: Palette) => string | undefined;
|
|
17
|
+
/** `undefined` measures against the substrate. */
|
|
18
|
+
readonly background?: (p: Palette) => string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** The pairs `checkPalette` and the contrast gate measure (Data Model §3.9), in that order. */
|
|
21
|
+
declare const PALETTE_PAIRS: readonly Pair[];
|
|
22
|
+
/** WCAG 2 contrast ratio of two hex colours (`#rgb` or `#rrggbb`), from 1 to 21. */
|
|
23
|
+
declare function contrastRatio(foreground: string, background: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* Every pair of Data Model §3.9 whose two colours are hex and whose ratio is below its threshold.
|
|
26
|
+
* The substrate is the palette's, else `substrate`, else cream (REQ-465).
|
|
27
|
+
*/
|
|
28
|
+
declare function checkPalette(palette: Palette, substrate?: string): readonly PaletteFinding[];
|
|
29
|
+
|
|
30
|
+
export { type PaletteFinding as P, PALETTE_PAIRS as a, contrastRatio as b, checkPalette as c };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { D as DashboardProps } from './types-
|
|
1
|
+
import { m as CommonChartProps } from './props-BZ9CcrGv.js';
|
|
2
|
+
import { D as DashboardProps } from './types-BT3Xm7fP.js';
|
|
3
3
|
|
|
4
4
|
/** One child of a reference dashboard: the catalog chart it holds, by name, and its props. */
|
|
5
5
|
interface DashboardDemoChild {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,57 +1,10 @@
|
|
|
1
|
-
import { G as Geometry,
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly caption: string;
|
|
9
|
-
readonly columns: readonly string[];
|
|
10
|
-
readonly rows: readonly (readonly string[])[];
|
|
11
|
-
}
|
|
12
|
-
/** What a recipe needs beyond the props: the resolved environment. */
|
|
13
|
-
interface RecipeContext {
|
|
14
|
-
/** Resolved instance id. */
|
|
15
|
-
readonly id: string;
|
|
16
|
-
/** Resolved container width in px; `undefined` while it has not been measured. */
|
|
17
|
-
readonly width: number | undefined;
|
|
18
|
-
readonly locale: string;
|
|
19
|
-
readonly emptyState: Ground['emptyState'];
|
|
20
|
-
readonly domainPadding: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Everything an adapter renders: the geometry plus the accessible layer. Adapters translate
|
|
24
|
-
* it into nodes and compute nothing (Art. 2).
|
|
25
|
-
*/
|
|
26
|
-
interface ChartModel {
|
|
27
|
-
readonly chart: string;
|
|
28
|
-
readonly id: string;
|
|
29
|
-
/** `deferred` while the container has no usable size (REQ-009). */
|
|
30
|
-
readonly status: 'ready' | 'deferred';
|
|
31
|
-
readonly geometry: Geometry;
|
|
32
|
-
readonly chrome: 'card' | 'bare';
|
|
33
|
-
/** Accessible name (REQ-120). */
|
|
34
|
-
readonly name: string;
|
|
35
|
-
/** Description summarising the series (REQ-120). */
|
|
36
|
-
readonly description: string;
|
|
37
|
-
readonly ids: Readonly<{
|
|
38
|
-
title: string;
|
|
39
|
-
desc: string;
|
|
40
|
-
table: string;
|
|
41
|
-
}>;
|
|
42
|
-
readonly table: DataTable;
|
|
43
|
-
readonly dataTable: 'visible' | 'hidden' | 'none';
|
|
44
|
-
}
|
|
45
|
-
/** A chart: its display name and the pure function from props to model. */
|
|
46
|
-
interface ChartRecipe<P extends CommonChartProps> {
|
|
47
|
-
readonly name: string;
|
|
48
|
-
build(props: P, context: RecipeContext): ChartModel;
|
|
49
|
-
}
|
|
50
|
-
/** Imperative handle every adapter exposes, deliberately minimal (API Spec §8.1). */
|
|
51
|
-
interface ChartHandle {
|
|
52
|
-
getGeometry(): Geometry;
|
|
53
|
-
toSVGString(): string;
|
|
54
|
-
}
|
|
1
|
+
import { G as Geometry, n as Seed, o as Stroke, p as StrokePaint, q as InkMode, r as TextLabel, s as Inker, t as GroundRef, u as SubstrateName, m as CommonChartProps, v as ProviderConfig, w as LineChartProps, x as Datum, A as ActiveItem, y as Rect, z as BulletChartProps, F as PyramidChartProps, J as HeatmapChartProps, K as TreemapChartProps, O as SankeyChartProps, Q as ActivityGridProps, U as StepChartProps, X as SparklineRowsProps, Y as KpiCardProps, Z as BarChartProps, _ as StackedBarChartProps, $ as ComposedChartProps, a0 as WaterfallChartProps, a1 as FunnelChartProps, a2 as DonutChartProps, a3 as RadarChartProps, a4 as PolarBarChartProps, a5 as CoxcombChartProps, a6 as RadialArcGroupProps, a7 as RadialRingsProps, a8 as GaugeArcProps, a9 as MeterChartProps, aa as WindRoseProps, ab as ChordRingProps, ac as OrbitChartProps, ad as VolvelleChartProps, ae as CandlestickChartProps, af as AreaChartProps, ag as RangeBandChartProps, ah as StreamChartProps, ai as ScatterChartProps, aj as BubbleChartProps } from './props-BZ9CcrGv.js';
|
|
2
|
+
export { ak as Accessor, a as BeeswarmChartProps, B as BoxPlotChartProps, b as BumpChartProps, al as ChartOrientation, C as ConnectedScatterChartProps, j as ContourChartProps, k as DelaunayChartProps, i as DensityBinChartProps, d as DivergingBarChartProps, D as DumbbellChartProps, E as EcdfChartProps, c as ErrorBarChartProps, am as Ground, an as GroundName, ao as HatchToneSpec, H as HistogramChartProps, ap as HitArea, aq as InkOptions, I as IntervalChartProps, ar as LabelKind, as as LineCurve, L as LollipopChartProps, M as MarimekkoChartProps, N as NetworkChartProps, at as NetworkNode, au as Palette, P as ParallelCoordinatesChartProps, g as PolarLineChartProps, h as PolarScatterChartProps, R as RidgelineChartProps, S as SlopeChartProps, e as SquarifiedTreemapProps, av as StrokePart, aw as StrokeRole, f as SunburstChartProps, ax as Tile, ay as TonalRamp, az as ToneLevel, aA as ToneSpec, T as TreeChartProps, aB as UiTokens, l as VectorFieldChartProps, V as ViolinChartProps, W as WaffleChartProps, aC as WeightToneSpec } from './props-BZ9CcrGv.js';
|
|
3
|
+
import { a as ChartModel, C as ChartRecipe } from './model-DVVt59AB.js';
|
|
4
|
+
export { b as ChartHandle, D as DataTable, R as RecipeContext } from './model-DVVt59AB.js';
|
|
5
|
+
import { P as PerBreakpoint, a as DashboardBreakpoint, b as DashboardLayout, R as ResolvedLayout, D as DashboardProps, c as DashboardModel, d as DashboardView, e as DashboardCellContext } from './types-BT3Xm7fP.js';
|
|
6
|
+
export { f as DashboardCellLayout, g as DashboardCellProps, h as DashboardLink, i as ResolvedCell, j as ResolvedSpan } from './types-BT3Xm7fP.js';
|
|
7
|
+
export { P as PaletteFinding } from './contrast-siWF_R5o.js';
|
|
55
8
|
|
|
56
9
|
/** Rounds to 2 decimals, the precision of every emitted coordinate (REQ-002). */
|
|
57
10
|
declare function round2(value: number): number;
|
|
@@ -185,10 +138,10 @@ declare function toSvgView(model: ChartModel, style: ViewStyle): SvgView;
|
|
|
185
138
|
* Serialises a view to SVG markup. This is the canonical render stored with each fixture;
|
|
186
139
|
* user text is always escaped, never interpolated as markup (TD §6).
|
|
187
140
|
*/
|
|
188
|
-
declare function svgString(view: SvgView): string;
|
|
141
|
+
declare function svgString(view: SvgView, style?: string): string;
|
|
189
142
|
|
|
190
143
|
/** Stable diagnostic codes, part of the public surface (API Spec §11). */
|
|
191
|
-
type SpCode = 'SP001' | 'SP002' | 'SP003' | 'SP004' | 'SP005' | 'SP006' | 'SP007' | 'SP008' | 'SP009' | 'SP010' | 'SP011' | 'SP012' | 'SP013' | 'SP014' | 'SP015' | 'SP016' | 'SP017' | 'SP018' | 'SP019';
|
|
144
|
+
type SpCode = 'SP001' | 'SP002' | 'SP003' | 'SP004' | 'SP005' | 'SP006' | 'SP007' | 'SP008' | 'SP009' | 'SP010' | 'SP011' | 'SP012' | 'SP013' | 'SP014' | 'SP015' | 'SP016' | 'SP017' | 'SP018' | 'SP019' | 'SP020' | 'SP021' | 'SP022' | 'SP023' | 'SP024' | 'SP025';
|
|
192
145
|
interface Detail {
|
|
193
146
|
/** The property involved. */
|
|
194
147
|
readonly property: string;
|
|
@@ -377,7 +330,8 @@ declare const NAVIGATION_KEYS: readonly string[];
|
|
|
377
330
|
* Keyboard traversal of the data points, as a pure function (REQ-122). Right and down move to
|
|
378
331
|
* the next point of the series, left and up to the previous one, Home and End to its ends,
|
|
379
332
|
* Escape clears. On a grid — every item carries a `cell` — the arrows move by column and row
|
|
380
|
-
* instead.
|
|
333
|
+
* instead. A chart with its own model — a hierarchy — gives every item its `moves`, and the keys
|
|
334
|
+
* follow them. Returns `undefined` for a key that is not a navigation key.
|
|
381
335
|
*/
|
|
382
336
|
declare function stepActive(geometry: Geometry, current: ActiveItem | null, key: string): ActiveItem | null | undefined;
|
|
383
337
|
/** Readout of an active item, positioned as percentages of the viewBox (REQ-141). */
|
|
@@ -588,12 +542,14 @@ declare function cellChartBox<P extends CommonChartProps>(cell: {
|
|
|
588
542
|
* The dashboard as an adapter writes it (REQ-200, REQ-214): the section's class, substrate, name
|
|
589
543
|
* and variables, the heading and description, and per cell its variables, its label and the
|
|
590
544
|
* context its chart reads. `children` gives, in source order, each child's `cell` and its chart's
|
|
591
|
-
* own `id` when the adapter can read it.
|
|
545
|
+
* own `id` when the adapter can read it. `palette` is the section's own palette as declarations
|
|
546
|
+
* (`paletteStyle`, from `@silverpoint/core/palettes`, off this entry's budget), written first in its
|
|
547
|
+
* style; the cells hand the palette on to their charts and components (REQ-461, REQ-462).
|
|
592
548
|
*/
|
|
593
549
|
declare function dashboardView(props: DashboardProps, children: readonly {
|
|
594
550
|
readonly cell?: string;
|
|
595
551
|
readonly id?: string;
|
|
596
|
-
}[]): DashboardView;
|
|
552
|
+
}[], palette?: string): DashboardView;
|
|
597
553
|
/**
|
|
598
554
|
* A chart's props inside a cell (API Spec §7.1, size precedence; REQ-212 config precedence): its
|
|
599
555
|
* own `id`, `height` and config win; the cell supplies the rest. `width` is the width to draw at
|
|
@@ -624,4 +580,4 @@ declare function linkFrom(key: string, source: string, active: ActiveItem | null
|
|
|
624
580
|
*/
|
|
625
581
|
declare function linkedMarks(model: Pick<ChartModel, 'id' | 'chart' | 'geometry' | 'table'>, state: LinkState | null | undefined): readonly string[];
|
|
626
582
|
|
|
627
|
-
export { ActiveItem, ActivityGridProps, AreaChartProps, type BandScale, BarChartProps, BubbleChartProps, BulletChartProps, CandlestickChartProps,
|
|
583
|
+
export { ActiveItem, ActivityGridProps, AreaChartProps, type BandScale, BarChartProps, BubbleChartProps, BulletChartProps, CandlestickChartProps, ChartModel, ChartRecipe, ChordRingProps, CommonChartProps, ComposedChartProps, CoxcombChartProps, DASHBOARD_DEFAULTS, DEFAULTS, DISPLAY_FACE_PROBE, DashboardBreakpoint, DashboardCellContext, DashboardLayout, DashboardModel, DashboardProps, DashboardView, Datum, type Detail, type DiagnosticSink, DonutChartProps, FORCED_PRECISION_QUERY, type FontFaceSetLike, FunnelChartProps, GaugeArcProps, Geometry, GroundRef, HeatmapChartProps, InkMode, Inker, type InteractionEvent, type InteractionResult, KpiCardProps, LINE_CHART_DEMO, LINE_CHART_DEMO_KEYS, LineChartProps, type LinearScale, type LinkState, MIN_TOUCH_TARGET, MeterChartProps, NAVIGATION_KEYS, NullInker, OrbitChartProps, PATH_BYTE_BUDGET, type PathView, type PatternView, PerBreakpoint, type PointerKind, PolarBarChartProps, ProviderConfig, PyramidChartProps, RadarChartProps, RadialArcGroupProps, RadialRingsProps, RangeBandChartProps, type Readout, Rect, type ResolvedConfig, ResolvedLayout, SankeyChartProps, type ScaleSite, ScatterChartProps, Seed, SilverpointError, type SpCode, SparklineRowsProps, StackedBarChartProps, StepChartProps, StreamChartProps, Stroke, StrokePaint, SubstrateName, type SvgView, TextLabel, type TextView, TreemapChartProps, type ViewStyle, VolvelleChartProps, WaterfallChartProps, WindRoseProps, __setDiagnosticSink, activityGrid, addDays, areaChart, bandScale, barChart, breakpointOf, bubbleChart, bulletChart, candlestickChart, cellChartBox, checkTypeface, chordRing, circlePath, composedChart, coxcombChart, createPrng, dashboardView, deriveSeed, diagnose, donutChart, enforceHeightening, expandDomain, extent, fnv1a32, funnelChart, gaugeArc, heatmapChart, inCell, instanceId, isoDate, kpiCard, lineChart, linearScale, linkFrom, linkedItems, linkedMarks, max, meterChart, min, orbitChart, parseGeometry, parseIsoDate, pathBytes, perBreakpoint, polarBarChart, pyramidChart, radarChart, radialArcGroup, radialRings, rangeBandChart, readout, reduceInteraction, registerInker, resolveActive, resolveConfig, resolveDashboard, resolveInker, resolveLayout, resolveSeed, round2, roundGeometry, roundPathData, sameActive, sankeyChart, scatterChart, serializeGeometry, sparklineRows, stackedBarChart, stepActive, stepChart, streamChart, svgString, toSvgPoint, toSvgView, treemapChart, volvelleChart, waterfallChart, weekday, windRose };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { DEFAULTS, FORCED_PRECISION_QUERY,
|
|
1
|
+
import { DEFAULTS } from './chunk-KFBSQH5G.js';
|
|
2
|
+
export { DEFAULTS, FORCED_PRECISION_QUERY, instanceId, resolveConfig } from './chunk-KFBSQH5G.js';
|
|
3
|
+
import { cardLayout, modelBase, measure, emptyModel, readyModel, parseIsoDate, isoDate, createPrng, weekday } from './chunk-E5CC2NNQ.js';
|
|
4
|
+
export { addDays, createPrng, isoDate, parseIsoDate, weekday } from './chunk-E5CC2NNQ.js';
|
|
5
|
+
import { circlePath, readSeries, checkVolume, accessorName, read, formatCategory, formatValue, cartesianPlot, extent, seriesValues, valueAxis, categoryAxis, categoryLabels, formatNumber, finite, inset, rectPath, warnValue, toneOf, toneLevel, TONE_SCALE, checkCount, linearScale, legend, AXIS_BAND, PLOT_INSET, horizontalValueAxis, pillPath, checkSectors, readSectors, polarFrame, ringTones, sectorPath, pointAt, sectorLegend, RIM_LABELS, rimLabels, arcPath, ringTone, polarLabel, TICK_CHAR } from './chunk-46QELMCG.js';
|
|
6
|
+
export { bandScale, circlePath, deriveSeed, expandDomain, extent, fnv1a32, linearScale, max, min, resolveSeed } from './chunk-46QELMCG.js';
|
|
7
|
+
import { round2 } from './chunk-5MP3BLZK.js';
|
|
8
|
+
export { round2, roundGeometry, roundPathData } from './chunk-5MP3BLZK.js';
|
|
9
|
+
import { diagnose } from './chunk-WYFRHI4S.js';
|
|
10
|
+
export { SilverpointError, __setDiagnosticSink, diagnose } from './chunk-WYFRHI4S.js';
|
|
3
11
|
import { curveStepAfter, curveNatural, curveLinear, curveMonotoneX, line, curveStep, curveStepBefore, area } from 'd3-shape';
|
|
4
12
|
import { chordDirected } from 'd3-chord';
|
|
5
13
|
|
|
@@ -20,36 +28,6 @@ function pathBytes(geometry) {
|
|
|
20
28
|
}
|
|
21
29
|
var PATH_BYTE_BUDGET = 4e4;
|
|
22
30
|
|
|
23
|
-
// src/render/prng.ts
|
|
24
|
-
function createPrng(seed) {
|
|
25
|
-
let state = seed >>> 0;
|
|
26
|
-
return () => {
|
|
27
|
-
state = state + 1831565813 >>> 0;
|
|
28
|
-
let t = state;
|
|
29
|
-
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
30
|
-
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
31
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/charts/shared/dates.ts
|
|
36
|
-
var DAY_MS = 864e5;
|
|
37
|
-
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
38
|
-
function parseIsoDate(iso) {
|
|
39
|
-
const match = ISO_DATE.exec(iso);
|
|
40
|
-
if (!match) return Number.NaN;
|
|
41
|
-
return Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3])) / DAY_MS;
|
|
42
|
-
}
|
|
43
|
-
function isoDate(day) {
|
|
44
|
-
return new Date(day * DAY_MS).toISOString().slice(0, 10);
|
|
45
|
-
}
|
|
46
|
-
function addDays(day, days) {
|
|
47
|
-
return day + days;
|
|
48
|
-
}
|
|
49
|
-
function weekday(day) {
|
|
50
|
-
return ((day + 4) % 7 + 7) % 7;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
31
|
// src/render/heighten.ts
|
|
54
32
|
function isOutlineOf(candidate, heightened) {
|
|
55
33
|
return candidate.part === "ink" && (candidate.paint ?? "stroke") === "stroke" && candidate.d === heightened.d;
|
|
@@ -140,7 +118,7 @@ function pathString(path) {
|
|
|
140
118
|
["fill", path.fill]
|
|
141
119
|
])}></path>`;
|
|
142
120
|
}
|
|
143
|
-
function svgString(view) {
|
|
121
|
+
function svgString(view, style = "") {
|
|
144
122
|
const { svg } = view;
|
|
145
123
|
const open = `<svg${attributes([
|
|
146
124
|
["xmlns", "http://www.w3.org/2000/svg"],
|
|
@@ -151,7 +129,9 @@ function svgString(view) {
|
|
|
151
129
|
["data-substrate", svg.substrate],
|
|
152
130
|
["data-mode", svg.mode],
|
|
153
131
|
["role", svg.role],
|
|
154
|
-
["aria-labelledby", svg.labelledby]
|
|
132
|
+
["aria-labelledby", svg.labelledby],
|
|
133
|
+
// A palette's declarations (REQ-461): the only attribute it changes (REQ-468).
|
|
134
|
+
["style", style || null]
|
|
155
135
|
])}>`;
|
|
156
136
|
const title = `<title id="${escape(view.title.id)}">${escape(view.title.text)}</title>`;
|
|
157
137
|
const desc = `<desc id="${escape(view.desc.id)}">${escape(view.desc.text)}</desc>`;
|
|
@@ -215,141 +195,6 @@ function resolveInker(name, chart, builtins = []) {
|
|
|
215
195
|
return NullInker;
|
|
216
196
|
}
|
|
217
197
|
|
|
218
|
-
// src/charts/shared/card.ts
|
|
219
|
-
var CARD_PADDING = 16;
|
|
220
|
-
var TITLE_ROW = 20;
|
|
221
|
-
var VALUE_ROW = 52;
|
|
222
|
-
var HEADER_GAP = 8;
|
|
223
|
-
var FOOTER_ROW = 30;
|
|
224
|
-
function cardLayout(props, options) {
|
|
225
|
-
const { width, areaHeight: areaHeight2, chrome, locale } = options;
|
|
226
|
-
if (chrome === "bare") {
|
|
227
|
-
const box = { x: 0, y: 0, width, height: areaHeight2 };
|
|
228
|
-
return { viewBox: box, area: box, strokes: [], labels: [] };
|
|
229
|
-
}
|
|
230
|
-
const labels = [];
|
|
231
|
-
const strokes = [];
|
|
232
|
-
const left = CARD_PADDING;
|
|
233
|
-
const right = width - CARD_PADDING;
|
|
234
|
-
let cursor = CARD_PADDING;
|
|
235
|
-
if (props.title !== void 0 || props.badge !== void 0) {
|
|
236
|
-
const baseline = cursor + 11;
|
|
237
|
-
if (props.title !== void 0) {
|
|
238
|
-
labels.push({ x: left, y: baseline, text: props.title, kind: "title", part: "text", anchor: "start" });
|
|
239
|
-
}
|
|
240
|
-
if (props.badge !== void 0) {
|
|
241
|
-
labels.push({ x: right, y: baseline, text: props.badge, kind: "badge", part: "axis", anchor: "end" });
|
|
242
|
-
}
|
|
243
|
-
cursor += TITLE_ROW;
|
|
244
|
-
}
|
|
245
|
-
if (props.value !== void 0 || props.unit !== void 0) {
|
|
246
|
-
if (props.value !== void 0) {
|
|
247
|
-
labels.push({
|
|
248
|
-
x: left,
|
|
249
|
-
y: cursor + 30,
|
|
250
|
-
text: formatValue(props.value, locale, props.numberFormat),
|
|
251
|
-
kind: "value",
|
|
252
|
-
part: "text",
|
|
253
|
-
anchor: "start"
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
if (props.unit !== void 0) {
|
|
257
|
-
labels.push({ x: left, y: cursor + 46, text: props.unit, kind: "unit", part: "axis", anchor: "start" });
|
|
258
|
-
}
|
|
259
|
-
cursor += VALUE_ROW;
|
|
260
|
-
}
|
|
261
|
-
if (cursor > CARD_PADDING) cursor += HEADER_GAP;
|
|
262
|
-
const area5 = { x: left, y: cursor, width: right - left, height: areaHeight2 };
|
|
263
|
-
cursor += areaHeight2;
|
|
264
|
-
if (props.footerLeft !== void 0 || props.footerRight !== void 0) {
|
|
265
|
-
const ruleY = cursor + 8;
|
|
266
|
-
strokes.push({ d: `M${left},${ruleY}H${right}`, role: "ornament", part: "rule" });
|
|
267
|
-
if (props.footerLeft !== void 0) {
|
|
268
|
-
labels.push({ x: left, y: ruleY + 18, text: props.footerLeft, kind: "footer", part: "axis", anchor: "start" });
|
|
269
|
-
}
|
|
270
|
-
if (props.footerRight !== void 0) {
|
|
271
|
-
labels.push({ x: right, y: ruleY + 18, text: props.footerRight, kind: "footer", part: "axis", anchor: "end" });
|
|
272
|
-
}
|
|
273
|
-
cursor += FOOTER_ROW;
|
|
274
|
-
}
|
|
275
|
-
const height = cursor + CARD_PADDING;
|
|
276
|
-
const inset2 = 0.5;
|
|
277
|
-
strokes.unshift({
|
|
278
|
-
d: `M${inset2},${inset2}H${width - inset2}V${height - inset2}H${inset2}Z`,
|
|
279
|
-
role: "ornament",
|
|
280
|
-
part: "rule"
|
|
281
|
-
});
|
|
282
|
-
return { viewBox: { x: 0, y: 0, width, height }, area: area5, strokes, labels };
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// src/charts/shared/shell.ts
|
|
286
|
-
function modelBase(chart, props, context, fallbackName, table) {
|
|
287
|
-
const { id } = context;
|
|
288
|
-
const name = props.label ?? props.title ?? fallbackName;
|
|
289
|
-
return {
|
|
290
|
-
chart,
|
|
291
|
-
id,
|
|
292
|
-
chrome: props.chrome ?? "card",
|
|
293
|
-
name,
|
|
294
|
-
ids: { title: `${id}-title`, desc: `${id}-desc`, table: `${id}-table` },
|
|
295
|
-
table: { caption: name, ...table },
|
|
296
|
-
dataTable: props.dataTable ?? "hidden"
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function areaHeight(props) {
|
|
300
|
-
return props.height ?? 160;
|
|
301
|
-
}
|
|
302
|
-
function measure(base, props, context) {
|
|
303
|
-
const width = props.width ?? context.width;
|
|
304
|
-
const height = areaHeight(props);
|
|
305
|
-
if (width !== void 0 && width > 0 && height > 0) return { width, height };
|
|
306
|
-
if (width !== void 0 && process.env.NODE_ENV !== "production") {
|
|
307
|
-
diagnose("SP003", base.chart, {
|
|
308
|
-
property: width <= 0 ? "width" : "height",
|
|
309
|
-
message: `Measured ${width} \xD7 ${height} px.`
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
const box = { x: 0, y: 0, width: 0, height: 0 };
|
|
313
|
-
return {
|
|
314
|
-
deferred: {
|
|
315
|
-
...base,
|
|
316
|
-
status: "deferred",
|
|
317
|
-
geometry: { viewBox: box, plot: box, strokes: [], labels: [], hitAreas: [], defs: [] },
|
|
318
|
-
description: props.description ?? base.name
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
function emptyModel(base, props, context, frame, datasetEmpty) {
|
|
323
|
-
if (datasetEmpty && process.env.NODE_ENV !== "production") {
|
|
324
|
-
diagnose("SP001", base.chart, { property: "data" });
|
|
325
|
-
}
|
|
326
|
-
const { plot } = frame;
|
|
327
|
-
const strokes = [...frame.strokes];
|
|
328
|
-
if (context.emptyState.rule) {
|
|
329
|
-
strokes.push({ d: `M${plot.x},${plot.y + plot.height}H${plot.x + plot.width}`, role: "ornament", part: "rule" });
|
|
330
|
-
}
|
|
331
|
-
const labels = [
|
|
332
|
-
...frame.labels,
|
|
333
|
-
{
|
|
334
|
-
x: plot.x + plot.width / 2,
|
|
335
|
-
y: plot.y + plot.height / 2,
|
|
336
|
-
text: context.emptyState.text,
|
|
337
|
-
kind: "empty",
|
|
338
|
-
part: "axis",
|
|
339
|
-
anchor: "middle"
|
|
340
|
-
}
|
|
341
|
-
];
|
|
342
|
-
return {
|
|
343
|
-
...base,
|
|
344
|
-
status: "ready",
|
|
345
|
-
description: props.description ?? `${base.name}. ${context.emptyState.text}.`,
|
|
346
|
-
geometry: roundGeometry({ viewBox: frame.viewBox, plot, strokes, labels, hitAreas: [], defs: [] })
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
function readyModel(base, description, geometry) {
|
|
350
|
-
return { ...base, status: "ready", description, geometry: roundGeometry({ ...geometry, defs: [] }) };
|
|
351
|
-
}
|
|
352
|
-
|
|
353
198
|
// src/charts/line-chart/demo.ts
|
|
354
199
|
var LINE_CHART_DEMO = /* @__PURE__ */ Object.freeze(
|
|
355
200
|
/* @__PURE__ */ [
|
|
@@ -545,6 +390,12 @@ var NAVIGATION_KEYS = ["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp", "Home"
|
|
|
545
390
|
function stepActive(geometry, current, key) {
|
|
546
391
|
if (!NAVIGATION_KEYS.includes(key)) return void 0;
|
|
547
392
|
if (key === "Escape") return null;
|
|
393
|
+
const hits = geometry.hitAreas;
|
|
394
|
+
if (hits[0]?.moves) {
|
|
395
|
+
const here = current ? hits.findIndex((hit) => hit.seriesKey === current.seriesKey && hit.index === current.index) : -1;
|
|
396
|
+
const to = here < 0 ? hits[0].moves[key === "End" ? "End" : "Home"] : hits[here]?.moves?.[key];
|
|
397
|
+
return toActiveItem(hits[to ?? Math.max(here, 0)]);
|
|
398
|
+
}
|
|
548
399
|
const grid = geometry.hitAreas.length > 0 && geometry.hitAreas.every((hit) => hit.cell !== void 0);
|
|
549
400
|
if (grid) return stepGrid(geometry.hitAreas, current, key);
|
|
550
401
|
const seriesKey = current?.seriesKey ?? geometry.hitAreas[0]?.seriesKey;
|
|
@@ -837,7 +688,6 @@ var CELL_GAP = 2;
|
|
|
837
688
|
var HEADER_BAND = 14;
|
|
838
689
|
var DIGIT_WIDTH = 5.5;
|
|
839
690
|
var LINE_HEIGHT = 12;
|
|
840
|
-
var CELL_SCALE = { 0: 0.4, 1: 0.55, 2: 0.7, 3: 0.85, 4: 1 };
|
|
841
691
|
function buildHeatmapChart(props, context) {
|
|
842
692
|
const usesDemo = props.data === void 0;
|
|
843
693
|
const data = props.data ?? HEATMAP_CHART_DEMO;
|
|
@@ -910,7 +760,7 @@ function buildHeatmapChart(props, context) {
|
|
|
910
760
|
continue;
|
|
911
761
|
}
|
|
912
762
|
const tone = toneOf(value / scaleMax);
|
|
913
|
-
const scale = printed ? 1 :
|
|
763
|
+
const scale = printed ? 1 : TONE_SCALE[tone];
|
|
914
764
|
const drawn = { x: cx - cell.width * scale / 2, y: cy - cell.height * scale / 2, width: cell.width * scale, height: cell.height * scale };
|
|
915
765
|
strokes.push({ d: rectPath(drawn), role: "encoding", part: "ink", ...tone > 0 ? { tone } : {} });
|
|
916
766
|
if (printed) labels.push({ x: cx, y: cy + 4, text: formatNumber(value, locale, numberFormat), kind: "tick", part: "text", anchor: "middle" });
|
|
@@ -1221,8 +1071,8 @@ var CHART7 = "ActivityGrid";
|
|
|
1221
1071
|
var PLOT_INSET7 = 6;
|
|
1222
1072
|
var MONTH_BAND = 14;
|
|
1223
1073
|
var DEFAULT_WEEKS = 26;
|
|
1224
|
-
var
|
|
1225
|
-
var
|
|
1074
|
+
var DAY_MS = 864e5;
|
|
1075
|
+
var CELL_SCALE = { 0: 0.4, 1: 0.55, 2: 0.7, 3: 0.85, 4: 1 };
|
|
1226
1076
|
var CELL_FILL = 0.86;
|
|
1227
1077
|
var MONTH_GAP = 3;
|
|
1228
1078
|
function buildActivityGrid(props, context) {
|
|
@@ -1287,7 +1137,7 @@ function buildActivityGrid(props, context) {
|
|
|
1287
1137
|
const column = Math.floor(index / 7);
|
|
1288
1138
|
const row = index % 7;
|
|
1289
1139
|
if (row === 0) {
|
|
1290
|
-
const name = month.format(new Date(d.day *
|
|
1140
|
+
const name = month.format(new Date(d.day * DAY_MS));
|
|
1291
1141
|
const last = months.at(-1);
|
|
1292
1142
|
if (name !== last?.name) {
|
|
1293
1143
|
if (last && column - last.column < MONTH_GAP) {
|
|
@@ -1297,7 +1147,7 @@ function buildActivityGrid(props, context) {
|
|
|
1297
1147
|
}
|
|
1298
1148
|
}
|
|
1299
1149
|
}
|
|
1300
|
-
const side = slot * CELL_FILL *
|
|
1150
|
+
const side = slot * CELL_FILL * CELL_SCALE[d.level];
|
|
1301
1151
|
const cx = plot.x + column * slot + slot / 2;
|
|
1302
1152
|
const cy = top + row * slot + slot / 2;
|
|
1303
1153
|
const cell = { x: cx - side / 2, y: cy - side / 2, width: side, height: side };
|
|
@@ -4349,7 +4199,7 @@ function cellChartBox(cell, chartProps, recipe) {
|
|
|
4349
4199
|
}
|
|
4350
4200
|
|
|
4351
4201
|
// src/dashboard/view.ts
|
|
4352
|
-
function dashboardView(props, children) {
|
|
4202
|
+
function dashboardView(props, children, palette = "") {
|
|
4353
4203
|
const model = resolveDashboard(props, children.map((c) => c.cell));
|
|
4354
4204
|
if (props.title === void 0 && props.label === void 0 && process.env.NODE_ENV !== "production") {
|
|
4355
4205
|
diagnose("SP002", "Dashboard", { property: "title", message: "Name the region with `title` or `label`." });
|
|
@@ -4361,7 +4211,7 @@ function dashboardView(props, children) {
|
|
|
4361
4211
|
const heading = titled ? { level: props.headingLevel ?? DASHBOARD_DEFAULTS.headingLevel, id: `${base}-title`, text: props.title } : void 0;
|
|
4362
4212
|
const description = props.description !== void 0 ? { id: `${base}-desc`, text: props.description } : void 0;
|
|
4363
4213
|
const config = {};
|
|
4364
|
-
for (const key of ["ground", "substrate", "mode", "locale"]) {
|
|
4214
|
+
for (const key of ["ground", "substrate", "mode", "locale", "palette"]) {
|
|
4365
4215
|
if (props[key] !== void 0) config[key] = props[key];
|
|
4366
4216
|
}
|
|
4367
4217
|
return {
|
|
@@ -4371,7 +4221,7 @@ function dashboardView(props, children) {
|
|
|
4371
4221
|
substrate: props.substrate ?? DEFAULTS.substrate,
|
|
4372
4222
|
...heading ? { labelledby: heading.id } : { label: props.label },
|
|
4373
4223
|
...description ? { describedby: description.id } : {},
|
|
4374
|
-
style: model.style
|
|
4224
|
+
style: { ...Object.fromEntries(palette.split(";").filter(Boolean).map((d) => d.split(":"))), ...model.style }
|
|
4375
4225
|
},
|
|
4376
4226
|
...heading ? { heading } : {},
|
|
4377
4227
|
...description ? { description } : {},
|
|
@@ -4388,6 +4238,11 @@ function inCell(props, cell, recipe) {
|
|
|
4388
4238
|
const box = cellChartBox(cell.box, props, recipe);
|
|
4389
4239
|
const merged = { ...props };
|
|
4390
4240
|
for (const [key, value] of Object.entries(cell.config)) merged[key] ??= value;
|
|
4241
|
+
if (props.palette && cell.config.palette) {
|
|
4242
|
+
const palette = { ...cell.config.palette };
|
|
4243
|
+
for (const [field, value] of Object.entries(props.palette)) if (value !== void 0) palette[field] = value;
|
|
4244
|
+
merged.palette = palette;
|
|
4245
|
+
}
|
|
4391
4246
|
return {
|
|
4392
4247
|
props: { ...merged, id: props.id ?? cell.chartId, height: props.height ?? box.height },
|
|
4393
4248
|
width: props.width ?? box.width
|
|
@@ -4410,6 +4265,6 @@ function linkedMarks(model, state) {
|
|
|
4410
4265
|
return linkedItems(model, state.key, state.value).map((index) => readout(model, toActiveItem(model.geometry.hitAreas[index])).marker.d);
|
|
4411
4266
|
}
|
|
4412
4267
|
|
|
4413
|
-
export { DASHBOARD_DEFAULTS, DISPLAY_FACE_PROBE, LINE_CHART_DEMO, LINE_CHART_DEMO_KEYS, MIN_TOUCH_TARGET, NAVIGATION_KEYS, NullInker, PATH_BYTE_BUDGET, activityGrid,
|
|
4268
|
+
export { DASHBOARD_DEFAULTS, DISPLAY_FACE_PROBE, LINE_CHART_DEMO, LINE_CHART_DEMO_KEYS, MIN_TOUCH_TARGET, NAVIGATION_KEYS, NullInker, PATH_BYTE_BUDGET, activityGrid, areaChart, barChart, breakpointOf, bubbleChart, bulletChart, candlestickChart, cellChartBox, checkTypeface, chordRing, composedChart, coxcombChart, dashboardView, donutChart, enforceHeightening, funnelChart, gaugeArc, heatmapChart, inCell, kpiCard, lineChart, linkFrom, linkedItems, linkedMarks, meterChart, orbitChart, parseGeometry, pathBytes, perBreakpoint, polarBarChart, pyramidChart, radarChart, radialArcGroup, radialRings, rangeBandChart, readout, reduceInteraction, registerInker, resolveActive, resolveDashboard, resolveInker, resolveLayout, sameActive, sankeyChart, scatterChart, serializeGeometry, sparklineRows, stackedBarChart, stepActive, stepChart, streamChart, svgString, toSvgPoint, toSvgView, treemapChart, volvelleChart, waterfallChart, windRose };
|
|
4414
4269
|
//# sourceMappingURL=index.js.map
|
|
4415
4270
|
//# sourceMappingURL=index.js.map
|