@niekes/charts-3d 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +69 -6
- package/dist/index.js +362 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
</tr>
|
|
39
39
|
<tr style="background-color: #f6f8fa">
|
|
40
40
|
<td><a target="_blank" href="https://niekes.github.io/charts-3d/docs/components/surface-chart-3d"><img src="assets/examples/surface-chart-3d.png" alt="Surface Chart 3D"></a></td>
|
|
41
|
+
<td><a target="_blank" href="https://niekes.github.io/charts-3d/docs/components/area-chart-3d"><img src="assets/examples/area-chart-3d.png" alt="Area Chart 3D"></a></td>
|
|
41
42
|
</tr>
|
|
42
43
|
</table>
|
|
43
44
|
|
package/dist/index.d.ts
CHANGED
|
@@ -30,9 +30,8 @@ export type View3D = {
|
|
|
30
30
|
export type Renderer3D = "svg" | "canvas" | "webgl";
|
|
31
31
|
/** Maps data values to the world box, which spans -1 to 1 on every axis, y up. */
|
|
32
32
|
export type World = Record<keyof AxesSpec, (value: number) => number>;
|
|
33
|
+
/** What a mark says while the pointer is on it, beside the pointer. */
|
|
33
34
|
export type Tooltip3D = {
|
|
34
|
-
/** The anchor in the units of the view box. */
|
|
35
|
-
at: Point2D;
|
|
36
35
|
title?: React.ReactNode;
|
|
37
36
|
items: {
|
|
38
37
|
label: React.ReactNode;
|
|
@@ -147,8 +146,14 @@ export type ChartContainer3DProps = {
|
|
|
147
146
|
* @defaultValue "bottom-left"
|
|
148
147
|
*/
|
|
149
148
|
gizmo?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | false;
|
|
149
|
+
/**
|
|
150
|
+
* The corner beside the pointer the tooltip sits at. Where the tooltip would
|
|
151
|
+
* leave the chart, it flips to the other side, on each axis alone.
|
|
152
|
+
* @defaultValue "top-right"
|
|
153
|
+
*/
|
|
154
|
+
tooltip?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
150
155
|
};
|
|
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;
|
|
156
|
+
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
157
|
/**
|
|
153
158
|
* Eases a chart into new data: the numbers of `values` glide from the ones
|
|
154
159
|
* on screen to these over the animationDuration of the container. A key
|
|
@@ -241,10 +246,68 @@ declare function shade(face: TransformedPoint<unknown>[], color: string): string
|
|
|
241
246
|
* after `shade`, which would mix a translucent color back towards opaque.
|
|
242
247
|
*/
|
|
243
248
|
declare function faded(color: string, opacity: number): string;
|
|
244
|
-
/**
|
|
245
|
-
|
|
249
|
+
/**
|
|
250
|
+
* The entries of `data` and their series, for a chart that lays the entries
|
|
251
|
+
* out along x and the series along z, as the bar and the area chart do. The
|
|
252
|
+
* name of every entry comes from its `index` field, the series are `keys` or
|
|
253
|
+
* the keys of the config, and the `target` of every cell is keyed by the name
|
|
254
|
+
* of its entry and its series, so it follows its entry when the data
|
|
255
|
+
* reorders; a value that is not a number stands as 0. Each glides by name:
|
|
256
|
+
* `values` from 0, `rows` - the place of every entry - to where it stands, and
|
|
257
|
+
* `presence` from 0 to 1 as an entry comes and back as it goes, the gone ones
|
|
258
|
+
* still among them. `labels` name the ticks: the entry at a tick of x, through
|
|
259
|
+
* `format.x` - a tick of a gone entry fades out unnamed - and the series at a
|
|
260
|
+
* tick of z.
|
|
261
|
+
*/
|
|
262
|
+
declare function useSeries<T extends Record<string, unknown>>({ data, index, keys, format }: {
|
|
263
|
+
data: T[];
|
|
264
|
+
index: keyof T & string;
|
|
265
|
+
keys?: string[];
|
|
266
|
+
format?: {
|
|
267
|
+
x?: (label: string) => React.ReactNode;
|
|
268
|
+
y?: (value: number) => React.ReactNode;
|
|
269
|
+
};
|
|
270
|
+
}): {
|
|
271
|
+
series: string[];
|
|
272
|
+
target: {
|
|
273
|
+
[k: string]: number;
|
|
274
|
+
};
|
|
275
|
+
values: Record<string, number>;
|
|
276
|
+
rows: Record<string, number>;
|
|
277
|
+
presence: Record<string, number>;
|
|
278
|
+
labels: {
|
|
279
|
+
x: (i: number) => React.ReactNode;
|
|
280
|
+
y: ((value: number) => React.ReactNode) | undefined;
|
|
281
|
+
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>>;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
246
284
|
/** The marks of a cube: its faces that look at the camera, shaded in `color`, each with `tooltip` on hover. */
|
|
247
285
|
declare function cubeMarks(id: string, faces: CubeFace[], color: string, tooltip: Tooltip3D): Mark3D[];
|
|
286
|
+
export type AreaChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
287
|
+
/** One entry per point along x, with a value per series. */
|
|
288
|
+
data: T[];
|
|
289
|
+
/** The field that names each entry, such as "year"; a point follows its name through updates, so the names should be unique. */
|
|
290
|
+
index: keyof T & string;
|
|
291
|
+
/**
|
|
292
|
+
* The fields that hold the series, one ribbon each.
|
|
293
|
+
* @defaultValue the keys of the chart config
|
|
294
|
+
*/
|
|
295
|
+
keys?: string[];
|
|
296
|
+
/** Formats the labels of the entries along x and the values along y. */
|
|
297
|
+
format?: {
|
|
298
|
+
x?: (label: string) => React.ReactNode;
|
|
299
|
+
y?: (value: number) => React.ReactNode;
|
|
300
|
+
};
|
|
301
|
+
/** The titles of the axes. */
|
|
302
|
+
titles?: Partial<Record<keyof AxesSpec, React.ReactNode>>;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Areas pushed back into ribbons: the entries of `data` along x, one ribbon
|
|
306
|
+
* per series along z, the area under its line reaching down to the floor of
|
|
307
|
+
* the box. The series are the keys of the chart config unless `keys` names
|
|
308
|
+
* them.
|
|
309
|
+
*/
|
|
310
|
+
export declare function AreaChart3D<T extends Record<string, unknown>>({ data, index, keys, format, titles }: AreaChart3DProps<T>): React.JSX.Element;
|
|
248
311
|
export type BarChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
249
312
|
/** One entry per row of bars, with a value per series. */
|
|
250
313
|
data: T[];
|
|
@@ -340,5 +403,5 @@ export type SurfaceChart3DProps = {
|
|
|
340
403
|
* of the chart config, by default its first two.
|
|
341
404
|
*/
|
|
342
405
|
export declare function SurfaceChart3D({ data, domain, colors, format, titles }: SurfaceChart3DProps): React.JSX.Element;
|
|
343
|
-
export { Axes3D, ChartContainer3D, ChartLegend3D, Labels3D, Marks3D, axis,
|
|
406
|
+
export { Axes3D, ChartContainer3D, ChartLegend3D, Labels3D, Marks3D, axis, cubeMarks, faded, intoWorld, linear, pad, shade, useSeries, useTween, useTweenAxes, worldBox };
|
|
344
407
|
//# sourceMappingURL=index.d.ts.map
|