@niekes/charts-3d 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +22 -0
- package/README.md +6 -5
- package/dist/index.d.ts +533 -29
- package/dist/index.js +2116 -449
- package/dist/index.js.map +1 -1
- package/package.json +13 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"
|
|
1
|
+
/// <reference types="geojson" />
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { AxesSpec, AxisSpec, Camera3DInstance, CubeFace, Point2D, Point3D, ShapeInstance, TransformedPoint } from "d3-3d";
|
|
4
4
|
declare const THEMES: {
|
|
@@ -26,13 +26,16 @@ export type View3D = {
|
|
|
26
26
|
/** The distance of the eye in box units; Infinity, the default, is orthographic. */
|
|
27
27
|
perspective?: number;
|
|
28
28
|
};
|
|
29
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* How the marks of a chart are drawn. The box, its labels, the tooltip and the
|
|
31
|
+
* legend are always SVG and HTML. "webgl" draws as "canvas", as it drew no
|
|
32
|
+
* faster, and goes in 1.0.0.
|
|
33
|
+
*/
|
|
30
34
|
export type Renderer3D = "svg" | "canvas" | "webgl";
|
|
31
35
|
/** Maps data values to the world box, which spans -1 to 1 on every axis, y up. */
|
|
32
36
|
export type World = Record<keyof AxesSpec, (value: number) => number>;
|
|
37
|
+
/** What a mark says while the pointer is on it, beside the pointer. */
|
|
33
38
|
export type Tooltip3D = {
|
|
34
|
-
/** The anchor in the units of the view box. */
|
|
35
|
-
at: Point2D;
|
|
36
39
|
title?: React.ReactNode;
|
|
37
40
|
items: {
|
|
38
41
|
label: React.ReactNode;
|
|
@@ -51,13 +54,17 @@ export type Mark3D = {
|
|
|
51
54
|
fill: string;
|
|
52
55
|
/** The ring around a circle, a CSS color. */
|
|
53
56
|
stroke?: string;
|
|
54
|
-
/**
|
|
55
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Shown while the pointer is over the mark. A function is called when the
|
|
59
|
+
* pointer lands on the mark, so a chart with thousands of marks pays for
|
|
60
|
+
* one tooltip per hover, not one per mark per frame; `null` shows none.
|
|
61
|
+
*/
|
|
62
|
+
tooltip?: Tooltip3D | (() => Tooltip3D | null);
|
|
56
63
|
/**
|
|
57
64
|
* The marks of the same element as this one: the faces of a bar, the
|
|
58
|
-
* segments of a flow. Pointing at a mark
|
|
59
|
-
*
|
|
60
|
-
*
|
|
65
|
+
* segments of a flow. Pointing at a mark fills them with the focus color -
|
|
66
|
+
* `--chart-3d-focus`, or their own fill lightened - until the pointer
|
|
67
|
+
* leaves the mark; a stroke of their own stays.
|
|
61
68
|
*/
|
|
62
69
|
groups?: string[];
|
|
63
70
|
};
|
|
@@ -73,6 +80,11 @@ type ChartContext3D = {
|
|
|
73
80
|
renderer: Renderer3D;
|
|
74
81
|
/** The marks of the chart, which the hover and the canvas read. */
|
|
75
82
|
scene: React.RefObject<Mark3D[]>;
|
|
83
|
+
/** Puts the marks of the `Marks3D` of `id`, drawn at `node` in the tree, into the scene, or takes them out. */
|
|
84
|
+
place: (id: string, set?: {
|
|
85
|
+
marks: Mark3D[];
|
|
86
|
+
node: Element;
|
|
87
|
+
}) => void;
|
|
76
88
|
repaint: () => void;
|
|
77
89
|
focus: Focus3D;
|
|
78
90
|
/** The time in ms a chart takes to glide into new data, 600 unless the container says. */
|
|
@@ -82,7 +94,7 @@ export declare function useChart3D(): ChartContext3D;
|
|
|
82
94
|
/** The actions a key triggers: each steps the camera, `help` opens the shortcut panel. */
|
|
83
95
|
export type KeyAction3D = "rotateLeft" | "rotateRight" | "rotateUp" | "rotateDown" | "panLeft" | "panRight" | "panUp" | "panDown" | "zoomIn" | "zoomOut" | "reset" | "help";
|
|
84
96
|
/** The gestures of the pointer, which `keymap` can turn off or rename but not rebind; the shortcut panel shows each with its modifier on the reader's platform. */
|
|
85
|
-
export type Gesture3D = "dragRotate" | "dragPan" | "wheelZoom" | "doubleClickReset";
|
|
97
|
+
export type Gesture3D = "dragRotate" | "touchOrbit" | "dragPan" | "wheelZoom" | "pinchZoom" | "doubleClickReset";
|
|
86
98
|
/**
|
|
87
99
|
* The shortcuts of a chart over their defaults, per action: `false` turns an
|
|
88
100
|
* action off, keys replace its keys and a label renames it in the shortcut
|
|
@@ -125,9 +137,10 @@ export type ChartContainer3DProps = {
|
|
|
125
137
|
*/
|
|
126
138
|
legend?: boolean;
|
|
127
139
|
/**
|
|
128
|
-
* How the marks of the chart are drawn: "canvas" suits many marks
|
|
129
|
-
*
|
|
130
|
-
* "webgl"
|
|
140
|
+
* How the marks of the chart are drawn: "canvas" suits many marks. The chart
|
|
141
|
+
* draws as SVG until the browser shows it has a canvas, and where it has
|
|
142
|
+
* none, as SVG. "webgl" draws as "canvas", as it drew no faster; it is
|
|
143
|
+
* deprecated and goes in 1.0.0.
|
|
131
144
|
* @defaultValue "svg"
|
|
132
145
|
*/
|
|
133
146
|
renderer?: Renderer3D;
|
|
@@ -147,15 +160,22 @@ export type ChartContainer3DProps = {
|
|
|
147
160
|
* @defaultValue "bottom-left"
|
|
148
161
|
*/
|
|
149
162
|
gizmo?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | false;
|
|
163
|
+
/**
|
|
164
|
+
* The corner beside the pointer the tooltip sits at. Where the tooltip would
|
|
165
|
+
* leave the chart, it flips to the other side, on each axis alone.
|
|
166
|
+
* @defaultValue "top-right"
|
|
167
|
+
*/
|
|
168
|
+
tooltip?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
150
169
|
};
|
|
151
|
-
declare function ChartContainer3D({ id, config, defaultView, width, height, animationDuration, legend, renderer: requested, shortcuts, keymap, gizmo, className, children, "aria-label": ariaLabel, ...props }: React.ComponentProps<"div"> & ChartContainer3DProps): React.JSX.Element;
|
|
170
|
+
declare function ChartContainer3D({ id, config, defaultView, width, height, animationDuration, legend, renderer: requested, shortcuts, keymap, gizmo, tooltip, className, children, "aria-label": ariaLabel, ...props }: React.ComponentProps<"div"> & ChartContainer3DProps): React.JSX.Element;
|
|
152
171
|
/**
|
|
153
172
|
* Eases a chart into new data: the numbers of `values` glide from the ones
|
|
154
173
|
* on screen to these over the animationDuration of the container. A key
|
|
155
174
|
* that is new starts at `enter`, or where it ends; a key that is gone glides
|
|
156
175
|
* back to `enter`, the mirror of its entering - without one it stands where
|
|
157
176
|
* it is - and leaves when the glide is done. Without time, or with reduced
|
|
158
|
-
* motion, the numbers jump.
|
|
177
|
+
* motion, the numbers jump. At rest it hands back the record of its target,
|
|
178
|
+
* no copy, so no frame rebuilds it: read it, never write to it.
|
|
159
179
|
*/
|
|
160
180
|
declare function useTween(values: Record<string, number>, enter?: number): Record<string, number>;
|
|
161
181
|
/**
|
|
@@ -168,13 +188,19 @@ declare function useTween(values: Record<string, number>, enter?: number): Recor
|
|
|
168
188
|
* shrinks from a dropped one instead of jumping when the glide is done.
|
|
169
189
|
*/
|
|
170
190
|
declare function useTweenAxes(spec: AxesSpec): AxesSpec;
|
|
191
|
+
/**
|
|
192
|
+
* The color of the config key `key`: the CSS variable the container declares
|
|
193
|
+
* for it. A chart without a config has no first key to fall back on, and
|
|
194
|
+
* draws in a variable nobody declares: colorless, as before.
|
|
195
|
+
*/
|
|
196
|
+
declare const colorOf: (key: string | undefined) => string;
|
|
171
197
|
/**
|
|
172
198
|
* The marks of a chart, drawn by the renderer of the container: as SVG
|
|
173
199
|
* elements, or on the canvas over the chart box. The hover reads them too.
|
|
174
200
|
*/
|
|
175
201
|
declare function Marks3D({ marks }: {
|
|
176
202
|
marks: Mark3D[];
|
|
177
|
-
}): React.JSX.Element
|
|
203
|
+
}): React.JSX.Element;
|
|
178
204
|
/**
|
|
179
205
|
* A label beside a mark, at `at` in the units of the view box. `toward`, a
|
|
180
206
|
* unit vector, lays the label on that side of `at`, touching it, and slides
|
|
@@ -223,6 +249,70 @@ declare function pad(spec: AxisSpec, cell: number): AxisSpec;
|
|
|
223
249
|
declare function linear([d0, d1]: number[], [r0, r1]: number[]): (value: number) => number;
|
|
224
250
|
/** The world box of `spec`: x from -1 to 1, y up from 1 to -1, z from -`depth` to `depth`. */
|
|
225
251
|
declare function worldBox(spec: AxesSpec, depth?: number): World;
|
|
252
|
+
/**
|
|
253
|
+
* The point at `lon` and `lat`, in degrees, on the sphere of `radius` around
|
|
254
|
+
* the center of the world box: the prime meridian faces the viewer at yaw 0,
|
|
255
|
+
* east lies to the right and the north pole is up - towards -y, as the box
|
|
256
|
+
* counts y. The globe chart builds its tiles from it, since a chart may not
|
|
257
|
+
* do trigonometry of its own.
|
|
258
|
+
*/
|
|
259
|
+
declare function globe(lon: number, lat: number, radius?: number): Point3D;
|
|
260
|
+
/** The radius of the globe in the world box: `geoView` projects the land at it, and a geo chart places its marks on it. */
|
|
261
|
+
declare const GLOBE_RADIUS = 1.15;
|
|
262
|
+
/**
|
|
263
|
+
* The camera without its perspective, a copy, since d3-3d shares the view of
|
|
264
|
+
* a camera it is handed: d3-geo has no perspective, so a geo chart projects
|
|
265
|
+
* its marks without one too, and they stay on the land.
|
|
266
|
+
*/
|
|
267
|
+
declare function orthographic(camera: Camera3DInstance): Camera3DInstance;
|
|
268
|
+
/** What `earth` sets on a projection of d3-geo: the three setters it needs, each returning the projection. */
|
|
269
|
+
export type GeoProjectionLike<P> = {
|
|
270
|
+
rotate(angles: [number, number]): P;
|
|
271
|
+
scale(scale: number): P;
|
|
272
|
+
translate(point: [number, number]): P;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Stands in for a canvas under d3-geo's `geoPath`: `marks(draw, key, fill)`
|
|
276
|
+
* runs `draw` and returns every ring it drew, cut at the horizon as d3-geo
|
|
277
|
+
* cuts it, as a polygon mark keyed `key-i`. A point is not a region: the ring
|
|
278
|
+
* its `moveTo` began goes with its `arc`. A hole is not one either: a ring
|
|
279
|
+
* wound the other way than the largest ring is left out, so the region
|
|
280
|
+
* around a hole fills it once, not twice.
|
|
281
|
+
*/
|
|
282
|
+
declare function ringSink(): {
|
|
283
|
+
beginPath: () => void;
|
|
284
|
+
moveTo: (x: number, y: number) => void;
|
|
285
|
+
lineTo: (x: number, y: number) => void;
|
|
286
|
+
closePath: () => void;
|
|
287
|
+
arc: () => void;
|
|
288
|
+
marks: (draw: () => void, key: string, fill: string) => Mark3D[];
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* The earth under the marks of a geo chart: the ocean and the land as marks,
|
|
292
|
+
* flat in `--chart-3d-ocean` and `--chart-3d-land`, falling back to the
|
|
293
|
+
* colors of the walls - scenery, grouped by nothing, with no tooltip, that
|
|
294
|
+
* neither enters nor glides. The chart hands in d3-geo's `geoOrthographic()`
|
|
295
|
+
* and `geoPath`, so the core carries no d3-geo; `earth` sets the projection
|
|
296
|
+
* to the camera and draws through a sink that collects every ring, cut at
|
|
297
|
+
* the horizon, as a polygon. `path` and `sink` come along for a chart that
|
|
298
|
+
* draws regions of its own: `sink.marks(() => path(feature), key, fill)`.
|
|
299
|
+
*/
|
|
300
|
+
declare function earth<Feature, P extends GeoProjectionLike<P>, Path extends (object: Feature | {
|
|
301
|
+
type: "Sphere";
|
|
302
|
+
}) => unknown>(land: {
|
|
303
|
+
features: Feature[];
|
|
304
|
+
}, camera: Camera3DInstance, projection: P, geoPath: (projection: P, sink: ReturnType<typeof ringSink>) => Path): {
|
|
305
|
+
marks: Mark3D[];
|
|
306
|
+
path: Path;
|
|
307
|
+
sink: {
|
|
308
|
+
beginPath: () => void;
|
|
309
|
+
moveTo: (x: number, y: number) => void;
|
|
310
|
+
lineTo: (x: number, y: number) => void;
|
|
311
|
+
closePath: () => void;
|
|
312
|
+
arc: () => void;
|
|
313
|
+
marks: (draw: () => void, key: string, fill: string) => Mark3D[];
|
|
314
|
+
};
|
|
315
|
+
};
|
|
226
316
|
/**
|
|
227
317
|
* Hands the projection its accessors into the world box, so every chart maps
|
|
228
318
|
* its shapes onto the screen the same way.
|
|
@@ -241,14 +331,165 @@ declare function shade(face: TransformedPoint<unknown>[], color: string): string
|
|
|
241
331
|
* after `shade`, which would mix a translucent color back towards opaque.
|
|
242
332
|
*/
|
|
243
333
|
declare function faded(color: string, opacity: number): string;
|
|
244
|
-
/**
|
|
245
|
-
|
|
334
|
+
/**
|
|
335
|
+
* Whether `value` is a number a chart can place: whatever `Number` reads as a
|
|
336
|
+
* finite number - a number, a string of one, a date, a bigint - but not what
|
|
337
|
+
* it reads as 0 for want of a value: null, a blank string and a boolean would
|
|
338
|
+
* draw an entry without a place at the origin.
|
|
339
|
+
*/
|
|
340
|
+
declare function finite(value: unknown): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* `value` as an amount a mark is sized by, such as the area of a dot or the
|
|
343
|
+
* height of a tile: one below 0, or one that is not a finite number, stands
|
|
344
|
+
* as 0.
|
|
345
|
+
*/
|
|
346
|
+
declare function nonNegative(value: unknown): number;
|
|
347
|
+
/**
|
|
348
|
+
* The entries of `data` and their series, for a chart that lays the entries
|
|
349
|
+
* out along x and the series along z, as the bar and the area chart do. The
|
|
350
|
+
* name of every entry comes from its `index` field, the series are `keys` or
|
|
351
|
+
* the keys of the config, and the `target` of every cell is keyed by the name
|
|
352
|
+
* of its entry and its series, so it follows its entry when the data
|
|
353
|
+
* reorders; a value that is not a finite number stands as 0. Each glides by name:
|
|
354
|
+
* `values` from 0, `rows` - the place of every entry - to where it stands, and
|
|
355
|
+
* `presence` from 0 to 1 as an entry comes and back as it goes, the gone ones
|
|
356
|
+
* still among them. `labels` name the ticks: the entry at a tick of x, through
|
|
357
|
+
* `format.x` - a tick of a gone entry fades out unnamed - and the series at a
|
|
358
|
+
* tick of z. Every entry is keyed by its id - its name, made unique where a
|
|
359
|
+
* name repeats - and `nameOf` reads the name back; `entries` holds the entry
|
|
360
|
+
* behind every id still in the data.
|
|
361
|
+
*/
|
|
362
|
+
declare function useSeries<T extends Record<string, unknown>>({ data, index, keys, format }: {
|
|
363
|
+
data: T[];
|
|
364
|
+
index: keyof T & string;
|
|
365
|
+
keys?: string[];
|
|
366
|
+
format?: {
|
|
367
|
+
x?: (label: string) => React.ReactNode;
|
|
368
|
+
y?: (value: number) => React.ReactNode;
|
|
369
|
+
};
|
|
370
|
+
}): {
|
|
371
|
+
series: string[];
|
|
372
|
+
target: {
|
|
373
|
+
[k: string]: number;
|
|
374
|
+
};
|
|
375
|
+
entries: Map<string, T>;
|
|
376
|
+
values: Record<string, number>;
|
|
377
|
+
rows: Record<string, number>;
|
|
378
|
+
presence: Record<string, number>;
|
|
379
|
+
labels: {
|
|
380
|
+
x: (i: number) => React.ReactNode;
|
|
381
|
+
y: ((value: number) => React.ReactNode) | undefined;
|
|
382
|
+
z: (j: number) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
383
|
+
};
|
|
384
|
+
nameOf: typeof nameOf;
|
|
385
|
+
};
|
|
386
|
+
/** The name of the entry of `id`, as its data names it. */
|
|
387
|
+
declare const nameOf: (id: string) => string;
|
|
246
388
|
/** The marks of a cube: its faces that look at the camera, shaded in `color`, each with `tooltip` on hover. */
|
|
247
|
-
declare function cubeMarks(id: string, faces: CubeFace[], color: string, tooltip:
|
|
389
|
+
declare function cubeMarks(id: string, faces: CubeFace[], color: string, tooltip: Mark3D["tooltip"]): Mark3D[];
|
|
390
|
+
/**
|
|
391
|
+
* The corners of a bar on the floor of `world`, at `x` and `z` in the values
|
|
392
|
+
* of the data, from 0 to `value`, `size` wide and deep in the world box.
|
|
393
|
+
* box() rises towards -y, so a negative bar starts at its value.
|
|
394
|
+
*/
|
|
395
|
+
declare function barCorners(world: World, x: number, z: number, value: number, size: {
|
|
396
|
+
width: number;
|
|
397
|
+
depth: number;
|
|
398
|
+
}): Point3D[];
|
|
399
|
+
/** The marks of one bar: the faces that look at the camera, shaded and faded to `opacity`, each with `tooltip` on hover. Its group is the bar alone, so hovering highlights one bar. */
|
|
400
|
+
declare function barMarks({ id, faces, color, tooltip, opacity }: {
|
|
401
|
+
id: string;
|
|
402
|
+
faces: CubeFace[];
|
|
403
|
+
color: string;
|
|
404
|
+
tooltip: Mark3D["tooltip"];
|
|
405
|
+
opacity: number;
|
|
406
|
+
}): {
|
|
407
|
+
/** Stable across renders, so React moves the shape instead of redrawing it. */
|
|
408
|
+
key: string;
|
|
409
|
+
/** The corners of a polygon, or the center of a circle, in the units of the view box. */
|
|
410
|
+
points: Point2D[];
|
|
411
|
+
r?: number;
|
|
412
|
+
/** The ring around a circle, a CSS color. */
|
|
413
|
+
stroke?: string;
|
|
414
|
+
/**
|
|
415
|
+
* Shown while the pointer is over the mark. A function is called when the
|
|
416
|
+
* pointer lands on the mark, so a chart with thousands of marks pays for
|
|
417
|
+
* one tooltip per hover, not one per mark per frame; `null` shows none.
|
|
418
|
+
*/
|
|
419
|
+
tooltip?: Tooltip3D | (() => Tooltip3D | null);
|
|
420
|
+
fill: string;
|
|
421
|
+
groups: string[];
|
|
422
|
+
}[];
|
|
423
|
+
/**
|
|
424
|
+
* The color at `value` on a ramp from the config color `low` at `lo` to
|
|
425
|
+
* `high` at `hi` - a value beyond them takes the color of the nearer end: a
|
|
426
|
+
* CSS color-mix, so it follows the theme.
|
|
427
|
+
*/
|
|
428
|
+
declare function ramp(value: number, [lo, hi]: [number, number], [low, high]: [string, string]): string;
|
|
429
|
+
/**
|
|
430
|
+
* Where the `count` columns or rows of a grid stand along one axis of
|
|
431
|
+
* arrangement: at their value of `at`, in any order, or evenly over `ends`,
|
|
432
|
+
* by default their indices; one without a finite value has no place. With
|
|
433
|
+
* the cell, the smallest gap between two places - 1 where there is none -
|
|
434
|
+
* and the axis over the places, its ticks within: its walls half a cell
|
|
435
|
+
* beyond them - the padding - or at them where not `padded`, never at a
|
|
436
|
+
* rounder tick, which would leave the box empty beyond the data.
|
|
437
|
+
*/
|
|
438
|
+
declare function gridAxis(count: number, { at, ends, padded }?: {
|
|
439
|
+
at?: number[];
|
|
440
|
+
ends?: [number, number];
|
|
441
|
+
padded?: boolean;
|
|
442
|
+
}): {
|
|
443
|
+
places: Record<number, number>;
|
|
444
|
+
cell: number;
|
|
445
|
+
spec: AxisSpec;
|
|
446
|
+
};
|
|
447
|
+
/** `cubes`, each with its bottom face as `floor`, found once: bars on one floor paint back to front by it. */
|
|
448
|
+
declare function floored<C extends {
|
|
449
|
+
faces: CubeFace[];
|
|
450
|
+
}>(cubes: C[]): (C & {
|
|
451
|
+
floor: CubeFace;
|
|
452
|
+
})[];
|
|
453
|
+
export type AreaChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
454
|
+
/** One entry per point along x, with a value per series. */
|
|
455
|
+
data: T[];
|
|
456
|
+
/** The field that names each entry, such as "year"; a point follows its name through updates, and an entry of a name that repeats is, in the order of the data, a point of its own. */
|
|
457
|
+
index: keyof T & string;
|
|
458
|
+
/**
|
|
459
|
+
* The fields that hold the series, one ribbon each.
|
|
460
|
+
* @defaultValue the keys of the chart config
|
|
461
|
+
*/
|
|
462
|
+
keys?: string[];
|
|
463
|
+
/** Formats the labels of the entries along x and the values along y. */
|
|
464
|
+
format?: {
|
|
465
|
+
x?: (label: string) => React.ReactNode;
|
|
466
|
+
y?: (value: number) => React.ReactNode;
|
|
467
|
+
};
|
|
468
|
+
/** The titles of the axes. */
|
|
469
|
+
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
470
|
+
/**
|
|
471
|
+
* What a face of a ribbon says on hover: `tooltip` is what it would say,
|
|
472
|
+
* its series and, on a segment of the top, the two entries it spans with
|
|
473
|
+
* their values as the ticks name them; `data` the series key and those
|
|
474
|
+
* entries, none on a side; `null` shows none.
|
|
475
|
+
* @defaultValue (tooltip) => tooltip
|
|
476
|
+
*/
|
|
477
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
478
|
+
key: string;
|
|
479
|
+
entries: T[];
|
|
480
|
+
}) => Tooltip3D | null;
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* Areas pushed back into ribbons: the entries of `data` along x, one ribbon
|
|
484
|
+
* per series along z, the area under its line reaching down to the floor of
|
|
485
|
+
* the box. The series are the keys of the chart config unless `keys` names
|
|
486
|
+
* them.
|
|
487
|
+
*/
|
|
488
|
+
export declare function AreaChart3D<T extends Record<string, unknown>>({ data, index, keys, format, titles, tooltip }: AreaChart3DProps<T>): React.JSX.Element;
|
|
248
489
|
export type BarChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
249
490
|
/** One entry per row of bars, with a value per series. */
|
|
250
491
|
data: T[];
|
|
251
|
-
/** The field that names each entry, such as "month"; a bar follows its name through updates,
|
|
492
|
+
/** The field that names each entry, such as "month"; a bar follows its name through updates, and an entry of a name that repeats is, in the order of the data, a bar of its own. */
|
|
252
493
|
index: keyof T & string;
|
|
253
494
|
/**
|
|
254
495
|
* The fields that hold the series, one row of bars each.
|
|
@@ -267,15 +508,242 @@ export type BarChart3DProps<T extends Record<string, unknown> = Record<string, u
|
|
|
267
508
|
};
|
|
268
509
|
/** The titles of the axes. */
|
|
269
510
|
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
511
|
+
/**
|
|
512
|
+
* What a bar says on hover: `tooltip` is what it would say, its entry and
|
|
513
|
+
* value as the ticks name them, `data` the entry and the series key behind
|
|
514
|
+
* it; `null` shows none.
|
|
515
|
+
* @defaultValue (tooltip) => tooltip
|
|
516
|
+
*/
|
|
517
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
518
|
+
entry: T;
|
|
519
|
+
key: string;
|
|
520
|
+
}) => Tooltip3D | null;
|
|
270
521
|
};
|
|
271
522
|
/**
|
|
272
523
|
* Bars on a floor: one row per entry of `data` along x, one per series
|
|
273
524
|
* along z, the value as the height. The series are the keys of the chart
|
|
274
525
|
* config unless `keys` names them.
|
|
275
526
|
*/
|
|
276
|
-
export declare function BarChart3D<T extends Record<string, unknown>>({ data, index, keys, barSize, format, titles }: BarChart3DProps<T>): React.JSX.Element;
|
|
527
|
+
export declare function BarChart3D<T extends Record<string, unknown>>({ data, index, keys, barSize, format, titles, tooltip }: BarChart3DProps<T>): React.JSX.Element;
|
|
528
|
+
export type BarFieldChart3DProps = {
|
|
529
|
+
/**
|
|
530
|
+
* The value of every bar, `data[row][column]`: the columns run along x, the
|
|
531
|
+
* rows along z, and a bar rises from 0 to its value. One that is not a
|
|
532
|
+
* finite number draws no bar.
|
|
533
|
+
*/
|
|
534
|
+
data: number[][];
|
|
535
|
+
/**
|
|
536
|
+
* The data values the first and the last column (x) and row (z) stand for,
|
|
537
|
+
* the others evenly between. The chart keeps half a cell between the bars
|
|
538
|
+
* and the walls of its box.
|
|
539
|
+
* @defaultValue the indices of the columns and rows
|
|
540
|
+
*/
|
|
541
|
+
domain?: {
|
|
542
|
+
x?: [number, number];
|
|
543
|
+
z?: [number, number];
|
|
544
|
+
};
|
|
545
|
+
/**
|
|
546
|
+
* The value every column stands at along x, `x[column]`, in any order and
|
|
547
|
+
* at any spacing, in place of `domain.x`. A column without a finite value
|
|
548
|
+
* draws no bars.
|
|
549
|
+
* @defaultValue evenly over `domain.x`
|
|
550
|
+
*/
|
|
551
|
+
x?: number[];
|
|
552
|
+
/**
|
|
553
|
+
* The value every row stands at along z, `z[row]`, in any order and at any
|
|
554
|
+
* spacing, in place of `domain.z`. A row without a finite value draws no
|
|
555
|
+
* bars.
|
|
556
|
+
* @defaultValue evenly over `domain.z`
|
|
557
|
+
*/
|
|
558
|
+
z?: number[];
|
|
559
|
+
/**
|
|
560
|
+
* What a bar says on hover: `tooltip` is what it would say, its x, z and
|
|
561
|
+
* value as the ticks name them, `data` the row and column of the bar, the
|
|
562
|
+
* x and z they stand for and its value; `null` shows none.
|
|
563
|
+
* @defaultValue (tooltip) => tooltip
|
|
564
|
+
*/
|
|
565
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
566
|
+
row: number;
|
|
567
|
+
column: number;
|
|
568
|
+
x: number;
|
|
569
|
+
z: number;
|
|
570
|
+
value: number;
|
|
571
|
+
}) => Tooltip3D | null;
|
|
572
|
+
/** Formats the tick labels of each axis. */
|
|
573
|
+
format?: Partial<Record<keyof AxesSpec, (value: number) => React.ReactNode>>;
|
|
574
|
+
/** The titles of the axes. */
|
|
575
|
+
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
576
|
+
/**
|
|
577
|
+
* The config keys of the colors at the lowest and at the highest value.
|
|
578
|
+
* @defaultValue the first two keys of the chart config
|
|
579
|
+
*/
|
|
580
|
+
colors?: [string, string];
|
|
581
|
+
};
|
|
582
|
+
/**
|
|
583
|
+
* A field of bars over a grid: `data[row][column]` is the value of a bar, the
|
|
584
|
+
* columns run along x and the rows along z. Everything about a bar comes from
|
|
585
|
+
* the data - its place from the value of its column and row, its footprint
|
|
586
|
+
* from the smallest gap between two of them, its height from its value, its
|
|
587
|
+
* color from the ramp between the two `colors` at the lowest and the highest
|
|
588
|
+
* value.
|
|
589
|
+
*/
|
|
590
|
+
export declare function BarFieldChart3D({ data, domain, x, z, tooltip, format, titles, colors }: BarFieldChart3DProps): React.JSX.Element;
|
|
591
|
+
export type ChoroplethChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
592
|
+
/** One entry per region: the region an entry names takes its color, and the last entry on a region wins. */
|
|
593
|
+
data: T[];
|
|
594
|
+
/**
|
|
595
|
+
* The regions of the earth, a GeoJSON feature collection, cut at the
|
|
596
|
+
* horizon; the `id` of a feature is what an entry names. d3-geo reads a
|
|
597
|
+
* region wound clockwise, the opposite of RFC 7946: topojson-client's
|
|
598
|
+
* `feature` winds it so, and a region wound the other way fills the globe
|
|
599
|
+
* around it.
|
|
600
|
+
*/
|
|
601
|
+
land: GeoJSON.FeatureCollection;
|
|
602
|
+
/**
|
|
603
|
+
* The field whose value, as a string, is the `id` of the region of the land
|
|
604
|
+
* the entry colors: for world-atlas the ISO 3166-1 numeric code, `"276"`
|
|
605
|
+
* for Germany.
|
|
606
|
+
*/
|
|
607
|
+
id: keyof T & string;
|
|
608
|
+
/** The field of the value of an entry, shown in the tooltip of its region. */
|
|
609
|
+
value: keyof T & string;
|
|
610
|
+
/**
|
|
611
|
+
* The field whose value is the config key of the color of a region.
|
|
612
|
+
* @defaultValue the first key of the chart config for every region
|
|
613
|
+
*/
|
|
614
|
+
series?: keyof T & string;
|
|
615
|
+
/**
|
|
616
|
+
* The field that names an entry: the title of the tooltip of its region.
|
|
617
|
+
* @defaultValue the label of the series
|
|
618
|
+
*/
|
|
619
|
+
label?: keyof T & string;
|
|
620
|
+
/** Formats the value in the tooltip. */
|
|
621
|
+
format?: (value: number) => React.ReactNode;
|
|
622
|
+
/**
|
|
623
|
+
* What a region says on hover: `tooltip` is what it would say, its name or
|
|
624
|
+
* its series and its value, `data` the entry behind it; `null` shows none.
|
|
625
|
+
* @defaultValue (tooltip) => tooltip
|
|
626
|
+
*/
|
|
627
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
628
|
+
entry: T;
|
|
629
|
+
}) => Tooltip3D | null;
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* The regions of the land on a globe, each in the color of its class. The
|
|
633
|
+
* region an entry names is colored over the land, in the config color of
|
|
634
|
+
* its series; one without an entry stays land. Nothing grows: a region fades
|
|
635
|
+
* in with its entry, out without it, and one that changes series leaves as
|
|
636
|
+
* one and enters as the other.
|
|
637
|
+
*/
|
|
638
|
+
export declare function ChoroplethChart3D<T extends Record<string, unknown>>({ data, land, id, value, series, label, format, tooltip }: ChoroplethChart3DProps<T>): React.JSX.Element;
|
|
639
|
+
export type GlobeChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
640
|
+
/** One entry per tile: the tile that holds an entry rises to its value, and the last entry on a tile wins. */
|
|
641
|
+
data: T[];
|
|
642
|
+
/**
|
|
643
|
+
* The regions of the earth under the tiles, a GeoJSON feature collection,
|
|
644
|
+
* cut at the horizon. d3-geo reads a region wound clockwise, the opposite
|
|
645
|
+
* of RFC 7946: topojson-client's `feature` winds it so, and a region
|
|
646
|
+
* wound the other way fills the globe around it.
|
|
647
|
+
*/
|
|
648
|
+
land: GeoJSON.FeatureCollection;
|
|
649
|
+
/** The field of the longitude of an entry, in degrees east. */
|
|
650
|
+
lon: keyof T & string;
|
|
651
|
+
/** The field of the latitude of an entry, in degrees north. */
|
|
652
|
+
lat: keyof T & string;
|
|
653
|
+
/** The field of the value of an entry, the height of its tile; a value below 0, or one that is not a finite number, stands as 0. */
|
|
654
|
+
value: keyof T & string;
|
|
655
|
+
/**
|
|
656
|
+
* The field whose value is the config key of the color of a tile.
|
|
657
|
+
* @defaultValue the first key of the chart config for every tile
|
|
658
|
+
*/
|
|
659
|
+
series?: keyof T & string;
|
|
660
|
+
/**
|
|
661
|
+
* The field that names an entry: the name of the last entry on a tile is
|
|
662
|
+
* the title of its tooltip.
|
|
663
|
+
* @defaultValue the label of the series
|
|
664
|
+
*/
|
|
665
|
+
label?: keyof T & string;
|
|
666
|
+
/**
|
|
667
|
+
* The width of a tile in degrees, a divisor of 180; one that is not
|
|
668
|
+
* above 0 and up to 180 draws the default.
|
|
669
|
+
* @defaultValue 5
|
|
670
|
+
*/
|
|
671
|
+
step?: number;
|
|
672
|
+
/** Formats the value in the tooltip. */
|
|
673
|
+
format?: (value: number) => React.ReactNode;
|
|
674
|
+
/**
|
|
675
|
+
* What a tile says on hover: `tooltip` is what it would say, its name or
|
|
676
|
+
* its series, its value and its center, `data` the entries on the tile;
|
|
677
|
+
* `null` shows none.
|
|
678
|
+
* @defaultValue (tooltip) => tooltip
|
|
679
|
+
*/
|
|
680
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
681
|
+
entries: T[];
|
|
682
|
+
}) => Tooltip3D | null;
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* A globe of tiles between meridians and parallels, `step` degrees wide, on
|
|
686
|
+
* the land. The tile that holds an entry rises from the globe to the entry's
|
|
687
|
+
* value, in the color of its series; one without an entry is not drawn.
|
|
688
|
+
*/
|
|
689
|
+
export declare function GlobeChart3D<T extends Record<string, unknown>>({ data, land, lon, lat, value, series, label, step: requested, format, tooltip }: GlobeChart3DProps<T>): React.JSX.Element;
|
|
690
|
+
export type PlacesChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
691
|
+
/** One entry per place: a dot on the globe. */
|
|
692
|
+
data: T[];
|
|
693
|
+
/**
|
|
694
|
+
* The regions of the earth under the dots, a GeoJSON feature collection,
|
|
695
|
+
* cut at the horizon. d3-geo reads a region wound clockwise, the opposite
|
|
696
|
+
* of RFC 7946: topojson-client's `feature` winds it so, and a region
|
|
697
|
+
* wound the other way fills the globe around it.
|
|
698
|
+
*/
|
|
699
|
+
land: GeoJSON.FeatureCollection;
|
|
700
|
+
/** The field of the longitude of an entry, in degrees east. */
|
|
701
|
+
lon: keyof T & string;
|
|
702
|
+
/** The field of the latitude of an entry, in degrees north. */
|
|
703
|
+
lat: keyof T & string;
|
|
704
|
+
/**
|
|
705
|
+
* The field of the value of an entry: the area of its dot, relative to the
|
|
706
|
+
* largest; a value below 0, or one that is not a finite number, stands as 0.
|
|
707
|
+
* @defaultValue every dot the same size
|
|
708
|
+
*/
|
|
709
|
+
value?: keyof T & string;
|
|
710
|
+
/**
|
|
711
|
+
* The field whose value is the config key of the color of a dot.
|
|
712
|
+
* @defaultValue the first key of the chart config for every dot
|
|
713
|
+
*/
|
|
714
|
+
series?: keyof T & string;
|
|
715
|
+
/**
|
|
716
|
+
* The field that names an entry: the title of its tooltip, and its identity
|
|
717
|
+
* through updates, so a new dot grows, a gone one shrinks away and one that
|
|
718
|
+
* moves glides. The names should be unique.
|
|
719
|
+
* @defaultValue the place of the entry
|
|
720
|
+
*/
|
|
721
|
+
id?: keyof T & string;
|
|
722
|
+
/**
|
|
723
|
+
* The radius of the largest dot - of every dot, without `value` - in the
|
|
724
|
+
* units of the view box.
|
|
725
|
+
* @defaultValue 6
|
|
726
|
+
*/
|
|
727
|
+
radius?: number;
|
|
728
|
+
/** Formats the value in the tooltip. */
|
|
729
|
+
format?: (value: number) => React.ReactNode;
|
|
730
|
+
/**
|
|
731
|
+
* What a dot says on hover: `tooltip` is what it would say, its name or
|
|
732
|
+
* its series, its value and its place, `data` the entry behind it; `null`
|
|
733
|
+
* shows none.
|
|
734
|
+
* @defaultValue (tooltip) => tooltip
|
|
735
|
+
*/
|
|
736
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
737
|
+
entry: T;
|
|
738
|
+
}) => Tooltip3D | null;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Dots on the land of a globe, one per place, its area its value. A dot on
|
|
742
|
+
* the far side is hidden by the globe.
|
|
743
|
+
*/
|
|
744
|
+
export declare function PlacesChart3D<T extends Record<string, unknown>>({ data, land, lon, lat, value, series, id, radius, format, tooltip }: PlacesChart3DProps<T>): React.JSX.Element;
|
|
277
745
|
export type ScatterChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
278
|
-
/** One entry per point. */
|
|
746
|
+
/** One entry per point; one whose x, y or z is missing or not a number has none. */
|
|
279
747
|
data: T[];
|
|
280
748
|
/** The field of the position along x. */
|
|
281
749
|
x: keyof T & string;
|
|
@@ -304,25 +772,50 @@ export type ScatterChart3DProps<T extends Record<string, unknown> = Record<strin
|
|
|
304
772
|
format?: Partial<Record<keyof AxesSpec, (value: number) => React.ReactNode>>;
|
|
305
773
|
/** The titles of the axes. */
|
|
306
774
|
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
775
|
+
/**
|
|
776
|
+
* What a point says on hover: `tooltip` is what it would say, its series
|
|
777
|
+
* and its x, y and z as the ticks name them, `data` the entry behind it;
|
|
778
|
+
* `null` shows none.
|
|
779
|
+
* @defaultValue (tooltip) => tooltip
|
|
780
|
+
*/
|
|
781
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
782
|
+
entry: T;
|
|
783
|
+
}) => Tooltip3D | null;
|
|
307
784
|
};
|
|
308
785
|
/**
|
|
309
786
|
* Points in the chart box, at the fields `x`, `y` and `z` of each entry.
|
|
310
787
|
* `series` names the field whose value is the config key of the color.
|
|
311
788
|
*/
|
|
312
|
-
export declare function ScatterChart3D<T extends Record<string, unknown>>({ data, x, y, z, id, series, radius, format, titles }: ScatterChart3DProps<T>): React.JSX.Element;
|
|
789
|
+
export declare function ScatterChart3D<T extends Record<string, unknown>>({ data: all, x, y, z, id, series, radius, format, titles, tooltip }: ScatterChart3DProps<T>): React.JSX.Element;
|
|
313
790
|
export type SurfaceChart3DProps = {
|
|
314
|
-
/** The heights on the grid, `data[row][column]
|
|
791
|
+
/** The heights on the grid, `data[row][column]`; one that is not a finite number stands at the lowest of the others. */
|
|
315
792
|
data: number[][];
|
|
316
793
|
/**
|
|
317
|
-
* The data values the first and the last column (x) and row (z) stand for
|
|
318
|
-
* The chart keeps half a cell between the grid
|
|
319
|
-
* domain given here names the box exactly,
|
|
794
|
+
* The data values the first and the last column (x) and row (z) stand for,
|
|
795
|
+
* the others evenly between. The chart keeps half a cell between the grid
|
|
796
|
+
* and the walls of its box; a domain given here names the box exactly,
|
|
797
|
+
* without that room.
|
|
320
798
|
* @defaultValue the indices of the columns and rows
|
|
321
799
|
*/
|
|
322
800
|
domain?: {
|
|
323
801
|
x?: [number, number];
|
|
324
802
|
z?: [number, number];
|
|
325
803
|
};
|
|
804
|
+
/**
|
|
805
|
+
* The value every column stands at along x, `x[column]`, at any spacing,
|
|
806
|
+
* in place of `domain.x`; the box spans them exactly. The surface joins
|
|
807
|
+
* the columns in the order of the data: give them ascending, or it folds
|
|
808
|
+
* back over itself. A column without a finite value drops out, its
|
|
809
|
+
* neighbours joined.
|
|
810
|
+
* @defaultValue evenly over `domain.x`
|
|
811
|
+
*/
|
|
812
|
+
x?: number[];
|
|
813
|
+
/**
|
|
814
|
+
* The value every row stands at along z, `z[row]`, as `x` does for the
|
|
815
|
+
* columns.
|
|
816
|
+
* @defaultValue evenly over `domain.z`
|
|
817
|
+
*/
|
|
818
|
+
z?: number[];
|
|
326
819
|
/**
|
|
327
820
|
* The config keys of the colors at the lowest and at the highest height.
|
|
328
821
|
* @defaultValue the first two keys of the chart config
|
|
@@ -332,6 +825,17 @@ export type SurfaceChart3DProps = {
|
|
|
332
825
|
format?: Partial<Record<keyof AxesSpec, (value: number) => React.ReactNode>>;
|
|
333
826
|
/** The titles of the axes. */
|
|
334
827
|
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
828
|
+
/**
|
|
829
|
+
* What a cell says on hover: `tooltip` is what it would say, its height as
|
|
830
|
+
* the ticks of y name it, `data` the row and column the cell starts at and
|
|
831
|
+
* its height, the mean of its four corners; `null` shows none.
|
|
832
|
+
* @defaultValue (tooltip) => tooltip
|
|
833
|
+
*/
|
|
834
|
+
tooltip?: (tooltip: Tooltip3D, data: {
|
|
835
|
+
row: number;
|
|
836
|
+
column: number;
|
|
837
|
+
value: number;
|
|
838
|
+
}) => Tooltip3D | null;
|
|
335
839
|
};
|
|
336
840
|
/**
|
|
337
841
|
* A surface over a grid: `data[row][column]` is the height, the columns run
|
|
@@ -339,6 +843,6 @@ export type SurfaceChart3DProps = {
|
|
|
339
843
|
* `colors` at the lowest height to the second at the highest; both are keys
|
|
340
844
|
* of the chart config, by default its first two.
|
|
341
845
|
*/
|
|
342
|
-
export declare function SurfaceChart3D({ data, domain, colors, format, titles }: SurfaceChart3DProps): React.JSX.Element;
|
|
343
|
-
export { Axes3D, ChartContainer3D, ChartLegend3D, Labels3D, Marks3D, axis,
|
|
846
|
+
export declare function SurfaceChart3D({ data: raw, domain, x, z, colors, format, titles, tooltip }: SurfaceChart3DProps): React.JSX.Element;
|
|
847
|
+
export { Axes3D, ChartContainer3D, ChartLegend3D, GLOBE_RADIUS, Labels3D, Marks3D, axis, barCorners, barMarks, colorOf, cubeMarks, earth, faded, finite, floored, globe, gridAxis, intoWorld, linear, nonNegative, orthographic, pad, ramp, shade, useSeries, useTween, useTweenAxes, worldBox };
|
|
344
848
|
//# sourceMappingURL=index.d.ts.map
|