athena-ui-js 2.2.0 → 2.3.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 +45 -3
- package/docs/styling.md +1 -1
- package/package.json +5 -1
- package/src/athena-ui.js +3 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/gridLayout.js +102 -0
- package/src/libs/core/i18n.js +32 -0
- package/src/res/themes/default/style.css +185 -0
- package/src/widgets.js +7 -0
- package/types/athena-ui.d.ts +2 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/gridLayout.d.ts +45 -0
- package/types/libs/core/motion.d.ts +123 -123
- package/types/libs/core/theme.d.ts +41 -41
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +95 -95
- package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -238
- package/types/libs/hephaestus/router/router.d.ts +71 -71
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +123 -123
- package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -0
- package/types/motion.d.ts +1 -1
- package/types/widgets.d.ts +2 -0
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
/** Does the person want less motion? The choice made with setMotion wins over the setting of the system. */
|
|
2
|
-
export function prefersReducedMotion(): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* Chooses how much motion there is: "system", "reduce" (none) or "full". It is put on <html> as data-motion, which the CSS tokens read (the durations
|
|
5
|
-
* become 0), and the functions of this module read it too.
|
|
6
|
-
*/
|
|
7
|
-
export function setMotion(value: any): boolean;
|
|
8
|
-
/** Called with { preference, reduced } when setMotion changes it, and when the system setting changes. Returns a function that stops it. */
|
|
9
|
-
export function onMotionChange(listener: any): () => boolean;
|
|
10
|
-
/** A duration token as milliseconds: readDuration("--athena-duration-base") -> 200. 0 under reduced motion. */
|
|
11
|
-
export function readDuration(token?: string, element?: HTMLElement): number;
|
|
12
|
-
/** How long an element takes to finish its CSS transitions, delays included, in ms (0 when it has none, or under reduced motion). */
|
|
13
|
-
export function transitionTime(element: any): number;
|
|
14
|
-
/** Removes an element when its exit transition is over (at once when it has none, which is also what reduced motion gives). */
|
|
15
|
-
export function removeAfterTransition(element: any): void;
|
|
16
|
-
/**
|
|
17
|
-
* A spring as a CSS easing: simulates a damped spring and returns the points as a `linear()` easing (which can overshoot) and how long it takes.
|
|
18
|
-
* `element.animate(keyframes, { duration, easing })` then moves like a spring. Settles when it stays within `precision` of 1.
|
|
19
|
-
*
|
|
20
|
-
* @param {{stiffness?: number, damping?: number, mass?: number, precision?: number}} [options]
|
|
21
|
-
* @returns {{easing: string, duration: number}} duration in ms
|
|
22
|
-
*/
|
|
23
|
-
export function spring({ stiffness, damping, mass, precision }?: {
|
|
24
|
-
stiffness?: number;
|
|
25
|
-
damping?: number;
|
|
26
|
-
mass?: number;
|
|
27
|
-
precision?: number;
|
|
28
|
-
}): {
|
|
29
|
-
easing: string;
|
|
30
|
-
duration: number;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Animates an element with the Web Animations API and resolves when it is over. Under reduced motion it does nothing and resolves at once.
|
|
34
|
-
* It resolves (never rejects) when the animation is cancelled, and `null` when there was none.
|
|
35
|
-
*
|
|
36
|
-
* @param {Element} element
|
|
37
|
-
* @param {Keyframe[]|PropertyIndexedKeyframes} keyframes e.g. [{ opacity: 0 }, { opacity: 1 }]
|
|
38
|
-
* @param {object} [options] the options of element.animate (duration, easing, delay, fill, ...), and
|
|
39
|
-
* @param {boolean} [options.commit=false] write the end state to the element's style when it is over (CSSOM: allowed by a strict policy)
|
|
40
|
-
* @param {AbortSignal} [options.signal] cancels the animation when aborted
|
|
41
|
-
* @returns {Promise<Animation|null>}
|
|
42
|
-
*/
|
|
43
|
-
export function animate(element: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: {
|
|
44
|
-
commit?: boolean;
|
|
45
|
-
signal?: AbortSignal;
|
|
46
|
-
}): Promise<Animation | null>;
|
|
47
|
-
/** Fades an element out and removes it. Under reduced motion it is removed at once. */
|
|
48
|
-
export function fadeOut(element: any, options: any): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* A change that is done with CSS (a class, an attribute) and has a CSS transition: runs `change()` and resolves when the element's transition is over.
|
|
51
|
-
* It waits at most the length of the transition (plus a little), so a transition that never ends does not hang anything.
|
|
52
|
-
*/
|
|
53
|
-
export function transition(element: any, change: any): Promise<any>;
|
|
54
|
-
/** Runs the functions one after the other, each when the one before is over. Resolves with their results. */
|
|
55
|
-
export function sequence(steps: any): Promise<any[]>;
|
|
56
|
-
/**
|
|
57
|
-
* The delays of a staggered animation: `count` items, `step` ms apart, starting from "start", "end" or "center".
|
|
58
|
-
* @returns {number[]}
|
|
59
|
-
*/
|
|
60
|
-
export function staggerDelays(count: any, step?: number, from?: string): number[];
|
|
61
|
-
/**
|
|
62
|
-
* Calls `run(item, index, delay)` for every item with its delay, and resolves when all are over: `stagger(rows, (row, i, delay) => fadeIn(row, { delay }))`.
|
|
63
|
-
* No more than `limit` items are staggered (the rest run with the last delay), so a long list does not take long.
|
|
64
|
-
*/
|
|
65
|
-
export function stagger(items: any, run: any, { step, from, limit }?: {
|
|
66
|
-
step?: number;
|
|
67
|
-
from?: string;
|
|
68
|
-
limit?: number;
|
|
69
|
-
}): Promise<any[]>;
|
|
70
|
-
/**
|
|
71
|
-
* Lets the children of a container move smoothly when `change()` rearranges them (sorting, filtering, inserting, removing): First (measure), Last (do the change,
|
|
72
|
-
* measure), Invert and Play (each child that moved starts at its old place and slides to the new one). New children fade in. Under reduced motion `change()` is
|
|
73
|
-
* just done.
|
|
74
|
-
*
|
|
75
|
-
* @param {Element} container its children are what moves
|
|
76
|
-
* @param {() => void} change rearranges the children (synchronously)
|
|
77
|
-
* @param {object} [options]
|
|
78
|
-
* @param {(element: Element) => *} [options.key] what makes a child "the same" before and after, default: the element itself
|
|
79
|
-
* @param {number} [options.limit=60] at most this many children are animated (a long list does not need it, and costs time)
|
|
80
|
-
* @param {number} [options.duration] ms, default the token --athena-duration-base
|
|
81
|
-
* @returns {Promise<void>} resolves when the animations are over
|
|
82
|
-
*/
|
|
83
|
-
export function flip(container: Element, change: () => void, { key, limit, duration }?: {
|
|
84
|
-
key?: (element: Element) => any;
|
|
85
|
-
limit?: number;
|
|
86
|
-
duration?: number;
|
|
87
|
-
}): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Changes numbers over time with requestAnimationFrame: tween({ from: 0, to: 100, duration: 500, easing: easings.easeOutCubic, onUpdate: v => ... }).
|
|
90
|
-
* `from` and `to` can be numbers, or objects with the same keys ({ x: 0, y: 0 } to { x: 10, y: 5 }); onUpdate then gets an object.
|
|
91
|
-
* Under reduced motion it jumps to the end (one onUpdate call). It runs on animation frames; in a page that is not drawn a timer keeps it going slowly, so it still ends.
|
|
92
|
-
*
|
|
93
|
-
* @returns {Promise<void> & {cancel: () => void}} resolves when it is over (also when cancelled)
|
|
94
|
-
*/
|
|
95
|
-
export function tween({ from, to, duration, easing, onUpdate, delay }?: {
|
|
96
|
-
from?: number;
|
|
97
|
-
to?: number;
|
|
98
|
-
duration?: number;
|
|
99
|
-
easing?: (t: any) => number;
|
|
100
|
-
delay?: number;
|
|
101
|
-
}): Promise<void> & {
|
|
102
|
-
cancel: () => void;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Runs `update()` (which changes the DOM) as a view transition when the browser can and motion is wanted: the old and the new state cross-fade
|
|
106
|
-
* (or whatever the CSS ::view-transition-* rules say). Elements with a `view-transition-name` move from one place to the other. Without the API,
|
|
107
|
-
* or under reduced motion, `update()` is just run. Resolves when it is over.
|
|
108
|
-
*/
|
|
109
|
-
export function viewTransition(update: any): Promise<void>;
|
|
110
|
-
export function getMotion(): "reduce" | "full" | "system";
|
|
111
|
-
export namespace easings {
|
|
112
|
-
function linear(t: any): any;
|
|
113
|
-
function easeInQuad(t: any): number;
|
|
114
|
-
function easeOutQuad(t: any): number;
|
|
115
|
-
function easeInOutQuad(t: any): number;
|
|
116
|
-
function easeInCubic(t: any): number;
|
|
117
|
-
function easeOutCubic(t: any): number;
|
|
118
|
-
function easeInOutCubic(t: any): number;
|
|
119
|
-
function easeOutBack(t: any): number;
|
|
120
|
-
function easeOutElastic(t: any): any;
|
|
121
|
-
}
|
|
122
|
-
export function fadeIn(element: any, options: any): Promise<Animation>;
|
|
123
|
-
export function parallel(steps: any): Promise<any[]>;
|
|
1
|
+
/** Does the person want less motion? The choice made with setMotion wins over the setting of the system. */
|
|
2
|
+
export function prefersReducedMotion(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Chooses how much motion there is: "system", "reduce" (none) or "full". It is put on <html> as data-motion, which the CSS tokens read (the durations
|
|
5
|
+
* become 0), and the functions of this module read it too.
|
|
6
|
+
*/
|
|
7
|
+
export function setMotion(value: any): boolean;
|
|
8
|
+
/** Called with { preference, reduced } when setMotion changes it, and when the system setting changes. Returns a function that stops it. */
|
|
9
|
+
export function onMotionChange(listener: any): () => boolean;
|
|
10
|
+
/** A duration token as milliseconds: readDuration("--athena-duration-base") -> 200. 0 under reduced motion. */
|
|
11
|
+
export function readDuration(token?: string, element?: HTMLElement): number;
|
|
12
|
+
/** How long an element takes to finish its CSS transitions, delays included, in ms (0 when it has none, or under reduced motion). */
|
|
13
|
+
export function transitionTime(element: any): number;
|
|
14
|
+
/** Removes an element when its exit transition is over (at once when it has none, which is also what reduced motion gives). */
|
|
15
|
+
export function removeAfterTransition(element: any): void;
|
|
16
|
+
/**
|
|
17
|
+
* A spring as a CSS easing: simulates a damped spring and returns the points as a `linear()` easing (which can overshoot) and how long it takes.
|
|
18
|
+
* `element.animate(keyframes, { duration, easing })` then moves like a spring. Settles when it stays within `precision` of 1.
|
|
19
|
+
*
|
|
20
|
+
* @param {{stiffness?: number, damping?: number, mass?: number, precision?: number}} [options]
|
|
21
|
+
* @returns {{easing: string, duration: number}} duration in ms
|
|
22
|
+
*/
|
|
23
|
+
export function spring({ stiffness, damping, mass, precision }?: {
|
|
24
|
+
stiffness?: number;
|
|
25
|
+
damping?: number;
|
|
26
|
+
mass?: number;
|
|
27
|
+
precision?: number;
|
|
28
|
+
}): {
|
|
29
|
+
easing: string;
|
|
30
|
+
duration: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Animates an element with the Web Animations API and resolves when it is over. Under reduced motion it does nothing and resolves at once.
|
|
34
|
+
* It resolves (never rejects) when the animation is cancelled, and `null` when there was none.
|
|
35
|
+
*
|
|
36
|
+
* @param {Element} element
|
|
37
|
+
* @param {Keyframe[]|PropertyIndexedKeyframes} keyframes e.g. [{ opacity: 0 }, { opacity: 1 }]
|
|
38
|
+
* @param {object} [options] the options of element.animate (duration, easing, delay, fill, ...), and
|
|
39
|
+
* @param {boolean} [options.commit=false] write the end state to the element's style when it is over (CSSOM: allowed by a strict policy)
|
|
40
|
+
* @param {AbortSignal} [options.signal] cancels the animation when aborted
|
|
41
|
+
* @returns {Promise<Animation|null>}
|
|
42
|
+
*/
|
|
43
|
+
export function animate(element: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: {
|
|
44
|
+
commit?: boolean;
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): Promise<Animation | null>;
|
|
47
|
+
/** Fades an element out and removes it. Under reduced motion it is removed at once. */
|
|
48
|
+
export function fadeOut(element: any, options: any): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* A change that is done with CSS (a class, an attribute) and has a CSS transition: runs `change()` and resolves when the element's transition is over.
|
|
51
|
+
* It waits at most the length of the transition (plus a little), so a transition that never ends does not hang anything.
|
|
52
|
+
*/
|
|
53
|
+
export function transition(element: any, change: any): Promise<any>;
|
|
54
|
+
/** Runs the functions one after the other, each when the one before is over. Resolves with their results. */
|
|
55
|
+
export function sequence(steps: any): Promise<any[]>;
|
|
56
|
+
/**
|
|
57
|
+
* The delays of a staggered animation: `count` items, `step` ms apart, starting from "start", "end" or "center".
|
|
58
|
+
* @returns {number[]}
|
|
59
|
+
*/
|
|
60
|
+
export function staggerDelays(count: any, step?: number, from?: string): number[];
|
|
61
|
+
/**
|
|
62
|
+
* Calls `run(item, index, delay)` for every item with its delay, and resolves when all are over: `stagger(rows, (row, i, delay) => fadeIn(row, { delay }))`.
|
|
63
|
+
* No more than `limit` items are staggered (the rest run with the last delay), so a long list does not take long.
|
|
64
|
+
*/
|
|
65
|
+
export function stagger(items: any, run: any, { step, from, limit }?: {
|
|
66
|
+
step?: number;
|
|
67
|
+
from?: string;
|
|
68
|
+
limit?: number;
|
|
69
|
+
}): Promise<any[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Lets the children of a container move smoothly when `change()` rearranges them (sorting, filtering, inserting, removing): First (measure), Last (do the change,
|
|
72
|
+
* measure), Invert and Play (each child that moved starts at its old place and slides to the new one). New children fade in. Under reduced motion `change()` is
|
|
73
|
+
* just done.
|
|
74
|
+
*
|
|
75
|
+
* @param {Element} container its children are what moves
|
|
76
|
+
* @param {() => void} change rearranges the children (synchronously)
|
|
77
|
+
* @param {object} [options]
|
|
78
|
+
* @param {(element: Element) => *} [options.key] what makes a child "the same" before and after, default: the element itself
|
|
79
|
+
* @param {number} [options.limit=60] at most this many children are animated (a long list does not need it, and costs time)
|
|
80
|
+
* @param {number} [options.duration] ms, default the token --athena-duration-base
|
|
81
|
+
* @returns {Promise<void>} resolves when the animations are over
|
|
82
|
+
*/
|
|
83
|
+
export function flip(container: Element, change: () => void, { key, limit, duration }?: {
|
|
84
|
+
key?: (element: Element) => any;
|
|
85
|
+
limit?: number;
|
|
86
|
+
duration?: number;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Changes numbers over time with requestAnimationFrame: tween({ from: 0, to: 100, duration: 500, easing: easings.easeOutCubic, onUpdate: v => ... }).
|
|
90
|
+
* `from` and `to` can be numbers, or objects with the same keys ({ x: 0, y: 0 } to { x: 10, y: 5 }); onUpdate then gets an object.
|
|
91
|
+
* Under reduced motion it jumps to the end (one onUpdate call). It runs on animation frames; in a page that is not drawn a timer keeps it going slowly, so it still ends.
|
|
92
|
+
*
|
|
93
|
+
* @returns {Promise<void> & {cancel: () => void}} resolves when it is over (also when cancelled)
|
|
94
|
+
*/
|
|
95
|
+
export function tween({ from, to, duration, easing, onUpdate, delay }?: {
|
|
96
|
+
from?: number;
|
|
97
|
+
to?: number;
|
|
98
|
+
duration?: number;
|
|
99
|
+
easing?: (t: any) => number;
|
|
100
|
+
delay?: number;
|
|
101
|
+
}): Promise<void> & {
|
|
102
|
+
cancel: () => void;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Runs `update()` (which changes the DOM) as a view transition when the browser can and motion is wanted: the old and the new state cross-fade
|
|
106
|
+
* (or whatever the CSS ::view-transition-* rules say). Elements with a `view-transition-name` move from one place to the other. Without the API,
|
|
107
|
+
* or under reduced motion, `update()` is just run. Resolves when it is over.
|
|
108
|
+
*/
|
|
109
|
+
export function viewTransition(update: any): Promise<void>;
|
|
110
|
+
export function getMotion(): "reduce" | "full" | "system";
|
|
111
|
+
export namespace easings {
|
|
112
|
+
function linear(t: any): any;
|
|
113
|
+
function easeInQuad(t: any): number;
|
|
114
|
+
function easeOutQuad(t: any): number;
|
|
115
|
+
function easeInOutQuad(t: any): number;
|
|
116
|
+
function easeInCubic(t: any): number;
|
|
117
|
+
function easeOutCubic(t: any): number;
|
|
118
|
+
function easeInOutCubic(t: any): number;
|
|
119
|
+
function easeOutBack(t: any): number;
|
|
120
|
+
function easeOutElastic(t: any): any;
|
|
121
|
+
}
|
|
122
|
+
export function fadeIn(element: any, options: any): Promise<Animation>;
|
|
123
|
+
export function parallel(steps: any): Promise<any[]>;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {object} options
|
|
3
|
-
* @param {{id: string, name?: string, description?: string}[]} options.themes the first one is the default
|
|
4
|
-
* @param {{id: string, name?: string}[]} [options.modes] default: system, light, dark. Ids "light" and "dark" are the ones that can be resolved
|
|
5
|
-
* @param {string} [options.storageKey="athena.appearance"] localStorage key (also give it to theme-boot.js)
|
|
6
|
-
* @param {string} [options.themeColorVariable] CSS variable whose value becomes <meta name="theme-color"> (the bar of a phone browser)
|
|
7
|
-
* @param {HTMLElement} [options.root] element that gets the attributes (default: <html>)
|
|
8
|
-
* @param {Storage} [options.storage] default: localStorage
|
|
9
|
-
* @param {boolean} [options.transition=true] colours cross-fade when the theme or the mode changes (not under reduced motion)
|
|
10
|
-
* @returns {{themes, modes, appearance: () => object, setTheme: (id) => boolean, setMode: (id) => boolean,
|
|
11
|
-
* onChange: (listener) => Function, refresh: Function, destroy: Function}}
|
|
12
|
-
*/
|
|
13
|
-
export function createThemeManager(options?: {
|
|
14
|
-
themes: {
|
|
15
|
-
id: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
}[];
|
|
19
|
-
modes?: {
|
|
20
|
-
id: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
}[];
|
|
23
|
-
storageKey?: string;
|
|
24
|
-
themeColorVariable?: string;
|
|
25
|
-
root?: HTMLElement;
|
|
26
|
-
storage?: Storage;
|
|
27
|
-
transition?: boolean;
|
|
28
|
-
}): {
|
|
29
|
-
themes: any;
|
|
30
|
-
modes: any;
|
|
31
|
-
appearance: () => object;
|
|
32
|
-
setTheme: (id: any) => boolean;
|
|
33
|
-
setMode: (id: any) => boolean;
|
|
34
|
-
onChange: (listener: any) => Function;
|
|
35
|
-
refresh: Function;
|
|
36
|
-
destroy: Function;
|
|
37
|
-
};
|
|
38
|
-
export const DEFAULT_MODES: {
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
}[];
|
|
1
|
+
/**
|
|
2
|
+
* @param {object} options
|
|
3
|
+
* @param {{id: string, name?: string, description?: string}[]} options.themes the first one is the default
|
|
4
|
+
* @param {{id: string, name?: string}[]} [options.modes] default: system, light, dark. Ids "light" and "dark" are the ones that can be resolved
|
|
5
|
+
* @param {string} [options.storageKey="athena.appearance"] localStorage key (also give it to theme-boot.js)
|
|
6
|
+
* @param {string} [options.themeColorVariable] CSS variable whose value becomes <meta name="theme-color"> (the bar of a phone browser)
|
|
7
|
+
* @param {HTMLElement} [options.root] element that gets the attributes (default: <html>)
|
|
8
|
+
* @param {Storage} [options.storage] default: localStorage
|
|
9
|
+
* @param {boolean} [options.transition=true] colours cross-fade when the theme or the mode changes (not under reduced motion)
|
|
10
|
+
* @returns {{themes, modes, appearance: () => object, setTheme: (id) => boolean, setMode: (id) => boolean,
|
|
11
|
+
* onChange: (listener) => Function, refresh: Function, destroy: Function}}
|
|
12
|
+
*/
|
|
13
|
+
export function createThemeManager(options?: {
|
|
14
|
+
themes: {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
}[];
|
|
19
|
+
modes?: {
|
|
20
|
+
id: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}[];
|
|
23
|
+
storageKey?: string;
|
|
24
|
+
themeColorVariable?: string;
|
|
25
|
+
root?: HTMLElement;
|
|
26
|
+
storage?: Storage;
|
|
27
|
+
transition?: boolean;
|
|
28
|
+
}): {
|
|
29
|
+
themes: any;
|
|
30
|
+
modes: any;
|
|
31
|
+
appearance: () => object;
|
|
32
|
+
setTheme: (id: any) => boolean;
|
|
33
|
+
setMode: (id: any) => boolean;
|
|
34
|
+
onChange: (listener: any) => Function;
|
|
35
|
+
refresh: Function;
|
|
36
|
+
destroy: Function;
|
|
37
|
+
};
|
|
38
|
+
export const DEFAULT_MODES: {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}[];
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
-
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
-
ticks: number[];
|
|
4
|
-
step: number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
-
* so peaks are not lost. Returns the kept indices.
|
|
9
|
-
*/
|
|
10
|
-
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
-
/**
|
|
12
|
-
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
-
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
-
* @param {string} [options.id] id of the svg element
|
|
18
|
-
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
-
* @param {string[]} [options.labels] category labels
|
|
20
|
-
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
-
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
-
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
-
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
-
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
-
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
-
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
-
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
-
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
-
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
-
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
-
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
-
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
-
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
-
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
-
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
-
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
-
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
-
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
39
|
-
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
40
|
-
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
41
|
-
* dataTable: (HTMLElement|null)})|null}
|
|
42
|
-
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
43
|
-
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
44
|
-
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
45
|
-
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
46
|
-
*/
|
|
47
|
-
export function generateChart(options?: {
|
|
48
|
-
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
49
|
-
parent?: string | Element;
|
|
50
|
-
id?: string;
|
|
51
|
-
title?: string;
|
|
52
|
-
labels?: string[];
|
|
53
|
-
times?: (number | Date | string)[];
|
|
54
|
-
series: {
|
|
55
|
-
name?: string;
|
|
56
|
-
data: number[];
|
|
57
|
-
color?: string;
|
|
58
|
-
}[];
|
|
59
|
-
width?: number;
|
|
60
|
-
height?: number;
|
|
61
|
-
legend?: boolean;
|
|
62
|
-
table?: boolean;
|
|
63
|
-
zero?: boolean;
|
|
64
|
-
zoom?: boolean;
|
|
65
|
-
zoomRange?: {
|
|
66
|
-
from: number;
|
|
67
|
-
to: number;
|
|
68
|
-
} | null;
|
|
69
|
-
onZoom?: (range: ({
|
|
70
|
-
from: number;
|
|
71
|
-
to: number;
|
|
72
|
-
} | null)) => void;
|
|
73
|
-
maxPoints?: number;
|
|
74
|
-
hiddenSeries?: number[];
|
|
75
|
-
animate?: boolean;
|
|
76
|
-
interactive?: boolean;
|
|
77
|
-
}): (SVGElement & {
|
|
78
|
-
element: SVGElement;
|
|
79
|
-
update: (options?: object) => SVGElement;
|
|
80
|
-
destroy: () => void;
|
|
81
|
-
zoom: (from: number, to: number) => void;
|
|
82
|
-
resetZoom: () => void;
|
|
83
|
-
getZoom: () => ({
|
|
84
|
-
from: number;
|
|
85
|
-
to: number;
|
|
86
|
-
} | null);
|
|
87
|
-
push: (point: {
|
|
88
|
-
x?: (number | Date | string);
|
|
89
|
-
label?: string;
|
|
90
|
-
values: (number | number[]);
|
|
91
|
-
}, config?: {
|
|
92
|
-
maxPoints?: number;
|
|
93
|
-
}) => void;
|
|
94
|
-
dataTable: (HTMLElement | null);
|
|
95
|
-
}) | null;
|
|
1
|
+
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
+
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
+
ticks: number[];
|
|
4
|
+
step: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
+
* so peaks are not lost. Returns the kept indices.
|
|
9
|
+
*/
|
|
10
|
+
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
+
/**
|
|
12
|
+
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} options
|
|
15
|
+
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
+
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
+
* @param {string} [options.id] id of the svg element
|
|
18
|
+
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
+
* @param {string[]} [options.labels] category labels
|
|
20
|
+
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
+
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
+
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
+
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
+
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
+
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
+
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
+
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
+
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
+
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
+
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
+
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
+
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
+
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
+
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
+
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
+
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
+
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
+
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
39
|
+
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
40
|
+
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
41
|
+
* dataTable: (HTMLElement|null)})|null}
|
|
42
|
+
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
43
|
+
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
44
|
+
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
45
|
+
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
46
|
+
*/
|
|
47
|
+
export function generateChart(options?: {
|
|
48
|
+
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
49
|
+
parent?: string | Element;
|
|
50
|
+
id?: string;
|
|
51
|
+
title?: string;
|
|
52
|
+
labels?: string[];
|
|
53
|
+
times?: (number | Date | string)[];
|
|
54
|
+
series: {
|
|
55
|
+
name?: string;
|
|
56
|
+
data: number[];
|
|
57
|
+
color?: string;
|
|
58
|
+
}[];
|
|
59
|
+
width?: number;
|
|
60
|
+
height?: number;
|
|
61
|
+
legend?: boolean;
|
|
62
|
+
table?: boolean;
|
|
63
|
+
zero?: boolean;
|
|
64
|
+
zoom?: boolean;
|
|
65
|
+
zoomRange?: {
|
|
66
|
+
from: number;
|
|
67
|
+
to: number;
|
|
68
|
+
} | null;
|
|
69
|
+
onZoom?: (range: ({
|
|
70
|
+
from: number;
|
|
71
|
+
to: number;
|
|
72
|
+
} | null)) => void;
|
|
73
|
+
maxPoints?: number;
|
|
74
|
+
hiddenSeries?: number[];
|
|
75
|
+
animate?: boolean;
|
|
76
|
+
interactive?: boolean;
|
|
77
|
+
}): (SVGElement & {
|
|
78
|
+
element: SVGElement;
|
|
79
|
+
update: (options?: object) => SVGElement;
|
|
80
|
+
destroy: () => void;
|
|
81
|
+
zoom: (from: number, to: number) => void;
|
|
82
|
+
resetZoom: () => void;
|
|
83
|
+
getZoom: () => ({
|
|
84
|
+
from: number;
|
|
85
|
+
to: number;
|
|
86
|
+
} | null);
|
|
87
|
+
push: (point: {
|
|
88
|
+
x?: (number | Date | string);
|
|
89
|
+
label?: string;
|
|
90
|
+
values: (number | number[]);
|
|
91
|
+
}, config?: {
|
|
92
|
+
maxPoints?: number;
|
|
93
|
+
}) => void;
|
|
94
|
+
dataTable: (HTMLElement | null);
|
|
95
|
+
}) | null;
|