athena-ui-js 2.5.0 → 2.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 +1158 -1122
- package/docs/migration-2.0.md +99 -83
- package/docs/styling.md +124 -123
- package/package.json +176 -189
- package/src/app.js +85 -0
- package/src/athena-ui.js +60 -135
- package/src/libs/config/config.js +66 -66
- package/src/libs/core/i18n.js +354 -352
- package/src/libs/hephaestus/MenuGenerator/menuGenerator.js +278 -265
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +772 -722
- package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +171 -161
- package/src/libs/hephaestus/formGenerator/formBuilder.js +470 -460
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +837 -825
- package/src/res/themes/default/style.css +3128 -3037
- package/types/app.d.ts +58 -0
- package/types/athena-ui.d.ts +1 -55
- package/types/libs/config/config.d.ts +96 -96
- package/types/libs/hephaestus/MenuGenerator/menuGenerator.d.ts +5 -0
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +123 -117
- package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +122 -122
- package/types/libs/hephaestus/feedbackGenerator/feedbackGenerator.d.ts +3 -0
- package/types/libs/hephaestus/formGenerator/authForms.d.ts +130 -130
- package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +128 -128
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +133 -129
package/types/app.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} [options]
|
|
5
|
+
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
+
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
+
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
+
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
+
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
+
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
+
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
+
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
+
* @returns {Promise<object>} the effective configuration
|
|
14
|
+
*/
|
|
15
|
+
export function init(options?: {
|
|
16
|
+
theme?: {
|
|
17
|
+
id?: number;
|
|
18
|
+
href?: string;
|
|
19
|
+
};
|
|
20
|
+
config?: object;
|
|
21
|
+
nav?: Function;
|
|
22
|
+
login?: Function;
|
|
23
|
+
register?: Function;
|
|
24
|
+
lostPassword?: Function;
|
|
25
|
+
changePassword?: Function;
|
|
26
|
+
menuItems?: object;
|
|
27
|
+
}): Promise<object>;
|
|
28
|
+
/**
|
|
29
|
+
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
+
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
+
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
+
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
+
*
|
|
34
|
+
* @param {object} options the options of init(), and
|
|
35
|
+
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
+
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
+
* config: object, update: Function, destroy: Function}>}
|
|
38
|
+
*/
|
|
39
|
+
export function createApp(options?: {
|
|
40
|
+
root: string | Element;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
element: HTMLElement;
|
|
43
|
+
container: HTMLElement;
|
|
44
|
+
header: HTMLElement | null;
|
|
45
|
+
wrapper: HTMLElement | null;
|
|
46
|
+
footer: HTMLElement | null;
|
|
47
|
+
config: object;
|
|
48
|
+
update: Function;
|
|
49
|
+
destroy: Function;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
+
* @returns {Promise<object>} the applied theme
|
|
54
|
+
*/
|
|
55
|
+
export function setTheme(selected: any): Promise<object>;
|
|
56
|
+
import config from "./libs/config/config.js";
|
|
57
|
+
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
58
|
+
export { config, loadScript };
|
package/types/athena-ui.d.ts
CHANGED
|
@@ -1,58 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} [options]
|
|
5
|
-
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
-
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
-
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
-
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
-
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
-
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
-
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
-
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
-
* @returns {Promise<object>} the effective configuration
|
|
14
|
-
*/
|
|
15
|
-
export function init(options?: {
|
|
16
|
-
theme?: {
|
|
17
|
-
id?: number;
|
|
18
|
-
href?: string;
|
|
19
|
-
};
|
|
20
|
-
config?: object;
|
|
21
|
-
nav?: Function;
|
|
22
|
-
login?: Function;
|
|
23
|
-
register?: Function;
|
|
24
|
-
lostPassword?: Function;
|
|
25
|
-
changePassword?: Function;
|
|
26
|
-
menuItems?: object;
|
|
27
|
-
}): Promise<object>;
|
|
28
|
-
/**
|
|
29
|
-
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
-
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
-
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
-
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
-
*
|
|
34
|
-
* @param {object} options the options of init(), and
|
|
35
|
-
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
-
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
-
* config: object, update: Function, destroy: Function}>}
|
|
38
|
-
*/
|
|
39
|
-
export function createApp(options?: {
|
|
40
|
-
root: string | Element;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
element: HTMLElement;
|
|
43
|
-
container: HTMLElement;
|
|
44
|
-
header: HTMLElement | null;
|
|
45
|
-
wrapper: HTMLElement | null;
|
|
46
|
-
footer: HTMLElement | null;
|
|
47
|
-
config: object;
|
|
48
|
-
update: Function;
|
|
49
|
-
destroy: Function;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
-
* @returns {Promise<object>} the applied theme
|
|
54
|
-
*/
|
|
55
|
-
export function setTheme(selected: any): Promise<object>;
|
|
56
1
|
export { default as Cookies } from "./libs/core/cookies.js";
|
|
57
2
|
export * from "./libs/core/elementGenerator.js";
|
|
58
3
|
export * from "./libs/core/controls.js";
|
|
@@ -100,4 +45,5 @@ export * from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
|
100
45
|
import config from "./libs/config/config.js";
|
|
101
46
|
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
102
47
|
export { config, loadScript };
|
|
48
|
+
export { init, createApp, setTheme } from "./app.js";
|
|
103
49
|
export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
export function applyConfig(...sources: any[]): {
|
|
2
|
-
version: "2.
|
|
3
|
-
container_class: "container";
|
|
4
|
-
header_class: "header-container";
|
|
5
|
-
header_menu_class: "header-menu menu";
|
|
6
|
-
wrapper_class: "wrapper-container";
|
|
7
|
-
footer_class: "footer-container";
|
|
8
|
-
footer_menu_class: "footer-menu menu";
|
|
9
|
-
loginForm_class: "login-form form";
|
|
10
|
-
registrationForm_class: "registration-form form";
|
|
11
|
-
lostPasswordForm_class: "lost-password-form form";
|
|
12
|
-
changePasswordForm_class: "change-password-form form";
|
|
13
|
-
bordered: true;
|
|
14
|
-
generateHeader: true;
|
|
15
|
-
generateFooter: true;
|
|
16
|
-
generateHeadercontent: true;
|
|
17
|
-
generateFooterContent: true;
|
|
18
|
-
generateWrappercontent: true;
|
|
19
|
-
login_enabled: false;
|
|
20
|
-
registration_enabled: false;
|
|
21
|
-
lost_password_enabled: false;
|
|
22
|
-
change_password_enabled: false;
|
|
23
|
-
login_remember_me: false;
|
|
24
|
-
header_title_text: "Athena UI";
|
|
25
|
-
header_img_url: any;
|
|
26
|
-
copyright: "Here is the bottom Copyright Text for website";
|
|
27
|
-
locale: "en";
|
|
28
|
-
session_cookie: "athena_session";
|
|
29
|
-
session_days: 7;
|
|
30
|
-
customLoader: any;
|
|
31
|
-
};
|
|
32
|
-
export function withBorder(className: any): any;
|
|
33
|
-
export const BORDERED_CLASS: "default-cointainer-bordered";
|
|
34
|
-
export const defaults: Readonly<{
|
|
35
|
-
version: "2.
|
|
36
|
-
container_class: "container";
|
|
37
|
-
header_class: "header-container";
|
|
38
|
-
header_menu_class: "header-menu menu";
|
|
39
|
-
wrapper_class: "wrapper-container";
|
|
40
|
-
footer_class: "footer-container";
|
|
41
|
-
footer_menu_class: "footer-menu menu";
|
|
42
|
-
loginForm_class: "login-form form";
|
|
43
|
-
registrationForm_class: "registration-form form";
|
|
44
|
-
lostPasswordForm_class: "lost-password-form form";
|
|
45
|
-
changePasswordForm_class: "change-password-form form";
|
|
46
|
-
bordered: true;
|
|
47
|
-
generateHeader: true;
|
|
48
|
-
generateFooter: true;
|
|
49
|
-
generateHeadercontent: true;
|
|
50
|
-
generateFooterContent: true;
|
|
51
|
-
generateWrappercontent: true;
|
|
52
|
-
login_enabled: false;
|
|
53
|
-
registration_enabled: false;
|
|
54
|
-
lost_password_enabled: false;
|
|
55
|
-
change_password_enabled: false;
|
|
56
|
-
login_remember_me: false;
|
|
57
|
-
header_title_text: "Athena UI";
|
|
58
|
-
header_img_url: any;
|
|
59
|
-
copyright: "Here is the bottom Copyright Text for website";
|
|
60
|
-
locale: "en";
|
|
61
|
-
session_cookie: "athena_session";
|
|
62
|
-
session_days: 7;
|
|
63
|
-
customLoader: any;
|
|
64
|
-
}>;
|
|
65
|
-
export default config;
|
|
66
|
-
declare namespace config {
|
|
67
|
-
let version: "2.
|
|
68
|
-
let container_class: "container";
|
|
69
|
-
let header_class: "header-container";
|
|
70
|
-
let header_menu_class: "header-menu menu";
|
|
71
|
-
let wrapper_class: "wrapper-container";
|
|
72
|
-
let footer_class: "footer-container";
|
|
73
|
-
let footer_menu_class: "footer-menu menu";
|
|
74
|
-
let loginForm_class: "login-form form";
|
|
75
|
-
let registrationForm_class: "registration-form form";
|
|
76
|
-
let lostPasswordForm_class: "lost-password-form form";
|
|
77
|
-
let changePasswordForm_class: "change-password-form form";
|
|
78
|
-
let bordered: true;
|
|
79
|
-
let generateHeader: true;
|
|
80
|
-
let generateFooter: true;
|
|
81
|
-
let generateHeadercontent: true;
|
|
82
|
-
let generateFooterContent: true;
|
|
83
|
-
let generateWrappercontent: true;
|
|
84
|
-
let login_enabled: false;
|
|
85
|
-
let registration_enabled: false;
|
|
86
|
-
let lost_password_enabled: false;
|
|
87
|
-
let change_password_enabled: false;
|
|
88
|
-
let login_remember_me: false;
|
|
89
|
-
let header_title_text: "Athena UI";
|
|
90
|
-
let header_img_url: any;
|
|
91
|
-
let copyright: "Here is the bottom Copyright Text for website";
|
|
92
|
-
let locale: "en";
|
|
93
|
-
let session_cookie: "athena_session";
|
|
94
|
-
let session_days: 7;
|
|
95
|
-
let customLoader: any;
|
|
96
|
-
}
|
|
1
|
+
export function applyConfig(...sources: any[]): {
|
|
2
|
+
version: "2.6.0";
|
|
3
|
+
container_class: "container";
|
|
4
|
+
header_class: "header-container";
|
|
5
|
+
header_menu_class: "header-menu menu";
|
|
6
|
+
wrapper_class: "wrapper-container";
|
|
7
|
+
footer_class: "footer-container";
|
|
8
|
+
footer_menu_class: "footer-menu menu";
|
|
9
|
+
loginForm_class: "login-form form";
|
|
10
|
+
registrationForm_class: "registration-form form";
|
|
11
|
+
lostPasswordForm_class: "lost-password-form form";
|
|
12
|
+
changePasswordForm_class: "change-password-form form";
|
|
13
|
+
bordered: true;
|
|
14
|
+
generateHeader: true;
|
|
15
|
+
generateFooter: true;
|
|
16
|
+
generateHeadercontent: true;
|
|
17
|
+
generateFooterContent: true;
|
|
18
|
+
generateWrappercontent: true;
|
|
19
|
+
login_enabled: false;
|
|
20
|
+
registration_enabled: false;
|
|
21
|
+
lost_password_enabled: false;
|
|
22
|
+
change_password_enabled: false;
|
|
23
|
+
login_remember_me: false;
|
|
24
|
+
header_title_text: "Athena UI";
|
|
25
|
+
header_img_url: any;
|
|
26
|
+
copyright: "Here is the bottom Copyright Text for website";
|
|
27
|
+
locale: "en";
|
|
28
|
+
session_cookie: "athena_session";
|
|
29
|
+
session_days: 7;
|
|
30
|
+
customLoader: any;
|
|
31
|
+
};
|
|
32
|
+
export function withBorder(className: any): any;
|
|
33
|
+
export const BORDERED_CLASS: "default-cointainer-bordered";
|
|
34
|
+
export const defaults: Readonly<{
|
|
35
|
+
version: "2.6.0";
|
|
36
|
+
container_class: "container";
|
|
37
|
+
header_class: "header-container";
|
|
38
|
+
header_menu_class: "header-menu menu";
|
|
39
|
+
wrapper_class: "wrapper-container";
|
|
40
|
+
footer_class: "footer-container";
|
|
41
|
+
footer_menu_class: "footer-menu menu";
|
|
42
|
+
loginForm_class: "login-form form";
|
|
43
|
+
registrationForm_class: "registration-form form";
|
|
44
|
+
lostPasswordForm_class: "lost-password-form form";
|
|
45
|
+
changePasswordForm_class: "change-password-form form";
|
|
46
|
+
bordered: true;
|
|
47
|
+
generateHeader: true;
|
|
48
|
+
generateFooter: true;
|
|
49
|
+
generateHeadercontent: true;
|
|
50
|
+
generateFooterContent: true;
|
|
51
|
+
generateWrappercontent: true;
|
|
52
|
+
login_enabled: false;
|
|
53
|
+
registration_enabled: false;
|
|
54
|
+
lost_password_enabled: false;
|
|
55
|
+
change_password_enabled: false;
|
|
56
|
+
login_remember_me: false;
|
|
57
|
+
header_title_text: "Athena UI";
|
|
58
|
+
header_img_url: any;
|
|
59
|
+
copyright: "Here is the bottom Copyright Text for website";
|
|
60
|
+
locale: "en";
|
|
61
|
+
session_cookie: "athena_session";
|
|
62
|
+
session_days: 7;
|
|
63
|
+
customLoader: any;
|
|
64
|
+
}>;
|
|
65
|
+
export default config;
|
|
66
|
+
declare namespace config {
|
|
67
|
+
let version: "2.6.0";
|
|
68
|
+
let container_class: "container";
|
|
69
|
+
let header_class: "header-container";
|
|
70
|
+
let header_menu_class: "header-menu menu";
|
|
71
|
+
let wrapper_class: "wrapper-container";
|
|
72
|
+
let footer_class: "footer-container";
|
|
73
|
+
let footer_menu_class: "footer-menu menu";
|
|
74
|
+
let loginForm_class: "login-form form";
|
|
75
|
+
let registrationForm_class: "registration-form form";
|
|
76
|
+
let lostPasswordForm_class: "lost-password-form form";
|
|
77
|
+
let changePasswordForm_class: "change-password-form form";
|
|
78
|
+
let bordered: true;
|
|
79
|
+
let generateHeader: true;
|
|
80
|
+
let generateFooter: true;
|
|
81
|
+
let generateHeadercontent: true;
|
|
82
|
+
let generateFooterContent: true;
|
|
83
|
+
let generateWrappercontent: true;
|
|
84
|
+
let login_enabled: false;
|
|
85
|
+
let registration_enabled: false;
|
|
86
|
+
let lost_password_enabled: false;
|
|
87
|
+
let change_password_enabled: false;
|
|
88
|
+
let login_remember_me: false;
|
|
89
|
+
let header_title_text: "Athena UI";
|
|
90
|
+
let header_img_url: any;
|
|
91
|
+
let copyright: "Here is the bottom Copyright Text for website";
|
|
92
|
+
let locale: "en";
|
|
93
|
+
let session_cookie: "athena_session";
|
|
94
|
+
let session_days: 7;
|
|
95
|
+
let customLoader: any;
|
|
96
|
+
}
|
|
@@ -18,7 +18,11 @@ export function badgeText(value: any): string;
|
|
|
18
18
|
* @param {boolean} [options.followHash=false] the item whose `href` equals location.hash is the active one, and follows hashchange
|
|
19
19
|
* @param {"bar"|"bottom-tabs"|"responsive"} [options.layout="bar"] "bottom-tabs": a bar of tabs at the bottom of the screen,
|
|
20
20
|
* groups open as sheets above it. "responsive": a bar on wide screens, bottom tabs on a tablet or phone (max 700px).
|
|
21
|
+
* @param {number} [options.breakpoint=700] layout "responsive": the screen width in px up to which the menu is a bar of tabs at the bottom
|
|
21
22
|
* @param {string} [options.label] accessible name of the navigation
|
|
23
|
+
*
|
|
24
|
+
* Colours: on a coloured header set --athena-menu-bg, --athena-menu-fg, --athena-menu-hover and --athena-menu-active (the line under the active item)
|
|
25
|
+
* on the menu or on a parent (they default to a transparent bar, the colour of the text, --athena-hover and --athena-accent).
|
|
22
26
|
* @param {string} [options.id]
|
|
23
27
|
* @param {string} [options.class]
|
|
24
28
|
* @returns {{element: HTMLElement, select: (id: string|null) => void, getActive: () => string|null, setBadge: (id: string, badge) => void,
|
|
@@ -31,6 +35,7 @@ export function generateMenu(options?: {
|
|
|
31
35
|
active?: string;
|
|
32
36
|
followHash?: boolean;
|
|
33
37
|
layout?: "bar" | "bottom-tabs" | "responsive";
|
|
38
|
+
breakpoint?: number;
|
|
34
39
|
label?: string;
|
|
35
40
|
id?: string;
|
|
36
41
|
class?: string;
|
|
@@ -1,117 +1,123 @@
|
|
|
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
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* @param {number} [options.
|
|
35
|
-
* @param {number
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {boolean} [options.
|
|
38
|
-
* @param {boolean} [options.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param {(value: number) => string} [options.
|
|
44
|
-
* @param {
|
|
45
|
-
*
|
|
46
|
-
* @
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
from: number;
|
|
79
|
-
to: number;
|
|
80
|
-
} | null
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
* Without `zoom` the arrow keys on the plot read the values from point to point (Home and End: first and last, Esc: hide); with `zoom` that is Alt + arrow
|
|
32
|
+
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
33
|
+
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
34
|
+
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
35
|
+
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
36
|
+
* @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
|
|
37
|
+
* @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)
|
|
38
|
+
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
39
|
+
* @param {boolean} [options.gaps=false] line and area charts: a missing value (null, NaN, undefined) breaks the line, and a point on its own is a dot;
|
|
40
|
+
* without it the line goes on from the value before to the one after
|
|
41
|
+
* @param {{from: (number|Date|string), to: (number|Date|string)}} [options.timeRange] line and area charts with `times`: the range of the time axis, when it is not the one
|
|
42
|
+
* the data covers (the last hour, of which only the last quarter has been measured)
|
|
43
|
+
* @param {(value: number) => string} [options.format] how a value is written: on the axis, in the tooltips and in the table of values (default: whole numbers, otherwise two decimals)
|
|
44
|
+
* @param {((time: number) => string)|Intl.DateTimeFormatOptions} [options.timeFormat] how a time is written in the tooltips and in the table of values (`times` only): a function of the
|
|
45
|
+
* time in milliseconds, or the options of Intl.DateTimeFormat (default: `{ dateStyle: "medium", timeStyle: "medium" }`, for example "Nov 19, 2026, 6:15:09 PM")
|
|
46
|
+
* @param {boolean} [options.points=true] line and area charts: false never draws the dots, however few the points are (the tooltip still follows the pointer and the keyboard)
|
|
47
|
+
* @param {(value: number) => string} [options.tickFormat] how the numbers of the value axis are written, when they should not be written like the values (a chart of whole numbers has ticks of 0.2)
|
|
48
|
+
* @param {{top?: number, right?: number, bottom?: number, left?: number}} [options.margin] room around the plot in px (default 40, 20, 50, 55): a chart without a title and a legend does not need the top
|
|
49
|
+
* @param {boolean} [options.responsive=false] the chart is as wide as its parent and follows it when it changes (`height` stays); `width` is only the first guess
|
|
50
|
+
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
51
|
+
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
52
|
+
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
53
|
+
* dataTable: (HTMLElement|null)})|null}
|
|
54
|
+
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
55
|
+
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
56
|
+
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
57
|
+
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
58
|
+
*/
|
|
59
|
+
export function generateChart(options?: {
|
|
60
|
+
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
61
|
+
parent?: string | Element;
|
|
62
|
+
id?: string;
|
|
63
|
+
title?: string;
|
|
64
|
+
labels?: string[];
|
|
65
|
+
times?: (number | Date | string)[];
|
|
66
|
+
series: {
|
|
67
|
+
name?: string;
|
|
68
|
+
data: number[];
|
|
69
|
+
color?: string;
|
|
70
|
+
}[];
|
|
71
|
+
width?: number;
|
|
72
|
+
height?: number;
|
|
73
|
+
legend?: boolean;
|
|
74
|
+
table?: boolean;
|
|
75
|
+
zero?: boolean;
|
|
76
|
+
zoom?: boolean;
|
|
77
|
+
zoomRange?: {
|
|
78
|
+
from: number;
|
|
79
|
+
to: number;
|
|
80
|
+
} | null;
|
|
81
|
+
onZoom?: (range: ({
|
|
82
|
+
from: number;
|
|
83
|
+
to: number;
|
|
84
|
+
} | null)) => void;
|
|
85
|
+
maxPoints?: number;
|
|
86
|
+
hiddenSeries?: number[];
|
|
87
|
+
animate?: boolean;
|
|
88
|
+
interactive?: boolean;
|
|
89
|
+
gaps?: boolean;
|
|
90
|
+
timeRange?: {
|
|
91
|
+
from: (number | Date | string);
|
|
92
|
+
to: (number | Date | string);
|
|
93
|
+
};
|
|
94
|
+
format?: (value: number) => string;
|
|
95
|
+
timeFormat?: ((time: number) => string) | Intl.DateTimeFormatOptions;
|
|
96
|
+
points?: boolean;
|
|
97
|
+
tickFormat?: (value: number) => string;
|
|
98
|
+
margin?: {
|
|
99
|
+
top?: number;
|
|
100
|
+
right?: number;
|
|
101
|
+
bottom?: number;
|
|
102
|
+
left?: number;
|
|
103
|
+
};
|
|
104
|
+
responsive?: boolean;
|
|
105
|
+
}): (SVGElement & {
|
|
106
|
+
element: SVGElement;
|
|
107
|
+
update: (options?: object) => SVGElement;
|
|
108
|
+
destroy: () => void;
|
|
109
|
+
zoom: (from: number, to: number) => void;
|
|
110
|
+
resetZoom: () => void;
|
|
111
|
+
getZoom: () => ({
|
|
112
|
+
from: number;
|
|
113
|
+
to: number;
|
|
114
|
+
} | null);
|
|
115
|
+
push: (point: {
|
|
116
|
+
x?: (number | Date | string);
|
|
117
|
+
label?: string;
|
|
118
|
+
values: (number | number[]);
|
|
119
|
+
}, config?: {
|
|
120
|
+
maxPoints?: number;
|
|
121
|
+
}) => void;
|
|
122
|
+
dataTable: (HTMLElement | null);
|
|
123
|
+
}) | null;
|