@sophistry/charts 0.0.0-stage → 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 +32 -2
- package/dist/3d/bar-chart3d.d.ts +55 -0
- package/dist/3d/definitions.d.ts +37 -0
- package/dist/3d/definitions.js +14 -0
- package/dist/3d/forward.d.ts +64 -0
- package/dist/3d/index.d.ts +30 -0
- package/dist/3d/index.js +1 -0
- package/dist/3d/quiver3d.d.ts +52 -0
- package/dist/3d/scatter3d.d.ts +44 -0
- package/dist/3d/stem3d.d.ts +45 -0
- package/dist/3d/surface-grid3d.d.ts +33 -0
- package/dist/3d/tri-surface3d.d.ts +45 -0
- package/dist/3d/voxels3d.d.ts +25 -0
- package/dist/3d/wireframe3d.d.ts +30 -0
- package/dist/band.d.ts +20 -0
- package/dist/bars/bar-chart.d.ts +143 -0
- package/dist/bars/bar-labels.d.ts +116 -0
- package/dist/bars/bars.d.ts +223 -0
- package/dist/bars/bullet.d.ts +157 -0
- package/dist/bars/candlestick.d.ts +97 -0
- package/dist/bars/funnel.d.ts +90 -0
- package/dist/bars/histogram.d.ts +108 -0
- package/dist/bars/index.d.ts +22 -0
- package/dist/bars/race.d.ts +28 -0
- package/dist/bars/rules.d.ts +121 -0
- package/dist/bars/shared.d.ts +41 -0
- package/dist/bars/transforms.d.ts +249 -0
- package/dist/bars/waterfall.d.ts +106 -0
- package/dist/batch.d.ts +142 -0
- package/dist/channels-_Xf-p6Lx.js +56 -0
- package/dist/chart.d.ts +87 -0
- package/dist/color-norm.d.ts +90 -0
- package/dist/context.d.ts +111 -0
- package/dist/curves/density.d.ts +125 -0
- package/dist/curves/ecdf.d.ts +72 -0
- package/dist/curves/fill-between.d.ts +100 -0
- package/dist/curves/index.d.ts +15 -0
- package/dist/curves/line-plot.d.ts +104 -0
- package/dist/curves/regression.d.ts +124 -0
- package/dist/curves/shared.d.ts +52 -0
- package/dist/curves/stack-plot.d.ts +140 -0
- package/dist/curves/stairs.d.ts +170 -0
- package/dist/data/channels.d.ts +170 -0
- package/dist/end-space.d.ts +81 -0
- package/dist/entries/definitions.d.ts +20 -0
- package/dist/entries/definitions.js +6 -0
- package/dist/frame/band-axis.d.ts +42 -0
- package/dist/frame/coords.d.ts +111 -0
- package/dist/frame/fit.d.ts +170 -0
- package/dist/frame/format.d.ts +40 -0
- package/dist/frame/guide-metrics.d.ts +36 -0
- package/dist/frame/guides.d.ts +67 -0
- package/dist/frame/keys.d.ts +96 -0
- package/dist/frame/layout.d.ts +145 -0
- package/dist/frame/registry.d.ts +31 -0
- package/dist/frame/reports.d.ts +53 -0
- package/dist/frame/secondary-axes.d.ts +73 -0
- package/dist/frame/secondary.d.ts +56 -0
- package/dist/frame/tooltip-overlay.d.ts +64 -0
- package/dist/frame/types.d.ts +658 -0
- package/dist/grids/barbs.d.ts +51 -0
- package/dist/grids/cell-rects.d.ts +37 -0
- package/dist/grids/cells.d.ts +130 -0
- package/dist/grids/contour-f.d.ts +80 -0
- package/dist/grids/contour-shared.d.ts +53 -0
- package/dist/grids/contour.d.ts +84 -0
- package/dist/grids/dendrogram.d.ts +104 -0
- package/dist/grids/heatmap.d.ts +163 -0
- package/dist/grids/hex-bin.d.ts +93 -0
- package/dist/grids/hist2d.d.ts +107 -0
- package/dist/grids/imshow.d.ts +84 -0
- package/dist/grids/index.d.ts +26 -0
- package/dist/grids/pcolormesh.d.ts +90 -0
- package/dist/grids/ramp-cells.d.ts +66 -0
- package/dist/grids/tri-contour.d.ts +120 -0
- package/dist/grids/tri-shared.d.ts +61 -0
- package/dist/grids/tripcolor.d.ts +73 -0
- package/dist/guides/colorbar.d.ts +110 -0
- package/dist/guides/index.d.ts +11 -0
- package/dist/guides/legend.d.ts +118 -0
- package/dist/guides/nodes.d.ts +13 -0
- package/dist/guides/size-legend.d.ts +233 -0
- package/dist/hierarchy/breadcrumbs.d.ts +133 -0
- package/dist/hierarchy/circle-pack.d.ts +72 -0
- package/dist/hierarchy/drill.d.ts +245 -0
- package/dist/hierarchy/frame.d.ts +67 -0
- package/dist/hierarchy/icicle.d.ts +76 -0
- package/dist/hierarchy/index.d.ts +20 -0
- package/dist/hierarchy/labels.d.ts +24 -0
- package/dist/hierarchy/mosaic.d.ts +130 -0
- package/dist/hierarchy/own-tooltip.d.ts +12 -0
- package/dist/hierarchy/props.d.ts +13 -0
- package/dist/hierarchy/sankey.d.ts +132 -0
- package/dist/hierarchy/shared.d.ts +247 -0
- package/dist/hierarchy/sunburst.d.ts +74 -0
- package/dist/hierarchy/tree.d.ts +124 -0
- package/dist/hierarchy/treemap.d.ts +76 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +5 -0
- package/dist/item-tooltip.d.ts +33 -0
- package/dist/join.d.ts +223 -0
- package/dist/math/3d/bar3d.d.ts +27 -0
- package/dist/math/3d/quiver3d.d.ts +26 -0
- package/dist/math/3d/scatter3d.d.ts +15 -0
- package/dist/math/3d/stem3d.d.ts +22 -0
- package/dist/math/3d/surfaceGrid3d.d.ts +33 -0
- package/dist/math/3d/trisurface.d.ts +11 -0
- package/dist/math/3d/voxels.d.ts +17 -0
- package/dist/math/aggregate.d.ts +68 -0
- package/dist/math/bar.d.ts +31 -0
- package/dist/math/barLabels.d.ts +83 -0
- package/dist/math/barbs.d.ts +36 -0
- package/dist/math/boxplot.d.ts +36 -0
- package/dist/math/breadcrumbs.d.ts +128 -0
- package/dist/math/bubble.d.ts +38 -0
- package/dist/math/bullet.d.ts +110 -0
- package/dist/math/chord.d.ts +103 -0
- package/dist/math/cluster.d.ts +88 -0
- package/dist/math/contour.d.ts +48 -0
- package/dist/math/contourf.d.ts +50 -0
- package/dist/math/dodge.d.ts +36 -0
- package/dist/math/ecdf.d.ts +41 -0
- package/dist/math/errorbar.d.ts +27 -0
- package/dist/math/eventplot.d.ts +26 -0
- package/dist/math/facet.d.ts +90 -0
- package/dist/math/fillBetween.d.ts +28 -0
- package/dist/math/gauge.d.ts +71 -0
- package/dist/math/hexbin.d.ts +20 -0
- package/dist/math/hierarchy.d.ts +179 -0
- package/dist/math/hierarchyJoin.d.ts +59 -0
- package/dist/math/histogram.d.ts +36 -0
- package/dist/math/histogram2d.d.ts +44 -0
- package/dist/math/imshow.d.ts +26 -0
- package/dist/math/index.d.ts +139 -0
- package/dist/math/index.js +3 -0
- package/dist/math/jitter.d.ts +16 -0
- package/dist/math/join.d.ts +135 -0
- package/dist/math/keyframes.d.ts +127 -0
- package/dist/math/legend.d.ts +120 -0
- package/dist/math/line.d.ts +53 -0
- package/dist/math/morph.d.ts +81 -0
- package/dist/math/mosaic.d.ts +119 -0
- package/dist/math/ordinal.d.ts +79 -0
- package/dist/math/parallel.d.ts +38 -0
- package/dist/math/pcolormesh.d.ts +22 -0
- package/dist/math/pie.d.ts +105 -0
- package/dist/math/polarArea.d.ts +34 -0
- package/dist/math/radar.d.ts +110 -0
- package/dist/math/range.d.ts +98 -0
- package/dist/math/regression.d.ts +109 -0
- package/dist/math/reveal.d.ts +63 -0
- package/dist/math/sankey.d.ts +154 -0
- package/dist/math/scatter.d.ts +14 -0
- package/dist/math/shared/binning.d.ts +23 -0
- package/dist/math/shared/gridCells.d.ts +41 -0
- package/dist/math/shared/gridExtent.d.ts +5 -0
- package/dist/math/shared/pairs.d.ts +2 -0
- package/dist/math/shared/polar.d.ts +23 -0
- package/dist/math/stack.d.ts +69 -0
- package/dist/math/stackplot.d.ts +35 -0
- package/dist/math/stairs.d.ts +17 -0
- package/dist/math/stem.d.ts +21 -0
- package/dist/math/symbol.d.ts +25 -0
- package/dist/math/tree.d.ts +117 -0
- package/dist/math/tricontour.d.ts +76 -0
- package/dist/math/violin.d.ts +99 -0
- package/dist/math/waffle.d.ts +48 -0
- package/dist/math/waterfall.d.ts +28 -0
- package/dist/math-CSHNpGej.js +3648 -0
- package/dist/mix.d.ts +24 -0
- package/dist/multiview/brush.d.ts +165 -0
- package/dist/multiview/chart-group.d.ts +265 -0
- package/dist/multiview/chart-link.d.ts +188 -0
- package/dist/multiview/chart-zoom.d.ts +144 -0
- package/dist/multiview/facet.d.ts +238 -0
- package/dist/multiview/group-guides.d.ts +99 -0
- package/dist/multiview/index.d.ts +17 -0
- package/dist/multiview/joint-plot.d.ts +114 -0
- package/dist/multiview/pair-plot.d.ts +153 -0
- package/dist/multiview/panels.d.ts +22 -0
- package/dist/multiview/parallel-coordinates.d.ts +109 -0
- package/dist/points/event-plot.d.ts +67 -0
- package/dist/points/index.d.ts +19 -0
- package/dist/points/labels.d.ts +70 -0
- package/dist/points/links.d.ts +123 -0
- package/dist/points/rects.d.ts +80 -0
- package/dist/points/rug.d.ts +72 -0
- package/dist/points/scatter.d.ts +169 -0
- package/dist/points/segment-marks.d.ts +39 -0
- package/dist/points/shared.d.ts +34 -0
- package/dist/points/stem.d.ts +75 -0
- package/dist/points/strip.d.ts +145 -0
- package/dist/points/symbol-marker.d.ts +33 -0
- package/dist/points/ticks.d.ts +102 -0
- package/dist/props.d.ts +126 -0
- package/dist/radial/chord.d.ts +148 -0
- package/dist/radial/gauge.d.ts +126 -0
- package/dist/radial/index.d.ts +15 -0
- package/dist/radial/pie-chart.d.ts +143 -0
- package/dist/radial/polar-area-chart.d.ts +135 -0
- package/dist/radial/radar-chart.d.ts +176 -0
- package/dist/radial/radial-bar-chart.d.ts +116 -0
- package/dist/radial/shared.d.ts +78 -0
- package/dist/radial/waffle.d.ts +130 -0
- package/dist/raster.d.ts +43 -0
- package/dist/series.d.ts +71 -0
- package/dist/src-CwGo1bes.js +19221 -0
- package/dist/stagger.d.ts +54 -0
- package/dist/statistics/box-plot.d.ts +151 -0
- package/dist/statistics/error-bar.d.ts +148 -0
- package/dist/statistics/groups.d.ts +140 -0
- package/dist/statistics/index.d.ts +7 -0
- package/dist/statistics/violin-plot.d.ts +143 -0
- package/dist/text-width.d.ts +9 -0
- package/dist/tooltip.d.ts +276 -0
- package/dist/util.d.ts +33 -0
- package/dist/voxels-9lJ2TZS4.js +235 -0
- package/dist/wireframe3d-D157GZAq.js +345 -0
- package/package.json +86 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `candlestick`: candles (or OHLC bars) for price data. The wicks (and the
|
|
3
|
+
* OHLC ticks) are one instances node of `line`s, the bodies one of `rect`s.
|
|
4
|
+
*
|
|
5
|
+
* On reveal, each line's `progress` channel traces a wick from its low end
|
|
6
|
+
* and an OHLC tick out from its end, and a body grows from the open
|
|
7
|
+
* towards the close; a body not started is left out of the batch.
|
|
8
|
+
* Every wick paints under every body (candles don't overlap, so this
|
|
9
|
+
* looks the same as painting them candle by candle).
|
|
10
|
+
*/
|
|
11
|
+
import type { ColorInput } from "@sophistry/core/color";
|
|
12
|
+
import type { BandKey } from "@sophistry/core/geometry";
|
|
13
|
+
import type { Channel, PositionValue } from "../data/channels.js";
|
|
14
|
+
import type { TooltipSpec } from "../tooltip.js";
|
|
15
|
+
/**
|
|
16
|
+
* Props of {@link candlestick}.
|
|
17
|
+
*
|
|
18
|
+
* @category Charts
|
|
19
|
+
*/
|
|
20
|
+
export interface CandlestickProps<T = unknown> {
|
|
21
|
+
/** One candle per datum: a period. */
|
|
22
|
+
data: readonly T[];
|
|
23
|
+
/**
|
|
24
|
+
* The period: a `Date`, Temporal value or epoch ms on a time axis, a number, or a category on a
|
|
25
|
+
* band axis.
|
|
26
|
+
*/
|
|
27
|
+
x: Channel<T, BandKey | PositionValue>;
|
|
28
|
+
/** Price at the period's open. */
|
|
29
|
+
open: Channel<T, number>;
|
|
30
|
+
/** Highest price in the period. */
|
|
31
|
+
high: Channel<T, number>;
|
|
32
|
+
/** Lowest price in the period. */
|
|
33
|
+
low: Channel<T, number>;
|
|
34
|
+
/** Price at the period's close. */
|
|
35
|
+
close: Channel<T, number>;
|
|
36
|
+
/**
|
|
37
|
+
* Body width: a fraction of the band on a band axis, or of the smallest gap between periods on
|
|
38
|
+
* a continuous one.
|
|
39
|
+
* @default 0.6
|
|
40
|
+
*/
|
|
41
|
+
bodyWidth?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Draw OHLC bars (open tick left, close tick right) instead of candles.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
ohlc?: boolean;
|
|
47
|
+
/** Colour of a period that closed up. Defaults to the theme's positive colour. */
|
|
48
|
+
upColor?: ColorInput;
|
|
49
|
+
/** Colour of a period that closed down. Defaults to the theme's negative colour. */
|
|
50
|
+
downColor?: ColorInput;
|
|
51
|
+
/** Wick and OHLC line width. */
|
|
52
|
+
strokeWidth?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Reveal, 0..1: each wick draws from low to high, then its body grows from open to close.
|
|
55
|
+
* @see https://sophistry.dev/guides/chart-animation/#reveals
|
|
56
|
+
*/
|
|
57
|
+
progress?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Fraction of the reveal spent staggering period after period in time order, 0..0.95.
|
|
60
|
+
* @default 0
|
|
61
|
+
*/
|
|
62
|
+
stagger?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Hover tooltip: `true` for a row per channel (`x`, `open`, `high`, `low`, `close`), or a
|
|
65
|
+
* template, function or options. See {@link TooltipSpec}.
|
|
66
|
+
*/
|
|
67
|
+
tooltip?: TooltipSpec<T>;
|
|
68
|
+
zIndex?: number;
|
|
69
|
+
visible?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Candlesticks (or OHLC bars) for price data, inside a `chart` on a time
|
|
73
|
+
* axis (`xAxis: { scale: "utc" }`) or a category axis. Wicks span low to
|
|
74
|
+
* high, bodies open to close coloured by direction; the value axis fits the
|
|
75
|
+
* prices without forcing zero.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { candlestick, chart } from "@sophistry/charts";
|
|
80
|
+
*
|
|
81
|
+
* const prices = [
|
|
82
|
+
* { day: new Date("2024-03-04"), o: 101, h: 106, l: 99, c: 104 },
|
|
83
|
+
* { day: new Date("2024-03-05"), o: 104, h: 105, l: 97, c: 98 },
|
|
84
|
+
* { day: new Date("2024-03-06"), o: 98, h: 103, l: 96, c: 102 },
|
|
85
|
+
* ];
|
|
86
|
+
* chart.create({
|
|
87
|
+
* width: 8,
|
|
88
|
+
* height: 4,
|
|
89
|
+
* xAxis: { scale: "utc" },
|
|
90
|
+
* children: [candlestick.create({ data: prices, x: "day", open: "o", high: "h", low: "l", close: "c" })],
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @see https://sophistry.dev/reference/chart-catalogue/#waterfalls-funnels-and-candlesticks
|
|
95
|
+
* @category Charts
|
|
96
|
+
*/
|
|
97
|
+
export declare const candlestick: import("@sophistry/core").Definition<CandlestickProps<any>, import("@sophistry/core/internal").CompositeNode<CandlestickProps<any>>, keyof CandlestickProps<any>>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `funnel`: how many make it through each stage of a process. A preset: a
|
|
3
|
+
* `chart` with a band y axis whose one layer (the internal `FunnelStages`)
|
|
4
|
+
* draws the stages as one instances node of `rect`s, the necks between them
|
|
5
|
+
* as one path batch (each neck is its own trapezoid), and the names and
|
|
6
|
+
* values as label nodes.
|
|
7
|
+
*/
|
|
8
|
+
import type { ColorInput } from "@sophistry/core/color";
|
|
9
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
10
|
+
import type { Channel, ColorChannel } from "../data/channels.js";
|
|
11
|
+
import type { TooltipSpec } from "../tooltip.js";
|
|
12
|
+
/**
|
|
13
|
+
* Props of {@link funnel}: `value` is required unless `data` is `number[]`.
|
|
14
|
+
*
|
|
15
|
+
* @category Charts
|
|
16
|
+
*/
|
|
17
|
+
export interface FunnelProps<T = unknown> {
|
|
18
|
+
/** One stage per datum, widest (first) at the top. */
|
|
19
|
+
data: readonly T[];
|
|
20
|
+
/** How many reached this stage. Defaults to the datum when `data` is `number[]`. */
|
|
21
|
+
value?: Channel<T, number>;
|
|
22
|
+
/** The stage's name, drawn to its left. Omitted, no names are drawn. */
|
|
23
|
+
label?: Channel<T, string>;
|
|
24
|
+
/** Width of the plotting area. */
|
|
25
|
+
width: number;
|
|
26
|
+
/** Height of the plotting area. */
|
|
27
|
+
height: number;
|
|
28
|
+
/** Centre of the plotting area. Defaults to the origin. */
|
|
29
|
+
center?: Point;
|
|
30
|
+
/** One colour for every stage, or `(d, i) => colour`. Wins over `colors`. */
|
|
31
|
+
color?: ColorChannel<T>;
|
|
32
|
+
/** Colours cycled across the stages. Defaults to the theme's categorical colours. */
|
|
33
|
+
colors?: readonly ColorInput[];
|
|
34
|
+
/**
|
|
35
|
+
* Fill opacity of the stages, 0..1.
|
|
36
|
+
* @default 0.85
|
|
37
|
+
*/
|
|
38
|
+
fillOpacity?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Gap between stages, as a fraction of a stage's slot.
|
|
41
|
+
* @default 0.25
|
|
42
|
+
*/
|
|
43
|
+
padding?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Shade the narrowing between stages.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
connectors?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* What to write in each stage: `"value"`, `"percent"` (of the first stage), `"both"`, or
|
|
51
|
+
* `"none"`.
|
|
52
|
+
* @default "both"
|
|
53
|
+
*/
|
|
54
|
+
show?: "value" | "percent" | "both" | "none";
|
|
55
|
+
/** Title above the chart. */
|
|
56
|
+
title?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Reveal, 0..1: stage names first, then each stage widens out from the centre, top to bottom.
|
|
59
|
+
* @see https://sophistry.dev/guides/chart-animation/#reveals
|
|
60
|
+
*/
|
|
61
|
+
progress?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Fraction of the data reveal spent staggering stage after stage, 0..0.95.
|
|
64
|
+
* @default 0.5
|
|
65
|
+
*/
|
|
66
|
+
stagger?: number;
|
|
67
|
+
/** Hover tooltip: `true` for "stage: value (pct)", or `(d, i) => string`. */
|
|
68
|
+
tooltip?: TooltipSpec<T>;
|
|
69
|
+
zIndex?: number;
|
|
70
|
+
visible?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A funnel: how many make it through each stage of a process. Stages stack
|
|
74
|
+
* top-down, each centred with a width proportional to its value, shaded
|
|
75
|
+
* necks showing the loss between them. A `chart` with a band y axis and no
|
|
76
|
+
* value axis.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { createScene } from "@sophistry/core";
|
|
81
|
+
* import { funnel } from "@sophistry/charts";
|
|
82
|
+
*
|
|
83
|
+
* const scene = createScene({ host: document.querySelector("#figure")!, units: 10 });
|
|
84
|
+
* scene.add(funnel.create({ data: [1200, 640, 310, 95], width: 6, height: 4 }));
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @see https://sophistry.dev/reference/chart-catalogue/#waterfalls-funnels-and-candlesticks
|
|
88
|
+
* @category Charts
|
|
89
|
+
*/
|
|
90
|
+
export declare const funnel: import("@sophistry/core").Definition<FunnelProps<any>, import("@sophistry/core/internal").CompositeNode<FunnelProps<any>>, keyof FunnelProps<any>>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `histogram`: values bucketed into equal-width bins, one touching bar per
|
|
3
|
+
* bin, drawn as one instances node of `rect`s keyed by the bin's place.
|
|
4
|
+
*
|
|
5
|
+
* The reveal and a transition's presence grow each bar's top from the
|
|
6
|
+
* baseline (geometry) or, on an axis without zero, fade it (per-item
|
|
7
|
+
* opacity); a bin not started is left out of the batch (it counts as
|
|
8
|
+
* `progress` 0).
|
|
9
|
+
*/
|
|
10
|
+
import type { ColorInput } from "@sophistry/core/color";
|
|
11
|
+
import type { Range } from "@sophistry/core/geometry";
|
|
12
|
+
import type { MarkTransition } from "../batch.js";
|
|
13
|
+
import type { Channel } from "../data/channels.js";
|
|
14
|
+
import type { RevealProps, TransitionProps } from "../props.js";
|
|
15
|
+
/**
|
|
16
|
+
* Props of {@link histogram}: `value` is required unless `data` is `number[]`.
|
|
17
|
+
*
|
|
18
|
+
* @category Charts
|
|
19
|
+
*/
|
|
20
|
+
export interface HistogramProps<T = unknown> extends TransitionProps<T>, RevealProps {
|
|
21
|
+
/** One observation per datum. */
|
|
22
|
+
data: readonly T[];
|
|
23
|
+
/**
|
|
24
|
+
* The observed value, in data units. Defaults to the datum when `data` is `number[]`; required
|
|
25
|
+
* otherwise. Non-finite values and values outside `range` are not counted.
|
|
26
|
+
*/
|
|
27
|
+
value?: Channel<T, number>;
|
|
28
|
+
/**
|
|
29
|
+
* Number of equal-width bins. Wins over a `range` step. Defaults to the count the `range` step
|
|
30
|
+
* implies, else 10.
|
|
31
|
+
*/
|
|
32
|
+
binCount?: number;
|
|
33
|
+
/**
|
|
34
|
+
* `[min, max, step?]` spanned by the bins, in data units; `step` is the bin width when
|
|
35
|
+
* `binCount` is not given (`[0, 10, 2]` is five bins). Defaults to the finite extent of the
|
|
36
|
+
* values.
|
|
37
|
+
*/
|
|
38
|
+
range?: Range;
|
|
39
|
+
/** Fill of every bar. Defaults to the theme's first series colour. */
|
|
40
|
+
color?: ColorInput;
|
|
41
|
+
/**
|
|
42
|
+
* Fill opacity, 0..1.
|
|
43
|
+
* @default 0.85
|
|
44
|
+
*/
|
|
45
|
+
fillOpacity?: number;
|
|
46
|
+
/** Outline colour. @default "none" */
|
|
47
|
+
stroke?: string;
|
|
48
|
+
/** Outline width. */
|
|
49
|
+
strokeWidth?: number;
|
|
50
|
+
/** Opacity 0..1. @default 1 */
|
|
51
|
+
opacity?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Reveal, 0..1: bars grow from the baseline (fading in when the axis has no zero).
|
|
54
|
+
* @default 1
|
|
55
|
+
*/
|
|
56
|
+
progress?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Fraction of the reveal spent staggering bin after bin, left to right, 0..0.95.
|
|
59
|
+
* @default 0
|
|
60
|
+
*/
|
|
61
|
+
stagger?: number;
|
|
62
|
+
/**
|
|
63
|
+
* The data to transition to, bins matched by place: shared bins move their edges and counts, so
|
|
64
|
+
* every frame is a histogram; extra bins grow in or shrink away. See {@link TransitionProps}.
|
|
65
|
+
* @see https://sophistry.dev/guides/chart-animation/#data-transitions
|
|
66
|
+
*/
|
|
67
|
+
to?: readonly T[];
|
|
68
|
+
/**
|
|
69
|
+
* `to`'s bin count; `to={data}` with a new `toBinCount` re-bins as a transition. Defaults to
|
|
70
|
+
* `binCount`.
|
|
71
|
+
*/
|
|
72
|
+
toBinCount?: number;
|
|
73
|
+
/** `to`'s binning range, as `range`. Defaults to `range`. */
|
|
74
|
+
toRange?: Range;
|
|
75
|
+
/**
|
|
76
|
+
* Fraction of a transition's enter stage spent staggering entering bins, left to right. See
|
|
77
|
+
* {@link TransitionProps}.
|
|
78
|
+
* @default 0
|
|
79
|
+
*/
|
|
80
|
+
enterStagger?: number;
|
|
81
|
+
/**
|
|
82
|
+
* How bars move when `data` changes (outside a `to` blend): a tween or a
|
|
83
|
+
* spring in the node's tween bank. Omitted, data changes are instant.
|
|
84
|
+
*/
|
|
85
|
+
transition?: MarkTransition;
|
|
86
|
+
/** Paint order; the bars paint at `zIndex + UNDER_AXES_Z_INDEX`. */
|
|
87
|
+
zIndex?: number;
|
|
88
|
+
visible?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A histogram: values bucketed into equal-width bins, one touching bar per
|
|
92
|
+
* bin, its height the count. `progress` grows bars from the baseline
|
|
93
|
+
* (fading in when the axis has no zero). Inside a `chart` (which fits the
|
|
94
|
+
* counts) or an `axes`. See {@link histogramBins} for the binning rule (the
|
|
95
|
+
* last bin is right-inclusive). Drawn as one instances node of rects.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* import { chart, histogram } from "@sophistry/charts";
|
|
100
|
+
*
|
|
101
|
+
* const heights = [162, 170, 175, 168, 181, 159, 177, 173, 166, 185, 171, 169];
|
|
102
|
+
* chart.create({ width: 8, height: 4, children: [histogram.create({ data: heights, binCount: 12 })] });
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @see https://sophistry.dev/reference/chart-catalogue/#histograms
|
|
106
|
+
* @category Charts
|
|
107
|
+
*/
|
|
108
|
+
export declare const histogram: import("@sophistry/core").Definition<HistogramProps<any>, import("@sophistry/core/internal").CompositeNode<HistogramProps<any>>, keyof HistogramProps<any>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Family barrel: bars and their kin. Owned by its family; re-exported from the package entry. */
|
|
2
|
+
export type { BarChartHandle, BarChartProps } from "./bar-chart.js";
|
|
3
|
+
export { barChart, barChartHandle } from "./bar-chart.js";
|
|
4
|
+
export type { BarLabelOptions } from "./bar-labels.js";
|
|
5
|
+
export type { BarsHandle, BarsProps } from "./bars.js";
|
|
6
|
+
export { bars, barsHandle } from "./bars.js";
|
|
7
|
+
export type { BulletProps } from "./bullet.js";
|
|
8
|
+
export { bullet, bulletTooltip } from "./bullet.js";
|
|
9
|
+
export type { CandlestickProps } from "./candlestick.js";
|
|
10
|
+
export { candlestick } from "./candlestick.js";
|
|
11
|
+
export type { FunnelProps } from "./funnel.js";
|
|
12
|
+
export { funnel } from "./funnel.js";
|
|
13
|
+
export type { HistogramProps } from "./histogram.js";
|
|
14
|
+
export { histogram } from "./histogram.js";
|
|
15
|
+
export type { RankRaceOptions } from "./race.js";
|
|
16
|
+
export { rankRace } from "./race.js";
|
|
17
|
+
export type { RuleBaseProps, RuleXProps, RuleYProps } from "./rules.js";
|
|
18
|
+
export { ruleX, ruleY } from "./rules.js";
|
|
19
|
+
export type { BinnedRow, BinOptions, DodgedRow, DodgeOptions, GroupedRow, GroupOptions, JitterTransformOptions, NormalizeOptions, RollingTransformOptions, StackedRow, StackOptions, SummarizeOptions, SummaryRow, } from "./transforms.js";
|
|
20
|
+
export { bin, dodge, group, jitter, normalize, rolling, stack, summarize, } from "./transforms.js";
|
|
21
|
+
export type { WaterfallProps } from "./waterfall.js";
|
|
22
|
+
export { waterfall } from "./waterfall.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** `rankRace`: a bar chart race from long-format rows. */
|
|
2
|
+
import type { BandKey } from "@sophistry/core/geometry";
|
|
3
|
+
import type { Channel } from "../data/channels.js";
|
|
4
|
+
import type { RaceOptions, RaceTimeline } from "../math/keyframes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Options for {@link rankRace}.
|
|
7
|
+
*
|
|
8
|
+
* @category Charts
|
|
9
|
+
*/
|
|
10
|
+
export interface RankRaceOptions<T> extends RaceOptions {
|
|
11
|
+
/** What races: a key of `T` or `(d, i) => key`. */
|
|
12
|
+
key: Channel<T, BandKey>;
|
|
13
|
+
/** When the row's value holds: a key of `T` or `(d, i) => number`. */
|
|
14
|
+
time: Channel<T, number>;
|
|
15
|
+
/** The value: a key of `T` or `(d, i) => number`. */
|
|
16
|
+
value: Channel<T, number>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A bar chart race from long-format rows (one per key per moment): see
|
|
20
|
+
* {@link raceTimeline}. Missing keys count as 0; duplicate rows are summed.
|
|
21
|
+
* Pass `view(time)`'s `categories` and `slot` to the `chart`'s `yAxis` (with
|
|
22
|
+
* `clip`) so bars and names slide together, and pin colours with
|
|
23
|
+
* `chart.create({ color: { domain: race.keys } })`.
|
|
24
|
+
*
|
|
25
|
+
* @see https://sophistry.dev/guides/chart-animation/#data-transitions
|
|
26
|
+
* @category Charts
|
|
27
|
+
*/
|
|
28
|
+
export declare function rankRace<T>(rows: readonly T[], options: RankRaceOptions<T>): RaceTimeline;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ruleX` / `ruleY`: reference lines across the plot, or segments between
|
|
3
|
+
* given ends, one per datum, drawn as one instances node of `line`s.
|
|
4
|
+
*
|
|
5
|
+
* Batched like every per-datum mark (see `points/scatter.ts`): each update
|
|
6
|
+
* builds one item per key (its two ends in scene units and its colour) and
|
|
7
|
+
* hands them to {@link createBatchedMark}. The reveal (and an entering or
|
|
8
|
+
* leaving rule's presence) is each item's `progress` channel: the line
|
|
9
|
+
* traces from its low end.
|
|
10
|
+
*/
|
|
11
|
+
import type { BandKey } from "@sophistry/core/geometry";
|
|
12
|
+
import type { MarkTransition } from "../batch.js";
|
|
13
|
+
import type { Channel, ColorChannel, PositionValue } from "../data/channels.js";
|
|
14
|
+
import type { KeyedTransitionProps, RevealProps } from "../props.js";
|
|
15
|
+
import type { TooltipSpec } from "../tooltip.js";
|
|
16
|
+
/**
|
|
17
|
+
* Props every rule takes.
|
|
18
|
+
*
|
|
19
|
+
* @category Charts
|
|
20
|
+
*/
|
|
21
|
+
export interface RuleBaseProps<T> extends KeyedTransitionProps<T>, RevealProps {
|
|
22
|
+
/** One rule per datum. `ruleY.create({ data: [0] })` is a zero line. */
|
|
23
|
+
data: readonly T[];
|
|
24
|
+
/** Rule colour, constant or `(d, i) => colour`. Defaults to the theme foreground. */
|
|
25
|
+
color?: ColorChannel<T>;
|
|
26
|
+
/** Line width. */
|
|
27
|
+
strokeWidth?: number;
|
|
28
|
+
/** Dash pattern, as on any line: `[0.1, 0.08]`. */
|
|
29
|
+
dash?: number[];
|
|
30
|
+
opacity?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Reveal, 0..1: each rule draws from its low end to its high end.
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
35
|
+
progress?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Hover tooltip: `true` for the rule's value, or a template, function or options. See {@link
|
|
38
|
+
* TooltipSpec}.
|
|
39
|
+
*/
|
|
40
|
+
tooltip?: TooltipSpec<T>;
|
|
41
|
+
/**
|
|
42
|
+
* How rules move when `data` changes (outside a `to` blend): a tween or a
|
|
43
|
+
* spring in the node's tween bank; new rules draw out of their low end,
|
|
44
|
+
* removed ones draw back into it. Omitted, data changes are instant.
|
|
45
|
+
*/
|
|
46
|
+
transition?: MarkTransition;
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
visible?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The data to transition to, matched to `data` by `key`: rules slide and stretch to their new
|
|
51
|
+
* place; new ones draw out, removed ones draw back in. See {@link KeyedTransitionProps}.
|
|
52
|
+
* @see https://sophistry.dev/guides/chart-animation/#data-transitions
|
|
53
|
+
*/
|
|
54
|
+
to?: readonly T[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Props of {@link ruleX}: `x` is required unless `data` is `number[]`.
|
|
58
|
+
*
|
|
59
|
+
* @category Charts
|
|
60
|
+
*/
|
|
61
|
+
export interface RuleXProps<T = unknown> extends RuleBaseProps<T> {
|
|
62
|
+
/**
|
|
63
|
+
* Where the vertical rule stands: a number in data units (a `Date` reads as epoch ms) or a
|
|
64
|
+
* category on a band axis. Defaults to the datum when `data` is `number[]`.
|
|
65
|
+
*/
|
|
66
|
+
x?: Channel<T, BandKey | PositionValue>;
|
|
67
|
+
/** Lower end, in data units. Defaults to the bottom of the plotting area. */
|
|
68
|
+
y1?: Channel<T, PositionValue>;
|
|
69
|
+
/** Upper end, in data units. Defaults to the top of the plotting area. */
|
|
70
|
+
y2?: Channel<T, PositionValue>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Props of {@link ruleY}: `y` is required unless `data` is `number[]`.
|
|
74
|
+
*
|
|
75
|
+
* @category Charts
|
|
76
|
+
*/
|
|
77
|
+
export interface RuleYProps<T = unknown> extends RuleBaseProps<T> {
|
|
78
|
+
/**
|
|
79
|
+
* Height of the horizontal rule: a number in data units (a `Date` reads as epoch ms) or a
|
|
80
|
+
* category on a band axis. Defaults to the datum when `data` is `number[]`.
|
|
81
|
+
*/
|
|
82
|
+
y?: Channel<T, BandKey | PositionValue>;
|
|
83
|
+
/** Left end, in data units. Defaults to the left of the plotting area. */
|
|
84
|
+
x1?: Channel<T, PositionValue>;
|
|
85
|
+
/** Right end, in data units. Defaults to the right of the plotting area. */
|
|
86
|
+
x2?: Channel<T, PositionValue>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Vertical reference lines across the plot; `y1`/`y2` shorten them to
|
|
90
|
+
* segments (a lollipop's stick, a candle's wick). Inside a `chart` or
|
|
91
|
+
* `axes`. Drawn as one instances node of lines: `event.key` is the datum's
|
|
92
|
+
* key.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* import { chart, ruleX } from "@sophistry/charts";
|
|
97
|
+
*
|
|
98
|
+
* chart.create({ width: 8, height: 4, children: [ruleX.create({ data: [2, 5], dash: [0.1, 0.08] })] });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @see https://sophistry.dev/guides/charts/#marks
|
|
102
|
+
* @category Charts
|
|
103
|
+
*/
|
|
104
|
+
export declare const ruleX: import("@sophistry/core").Definition<RuleXProps<any>, import("@sophistry/core/internal").CompositeNode<RuleXProps<any>>, keyof RuleXProps<any>>;
|
|
105
|
+
/**
|
|
106
|
+
* Horizontal reference lines across the plot; `ruleY.create({ data: [0] })`
|
|
107
|
+
* is a zero line and `x1`/`x2` shorten them to segments. Inside a `chart`
|
|
108
|
+
* or `axes`. Drawn as one instances node of lines.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* import { chart, linePlot, ruleY } from "@sophistry/charts";
|
|
113
|
+
*
|
|
114
|
+
* const data = [-2, 1, 3, -1, 4];
|
|
115
|
+
* chart.create({ width: 8, height: 4, children: [linePlot.create({ data }), ruleY.create({ data: [0] })] });
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @see https://sophistry.dev/guides/charts/#marks
|
|
119
|
+
* @category Charts
|
|
120
|
+
*/
|
|
121
|
+
export declare const ruleY: import("@sophistry/core").Definition<RuleYProps<any>, import("@sophistry/core/internal").CompositeNode<RuleYProps<any>>, keyof RuleYProps<any>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers the bar family shares: a label placed beside a point, box arithmetic, and the tooltip props a batched node
|
|
3
|
+
* takes. Internal to the family.
|
|
4
|
+
*/
|
|
5
|
+
import type { Bounds, Placement, Point, Vec2 } from "@sophistry/core";
|
|
6
|
+
import type { TooltipState } from "../tooltip.js";
|
|
7
|
+
/** The metrics style labels are measured in: the label defaults. */
|
|
8
|
+
export declare function labelStyle(fontSize: number, fontFamily: string): {
|
|
9
|
+
fontSize: number;
|
|
10
|
+
fontFamily: string;
|
|
11
|
+
fontWeight: number;
|
|
12
|
+
italic: boolean;
|
|
13
|
+
letterSpacing: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Where a label goes to sit beside `at` (in `direction`, `gap` away) rather
|
|
17
|
+
* than centred on it, measured the same
|
|
18
|
+
* way core's axes place their end labels (the label's own width, one line
|
|
19
|
+
* height per font).
|
|
20
|
+
*
|
|
21
|
+
* @returns The label's `place`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function besidePlace(text: string, at: Point, direction: Vec2, gap: number, fontSize: number, fontFamily: string): Placement;
|
|
24
|
+
/** A box's centre. */
|
|
25
|
+
export declare function boxCenter(box: Bounds): Point;
|
|
26
|
+
/** The box spanned by two corners. */
|
|
27
|
+
export declare function boxOfCorners(a: Point, b: Point): Bounds;
|
|
28
|
+
/** Whether two boxes are equal field by field. */
|
|
29
|
+
export declare function sameBox(a: Bounds | null, b: Bounds | null): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The interaction props a batched node shares for item tooltips: the
|
|
32
|
+
* handlers when the chart has a tooltip and the mark (or the chart) asks for
|
|
33
|
+
* one, else none.
|
|
34
|
+
*/
|
|
35
|
+
export declare function tooltipProps(tooltip: TooltipState | null, own: unknown, handlers: {
|
|
36
|
+
readonly label?: string;
|
|
37
|
+
readonly onEnter?: unknown;
|
|
38
|
+
readonly onLeave?: unknown;
|
|
39
|
+
readonly onTap?: unknown;
|
|
40
|
+
readonly itemLabel?: unknown;
|
|
41
|
+
}): Record<string, unknown>;
|