@lilt-ui/charts 0.1.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/LICENSE +21 -0
- package/README.md +107 -0
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/activity-ring.d.ts +44 -0
- package/dist/analysis-BLLWEKBw.js +105 -0
- package/dist/cards/activity-ring-card.d.ts +60 -0
- package/dist/cards/area-chart-card.d.ts +19 -0
- package/dist/cards/area-chart-card.typecheck.d.ts +9 -0
- package/dist/cards/bar-chart-card.d.ts +34 -0
- package/dist/cards/cartesian-card.d.ts +206 -0
- package/dist/cards/chart-card.d.ts +77 -0
- package/dist/cards/combo-chart-card.d.ts +51 -0
- package/dist/cards/format.d.ts +36 -0
- package/dist/cards/funnel-chart-card.d.ts +62 -0
- package/dist/cards/heatmap-chart-card.d.ts +107 -0
- package/dist/cards/horizontal-bar-chart-card.d.ts +60 -0
- package/dist/cards/keys.d.ts +19 -0
- package/dist/cards/line-chart-card.d.ts +19 -0
- package/dist/cards/progress-card.d.ts +55 -0
- package/dist/cards/radar-chart-card.d.ts +93 -0
- package/dist/cards/radial-chart-card.d.ts +79 -0
- package/dist/cards/rank.d.ts +21 -0
- package/dist/cards/sankey-chart-card.d.ts +69 -0
- package/dist/cards/scatter-chart-card.d.ts +91 -0
- package/dist/cards/slope-chart-card.d.ts +73 -0
- package/dist/cards/stat-card.d.ts +68 -0
- package/dist/chart-context.d.ts +102 -0
- package/dist/chart-plot.d.ts +13 -0
- package/dist/chart.d.ts +17 -0
- package/dist/data/chart-data.d.ts +24 -0
- package/dist/data.d.ts +5 -0
- package/dist/data.js +2 -0
- package/dist/engine/analysis.d.ts +11 -0
- package/dist/engine/bars.d.ts +38 -0
- package/dist/engine/comparison.d.ts +3 -0
- package/dist/engine/composition.d.ts +6 -0
- package/dist/engine/domains.d.ts +13 -0
- package/dist/engine/geometry.d.ts +73 -0
- package/dist/engine/lifecycle.d.ts +10 -0
- package/dist/engine/lookup.d.ts +3 -0
- package/dist/engine/normalize.d.ts +21 -0
- package/dist/engine/ranking.d.ts +20 -0
- package/dist/engine/sankey.d.ts +36 -0
- package/dist/engine/scatter.d.ts +15 -0
- package/dist/engine/slope.d.ts +46 -0
- package/dist/engine/stack.d.ts +11 -0
- package/dist/export-chart-svg.d.ts +8 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +11309 -0
- package/dist/interaction/adaptive-readout.d.ts +16 -0
- package/dist/interaction/axis-cursor.d.ts +30 -0
- package/dist/interaction/brush-gesture.d.ts +15 -0
- package/dist/interaction/brush-view.d.ts +12 -0
- package/dist/interaction/chart-controller.d.ts +6 -0
- package/dist/interaction/chart-sync.d.ts +35 -0
- package/dist/interaction/comparison-answer.d.ts +11 -0
- package/dist/interaction/comparison-layer.d.ts +19 -0
- package/dist/interaction/comparison-tooltip.d.ts +14 -0
- package/dist/interaction/focus-overview.d.ts +10 -0
- package/dist/interaction/inspection-layer.d.ts +29 -0
- package/dist/interaction/legend.d.ts +50 -0
- package/dist/interaction/pin-marker.d.ts +12 -0
- package/dist/interaction/tooltip-context.d.ts +4 -0
- package/dist/interaction/tooltip-view.d.ts +26 -0
- package/dist/interaction/tooltip.d.ts +10 -0
- package/dist/interaction/use-category-state.d.ts +24 -0
- package/dist/interaction/use-pinned-selection.d.ts +3 -0
- package/dist/interaction/value-legend.d.ts +32 -0
- package/dist/interaction/visibility.d.ts +8 -0
- package/dist/lifecycle/loading-layer.d.ts +38 -0
- package/dist/lifecycle/skeleton-sheen.d.ts +18 -0
- package/dist/lifecycle/status-content.d.ts +6 -0
- package/dist/model/cartesian-model.d.ts +132 -0
- package/dist/model/cartesian-model.typecheck.d.ts +1 -0
- package/dist/model/use-chart-state.d.ts +6 -0
- package/dist/motion/animated-number.d.ts +54 -0
- package/dist/motion/bounded-text.d.ts +13 -0
- package/dist/motion/entrance.d.ts +9 -0
- package/dist/motion/number-format.d.ts +4 -0
- package/dist/motion/use-chart-motion.d.ts +10 -0
- package/dist/motion/use-focus-domain.d.ts +7 -0
- package/dist/motion/use-glide.d.ts +13 -0
- package/dist/motion/use-series-weights.d.ts +2 -0
- package/dist/paint.d.ts +11 -0
- package/dist/primitives/annotations.d.ts +4 -0
- package/dist/primitives/area.d.ts +8 -0
- package/dist/primitives/axes.d.ts +9 -0
- package/dist/primitives/bar-shape.d.ts +39 -0
- package/dist/primitives/bar.d.ts +7 -0
- package/dist/primitives/change-comparison.d.ts +3 -0
- package/dist/primitives/grid.d.ts +3 -0
- package/dist/primitives/interval-band.d.ts +4 -0
- package/dist/primitives/line.d.ts +8 -0
- package/dist/primitives/plot-background.d.ts +10 -0
- package/dist/primitives/reference-line.d.ts +4 -0
- package/dist/primitives/runoff.d.ts +49 -0
- package/dist/runtime/chart-runtime.d.ts +95 -0
- package/dist/styles.css +2 -0
- package/dist/toolkit/chart-brush.d.ts +3 -0
- package/dist/toolkit/chart-overview.d.ts +3 -0
- package/dist/toolkit/chart-range-summary.d.ts +5 -0
- package/dist/toolkit/chart-readout.d.ts +3 -0
- package/dist/toolkit/chart-toolbar.d.ts +3 -0
- package/dist/toolkit/comparison-details.d.ts +7 -0
- package/dist/types.d.ts +555 -0
- package/dist/use-chart-width.d.ts +5 -0
- package/media/cards-dark.webp +0 -0
- package/media/cards-light.webp +0 -0
- package/media/hero-dark.webp +0 -0
- package/media/hero-light.webp +0 -0
- package/package.json +71 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartMotion, ChartPalette, ChartStyle, ChartSurface, RankingOrder } from '../types';
|
|
3
|
+
import { CardRange } from './cartesian-card';
|
|
4
|
+
import { NumericKey, TextKey } from './keys';
|
|
5
|
+
import { RankedRow } from './rank';
|
|
6
|
+
import { AnimatedNumberVariant } from '../motion/animated-number';
|
|
7
|
+
export type RadialChartCardVariant = 'donut' | 'pie' | 'semi' | 'rings';
|
|
8
|
+
export interface RadialChartCardProps<Row, Key extends NumericKey<Row>> {
|
|
9
|
+
title: string;
|
|
10
|
+
/** One row per category. Omit when `ranges` supplies the data. */
|
|
11
|
+
data?: readonly Row[];
|
|
12
|
+
/** Text field that names each slice. Names must be unique. */
|
|
13
|
+
category: TextKey<Row>;
|
|
14
|
+
/** Numeric field sized by each slice. Values must not be negative; `null` is "No data". */
|
|
15
|
+
value: Key;
|
|
16
|
+
/**
|
|
17
|
+
* `donut` (default) shows the share in the middle, `pie` fills the circle, `semi` is a half
|
|
18
|
+
* donut with rounded ends, and `rings` gives each category its own ring on one shared scale.
|
|
19
|
+
*/
|
|
20
|
+
variant?: RadialChartCardVariant;
|
|
21
|
+
/**
|
|
22
|
+
* `list` rows with value and share, value `tiles`, or an `inline` key. Defaults to tiles for
|
|
23
|
+
* rings, inline for semi, and list otherwise.
|
|
24
|
+
*/
|
|
25
|
+
legend?: 'list' | 'tiles' | 'inline';
|
|
26
|
+
/** Resting headline. Defaults to the total of every slice. */
|
|
27
|
+
headline?: number;
|
|
28
|
+
/** Fractional change shown as a chip, e.g. 0.082 → +8.2%. */
|
|
29
|
+
delta?: number;
|
|
30
|
+
deltaTone?: 'default' | 'inverse' | 'neutral';
|
|
31
|
+
/** Static period label, e.g. "This month". */
|
|
32
|
+
range?: string;
|
|
33
|
+
/** Period select. Each range replaces data, delta, and headline; slices ease to their new size. */
|
|
34
|
+
ranges?: readonly CardRange<Row>[];
|
|
35
|
+
defaultRange?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Slices shown before the rest are added up as one "Other" slice. Defaults to 5, since more
|
|
38
|
+
* than six colors stop being told apart. `Infinity` shows every category.
|
|
39
|
+
*/
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** Label of the combined slice. Defaults to "Other". */
|
|
42
|
+
otherLabel?: string;
|
|
43
|
+
/** `descending` (default) puts the largest first; `input` keeps your order. */
|
|
44
|
+
sort?: RankingOrder;
|
|
45
|
+
valueFormat?: Intl.NumberFormatOptions;
|
|
46
|
+
locale?: string;
|
|
47
|
+
formatValue?: (value: number) => string;
|
|
48
|
+
surface?: ChartSurface;
|
|
49
|
+
/** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */
|
|
50
|
+
badge?: ReactNode;
|
|
51
|
+
/** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */
|
|
52
|
+
numberStyle?: AnimatedNumberVariant;
|
|
53
|
+
palette?: ChartPalette;
|
|
54
|
+
loading?: boolean;
|
|
55
|
+
/** `none` turns off decorative motion; reduced-motion users get this automatically. */
|
|
56
|
+
motion?: ChartMotion;
|
|
57
|
+
className?: string;
|
|
58
|
+
style?: CSSProperties | ChartStyle;
|
|
59
|
+
}
|
|
60
|
+
interface Slice {
|
|
61
|
+
id: string;
|
|
62
|
+
startAngle: number;
|
|
63
|
+
endAngle: number;
|
|
64
|
+
}
|
|
65
|
+
/** Angles for each observed slice, in row order. Missing values take no room. */
|
|
66
|
+
export declare function sliceAngles(rows: readonly RankedRow[]): Slice[];
|
|
67
|
+
/**
|
|
68
|
+
* The top of a rings scale: the largest value rounded up to a quarter step of its magnitude, so
|
|
69
|
+
* the longest ring stops short of closing and every ring reads against the same full turn.
|
|
70
|
+
*/
|
|
71
|
+
export declare function ringScale(max: number): number;
|
|
72
|
+
/** One ring per observed row: each sweeps from the top by its value on the shared scale. */
|
|
73
|
+
export declare function ringAngles(rows: readonly RankedRow[]): Slice[];
|
|
74
|
+
/**
|
|
75
|
+
* A donut or pie card: the headline total, slices with a matching legend, and each slice's
|
|
76
|
+
* share. Hovering a slice or a legend row reads it in the headline.
|
|
77
|
+
*/
|
|
78
|
+
export declare function RadialChartCard<Row, const Key extends NumericKey<Row>>({ title, data: suppliedData, category, value, variant, legend, headline: suppliedHeadline, delta: suppliedDelta, deltaTone, range, ranges, defaultRange, limit, otherLabel, sort, valueFormat, locale, formatValue: suppliedFormatValue, surface, badge, numberStyle, palette, loading, motion: motionMode, className, style, }: RadialChartCardProps<Row, Key>): ReactElement;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RankingOrder } from '../types';
|
|
2
|
+
/** One ranked category, or the "Other" row that adds up everything past the limit. */
|
|
3
|
+
export interface RankedRow {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
value: number | null;
|
|
7
|
+
other?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const OTHER_ID = "\0other";
|
|
10
|
+
export declare const sharePercent: Intl.NumberFormat;
|
|
11
|
+
/** Rank rows, then fold everything past `limit` into one "Other" row. */
|
|
12
|
+
export declare function rankRows<Row>(data: readonly Row[], category: string, value: string, sort: RankingOrder, limit: number | undefined, otherLabel: string): RankedRow[];
|
|
13
|
+
/**
|
|
14
|
+
* The total of observed values and whether shares of it mean anything: they don't when values
|
|
15
|
+
* mix gains and losses, or when nothing positive was observed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function shareTotals(rows: readonly RankedRow[]): {
|
|
18
|
+
observed: number;
|
|
19
|
+
total: number;
|
|
20
|
+
shareable: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { SankeyGraph, SankeyLink, SankeyNode } from '../engine/sankey';
|
|
3
|
+
import { ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
|
|
4
|
+
import { CardRange } from './cartesian-card';
|
|
5
|
+
import { NumericKey, TextKey } from './keys';
|
|
6
|
+
import { AnimatedNumberVariant } from '../motion/animated-number';
|
|
7
|
+
export interface SankeyChartCardProps<Row, Key extends NumericKey<Row>> {
|
|
8
|
+
title: string;
|
|
9
|
+
/** One row per flow between two steps. Omit when `ranges` supplies the data. */
|
|
10
|
+
data?: readonly Row[];
|
|
11
|
+
/** Text field naming the step a flow leaves. */
|
|
12
|
+
source: TextKey<Row>;
|
|
13
|
+
/** Text field naming the step a flow reaches. */
|
|
14
|
+
target: TextKey<Row>;
|
|
15
|
+
/** How much moves along the flow. `null` means it wasn't measured and isn't drawn. */
|
|
16
|
+
value: Key;
|
|
17
|
+
/**
|
|
18
|
+
* `loss` (default) lets a step pass on less than it receives, as when visitors leave;
|
|
19
|
+
* `strict` requires every middle step to pass on exactly what it receives.
|
|
20
|
+
*/
|
|
21
|
+
conservation?: 'loss' | 'strict';
|
|
22
|
+
/** Plot height in pixels. Defaults to 280. */
|
|
23
|
+
height?: number;
|
|
24
|
+
/** Resting headline. Defaults to everything entering the first steps. */
|
|
25
|
+
headline?: number;
|
|
26
|
+
/** Fractional change shown as a chip, e.g. 0.052 → +5.2%. */
|
|
27
|
+
delta?: number;
|
|
28
|
+
deltaTone?: 'default' | 'inverse' | 'neutral';
|
|
29
|
+
/** Static period label, e.g. "Last 7 days". */
|
|
30
|
+
range?: string;
|
|
31
|
+
/** Period select. Each range replaces data, delta, and headline; flows redraw left to right. */
|
|
32
|
+
ranges?: readonly CardRange<Row>[];
|
|
33
|
+
defaultRange?: string;
|
|
34
|
+
valueFormat?: Intl.NumberFormatOptions;
|
|
35
|
+
locale?: string;
|
|
36
|
+
formatValue?: (value: number) => string;
|
|
37
|
+
surface?: ChartSurface;
|
|
38
|
+
/** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */
|
|
39
|
+
badge?: ReactNode;
|
|
40
|
+
/** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */
|
|
41
|
+
numberStyle?: AnimatedNumberVariant;
|
|
42
|
+
palette?: ChartPalette;
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
/** `none` turns off decorative motion; reduced-motion users get this automatically. */
|
|
45
|
+
motion?: ChartMotion;
|
|
46
|
+
className?: string;
|
|
47
|
+
style?: CSSProperties | ChartStyle;
|
|
48
|
+
}
|
|
49
|
+
interface FlowGraph<Row> {
|
|
50
|
+
graph: SankeyGraph<SankeyNode, SankeyLink & {
|
|
51
|
+
row: Row;
|
|
52
|
+
}> | null;
|
|
53
|
+
error: string | null;
|
|
54
|
+
}
|
|
55
|
+
/** Turn rows of flows into a validated graph; steps take their names from the rows. */
|
|
56
|
+
export declare function sankeyGraph<Row>({ data, source, target, value, conservation, }: {
|
|
57
|
+
data: readonly Row[];
|
|
58
|
+
source: string;
|
|
59
|
+
target: string;
|
|
60
|
+
value: string;
|
|
61
|
+
conservation: 'loss' | 'strict';
|
|
62
|
+
}): FlowGraph<Row>;
|
|
63
|
+
/**
|
|
64
|
+
* A Sankey card: steps as columns of nodes, flows between them as ribbons whose thickness is the
|
|
65
|
+
* amount that moved. Hovering or stepping through flows with the arrow keys reads each in the
|
|
66
|
+
* headline with its share of the step it left.
|
|
67
|
+
*/
|
|
68
|
+
export declare function SankeyChartCard<Row, const Key extends NumericKey<Row>>({ title, data: suppliedData, source, target, value, conservation, height, headline: suppliedHeadline, delta: suppliedDelta, deltaTone, range, ranges, defaultRange, valueFormat, locale, formatValue: suppliedFormatValue, surface, badge, numberStyle, palette, loading, motion: motionMode, className, style, }: SankeyChartCardProps<Row, Key>): ReactElement;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
|
|
3
|
+
import { CardRange } from './cartesian-card';
|
|
4
|
+
import { NumericKey, TextKey } from './keys';
|
|
5
|
+
import { AnimatedNumberVariant } from '../motion/animated-number';
|
|
6
|
+
/** How the resting headline sums up every plotted point's `y`. */
|
|
7
|
+
export type ScatterAggregate = 'sum' | 'mean' | 'max';
|
|
8
|
+
export interface ScatterChartCardProps<Row, Key extends NumericKey<Row>> {
|
|
9
|
+
title: string;
|
|
10
|
+
/** One row per point. Omit when `ranges` supplies the data. */
|
|
11
|
+
data?: readonly Row[];
|
|
12
|
+
/** Numeric field for the horizontal position. */
|
|
13
|
+
x: NumericKey<Row>;
|
|
14
|
+
/** Numeric field for the vertical position. It also drives the headline. */
|
|
15
|
+
y: Key;
|
|
16
|
+
/** Numeric field that sizes each point by area, turning dots into bubbles. */
|
|
17
|
+
size?: NumericKey<Row>;
|
|
18
|
+
/** Names the size measure in readouts, e.g. "Reach". */
|
|
19
|
+
sizeLabel?: string;
|
|
20
|
+
/** Text field that colors points by group and adds a legend. */
|
|
21
|
+
group?: TextKey<Row>;
|
|
22
|
+
/** Text field that names a point when it is hovered or focused. */
|
|
23
|
+
label?: TextKey<Row>;
|
|
24
|
+
/** Axis titles, e.g. "Spend" and "Sign-ups". */
|
|
25
|
+
xLabel?: string;
|
|
26
|
+
yLabel?: string;
|
|
27
|
+
/** A least-squares line through the points, with its r² in the footer. */
|
|
28
|
+
trend?: boolean;
|
|
29
|
+
/** Plot height in pixels, including the axes. Defaults to 260. */
|
|
30
|
+
height?: number;
|
|
31
|
+
/** How the resting headline sums up `y`: `sum` (default), `mean`, or `max`. */
|
|
32
|
+
aggregate?: ScatterAggregate;
|
|
33
|
+
/** Resting headline. Defaults to the `aggregate` of every plotted `y`. */
|
|
34
|
+
headline?: number;
|
|
35
|
+
/** Fractional change shown as a chip, e.g. 0.052 → +5.2%. */
|
|
36
|
+
delta?: number;
|
|
37
|
+
deltaTone?: 'default' | 'inverse' | 'neutral';
|
|
38
|
+
/** Static period label, e.g. "Last 30 days". */
|
|
39
|
+
range?: string;
|
|
40
|
+
/** Period select. Each range replaces data, delta, and headline; points glide to their place. */
|
|
41
|
+
ranges?: readonly CardRange<Row>[];
|
|
42
|
+
defaultRange?: string;
|
|
43
|
+
/** Number format for `y`: the headline, legend, and y axis. */
|
|
44
|
+
valueFormat?: Intl.NumberFormatOptions;
|
|
45
|
+
/** Number format for `x`, e.g. `{ style: 'currency', currency: 'USD' }`. */
|
|
46
|
+
xFormat?: Intl.NumberFormatOptions;
|
|
47
|
+
locale?: string;
|
|
48
|
+
formatValue?: (value: number) => string;
|
|
49
|
+
formatX?: (value: number) => string;
|
|
50
|
+
/** Any CSS color for the points when there is no `group`. */
|
|
51
|
+
color?: string;
|
|
52
|
+
surface?: ChartSurface;
|
|
53
|
+
/** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */
|
|
54
|
+
badge?: ReactNode;
|
|
55
|
+
/** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */
|
|
56
|
+
numberStyle?: AnimatedNumberVariant;
|
|
57
|
+
palette?: ChartPalette;
|
|
58
|
+
loading?: boolean;
|
|
59
|
+
/** `none` turns off decorative motion; reduced-motion users get this automatically. */
|
|
60
|
+
motion?: ChartMotion;
|
|
61
|
+
className?: string;
|
|
62
|
+
style?: CSSProperties | ChartStyle;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A readable domain for one axis: rounded to the same ticks the axis draws, anchored at zero when
|
|
66
|
+
* the data starts near it, and never zero-width.
|
|
67
|
+
*/
|
|
68
|
+
export declare function scatterDomain(values: readonly number[], ticks?: number): [number, number];
|
|
69
|
+
/** Least-squares fit. `null` when fewer than three points or every x is the same. */
|
|
70
|
+
export declare function scatterTrend(points: readonly {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
}[]): {
|
|
74
|
+
slope: number;
|
|
75
|
+
intercept: number;
|
|
76
|
+
r2: number;
|
|
77
|
+
} | null;
|
|
78
|
+
/**
|
|
79
|
+
* The part of the line `y = slope·x + intercept` between `x0` and `x1` that stays inside the y
|
|
80
|
+
* domain, or `null` when it never enters it.
|
|
81
|
+
*/
|
|
82
|
+
export declare function clipTrend(fit: {
|
|
83
|
+
slope: number;
|
|
84
|
+
intercept: number;
|
|
85
|
+
}, [x0, x1]: readonly [number, number], [low, high]: readonly [number, number]): [number, number, number, number] | null;
|
|
86
|
+
/**
|
|
87
|
+
* A scatter card: one point per row, placed by two measurements and optionally sized by a third
|
|
88
|
+
* and colored by group. Hovering or stepping through points with the arrow keys reads each one in
|
|
89
|
+
* the headline, with its position marked on both axes.
|
|
90
|
+
*/
|
|
91
|
+
export declare function ScatterChartCard<Row, const Key extends NumericKey<Row>>({ title, data: suppliedData, x, y, size, sizeLabel, group, label, xLabel, yLabel, trend, height, aggregate, headline: suppliedHeadline, delta: suppliedDelta, deltaTone, range, ranges, defaultRange, valueFormat, xFormat, locale, formatValue: suppliedFormatValue, formatX: suppliedFormatX, color, surface, badge, numberStyle, palette, loading, motion: motionMode, className, style, }: ScatterChartCardProps<Row, Key>): ReactElement;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { SlopeOrder } from '../engine/slope';
|
|
3
|
+
import { ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
|
|
4
|
+
import { CardRange } from './cartesian-card';
|
|
5
|
+
import { NumericKey, TextKey } from './keys';
|
|
6
|
+
import { AnimatedNumberVariant } from '../motion/animated-number';
|
|
7
|
+
export type { SlopeOrder } from '../engine/slope';
|
|
8
|
+
export interface SlopeChartCardProps<Row, Key extends NumericKey<Row>> {
|
|
9
|
+
title: string;
|
|
10
|
+
/** One row per category with both measurements. Omit when `ranges` supplies the data. */
|
|
11
|
+
data?: readonly Row[];
|
|
12
|
+
/** Text field that names each row. Names must be unique. */
|
|
13
|
+
category: TextKey<Row>;
|
|
14
|
+
/** Numeric field with the earlier value, e.g. last year. */
|
|
15
|
+
from: Key;
|
|
16
|
+
/** Numeric field with the later value, e.g. this year. */
|
|
17
|
+
to: Key;
|
|
18
|
+
/** Names the earlier measurement. Defaults to the `from` key. */
|
|
19
|
+
fromLabel?: string;
|
|
20
|
+
/** Names the later measurement. Defaults to the `to` key. */
|
|
21
|
+
toLabel?: string;
|
|
22
|
+
/**
|
|
23
|
+
* `slope` (default) joins each category's two values across two columns; `dumbbell` lists
|
|
24
|
+
* categories as rows with both values on one shared scale.
|
|
25
|
+
*/
|
|
26
|
+
variant?: 'slope' | 'dumbbell';
|
|
27
|
+
/** `change` (default) puts the largest gain first, `to` the largest later value, `input` keeps your order. */
|
|
28
|
+
sort?: SlopeOrder;
|
|
29
|
+
/**
|
|
30
|
+
* How the headline and its change summarize categories: `sum` (default) for counts and money,
|
|
31
|
+
* `mean` for rates and shares.
|
|
32
|
+
*/
|
|
33
|
+
aggregate?: 'sum' | 'mean';
|
|
34
|
+
/** Resting headline. Defaults to the later values summarized with `aggregate`. */
|
|
35
|
+
headline?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Fractional change for the chip. Defaults to the change in total across categories measured
|
|
38
|
+
* at both ends.
|
|
39
|
+
*/
|
|
40
|
+
delta?: number;
|
|
41
|
+
/** Direction is not desirability. Use `inverse` when a decrease is good, `neutral` for neither. */
|
|
42
|
+
deltaTone?: 'default' | 'inverse' | 'neutral';
|
|
43
|
+
/** Static period label, e.g. "2025 → 2026". */
|
|
44
|
+
range?: string;
|
|
45
|
+
/** Period select. Each range replaces data, delta and headline. */
|
|
46
|
+
ranges?: readonly CardRange<Row>[];
|
|
47
|
+
defaultRange?: string;
|
|
48
|
+
/** One color for every category. By default rises and falls take the positive and negative colors. */
|
|
49
|
+
color?: string;
|
|
50
|
+
/** Plot height in pixels for the slope variant. Defaults to 260. */
|
|
51
|
+
height?: number;
|
|
52
|
+
valueFormat?: Intl.NumberFormatOptions;
|
|
53
|
+
locale?: string;
|
|
54
|
+
formatValue?: (value: number) => string;
|
|
55
|
+
surface?: ChartSurface;
|
|
56
|
+
/** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */
|
|
57
|
+
badge?: ReactNode;
|
|
58
|
+
/** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */
|
|
59
|
+
numberStyle?: AnimatedNumberVariant;
|
|
60
|
+
palette?: ChartPalette;
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
/** `none` turns off decorative motion; reduced-motion users get this automatically. */
|
|
63
|
+
motion?: ChartMotion;
|
|
64
|
+
className?: string;
|
|
65
|
+
style?: CSSProperties | ChartStyle;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Two measurements per category, such as last year and this year. The slope variant shows who
|
|
69
|
+
* rose and who fell at a glance; the dumbbell variant lists the gap for each category. Hovering a
|
|
70
|
+
* category reads its later value and change in the headline; click pins it, and the arrow keys
|
|
71
|
+
* move through categories.
|
|
72
|
+
*/
|
|
73
|
+
export declare function SlopeChartCard<Row, const Key extends NumericKey<Row>>({ title, data: suppliedData, category, from, to, fromLabel, toLabel, variant, sort, aggregate, headline: suppliedHeadline, delta: suppliedDelta, deltaTone, range, ranges, defaultRange, color, height, valueFormat, locale, formatValue: suppliedFormatValue, surface, badge, numberStyle, palette, loading, motion: motionMode, className, style, }: SlopeChartCardProps<Row, Key>): ReactElement;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartBarAppearance, ChartMotion, ChartPalette, ChartStyle, ChartSurface } from '../types';
|
|
3
|
+
import { NumericKey, XKey, XKind } from './keys';
|
|
4
|
+
import { CardAggregate } from './format';
|
|
5
|
+
import { AnimatedNumberVariant } from '../motion/animated-number';
|
|
6
|
+
export type StatCardChart = 'area' | 'line' | 'bars' | 'meter' | 'ring' | 'none';
|
|
7
|
+
export interface StatCardProps<Row, Key extends NumericKey<Row>> {
|
|
8
|
+
/** The metric's name, e.g. "Revenue". Also names the card for screen readers. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** One row per observation. Optional when `headline` is supplied. */
|
|
11
|
+
data?: readonly Row[];
|
|
12
|
+
/** Numeric field to summarize and chart. */
|
|
13
|
+
value?: Key;
|
|
14
|
+
/** Field that names each observation on hover: text, number, or Date. */
|
|
15
|
+
x?: XKey<Row>;
|
|
16
|
+
/** Override x inference. Numbers default to `number`; use `time` for timestamps. */
|
|
17
|
+
xType?: XKind;
|
|
18
|
+
/** Resting value. Defaults to `value` summarized with `aggregate`. */
|
|
19
|
+
headline?: number;
|
|
20
|
+
/**
|
|
21
|
+
* How the resting value summarizes the data: `sum` (default) for counts and money, `mean` or
|
|
22
|
+
* `max` for rates, `last` for levels such as active users.
|
|
23
|
+
*/
|
|
24
|
+
aggregate?: CardAggregate;
|
|
25
|
+
/** Fractional change shown as a chip, e.g. 0.082 → +8.2%. */
|
|
26
|
+
delta?: number;
|
|
27
|
+
deltaTone?: 'default' | 'inverse' | 'neutral';
|
|
28
|
+
/** Quiet text beside the delta, e.g. "vs last month". */
|
|
29
|
+
caption?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The small chart: `area` (default), `line`, or `bars` under the value; a `meter` of cells or a
|
|
32
|
+
* `ring` beside the value, both filling toward `target`; or `none`.
|
|
33
|
+
*/
|
|
34
|
+
chart?: StatCardChart;
|
|
35
|
+
/** Bar treatment for `chart="bars"`: `solid` (default), `segmented`, `needle`, `gradient`, `outline`. */
|
|
36
|
+
barStyle?: ChartBarAppearance;
|
|
37
|
+
/** Goal for `chart="meter"` or `chart="ring"`, in the same unit as the value. */
|
|
38
|
+
target?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Link the small chart's hover with every card that uses the same name, matched by `x`.
|
|
41
|
+
* Requires `x`.
|
|
42
|
+
*/
|
|
43
|
+
sync?: string;
|
|
44
|
+
/** Chart height in pixels. Defaults to 56 (also the ring's size), or 10 for a meter. */
|
|
45
|
+
height?: number;
|
|
46
|
+
/** Any CSS color. Defaults to the palette's first color. */
|
|
47
|
+
color?: string;
|
|
48
|
+
/** Right side of the header, e.g. an icon or a menu. */
|
|
49
|
+
aside?: ReactNode;
|
|
50
|
+
valueFormat?: Intl.NumberFormatOptions;
|
|
51
|
+
locale?: string;
|
|
52
|
+
formatValue?: (value: number) => string;
|
|
53
|
+
formatX?: (value: string | number | Date) => string;
|
|
54
|
+
/** `elevated` (default), `outline`, or `ghost` inside your own card. */
|
|
55
|
+
surface?: ChartSurface;
|
|
56
|
+
/** A glass tab tucked behind the card's top edge, e.g. a caption, a command, or actions. */
|
|
57
|
+
badge?: ReactNode;
|
|
58
|
+
/** Headline motion: `count` (default), `pop`, `slide`, `roll`, `flow`, or `scramble`. */
|
|
59
|
+
numberStyle?: AnimatedNumberVariant;
|
|
60
|
+
palette?: ChartPalette;
|
|
61
|
+
loading?: boolean;
|
|
62
|
+
motion?: ChartMotion;
|
|
63
|
+
className?: string;
|
|
64
|
+
style?: CSSProperties | ChartStyle;
|
|
65
|
+
}
|
|
66
|
+
/** Cells of a meter: whole cells up to the value, then one cell trimmed to the exact remainder. */
|
|
67
|
+
export declare function meterCells(ratio: number, count?: number): number[];
|
|
68
|
+
export declare function StatCard<Row, const Key extends NumericKey<Row>>({ title, data, value: valueKey, x, xType, headline: suppliedHeadline, aggregate, delta, deltaTone, caption, chart, barStyle, target, sync, height, color, aside, valueFormat, locale, formatValue: suppliedFormatValue, formatX, surface, badge, numberStyle, palette, loading, motion, className, style, }: StatCardProps<Row, Key>): ReactElement;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ChartBarLayout, ChartMargins, ChartSeries, ChartXConfig, ChartYConfig } from './types';
|
|
2
|
+
import { NormalizedData } from './engine/normalize';
|
|
3
|
+
import { PlotGeometry } from './engine/geometry';
|
|
4
|
+
import { StackMode } from './engine/stack';
|
|
5
|
+
export declare const DEFAULT_MARGINS: ChartMargins;
|
|
6
|
+
export interface PlotBox {
|
|
7
|
+
left: number;
|
|
8
|
+
top: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
right: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
}
|
|
14
|
+
/** Which series a plot draws as bars and which it stacks, resolved from its props. */
|
|
15
|
+
export interface PlotArrangement {
|
|
16
|
+
/** Series drawn as bars, or null for none. Stacked bars draw exactly the stack's series. */
|
|
17
|
+
bars: readonly string[] | null;
|
|
18
|
+
/** Series that stack, in chart series order, and how they combine. */
|
|
19
|
+
stack: {
|
|
20
|
+
series: readonly string[];
|
|
21
|
+
mode: StackMode;
|
|
22
|
+
} | null;
|
|
23
|
+
}
|
|
24
|
+
export declare const LINE_ARRANGEMENT: PlotArrangement;
|
|
25
|
+
export interface ChartSnapshot<T> {
|
|
26
|
+
bars: readonly string[] | null;
|
|
27
|
+
/** `signed` marks a sum stack with values below zero. */
|
|
28
|
+
stack: {
|
|
29
|
+
series: readonly string[];
|
|
30
|
+
mode: StackMode;
|
|
31
|
+
signed: boolean;
|
|
32
|
+
} | null;
|
|
33
|
+
barLayout: ChartBarLayout;
|
|
34
|
+
stackWeights?: Readonly<Record<string, number>>;
|
|
35
|
+
data: NormalizedData<T>;
|
|
36
|
+
xDomain: readonly [number, number];
|
|
37
|
+
yDomain: readonly [number, number] | null;
|
|
38
|
+
xTicks: readonly number[];
|
|
39
|
+
yTicks: readonly number[];
|
|
40
|
+
xToPixel: (value: number) => number;
|
|
41
|
+
yToPixel: (value: number) => number;
|
|
42
|
+
geometry: PlotGeometry | null;
|
|
43
|
+
plot: PlotBox;
|
|
44
|
+
formatX: (value: number) => string;
|
|
45
|
+
formatY: (value: number) => string;
|
|
46
|
+
/** Raw measurements retain their unit when the plotted axis is normalized. */
|
|
47
|
+
formatValue: (value: number) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Present when some series use `scale: 'secondary'`: their values equal primary values times
|
|
50
|
+
* `factor`, so they share the primary ticks.
|
|
51
|
+
*/
|
|
52
|
+
secondary: {
|
|
53
|
+
factor: number;
|
|
54
|
+
format: (value: number) => string;
|
|
55
|
+
} | null;
|
|
56
|
+
}
|
|
57
|
+
export interface AxisTick {
|
|
58
|
+
value: number;
|
|
59
|
+
entering?: boolean;
|
|
60
|
+
leaving?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ChartContextValue<T> {
|
|
63
|
+
snapshot: ChartSnapshot<T>;
|
|
64
|
+
previousSnapshot: ChartSnapshot<T> | null;
|
|
65
|
+
series: readonly ChartSeries<T>[];
|
|
66
|
+
xConfig: ChartXConfig<T>;
|
|
67
|
+
yConfig: ChartYConfig;
|
|
68
|
+
margins: ChartMargins;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
revealProgress: number;
|
|
72
|
+
reducedMotion: boolean;
|
|
73
|
+
transitionDuration: number;
|
|
74
|
+
transitionKind: 'initial' | 'handoff' | 'matched-update' | 'topology-update' | null;
|
|
75
|
+
axis: {
|
|
76
|
+
x: readonly AxisTick[];
|
|
77
|
+
y: readonly AxisTick[];
|
|
78
|
+
};
|
|
79
|
+
clipId: string;
|
|
80
|
+
gridGradientId: string;
|
|
81
|
+
paintId: (seriesId: string, treatment: 'fade' | 'hatch' | 'dots') => string;
|
|
82
|
+
inspectionSeries?: string;
|
|
83
|
+
inspecting: boolean;
|
|
84
|
+
focusedSeries?: string | null;
|
|
85
|
+
visibleSeries: readonly string[];
|
|
86
|
+
}
|
|
87
|
+
declare const ChartContext: import('react').Context<ChartContextValue<unknown> | null>;
|
|
88
|
+
export declare function ChartContextProvider<T>({ value, children, }: {
|
|
89
|
+
value: ChartContextValue<T>;
|
|
90
|
+
children: React.ReactNode;
|
|
91
|
+
}): React.ReactElement;
|
|
92
|
+
export declare function useChartContext<T>(): ChartContextValue<T>;
|
|
93
|
+
export declare function defaultXFormatter(type: 'time' | 'number', value: number): string;
|
|
94
|
+
export declare function defaultYFormatter(value: number): string;
|
|
95
|
+
export declare function makeAxisTicks(snapshot: ChartSnapshot<unknown>, previous: ChartSnapshot<unknown> | undefined): {
|
|
96
|
+
x: AxisTick[];
|
|
97
|
+
y: AxisTick[];
|
|
98
|
+
};
|
|
99
|
+
export declare function buildSnapshot<T>(data: NormalizedData<T>, series: readonly ChartSeries<T>[], xConfig: ChartXConfig<T>, yConfig: ChartYConfig, margins: ChartMargins, width: number, height: number, yDomainOverride?: readonly [number, number] | null, xDomainOverride?: readonly [number, number] | null, geometrySeries?: readonly ChartSeries<T>[], arrangement?: PlotArrangement, stackWeights?: Readonly<Record<string, number>>, barLayout?: ChartBarLayout,
|
|
100
|
+
/** Keeps line and area observations off the plot edges so labels can center on them. */
|
|
101
|
+
edgeInset?: number): ChartSnapshot<T>;
|
|
102
|
+
export { ChartContext };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ChartBars, ChartPlotProps, ChartStack, ChartStackMode } from './types';
|
|
3
|
+
import { CartesianChartModel } from './model/cartesian-model';
|
|
4
|
+
export type ModelChartPlotProps<Row, Id extends string> = Omit<ChartPlotProps, 'bars' | 'stack'> & {
|
|
5
|
+
model: CartesianChartModel<Row, Id>;
|
|
6
|
+
bars?: true | ChartBars<NoInfer<Id>>;
|
|
7
|
+
stack?: true | ChartStackMode | ChartStack<NoInfer<Id>>;
|
|
8
|
+
inspectionSeries?: NoInfer<Id>;
|
|
9
|
+
};
|
|
10
|
+
export declare function ChartPlot<Row, Id extends string>(props: ModelChartPlotProps<Row, Id>): ReactElement;
|
|
11
|
+
export declare function ChartPlot(props: ChartPlotProps & {
|
|
12
|
+
model?: never;
|
|
13
|
+
}): ReactElement;
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { PlotArrangement } from './chart-context';
|
|
3
|
+
import { ChartBarLayout, ChartPlotProps, ChartProps } from './types';
|
|
4
|
+
import { ToolkitStore } from './runtime/chart-runtime';
|
|
5
|
+
import { CartesianChartModel } from './model/cartesian-model';
|
|
6
|
+
type ChartPlotRendererProps<T> = Omit<ChartProps<T>, 'className' | 'style'> & Omit<ChartPlotProps, 'bars' | 'stack' | 'tooltip'> & {
|
|
7
|
+
arrangement?: PlotArrangement;
|
|
8
|
+
barLayout?: ChartBarLayout;
|
|
9
|
+
selectedCategoryId?: string | null;
|
|
10
|
+
onSelectedCategoryIdChange?: (id: string | null) => void;
|
|
11
|
+
toolkit: ToolkitStore;
|
|
12
|
+
model?: CartesianChartModel<T, string>;
|
|
13
|
+
controllerLinked?: boolean;
|
|
14
|
+
tooltipNode?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
export declare function ChartPlotRenderer<T>({ data, x, y, series, height, compactHeight, margins: marginProps, arrangement, barLayout: barsProps, compact, tooltipNode, inspectionSeries: plotInspectionSeries, className, style, 'aria-label': ariaLabel, children, status, interactive, error, renderRetry, motion: motionPreference, animateIn, resetKey, onSelectionChange, controller, linkedSelection, selectedCategoryId, onSelectedCategoryIdChange, compare, focus, live, brush, visibleSeries, onVisibleSeriesChange, toolkit, model, controllerLinked, axis: axisStyle, pill, pillSeries, pillValue, pillPosition, axisInset, runoff, labelOverhang, }: ChartPlotRendererProps<T>): ReactElement;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChartRange } from '../types';
|
|
2
|
+
export interface ChartSummary {
|
|
3
|
+
count: number;
|
|
4
|
+
missing: number;
|
|
5
|
+
total: number | null;
|
|
6
|
+
mean: number | null;
|
|
7
|
+
min: number | null;
|
|
8
|
+
max: number | null;
|
|
9
|
+
first: number | null;
|
|
10
|
+
last: number | null;
|
|
11
|
+
change: number | null;
|
|
12
|
+
}
|
|
13
|
+
/** Inclusive bounds; missing observations are counted, never silently turned into zero. */
|
|
14
|
+
export declare function summarizeRange<T>(data: readonly T[], options: {
|
|
15
|
+
x: (row: T) => number | Date;
|
|
16
|
+
value: (row: T) => number | null;
|
|
17
|
+
range?: ChartRange | null;
|
|
18
|
+
}): ChartSummary;
|
|
19
|
+
export interface CsvColumn<T> {
|
|
20
|
+
header: string;
|
|
21
|
+
value: (row: T) => string | number | boolean | Date | null;
|
|
22
|
+
}
|
|
23
|
+
/** RFC 4180 fields, UTC dates, blank nulls and spreadsheet-safe text cells. No browser side effects. */
|
|
24
|
+
export declare function toChartCsv<T>(data: readonly T[], columns: readonly CsvColumn<T>[]): string;
|
package/dist/data.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Server-safe data operations. This entry does not import the interactive chart runtime. */
|
|
2
|
+
export { summarizeRange, toChartCsv } from './data/chart-data';
|
|
3
|
+
export type { ChartSummary, CsvColumn } from './data/chart-data';
|
|
4
|
+
export { funnelRows as summarizeFunnelStages } from './engine/analysis';
|
|
5
|
+
export type { FunnelRow as FunnelStageSummary } from './engine/analysis';
|
package/dist/data.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RankingCategory, RankingRow } from './ranking';
|
|
2
|
+
export interface FunnelRow<T> extends RankingRow<T> {
|
|
3
|
+
share: number | null;
|
|
4
|
+
conversion: number | null;
|
|
5
|
+
drop: number | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function funnelRows<T>(props: {
|
|
8
|
+
data: readonly T[];
|
|
9
|
+
category: RankingCategory<T>;
|
|
10
|
+
value: (row: T) => number | null;
|
|
11
|
+
}): FunnelRow<T>[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface BarGeometry {
|
|
2
|
+
/** Original observation identity, never a pixel coordinate. */
|
|
3
|
+
valueX: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
baseline: number;
|
|
9
|
+
negative: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Preserve real time/numeric spacing, including gaps, while keeping edge bars inside the plot. */
|
|
12
|
+
export declare function barSpacing(values: readonly number[], span: number, width: number): {
|
|
13
|
+
inset: number;
|
|
14
|
+
slot: number;
|
|
15
|
+
groupWidth: number;
|
|
16
|
+
};
|
|
17
|
+
/** Whether a later nonempty segment covers this segment's value end. */
|
|
18
|
+
export declare function hasStackedSuccessor(geometry: Readonly<Record<string, readonly BarGeometry[]>>, seriesIds: readonly string[], seriesId: string, bar: BarGeometry): boolean;
|
|
19
|
+
/** Round exposed value ends or both ends; trim covered ends to create deliberate gaps. */
|
|
20
|
+
export declare function barPath(bar: BarGeometry, progress?: number, options?: {
|
|
21
|
+
originY?: number;
|
|
22
|
+
roundValueEnd?: boolean;
|
|
23
|
+
roundBothEnds?: boolean;
|
|
24
|
+
radius?: number;
|
|
25
|
+
valueGap?: number;
|
|
26
|
+
}): string;
|
|
27
|
+
/** Use one path rule for resting marks and inspection highlights. */
|
|
28
|
+
export declare function barMarkPath(bar: BarGeometry, options: {
|
|
29
|
+
stacked: boolean;
|
|
30
|
+
geometry: Readonly<Record<string, readonly BarGeometry[]>>;
|
|
31
|
+
seriesIds: readonly string[];
|
|
32
|
+
seriesId: string;
|
|
33
|
+
radius?: number;
|
|
34
|
+
roundBothEnds?: boolean;
|
|
35
|
+
segmentGap?: number;
|
|
36
|
+
progress?: number;
|
|
37
|
+
originY?: number;
|
|
38
|
+
}): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChartComparison, ChartPercentagePolicy, ChartRange } from '../types';
|
|
2
|
+
import { NormalizedData } from './normalize';
|
|
3
|
+
export declare function comparisonForRange<T>(data: NormalizedData<T>, range: ChartRange, series: string, percentage?: ChartPercentagePolicy): ChartComparison;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shares in percentage points, preserving measured zero. A missing, invalid, negative,
|
|
3
|
+
* or zero-total period has no meaningful composition and returns gaps for every series.
|
|
4
|
+
* Scaling before summing also supports large finite inputs without overflowing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function compositionShares(values: readonly unknown[]): (number | null)[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChartSeries, ChartYConfig } from '../types';
|
|
2
|
+
import { NormalizedData } from './normalize';
|
|
3
|
+
export declare function computeYDomain<T>(data: NormalizedData<T>, series: readonly ChartSeries<T>[], config?: ChartYConfig): readonly [number, number];
|
|
4
|
+
export declare function interpolateDomain(from: readonly [number, number], to: readonly [number, number], progress: number): readonly [number, number];
|
|
5
|
+
/** The smallest of 1, 2, 2.5, 5 × 10ⁿ at or above `value`. */
|
|
6
|
+
export declare function niceCeil(value: number): number;
|
|
7
|
+
/**
|
|
8
|
+
* A second value scale that shares the primary scale's gridlines: every secondary value is the
|
|
9
|
+
* primary value times one factor, so zero and every tick line up, and the factor is chosen so
|
|
10
|
+
* the secondary ticks land on round numbers. Returns null when the primary domain excludes zero
|
|
11
|
+
* or the secondary values cannot fit on the same side of it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function alignedSecondaryFactor(primary: readonly [number, number], primaryStep: number, values: readonly number[]): number | null;
|