@lilt-ui/charts 0.12.2 → 0.13.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.
- package/CHANGELOG.md +288 -270
- package/README.md +21 -59
- package/dist/cards/arc-bridges-card.d.ts +17 -0
- package/dist/cards/area-chart-card.d.ts +1 -10
- package/dist/cards/block-city-card.d.ts +21 -0
- package/dist/cards/calendar-heatmap-card.d.ts +31 -1
- package/dist/cards/cartesian-card.d.ts +9 -27
- package/dist/cards/chart-card.d.ts +1 -12
- package/dist/cards/chord-loom-card.d.ts +17 -0
- package/dist/cards/circle-archipelago-card.d.ts +9 -0
- package/dist/cards/cluster-constellation-card.d.ts +16 -0
- package/dist/cards/comparison-forms.d.ts +30 -0
- package/dist/cards/composition-forms.d.ts +10 -0
- package/dist/cards/contour-islands-card.d.ts +25 -0
- package/dist/cards/density-contours.d.ts +3 -0
- package/dist/cards/distribution-forms.d.ts +37 -0
- package/dist/cards/event-helix-card.d.ts +26 -0
- package/dist/cards/helix-ribbons-card.d.ts +14 -0
- package/dist/cards/hex-city-card.d.ts +25 -0
- package/dist/cards/hierarchy-layouts.d.ts +21 -0
- package/dist/cards/horizon-folds-card.d.ts +10 -0
- package/dist/cards/horizontal-bar-chart-card.d.ts +1 -1
- package/dist/cards/intersection-towers-card.d.ts +9 -0
- package/dist/cards/line-chart-card.d.ts +4 -11
- package/dist/cards/link-readings.d.ts +26 -0
- package/dist/cards/marimekko-blocks-card.d.ts +10 -0
- package/dist/cards/observations-card.d.ts +45 -2
- package/dist/cards/parallel-ribbons-card.d.ts +27 -0
- package/dist/cards/prism-grid.d.ts +58 -0
- package/dist/cards/prism.d.ts +42 -0
- package/dist/cards/progress-forms.d.ts +21 -0
- package/dist/cards/rank-ribbons-card.d.ts +22 -0
- package/dist/cards/ridgeline-card.d.ts +24 -0
- package/dist/cards/scatter-chart-card.d.ts +19 -1
- package/dist/cards/sculpted-geometry.d.ts +18 -0
- package/dist/cards/skyline-card.d.ts +12 -0
- package/dist/cards/spatial-composition-layouts.d.ts +14 -0
- package/dist/cards/spatial-geometry.d.ts +34 -0
- package/dist/cards/spatial-hierarchy.d.ts +10 -0
- package/dist/cards/spatial-point-layouts.d.ts +16 -0
- package/dist/cards/spatial-series-layouts.d.ts +12 -0
- package/dist/cards/spiral-year-card.d.ts +17 -0
- package/dist/cards/sunburst-terraces-card.d.ts +10 -0
- package/dist/cards/ternary-prism-card.d.ts +13 -0
- package/dist/cards/terrain-card.d.ts +21 -0
- package/dist/cards/treemap-chart-card.d.ts +3 -1
- package/dist/cards/trend-forms.d.ts +11 -0
- package/dist/cards/voxel-cloud-card.d.ts +16 -0
- package/dist/cards/voxel-waffle-card.d.ts +18 -0
- package/dist/cards/wind-rose-card.d.ts +11 -0
- package/dist/engine/domains.d.ts +0 -1
- package/dist/finance.js +310 -311
- package/dist/index.d.ts +39 -4
- package/dist/index.js +8919 -2948
- package/dist/{skeleton-block-DIgcA9t6.js → skeleton-block-BPoUJvcR.js} +3596 -2971
- package/dist/styles.css +1 -1
- package/package.json +79 -85
- package/dist/report-context-CIUa6iiD.js +0 -1101
- package/dist/watch/board/board-state.d.ts +0 -72
- package/dist/watch/board/board-toast.d.ts +0 -19
- package/dist/watch/board/chart-board.d.ts +0 -93
- package/dist/watch/board/report-context.d.ts +0 -3
- package/dist/watch/engine/describe.d.ts +0 -9
- package/dist/watch/engine/explain.d.ts +0 -48
- package/dist/watch/engine/normal.d.ts +0 -114
- package/dist/watch/engine/robust.d.ts +0 -7
- package/dist/watch/engine/rules.d.ts +0 -22
- package/dist/watch/engine/status.d.ts +0 -39
- package/dist/watch/index.d.ts +0 -14
- package/dist/watch/normal-layer.d.ts +0 -18
- package/dist/watch.d.ts +0 -2
- package/dist/watch.js +0 -636
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { NormalSeverity } from '../engine/normal';
|
|
2
|
-
/** What a watched chart tells its board. `null` means it is not watching anything. */
|
|
3
|
-
export interface NormalReport {
|
|
4
|
-
/** The series has stayed unusual long enough to count as an incident. */
|
|
5
|
-
active: boolean;
|
|
6
|
-
severity: NormalSeverity | null;
|
|
7
|
-
/** A short sentence, such as "Unusually low". */
|
|
8
|
-
reason: string | null;
|
|
9
|
-
/** Which segment caused it, when the chart has a breakdown: "91% of the drop is Mobile Safari". */
|
|
10
|
-
why: string | null;
|
|
11
|
-
/** Where the incident started, as the chart labels it, such as "Tue 2 PM". */
|
|
12
|
-
since: string | null;
|
|
13
|
-
/** The incident's start as an x position; epoch milliseconds on time axes. */
|
|
14
|
-
sinceAt: number | null;
|
|
15
|
-
/** How far past normal, where 1 is just outside. */
|
|
16
|
-
score: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* `active` needs attention, `acknowledged` has been seen, `cleared` recently returned to normal
|
|
20
|
-
* and is about to settle back into place.
|
|
21
|
-
*/
|
|
22
|
-
export type BoardAlarm = 'normal' | 'active' | 'acknowledged' | 'cleared';
|
|
23
|
-
export interface BoardItemState {
|
|
24
|
-
id: string;
|
|
25
|
-
/** Position among the board's children, used when nothing else decides. */
|
|
26
|
-
order: number;
|
|
27
|
-
alarm: BoardAlarm;
|
|
28
|
-
/** Pinned by the viewer. Always first, and never moved by the board. */
|
|
29
|
-
pinned: boolean;
|
|
30
|
-
severity: NormalSeverity | null;
|
|
31
|
-
reason: string | null;
|
|
32
|
-
why: string | null;
|
|
33
|
-
since: string | null;
|
|
34
|
-
sinceAt: number | null;
|
|
35
|
-
score: number;
|
|
36
|
-
/** Wall-clock times, in milliseconds. */
|
|
37
|
-
raisedAt: number | null;
|
|
38
|
-
acknowledgedAt: number | null;
|
|
39
|
-
clearedAt: number | null;
|
|
40
|
-
}
|
|
41
|
-
export type BoardAction = {
|
|
42
|
-
type: 'register';
|
|
43
|
-
id: string;
|
|
44
|
-
order: number;
|
|
45
|
-
} | {
|
|
46
|
-
type: 'unregister';
|
|
47
|
-
id: string;
|
|
48
|
-
} | {
|
|
49
|
-
type: 'report';
|
|
50
|
-
id: string;
|
|
51
|
-
report: NormalReport | null;
|
|
52
|
-
now: number;
|
|
53
|
-
} | {
|
|
54
|
-
type: 'acknowledge';
|
|
55
|
-
id: string;
|
|
56
|
-
now: number;
|
|
57
|
-
} | {
|
|
58
|
-
type: 'pin';
|
|
59
|
-
id: string;
|
|
60
|
-
pinned: boolean;
|
|
61
|
-
} | {
|
|
62
|
-
type: 'settle';
|
|
63
|
-
id: string;
|
|
64
|
-
};
|
|
65
|
-
export type BoardState = Readonly<Record<string, BoardItemState>>;
|
|
66
|
-
export declare function boardReducer(state: BoardState, action: BoardAction): BoardState;
|
|
67
|
-
/**
|
|
68
|
-
* The order to show items in: the viewer's pins, then what needs attention (critical first, then
|
|
69
|
-
* whatever has been wrong longest), then what has been seen, then what just cleared, then the
|
|
70
|
-
* rest in their written order.
|
|
71
|
-
*/
|
|
72
|
-
export declare function rankBoard(state: BoardState): string[];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { NormalSeverity } from '../engine/normal';
|
|
3
|
-
/** One item waiting in the toast. */
|
|
4
|
-
export interface BoardAlert {
|
|
5
|
-
id: string;
|
|
6
|
-
title: string;
|
|
7
|
-
reason: string | null;
|
|
8
|
-
severity: NormalSeverity;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A small glass toast for items that turned unusual off screen. One item names itself and its
|
|
12
|
-
* reason; several group into a count. View takes the viewer to the most urgent one.
|
|
13
|
-
*/
|
|
14
|
-
export declare function BoardToast({ alerts, reducedMotion, onView, onDismiss, }: {
|
|
15
|
-
alerts: readonly BoardAlert[];
|
|
16
|
-
reducedMotion: boolean;
|
|
17
|
-
onView: () => void;
|
|
18
|
-
onDismiss: () => void;
|
|
19
|
-
}): ReactElement | null;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { ChartMotion } from '../../types';
|
|
3
|
-
import { BoardItemState } from './board-state';
|
|
4
|
-
export interface BoardItemProps {
|
|
5
|
-
/** Stable and unique within the board. */
|
|
6
|
-
id: string;
|
|
7
|
-
/** Names the item in announcements and controls, e.g. "Orders". */
|
|
8
|
-
title: string;
|
|
9
|
-
/** Grid columns to span. Defaults to 1. */
|
|
10
|
-
span?: 1 | 2;
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* One chart on a board. A watched chart inside it reports its own status; the board ranks,
|
|
15
|
-
* pins, and announces it.
|
|
16
|
-
*/
|
|
17
|
-
export declare function BoardItem({ children }: BoardItemProps): ReactElement;
|
|
18
|
-
/** Something that happened to an item, for your own alerts. */
|
|
19
|
-
export interface BoardEvent {
|
|
20
|
-
type: 'raised' | 'escalated' | 'acknowledged' | 'cleared';
|
|
21
|
-
id: string;
|
|
22
|
-
title: string;
|
|
23
|
-
item: BoardItemState;
|
|
24
|
-
/** Scroll the item into view, focus it, and highlight it briefly. */
|
|
25
|
-
show: () => void;
|
|
26
|
-
}
|
|
27
|
-
/** Where a board remembers what you last saw. Defaults to `localStorage`. */
|
|
28
|
-
export interface BoardStorage {
|
|
29
|
-
get: (key: string) => string | null;
|
|
30
|
-
set: (key: string, value: string) => void;
|
|
31
|
-
}
|
|
32
|
-
export interface ChartBoardProps {
|
|
33
|
-
/** `BoardItem`s, in the order they sit while everything is normal. */
|
|
34
|
-
children?: ReactNode;
|
|
35
|
-
'aria-label': string;
|
|
36
|
-
/** How long a cleared item stays in place before settling back, in milliseconds. Defaults to 8000. */
|
|
37
|
-
settleAfter?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Remember which incidents you have seen under this name, and mark new ones "New since you
|
|
40
|
-
* last looked". Off unless set.
|
|
41
|
-
*/
|
|
42
|
-
memory?: string;
|
|
43
|
-
storage?: BoardStorage;
|
|
44
|
-
/** Called when an item is raised, escalates, is acknowledged, or clears. */
|
|
45
|
-
onEvent?: (event: BoardEvent) => void;
|
|
46
|
-
/**
|
|
47
|
-
* Show a small toast when an item needs attention while it is off screen, with View to go
|
|
48
|
-
* there, and count alerts in the page title while the tab is in the background. Off unless
|
|
49
|
-
* set; `onEvent` and its `show` build your own.
|
|
50
|
-
*/
|
|
51
|
-
toast?: boolean;
|
|
52
|
-
/** Offer "Order changed · Show" while a new order waits. Defaults to true. */
|
|
53
|
-
toolbar?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Give each card the board's tab, edge tone, and pin. Defaults to true; turn off to build your
|
|
56
|
-
* own with `useBoardItem` and `CardFrameContext`.
|
|
57
|
-
*/
|
|
58
|
-
status?: boolean;
|
|
59
|
-
/** `none` turns off reordering motion; reduced-motion users get this automatically. */
|
|
60
|
-
motion?: ChartMotion;
|
|
61
|
-
className?: string;
|
|
62
|
-
style?: CSSProperties;
|
|
63
|
-
}
|
|
64
|
-
/** The whole board's state, for a custom summary or controls. */
|
|
65
|
-
export declare function useBoard(): {
|
|
66
|
-
items: BoardItemState[];
|
|
67
|
-
attention: BoardItemState[];
|
|
68
|
-
fresh: BoardItemState[];
|
|
69
|
-
pending: boolean;
|
|
70
|
-
apply: () => void;
|
|
71
|
-
acknowledge: (id: string) => void;
|
|
72
|
-
pin: (id: string, pinned: boolean) => void;
|
|
73
|
-
};
|
|
74
|
-
/** The enclosing item's state and actions, for a custom tab. */
|
|
75
|
-
export declare function useBoardItem(): {
|
|
76
|
-
item: BoardItemState;
|
|
77
|
-
title: string;
|
|
78
|
-
fresh: boolean;
|
|
79
|
-
acknowledge: () => void;
|
|
80
|
-
pin: (pinned: boolean) => void;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* The default tab for an item's card: what is going on, how new it is, and quiet actions to
|
|
84
|
-
* acknowledge it or keep it pinned.
|
|
85
|
-
*/
|
|
86
|
-
export declare function BoardItemTab(): ReactElement;
|
|
87
|
-
/**
|
|
88
|
-
* The default bar over the board. It appears only while a new order is waiting for the viewer
|
|
89
|
-
* to finish reading; `useBoard` builds a summary of your own.
|
|
90
|
-
*/
|
|
91
|
-
export declare function BoardToolbar(): ReactElement | null;
|
|
92
|
-
/** ChartBoard with its own MotionScope, so it animates wherever it is rendered. */
|
|
93
|
-
export declare function ChartBoard(props: ChartBoardProps): ReactElement;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NormalFlag } from './normal';
|
|
2
|
-
export interface DescribeFlagOptions {
|
|
3
|
-
/** Formats bounds in the series' unit. Defaults to plain numbers. */
|
|
4
|
-
formatValue?: (value: number) => string;
|
|
5
|
-
/** Names the `around` series, e.g. "target". Defaults to "reference". */
|
|
6
|
-
aroundLabel?: string;
|
|
7
|
-
}
|
|
8
|
-
/** A short sentence for a flag, such as "Above max 2%" or "Unusually low". */
|
|
9
|
-
export declare function describeFlag(flag: NormalFlag, { formatValue, aroundLabel }?: DescribeFlagOptions): string;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { NormalPoint } from './normal';
|
|
2
|
-
export interface DeviationPart {
|
|
3
|
-
segment: string;
|
|
4
|
-
actual: number;
|
|
5
|
-
expected: number;
|
|
6
|
-
/** `actual - expected` for this segment. */
|
|
7
|
-
delta: number;
|
|
8
|
-
/** This segment's part of the total difference. Offsetting segments are negative. */
|
|
9
|
-
share: number;
|
|
10
|
-
}
|
|
11
|
-
export interface DeviationExplanation {
|
|
12
|
-
actual: number;
|
|
13
|
-
expected: number;
|
|
14
|
-
delta: number;
|
|
15
|
-
/** Largest contributor first, in the direction of the total difference. */
|
|
16
|
-
parts: readonly DeviationPart[];
|
|
17
|
-
/** Segments without both readings. They are left out rather than counted as zero. */
|
|
18
|
-
missing: readonly string[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Split a difference from normal into the segments that caused it, such as regions or
|
|
22
|
-
* devices: "87% of the drop is EU".
|
|
23
|
-
*/
|
|
24
|
-
export declare function explainDeviation(actual: Readonly<Record<string, number | null | undefined>>, expected: Readonly<Record<string, number | null | undefined>>): DeviationExplanation;
|
|
25
|
-
/** Splits one row into the segments that add up to the watched value, such as orders by device. */
|
|
26
|
-
export type NormalBreakdown<Row> = (row: Row) => Readonly<Record<string, number | null | undefined>>;
|
|
27
|
-
export interface ExplainReadingsOptions<Row> {
|
|
28
|
-
/** The rows `points` were evaluated on. */
|
|
29
|
-
data: readonly Row[];
|
|
30
|
-
points: readonly NormalPoint[];
|
|
31
|
-
/** Row indices to explain, such as one unusual stretch. */
|
|
32
|
-
indices: readonly number[];
|
|
33
|
-
breakdown: NormalBreakdown<Row>;
|
|
34
|
-
/** Normal readings to compare with when a row has no learned basis. Defaults to 6. */
|
|
35
|
-
fallback?: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Explain unusual readings by segment. Each segment is compared with the same earlier rows the
|
|
39
|
-
* learned normal came from, so "usual for this segment" means the same hour on the same weekday;
|
|
40
|
-
* without a learned normal, with the latest normal readings before the stretch.
|
|
41
|
-
*/
|
|
42
|
-
export declare function explainReadings<Row>({ data, points, indices, breakdown, fallback, }: ExplainReadingsOptions<Row>): DeviationExplanation | null;
|
|
43
|
-
export interface DescribeExplanationOptions {
|
|
44
|
-
/** Share of the difference one segment needs to be named alone. Defaults to 0.5. */
|
|
45
|
-
lead?: number;
|
|
46
|
-
}
|
|
47
|
-
/** A short sentence, such as "91% of the drop is Mobile Safari". `null` when nothing stands out. */
|
|
48
|
-
export declare function describeExplanation(explanation: DeviationExplanation | null, { lead }?: DescribeExplanationOptions): string | null;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { NumericKey } from '../../cards/keys';
|
|
2
|
-
export type NormalSeverity = 'warning' | 'critical';
|
|
3
|
-
/** Which layer raised a flag, so explanations can say why a value is unusual. */
|
|
4
|
-
export type NormalSource = 'limit' | 'around' | 'learned' | 'rule';
|
|
5
|
-
/** An absolute distance in the series unit, or a share of the reference such as `'10%'`. */
|
|
6
|
-
export type NormalTolerance = number | `${number}%`;
|
|
7
|
-
export interface NormalLimits {
|
|
8
|
-
min?: number;
|
|
9
|
-
max?: number;
|
|
10
|
-
/** Defaults to `'critical'`: a declared limit is the strongest signal. */
|
|
11
|
-
severity?: NormalSeverity;
|
|
12
|
-
}
|
|
13
|
-
export type NormalPeriod = 'week' | 'day' | 'all';
|
|
14
|
-
export interface NormalLearnOptions {
|
|
15
|
-
/**
|
|
16
|
-
* `'week'` compares with the same time on the same weekday, `'day'` with the same time of day,
|
|
17
|
-
* and `'all'` with every earlier value.
|
|
18
|
-
*/
|
|
19
|
-
period: NormalPeriod;
|
|
20
|
-
/** Band half-width in robust standard deviations. Defaults to 3. */
|
|
21
|
-
width?: number;
|
|
22
|
-
/** Earlier samples kept per time slot. Defaults to 8. */
|
|
23
|
-
history?: number;
|
|
24
|
-
/** Samples needed before a slot has a learned normal. Defaults to 3. */
|
|
25
|
-
minSamples?: number;
|
|
26
|
-
/** Time slot size. Defaults to the typical spacing of the data, capped at one day. */
|
|
27
|
-
slotMinutes?: number;
|
|
28
|
-
/** Offset from UTC used to find the weekday and time of day. Defaults to 0. */
|
|
29
|
-
utcOffsetMinutes?: number;
|
|
30
|
-
/** Defaults to `'warning'`. */
|
|
31
|
-
severity?: NormalSeverity;
|
|
32
|
-
}
|
|
33
|
-
export interface NormalGiven<Row> {
|
|
34
|
-
key: NumericKey<Row>;
|
|
35
|
-
/** Width of each condition bin. Defaults to an eighth of the observed range. */
|
|
36
|
-
step?: number;
|
|
37
|
-
}
|
|
38
|
-
export interface NormalRuleContext<Row> {
|
|
39
|
-
index: number;
|
|
40
|
-
rows: readonly Row[];
|
|
41
|
-
/** The watched value at this row. `null` is missing. */
|
|
42
|
-
value: number | null;
|
|
43
|
-
/** Every watched value, in row order. */
|
|
44
|
-
values: readonly (number | null)[];
|
|
45
|
-
}
|
|
46
|
-
export type NormalRuleTest<Row> = (row: Row, context: NormalRuleContext<Row>) => boolean;
|
|
47
|
-
export interface NormalRuleConfig<Row> {
|
|
48
|
-
test: NormalRuleTest<Row>;
|
|
49
|
-
/** Defaults to `'critical'`. */
|
|
50
|
-
severity?: NormalSeverity;
|
|
51
|
-
/** A short sentence shown when the rule fires. Defaults to the rule name. */
|
|
52
|
-
message?: string;
|
|
53
|
-
}
|
|
54
|
-
export type NormalRule<Row> = NormalRuleTest<Row> | NormalRuleConfig<Row>;
|
|
55
|
-
/**
|
|
56
|
-
* What counts as normal for one series. Every layer is off unless you set it; an empty spec
|
|
57
|
-
* judges nothing.
|
|
58
|
-
*/
|
|
59
|
-
export interface NormalSpec<Row> {
|
|
60
|
-
limits?: NormalLimits;
|
|
61
|
-
/** Normal is close to another series, such as a target or setpoint. */
|
|
62
|
-
around?: NumericKey<Row>;
|
|
63
|
-
/** Distance from `around` that is still normal. Required with `around`. */
|
|
64
|
-
tolerance?: NormalTolerance;
|
|
65
|
-
/** Defaults to `'warning'`. */
|
|
66
|
-
aroundSeverity?: NormalSeverity;
|
|
67
|
-
/** Learn normal from the series' own history. Off unless set. */
|
|
68
|
-
learn?: NormalPeriod | NormalLearnOptions;
|
|
69
|
-
/** Compare only with earlier values taken under similar conditions. Needs `learn`. */
|
|
70
|
-
given?: NumericKey<Row> | NormalGiven<Row>;
|
|
71
|
-
/** Judge only rows where this returns true. Other rows are skipped and never learned from. */
|
|
72
|
-
when?: (row: Row, index: number) => boolean;
|
|
73
|
-
rules?: Record<string, NormalRule<Row>>;
|
|
74
|
-
}
|
|
75
|
-
export interface NormalFlag {
|
|
76
|
-
source: NormalSource;
|
|
77
|
-
/** `'min'`, `'max'`, `'around'`, `'learned'`, or the rule name. */
|
|
78
|
-
id: string;
|
|
79
|
-
severity: NormalSeverity;
|
|
80
|
-
direction?: 'above' | 'below';
|
|
81
|
-
/** The edge that was crossed. */
|
|
82
|
-
bound?: number;
|
|
83
|
-
message?: string;
|
|
84
|
-
/** How far past normal, where 1 is just outside. Used to rank. */
|
|
85
|
-
score: number;
|
|
86
|
-
}
|
|
87
|
-
export interface NormalPoint {
|
|
88
|
-
index: number;
|
|
89
|
-
value: number | null;
|
|
90
|
-
/** False where `when` skipped the row. */
|
|
91
|
-
judged: boolean;
|
|
92
|
-
/** The learned median, or the `around` value. */
|
|
93
|
-
expected: number | null;
|
|
94
|
-
/** The normal band to draw: every declared and learned layer combined. */
|
|
95
|
-
lower: number | null;
|
|
96
|
-
upper: number | null;
|
|
97
|
-
flags: readonly NormalFlag[];
|
|
98
|
-
severity: NormalSeverity | null;
|
|
99
|
-
score: number;
|
|
100
|
-
/**
|
|
101
|
-
* The earlier rows the learned normal came from, such as the same hour in previous weeks.
|
|
102
|
-
* Explanations compare each segment with these same rows. `null` without a learned normal.
|
|
103
|
-
*/
|
|
104
|
-
basis: readonly number[] | null;
|
|
105
|
-
}
|
|
106
|
-
export interface EvaluateNormalOptions<Row> {
|
|
107
|
-
data: readonly Row[];
|
|
108
|
-
/** The x key. Learning by `'week'` or `'day'` needs dates or epoch milliseconds. */
|
|
109
|
-
x: string;
|
|
110
|
-
value: NumericKey<Row>;
|
|
111
|
-
normal: NormalSpec<Row>;
|
|
112
|
-
}
|
|
113
|
-
/** Judge each row against the layers switched on in `normal`. Learning only uses earlier rows. */
|
|
114
|
-
export declare function evaluateNormal<Row>({ data, x, value, normal, }: EvaluateNormalOptions<Row>): NormalPoint[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Median of finite values. Returns null for an empty list. */
|
|
2
|
-
export declare function median(values: readonly number[]): number | null;
|
|
3
|
-
/**
|
|
4
|
-
* Median absolute deviation, scaled so it estimates a standard deviation for normal data.
|
|
5
|
-
* A few extreme values barely move it, so past incidents do not widen the learned band.
|
|
6
|
-
*/
|
|
7
|
-
export declare function robustScale(values: readonly number[], center: number): number;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { NormalRuleConfig, NormalSeverity } from './normal';
|
|
2
|
-
export interface FlatlineOptions {
|
|
3
|
-
/** Identical readings in a row before the series counts as stuck. Defaults to 6. */
|
|
4
|
-
points?: number;
|
|
5
|
-
severity?: NormalSeverity;
|
|
6
|
-
message?: string;
|
|
7
|
-
}
|
|
8
|
-
/** Flags a reading that has not changed for `points` readings, such as a stuck sensor. */
|
|
9
|
-
export declare function flatline<Row>({ points, severity, message, }?: FlatlineOptions): NormalRuleConfig<Row>;
|
|
10
|
-
export interface JumpOptions {
|
|
11
|
-
/** Relative change from the previous reading, such as 0.5 for 50%. */
|
|
12
|
-
by: number;
|
|
13
|
-
/** Defaults to `'both'`. */
|
|
14
|
-
direction?: 'up' | 'down' | 'both';
|
|
15
|
-
severity?: NormalSeverity;
|
|
16
|
-
message?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Flags a sudden relative change from the previous known reading. Gaps are skipped, and a
|
|
20
|
-
* previous reading of zero has no relative change, so it never fires.
|
|
21
|
-
*/
|
|
22
|
-
export declare function jump<Row>({ by, direction, severity, message, }: JumpOptions): NormalRuleConfig<Row>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { NormalFlag, NormalPoint, NormalSeverity } from './normal';
|
|
2
|
-
export interface NormalStatusOptions {
|
|
3
|
-
/** Flagged readings in a row before the series becomes active. Defaults to 2. */
|
|
4
|
-
enter?: number;
|
|
5
|
-
/** Normal readings in a row before an active series clears. Defaults to 3. */
|
|
6
|
-
exit?: number;
|
|
7
|
-
}
|
|
8
|
-
export type NormalStatusEvent = {
|
|
9
|
-
type: 'activated';
|
|
10
|
-
index: number;
|
|
11
|
-
severity: NormalSeverity;
|
|
12
|
-
flags: readonly NormalFlag[];
|
|
13
|
-
} | {
|
|
14
|
-
type: 'escalated';
|
|
15
|
-
index: number;
|
|
16
|
-
severity: 'critical';
|
|
17
|
-
flags: readonly NormalFlag[];
|
|
18
|
-
} | {
|
|
19
|
-
type: 'cleared';
|
|
20
|
-
index: number;
|
|
21
|
-
};
|
|
22
|
-
export interface NormalStatus {
|
|
23
|
-
active: boolean;
|
|
24
|
-
/** The strongest severity since the series became active. */
|
|
25
|
-
severity: NormalSeverity | null;
|
|
26
|
-
/** Row index where the current incident started. */
|
|
27
|
-
since: number | null;
|
|
28
|
-
/** Flags on the latest flagged reading of the current incident. */
|
|
29
|
-
flags: readonly NormalFlag[];
|
|
30
|
-
/** The largest score in the current incident. */
|
|
31
|
-
score: number;
|
|
32
|
-
events: readonly NormalStatusEvent[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Turn per-reading flags into a steady incident state. A series must stay unusual for `enter`
|
|
36
|
-
* readings to activate and normal for `exit` readings to clear, so a value sitting on an edge
|
|
37
|
-
* does not flicker. Skipped rows and missing readings hold the current state.
|
|
38
|
-
*/
|
|
39
|
-
export declare function trackNormalStatus(points: readonly NormalPoint[], { enter, exit }?: NormalStatusOptions): NormalStatus;
|
package/dist/watch/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { evaluateNormal } from './engine/normal';
|
|
2
|
-
export type { EvaluateNormalOptions, NormalFlag, NormalGiven, NormalLearnOptions, NormalLimits, NormalPeriod, NormalPoint, NormalRule, NormalRuleConfig, NormalRuleContext, NormalRuleTest, NormalSeverity, NormalSource, NormalSpec, NormalTolerance, } from './engine/normal';
|
|
3
|
-
export { flatline, jump } from './engine/rules';
|
|
4
|
-
export type { FlatlineOptions, JumpOptions } from './engine/rules';
|
|
5
|
-
export { trackNormalStatus } from './engine/status';
|
|
6
|
-
export type { NormalStatus, NormalStatusEvent, NormalStatusOptions } from './engine/status';
|
|
7
|
-
export { describeFlag } from './engine/describe';
|
|
8
|
-
export type { DescribeFlagOptions } from './engine/describe';
|
|
9
|
-
export { describeExplanation, explainDeviation, explainReadings } from './engine/explain';
|
|
10
|
-
export type { DescribeExplanationOptions, DeviationExplanation, DeviationPart, ExplainReadingsOptions, NormalBreakdown, } from './engine/explain';
|
|
11
|
-
export { BoardItem, BoardItemTab, BoardToolbar, ChartBoard, useBoard, useBoardItem, } from './board/chart-board';
|
|
12
|
-
export type { BoardEvent, BoardItemProps, BoardStorage, ChartBoardProps, } from './board/chart-board';
|
|
13
|
-
export { boardReducer, rankBoard } from './board/board-state';
|
|
14
|
-
export type { BoardAction, BoardAlarm, BoardItemState, BoardState, NormalReport, } from './board/board-state';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { NormalSeverity } from './engine/normal';
|
|
3
|
-
/** Field IDs a watched series carries for its normal band. */
|
|
4
|
-
export declare const NORMAL_LOWER = "normalLower";
|
|
5
|
-
export declare const NORMAL_UPPER = "normalUpper";
|
|
6
|
-
export interface NormalLayerProps {
|
|
7
|
-
series: string;
|
|
8
|
-
/** Severity of each unusual reading, by row index in the card's data. */
|
|
9
|
-
flagged: ReadonlyMap<number, NormalSeverity>;
|
|
10
|
-
/** The band sits under the series' line; the unusual stretches sit over it. */
|
|
11
|
-
part: 'band' | 'flags';
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The calm band where a series is expected to be, and the series' own line recolored where it
|
|
15
|
-
* is unusual, with a dot where each unusual stretch ends. The band reads from the series'
|
|
16
|
-
* normal fields and breaks wherever either edge is unknown.
|
|
17
|
-
*/
|
|
18
|
-
export declare function NormalLayer({ series, flagged, part }: NormalLayerProps): ReactElement;
|
package/dist/watch.d.ts
DELETED