@danxbot/ui 18.2.0 → 18.2.1
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.
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Ref } from "react";
|
|
2
|
+
export type TimeSeriesRole = "member" | "other";
|
|
3
|
+
export interface TimeSeriesSeries {
|
|
4
|
+
/** Unique within the chart. */
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** `other` is the neutral remainder: drawn last, in a neutral tone, never selectable. @default "member" */
|
|
8
|
+
role?: TimeSeriesRole;
|
|
9
|
+
/** One value per bucket, same order. Finite and >= 0 — anything else throws. */
|
|
10
|
+
points: readonly number[];
|
|
11
|
+
}
|
|
12
|
+
/** A named kind of unmeasured span: its label is its legend entry. At most two (45 and 135 degree hatching). */
|
|
13
|
+
export interface TimeSeriesBlockKind {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}
|
|
17
|
+
/** A span the chart cannot place in time, drawn hatched in the bucket that holds `at`. */
|
|
18
|
+
export interface TimeSeriesBlock {
|
|
19
|
+
/** Unique within the chart. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Epoch ms; must fall inside one of the buckets. */
|
|
22
|
+
at: number;
|
|
23
|
+
/** Finite and >= 0. Counts toward the bucket total. */
|
|
24
|
+
value: number;
|
|
25
|
+
/** What this span is, for its tooltip line and the table. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** A `TimeSeriesBlockKind.key`. */
|
|
28
|
+
kind: string;
|
|
29
|
+
}
|
|
30
|
+
export interface TimeSeriesChartProps {
|
|
31
|
+
/** Each bucket's start, epoch ms, strictly ascending. */
|
|
32
|
+
buckets: readonly number[];
|
|
33
|
+
/** The width of one bucket in ms; null only when there are no buckets. */
|
|
34
|
+
bucketMs: number | null;
|
|
35
|
+
/** In stacking order, bottom first; also the palette order. */
|
|
36
|
+
series: readonly TimeSeriesSeries[];
|
|
37
|
+
blocks?: readonly TimeSeriesBlock[];
|
|
38
|
+
blockKinds?: readonly TimeSeriesBlockKind[];
|
|
39
|
+
/** What the chart measures, e.g. "Tokens over time". Names the group and captions the table. */
|
|
40
|
+
label: string;
|
|
41
|
+
/** @default "bar" */
|
|
42
|
+
variant?: "bar" | "area";
|
|
43
|
+
/** How a raw value reads in the tooltip and the table. @default locale-formatted number */
|
|
44
|
+
formatValue?: (value: number) => string;
|
|
45
|
+
/** How a value reads on the y axis; use a compact form here. @default `formatValue` */
|
|
46
|
+
formatAxis?: (value: number) => string;
|
|
47
|
+
/** Locale of the time labels. @default the viewer's */
|
|
48
|
+
locale?: string;
|
|
49
|
+
/** IANA zone the buckets are labelled in, e.g. "UTC". @default the viewer's */
|
|
50
|
+
timeZone?: string;
|
|
51
|
+
/** Called with a member series' key when its band or its legend name is clicked. */
|
|
52
|
+
onSelectSeries?: (key: string) => void;
|
|
53
|
+
/** Plot height in px. @default 240 */
|
|
54
|
+
height?: number;
|
|
55
|
+
/** Said when there is nothing to draw. @default "No data" */
|
|
56
|
+
emptyLabel?: string;
|
|
57
|
+
/** Said over the axis when every value is zero. @default "All values are zero" */
|
|
58
|
+
zeroLabel?: string;
|
|
59
|
+
className?: string;
|
|
60
|
+
ref?: Ref<HTMLDivElement>;
|
|
61
|
+
}
|
|
62
|
+
export declare function TimeSeriesChart(props: TimeSeriesChartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const MINUTE_MS = 60000;
|
|
2
|
+
export declare const DAY_MS = 86400000;
|
|
3
|
+
/**
|
|
4
|
+
* A value axis that starts at zero and ends on a round number at or above
|
|
5
|
+
* `max`, with about `count` intervals: steps of 1, 2 or 5 times a power of ten.
|
|
6
|
+
* No data (`max <= 0`) is a 0-to-1 axis, never a zero-height one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function niceTicks(max: number, count?: number): {
|
|
9
|
+
ticks: number[];
|
|
10
|
+
max: number;
|
|
11
|
+
};
|
|
12
|
+
export interface TimeFormatters {
|
|
13
|
+
/** The label under a tick: a primary line, and a secondary line when the day (or year) changed since the last tick. */
|
|
14
|
+
tick: (ms: number, previousMs: number | null) => {
|
|
15
|
+
primary: string;
|
|
16
|
+
secondary: string | null;
|
|
17
|
+
};
|
|
18
|
+
/** The whole instant, for the tooltip and the table. */
|
|
19
|
+
full: (ms: number) => string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* How a bucket start reads for a bucket this wide. Under a day the time is the
|
|
23
|
+
* label and the date appears where it changes; a day or wider is labelled by
|
|
24
|
+
* its date; a month or wider by month and year. `timeZone` is passed straight
|
|
25
|
+
* to `Intl` (an unknown zone throws, loudly); undefined is the viewer's own.
|
|
26
|
+
*/
|
|
27
|
+
export declare function timeFormatters(bucketMs: number, locale: string | undefined, timeZone: string | undefined): TimeFormatters;
|
|
28
|
+
/** The index of the bucket whose span `[start, start + bucketMs)` holds `at`, or -1. */
|
|
29
|
+
export declare function bucketIndexAt(buckets: readonly number[], bucketMs: number, at: number): number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export { ConcentricRing, type ConcentricRingProps, type ConcentricRingLevel, } f
|
|
|
75
75
|
export { Stat, StatRow, Sparkline, type StatProps, type StatRowProps, type SparklineProps, type StatSize, type StatTrend, type StatSentiment, } from "./components/Stat";
|
|
76
76
|
export { ShareBar, type ShareBarProps, type ShareBarSegment, } from "./components/chart/ShareBar";
|
|
77
77
|
export { BarList, type BarListProps, type BarListItem, } from "./components/chart/BarList";
|
|
78
|
+
export { TimeSeriesChart, type TimeSeriesChartProps, type TimeSeriesSeries, type TimeSeriesRole, type TimeSeriesBlock, type TimeSeriesBlockKind, } from "./components/chart/TimeSeriesChart";
|
|
78
79
|
export { CHART_SERIES_COUNT, CHART_SERIES_TOKENS, CHART_SEQUENTIAL_TOKEN, CHART_SEQUENTIAL_COLOR, chartSeriesColor, } from "./lib/chart-palette";
|
|
79
80
|
export { DataTable, TableEmptyState, CellStack, type DataTableProps, type TableDensity, } from "./components/Table";
|
|
80
81
|
export { CodeEditor, CodeEditorToolbar, CodeEditorCaption, CodeEditorCopyButton, CodeEditorWrapToggle, CodeEditorViewSwitch, type CodeEditorProps, type CodeEditorToolbarProps, type CodeEditorView, } from "./components/CodeEditor";
|