@niekes/charts-3d 0.4.0 → 0.5.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 CHANGED
@@ -38,7 +38,6 @@
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/sankey-chart-3d"><img src="assets/examples/sankey-chart-3d.png" alt="Sankey Chart 3D"></a></td>
42
41
  </tr>
43
42
  </table>
44
43
 
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ export type View3D = {
27
27
  perspective?: number;
28
28
  };
29
29
  /** How the marks of a chart are drawn. The box, its labels, the tooltip and the legend are always SVG and HTML. */
30
- export type Renderer3D = "svg" | "canvas";
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
33
  export type Tooltip3D = {
@@ -54,9 +54,10 @@ export type Mark3D = {
54
54
  /** Shown while the pointer is over the mark. */
55
55
  tooltip?: Tooltip3D;
56
56
  /**
57
- * What the mark belongs to, such as a flow, or connects, such as a node.
58
- * Pointing at a mark fades every mark and label that shares none of its
59
- * groups, until the pointer leaves the chart; one without groups never fades.
57
+ * The marks of the same element as this one: the faces of a bar, the
58
+ * segments of a flow. Pointing at a mark gives them an edge in the focus
59
+ * color - `--chart-3d-focus`, or their own fill lightened - until the
60
+ * pointer leaves the mark; the fill never changes on hover.
60
61
  */
61
62
  groups?: string[];
62
63
  };
@@ -80,7 +81,7 @@ type ChartContext3D = {
80
81
  export declare function useChart3D(): ChartContext3D;
81
82
  /** The actions a key triggers: each steps the camera, `help` opens the shortcut panel. */
82
83
  export type KeyAction3D = "rotateLeft" | "rotateRight" | "rotateUp" | "rotateDown" | "panLeft" | "panRight" | "panUp" | "panDown" | "zoomIn" | "zoomOut" | "reset" | "help";
83
- /** The gestures of the pointer: a drag turns the camera, with Space held it pans, Ctrl or ⌘ with the wheel zooms, a double click resets. */
84
+ /** 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. */
84
85
  export type Gesture3D = "dragRotate" | "dragPan" | "wheelZoom" | "doubleClickReset";
85
86
  /**
86
87
  * The shortcuts of a chart over their defaults, per action: `false` turns an
@@ -124,9 +125,9 @@ export type ChartContainer3DProps = {
124
125
  */
125
126
  legend?: boolean;
126
127
  /**
127
- * How the marks of the chart are drawn: "canvas" suits many marks. The
128
- * chart draws as SVG until the browser shows it has a canvas, and where it
129
- * has none.
128
+ * How the marks of the chart are drawn: "canvas" suits many marks, "webgl" more.
129
+ * The chart draws as SVG until the browser shows it has the requested renderer,
130
+ * "webgl" falling back to "canvas", and where it has none, as SVG.
130
131
  * @defaultValue "svg"
131
132
  */
132
133
  renderer?: Renderer3D;
@@ -151,15 +152,20 @@ declare function ChartContainer3D({ id, config, defaultView, width, height, anim
151
152
  /**
152
153
  * Eases a chart into new data: the numbers of `values` glide from the ones
153
154
  * on screen to these over the animationDuration of the container. A key
154
- * that is new starts at `enter`, or where it ends; a key that is gone goes
155
- * at once. Without time, or with reduced motion, the numbers jump.
155
+ * that is new starts at `enter`, or where it ends; a key that is gone glides
156
+ * back to `enter`, the mirror of its entering - without one it stands where
157
+ * it is - and leaves when the glide is done. Without time, or with reduced
158
+ * motion, the numbers jump.
156
159
  */
157
160
  declare function useTween(values: Record<string, number>, enter?: number): Record<string, number>;
158
161
  /**
159
162
  * `spec` gliding into new data with the marks: the ends of every axis glide
160
163
  * as `useTween` glides the numbers, where ends rounded from the numbers on
161
164
  * screen would jump from one round number to the next, and the box with
162
- * them. The ticks are those of `spec` that lie between the ends.
165
+ * them. The ticks stay those of `spec`; labels of ticks outside the gliding
166
+ * ends fade out in `edgeLabels` instead of popping out of the range. The
167
+ * outermost ticks glide too, so the line of the axis grows to a new tick and
168
+ * shrinks from a dropped one instead of jumping when the glide is done.
163
169
  */
164
170
  declare function useTweenAxes(spec: AxesSpec): AxesSpec;
165
171
  /**
@@ -168,7 +174,7 @@ declare function useTweenAxes(spec: AxesSpec): AxesSpec;
168
174
  */
169
175
  declare function Marks3D({ marks }: {
170
176
  marks: Mark3D[];
171
- }): React.JSX.Element[] | null;
177
+ }): React.JSX.Element | null;
172
178
  /**
173
179
  * A label beside a mark, at `at` in the units of the view box. `toward`, a
174
180
  * unit vector, lays the label on that side of `at`, touching it, and slides
@@ -181,8 +187,6 @@ export type Label3D = {
181
187
  text: React.ReactNode;
182
188
  anchor?: "start" | "middle" | "end";
183
189
  toward?: Point2D;
184
- /** The groups of the mark it names, so it fades with the mark out of focus. */
185
- groups?: string[];
186
190
  };
187
191
  /**
188
192
  * The labels of the marks of a chart, ringed by the background so that they
@@ -230,6 +234,13 @@ declare function intoWorld<Datum extends Point3D, T extends ShapeInstance<Datum>
230
234
  * shade follows the theme variables.
231
235
  */
232
236
  declare function shade(face: TransformedPoint<unknown>[], color: string): string;
237
+ /**
238
+ * `color` at `opacity`, from 0 to 1: a CSS color-mix with transparent, so a
239
+ * mark fades on every renderer while its color stays in CSS. Rounded to a
240
+ * percent, so the renderers that resolve colors cache a bounded few. Fade
241
+ * after `shade`, which would mix a translucent color back towards opaque.
242
+ */
243
+ declare function faded(color: string, opacity: number): string;
233
244
  /** The mean of the projected points, where a tooltip points at. */
234
245
  declare function center(points: TransformedPoint<unknown>[]): Point2D;
235
246
  /** The marks of a cube: its faces that look at the camera, shaded in `color`, each with `tooltip` on hover. */
@@ -237,7 +248,7 @@ declare function cubeMarks(id: string, faces: CubeFace[], color: string, tooltip
237
248
  export type BarChart3DProps<T extends Record<string, unknown> = Record<string, unknown>> = {
238
249
  /** One entry per row of bars, with a value per series. */
239
250
  data: T[];
240
- /** The field that names each entry, such as "month". */
251
+ /** The field that names each entry, such as "month"; a bar follows its name through updates, so the names should be unique. */
241
252
  index: keyof T & string;
242
253
  /**
243
254
  * The fields that hold the series, one row of bars each.
@@ -272,6 +283,13 @@ export type ScatterChart3DProps<T extends Record<string, unknown> = Record<strin
272
283
  y: keyof T & string;
273
284
  /** The field of the position along z. */
274
285
  z: keyof T & string;
286
+ /**
287
+ * The field that names an entry, so a point follows its name through
288
+ * updates: a new one grows, a gone one shrinks away, one that moves glides.
289
+ * The names should be unique.
290
+ * @defaultValue the position of the entry
291
+ */
292
+ id?: keyof T & string;
275
293
  /**
276
294
  * The field whose value is the config key of the color of a point.
277
295
  * @defaultValue the first key of the chart config for every point
@@ -291,7 +309,7 @@ export type ScatterChart3DProps<T extends Record<string, unknown> = Record<strin
291
309
  * Points in the chart box, at the fields `x`, `y` and `z` of each entry.
292
310
  * `series` names the field whose value is the config key of the color.
293
311
  */
294
- export declare function ScatterChart3D<T extends Record<string, unknown>>({ data, x, y, z, series, radius, format, titles }: ScatterChart3DProps<T>): React.JSX.Element;
312
+ export declare function ScatterChart3D<T extends Record<string, unknown>>({ data, x, y, z, id, series, radius, format, titles }: ScatterChart3DProps<T>): React.JSX.Element;
295
313
  export type SurfaceChart3DProps = {
296
314
  /** The heights on the grid, `data[row][column]`. */
297
315
  data: number[][];
@@ -322,32 +340,5 @@ export type SurfaceChart3DProps = {
322
340
  * of the chart config, by default its first two.
323
341
  */
324
342
  export declare function SurfaceChart3D({ data, domain, colors, format, titles }: SurfaceChart3DProps): React.JSX.Element;
325
- export type SankeyChart3DProps = {
326
- /** One entry per flow. `source` and `target` are keys of the chart config, which names and colors the nodes. */
327
- data: {
328
- source: string;
329
- target: string;
330
- value: number;
331
- }[];
332
- /**
333
- * The width of a node, as a share of the distance between two columns.
334
- * @defaultValue 0.2
335
- */
336
- nodeWidth?: number;
337
- /**
338
- * The gap between two nodes of a column, as a share of the height.
339
- * @defaultValue 0.05
340
- */
341
- nodePadding?: number;
342
- /** Formats the values in the tooltip. */
343
- format?: (value: number) => React.ReactNode;
344
- };
345
- /**
346
- * Flows from left to right: every node a box in its column, as high as the
347
- * larger of what flows in and what flows out, and every flow a band from node
348
- * to node, as thick as its value, that turns from the color of its source to
349
- * the color of its target.
350
- */
351
- export declare function SankeyChart3D({ data, nodeWidth, nodePadding, format }: SankeyChart3DProps): React.JSX.Element;
352
- export { Axes3D, ChartContainer3D, ChartLegend3D, Labels3D, Marks3D, axis, center, cubeMarks, intoWorld, linear, pad, shade, useTween, useTweenAxes, worldBox };
343
+ export { Axes3D, ChartContainer3D, ChartLegend3D, Labels3D, Marks3D, axis, center, cubeMarks, faded, intoWorld, linear, pad, shade, useTween, useTweenAxes, worldBox };
353
344
  //# sourceMappingURL=index.d.ts.map