@silverpoint/core 0.3.0 → 0.6.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 +4 -0
- package/dist/catalog.d.ts +97 -0
- package/dist/catalog.js +8002 -0
- package/dist/catalog.js.map +1 -0
- package/dist/chunk-KFBSQH5G.js +34 -0
- package/dist/chunk-KFBSQH5G.js.map +1 -0
- package/dist/{chunk-I6BAZ7MJ.js → chunk-OLYKR5PS.js} +55 -45
- package/dist/chunk-OLYKR5PS.js.map +1 -0
- package/dist/chunk-PD4MD7JU.js +170 -0
- package/dist/chunk-PD4MD7JU.js.map +1 -0
- package/dist/dashboard-demos.d.ts +2 -2
- package/dist/index.d.ts +10 -57
- package/dist/index.js +18 -174
- package/dist/index.js.map +1 -1
- package/dist/model-CLhtoG75.d.ts +53 -0
- package/dist/{props-3G1XYd-r.d.ts → props-Dq8FC8GG.d.ts} +342 -2
- package/dist/{types-CbVMKvyQ.d.ts → types-B81k-s9_.d.ts} +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +2 -1
- package/dist/ui.js.map +1 -1
- package/package.json +7 -1
- package/dist/chunk-I6BAZ7MJ.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,57 +1,9 @@
|
|
|
1
|
-
import { G as Geometry,
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interface DataTable {
|
|
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-Dq8FC8GG.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, P as ParallelCoordinatesChartProps, g as PolarLineChartProps, h as PolarScatterChartProps, R as RidgelineChartProps, S as SlopeChartProps, e as SquarifiedTreemapProps, au as StrokePart, av as StrokeRole, f as SunburstChartProps, aw as Tile, ax as TonalRamp, ay as ToneLevel, az as ToneSpec, T as TreeChartProps, aA as UiTokens, l as VectorFieldChartProps, V as ViolinChartProps, W as WaffleChartProps, aB as WeightToneSpec } from './props-Dq8FC8GG.js';
|
|
3
|
+
import { a as ChartModel, C as ChartRecipe } from './model-CLhtoG75.js';
|
|
4
|
+
export { b as ChartHandle, D as DataTable, R as RecipeContext } from './model-CLhtoG75.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-B81k-s9_.js';
|
|
6
|
+
export { f as DashboardCellLayout, g as DashboardCellProps, h as DashboardLink, i as ResolvedCell, j as ResolvedSpan } from './types-B81k-s9_.js';
|
|
55
7
|
|
|
56
8
|
/** Rounds to 2 decimals, the precision of every emitted coordinate (REQ-002). */
|
|
57
9
|
declare function round2(value: number): number;
|
|
@@ -188,7 +140,7 @@ declare function toSvgView(model: ChartModel, style: ViewStyle): SvgView;
|
|
|
188
140
|
declare function svgString(view: SvgView): string;
|
|
189
141
|
|
|
190
142
|
/** 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';
|
|
143
|
+
type SpCode = 'SP001' | 'SP002' | 'SP003' | 'SP004' | 'SP005' | 'SP006' | 'SP007' | 'SP008' | 'SP009' | 'SP010' | 'SP011' | 'SP012' | 'SP013' | 'SP014' | 'SP015' | 'SP016' | 'SP017' | 'SP018' | 'SP019' | 'SP020' | 'SP021' | 'SP022';
|
|
192
144
|
interface Detail {
|
|
193
145
|
/** The property involved. */
|
|
194
146
|
readonly property: string;
|
|
@@ -377,7 +329,8 @@ declare const NAVIGATION_KEYS: readonly string[];
|
|
|
377
329
|
* Keyboard traversal of the data points, as a pure function (REQ-122). Right and down move to
|
|
378
330
|
* the next point of the series, left and up to the previous one, Home and End to its ends,
|
|
379
331
|
* Escape clears. On a grid — every item carries a `cell` — the arrows move by column and row
|
|
380
|
-
* instead.
|
|
332
|
+
* instead. A chart with its own model — a hierarchy — gives every item its `moves`, and the keys
|
|
333
|
+
* follow them. Returns `undefined` for a key that is not a navigation key.
|
|
381
334
|
*/
|
|
382
335
|
declare function stepActive(geometry: Geometry, current: ActiveItem | null, key: string): ActiveItem | null | undefined;
|
|
383
336
|
/** Readout of an active item, positioned as percentages of the viewBox (REQ-141). */
|
|
@@ -624,4 +577,4 @@ declare function linkFrom(key: string, source: string, active: ActiveItem | null
|
|
|
624
577
|
*/
|
|
625
578
|
declare function linkedMarks(model: Pick<ChartModel, 'id' | 'chart' | 'geometry' | 'table'>, state: LinkState | null | undefined): readonly string[];
|
|
626
579
|
|
|
627
|
-
export { ActiveItem, ActivityGridProps, AreaChartProps, type BandScale, BarChartProps, BubbleChartProps, BulletChartProps, CandlestickChartProps,
|
|
580
|
+
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,9 @@
|
|
|
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-PD4MD7JU.js';
|
|
4
|
+
export { addDays, createPrng, isoDate, parseIsoDate, weekday } from './chunk-PD4MD7JU.js';
|
|
5
|
+
import { diagnose, circlePath, round2, 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-OLYKR5PS.js';
|
|
6
|
+
export { SilverpointError, __setDiagnosticSink, bandScale, circlePath, deriveSeed, diagnose, expandDomain, extent, fnv1a32, linearScale, max, min, resolveSeed, round2, roundGeometry, roundPathData } from './chunk-OLYKR5PS.js';
|
|
3
7
|
import { curveStepAfter, curveNatural, curveLinear, curveMonotoneX, line, curveStep, curveStepBefore, area } from 'd3-shape';
|
|
4
8
|
import { chordDirected } from 'd3-chord';
|
|
5
9
|
|
|
@@ -20,36 +24,6 @@ function pathBytes(geometry) {
|
|
|
20
24
|
}
|
|
21
25
|
var PATH_BYTE_BUDGET = 4e4;
|
|
22
26
|
|
|
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
27
|
// src/render/heighten.ts
|
|
54
28
|
function isOutlineOf(candidate, heightened) {
|
|
55
29
|
return candidate.part === "ink" && (candidate.paint ?? "stroke") === "stroke" && candidate.d === heightened.d;
|
|
@@ -215,141 +189,6 @@ function resolveInker(name, chart, builtins = []) {
|
|
|
215
189
|
return NullInker;
|
|
216
190
|
}
|
|
217
191
|
|
|
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
192
|
// src/charts/line-chart/demo.ts
|
|
354
193
|
var LINE_CHART_DEMO = /* @__PURE__ */ Object.freeze(
|
|
355
194
|
/* @__PURE__ */ [
|
|
@@ -545,6 +384,12 @@ var NAVIGATION_KEYS = ["ArrowRight", "ArrowDown", "ArrowLeft", "ArrowUp", "Home"
|
|
|
545
384
|
function stepActive(geometry, current, key) {
|
|
546
385
|
if (!NAVIGATION_KEYS.includes(key)) return void 0;
|
|
547
386
|
if (key === "Escape") return null;
|
|
387
|
+
const hits = geometry.hitAreas;
|
|
388
|
+
if (hits[0]?.moves) {
|
|
389
|
+
const here = current ? hits.findIndex((hit) => hit.seriesKey === current.seriesKey && hit.index === current.index) : -1;
|
|
390
|
+
const to = here < 0 ? hits[0].moves[key === "End" ? "End" : "Home"] : hits[here]?.moves?.[key];
|
|
391
|
+
return toActiveItem(hits[to ?? Math.max(here, 0)]);
|
|
392
|
+
}
|
|
548
393
|
const grid = geometry.hitAreas.length > 0 && geometry.hitAreas.every((hit) => hit.cell !== void 0);
|
|
549
394
|
if (grid) return stepGrid(geometry.hitAreas, current, key);
|
|
550
395
|
const seriesKey = current?.seriesKey ?? geometry.hitAreas[0]?.seriesKey;
|
|
@@ -837,7 +682,6 @@ var CELL_GAP = 2;
|
|
|
837
682
|
var HEADER_BAND = 14;
|
|
838
683
|
var DIGIT_WIDTH = 5.5;
|
|
839
684
|
var LINE_HEIGHT = 12;
|
|
840
|
-
var CELL_SCALE = { 0: 0.4, 1: 0.55, 2: 0.7, 3: 0.85, 4: 1 };
|
|
841
685
|
function buildHeatmapChart(props, context) {
|
|
842
686
|
const usesDemo = props.data === void 0;
|
|
843
687
|
const data = props.data ?? HEATMAP_CHART_DEMO;
|
|
@@ -910,7 +754,7 @@ function buildHeatmapChart(props, context) {
|
|
|
910
754
|
continue;
|
|
911
755
|
}
|
|
912
756
|
const tone = toneOf(value / scaleMax);
|
|
913
|
-
const scale = printed ? 1 :
|
|
757
|
+
const scale = printed ? 1 : TONE_SCALE[tone];
|
|
914
758
|
const drawn = { x: cx - cell.width * scale / 2, y: cy - cell.height * scale / 2, width: cell.width * scale, height: cell.height * scale };
|
|
915
759
|
strokes.push({ d: rectPath(drawn), role: "encoding", part: "ink", ...tone > 0 ? { tone } : {} });
|
|
916
760
|
if (printed) labels.push({ x: cx, y: cy + 4, text: formatNumber(value, locale, numberFormat), kind: "tick", part: "text", anchor: "middle" });
|
|
@@ -1221,8 +1065,8 @@ var CHART7 = "ActivityGrid";
|
|
|
1221
1065
|
var PLOT_INSET7 = 6;
|
|
1222
1066
|
var MONTH_BAND = 14;
|
|
1223
1067
|
var DEFAULT_WEEKS = 26;
|
|
1224
|
-
var
|
|
1225
|
-
var
|
|
1068
|
+
var DAY_MS = 864e5;
|
|
1069
|
+
var CELL_SCALE = { 0: 0.4, 1: 0.55, 2: 0.7, 3: 0.85, 4: 1 };
|
|
1226
1070
|
var CELL_FILL = 0.86;
|
|
1227
1071
|
var MONTH_GAP = 3;
|
|
1228
1072
|
function buildActivityGrid(props, context) {
|
|
@@ -1287,7 +1131,7 @@ function buildActivityGrid(props, context) {
|
|
|
1287
1131
|
const column = Math.floor(index / 7);
|
|
1288
1132
|
const row = index % 7;
|
|
1289
1133
|
if (row === 0) {
|
|
1290
|
-
const name = month.format(new Date(d.day *
|
|
1134
|
+
const name = month.format(new Date(d.day * DAY_MS));
|
|
1291
1135
|
const last = months.at(-1);
|
|
1292
1136
|
if (name !== last?.name) {
|
|
1293
1137
|
if (last && column - last.column < MONTH_GAP) {
|
|
@@ -1297,7 +1141,7 @@ function buildActivityGrid(props, context) {
|
|
|
1297
1141
|
}
|
|
1298
1142
|
}
|
|
1299
1143
|
}
|
|
1300
|
-
const side = slot * CELL_FILL *
|
|
1144
|
+
const side = slot * CELL_FILL * CELL_SCALE[d.level];
|
|
1301
1145
|
const cx = plot.x + column * slot + slot / 2;
|
|
1302
1146
|
const cy = top + row * slot + slot / 2;
|
|
1303
1147
|
const cell = { x: cx - side / 2, y: cy - side / 2, width: side, height: side };
|
|
@@ -4410,6 +4254,6 @@ function linkedMarks(model, state) {
|
|
|
4410
4254
|
return linkedItems(model, state.key, state.value).map((index) => readout(model, toActiveItem(model.geometry.hitAreas[index])).marker.d);
|
|
4411
4255
|
}
|
|
4412
4256
|
|
|
4413
|
-
export { DASHBOARD_DEFAULTS, DISPLAY_FACE_PROBE, LINE_CHART_DEMO, LINE_CHART_DEMO_KEYS, MIN_TOUCH_TARGET, NAVIGATION_KEYS, NullInker, PATH_BYTE_BUDGET, activityGrid,
|
|
4257
|
+
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
4258
|
//# sourceMappingURL=index.js.map
|
|
4415
4259
|
//# sourceMappingURL=index.js.map
|