@circutor/charts 0.1.0 → 0.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/dist/bundler/index.d.ts +35 -0
- package/dist/bundler/index.js +1 -0
- package/dist/bundler/itic-chart.d.ts +11 -0
- package/dist/bundler/itic-chart.js +1 -0
- package/dist/charts/charts.esm.js +1 -1
- package/dist/charts/p-7d11d611.entry.js +25 -0
- package/dist/charts/p-BPCJmLvQ.js +3 -0
- package/dist/cjs/charts.cjs.js +2 -2
- package/dist/cjs/{index-_N-tWlJj.js → index-dJHivNOd.js} +21 -0
- package/dist/cjs/itic-chart.cjs.entry.js +489 -77
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/itic-chart/index.js +133 -6
- package/dist/collection/components/itic-chart/itic-chart.css +5 -0
- package/dist/collection/components/itic-chart/itic-chart.i18n.js +26 -0
- package/dist/collection/components/itic-chart/itic-chart.options.js +115 -32
- package/dist/collection/components/itic-chart/itic-chart.phases.js +55 -0
- package/dist/components/index.js +1 -1
- package/dist/components/itic-chart.js +3 -3
- package/dist/esm/charts.js +3 -3
- package/dist/esm/{index--cwjvYaF.js → index-BPCJmLvQ.js} +20 -1
- package/dist/esm/itic-chart.entry.js +489 -77
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/itic-chart/index.d.ts +29 -2
- package/dist/types/components/itic-chart/itic-chart.i18n.d.ts +13 -0
- package/dist/types/components/itic-chart/itic-chart.options.d.ts +53 -4
- package/dist/types/components/itic-chart/itic-chart.phases.d.ts +17 -0
- package/dist/types/components.d.ts +43 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +11 -7
- package/readme.md +273 -37
- package/dist/charts/p--cwjvYaF.js +0 -3
- package/dist/charts/p-35caac53.entry.js +0 -25
package/dist/esm/loader.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { b as bootstrapLazy } from './index
|
|
2
|
-
export { s as setNonce } from './index
|
|
1
|
+
import { b as bootstrapLazy } from './index-BPCJmLvQ.js';
|
|
2
|
+
export { s as setNonce } from './index-BPCJmLvQ.js';
|
|
3
3
|
import { g as globalScripts } from './app-globals-DQuL1Twl.js';
|
|
4
4
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["itic-chart",[[1,"itic-chart",{"groups":[1]},null,{"groups":[{"onGroupsChange":0}]}]]]], options);
|
|
8
|
+
return bootstrapLazy([["itic-chart",[[1,"itic-chart",{"groups":[1],"locale":[1],"timeZone":[1,"time-zone"]},null,{"groups":[{"onGroupsChange":0}],"locale":[{"onLocaleChange":0}],"timeZone":[{"onTimeZoneChange":0}]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -1,16 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { type ITICChartMarks, type ITICPointClickDetail } from './itic-chart.options';
|
|
2
3
|
export declare class IticChart {
|
|
4
|
+
el: HTMLElement;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Point groups, as an array or a JSON string. Each group's `phase` code sets its name, color and order.
|
|
7
|
+
* Extra fields in groups and points are kept and passed back in `pointClick`.
|
|
5
8
|
*/
|
|
6
9
|
groups: ITICChartMarks[] | string;
|
|
10
|
+
/**
|
|
11
|
+
* Language of the texts, dates and numbers: `ca`, `de`, `en`, `es`, `fr` or `pt`. Only the language
|
|
12
|
+
* is used (`es-ES` → `es`); any other value falls back to `en`.
|
|
13
|
+
*/
|
|
14
|
+
locale: string;
|
|
15
|
+
/**
|
|
16
|
+
* IANA time zone of the dates in the tooltip (e.g. `Europe/Madrid`). Defaults to the browser's,
|
|
17
|
+
* which is also used, with a console error, when the value isn't valid.
|
|
18
|
+
*/
|
|
19
|
+
timeZone?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Emitted when a clickable point is clicked (`clickable` isn't `false`). `detail` holds the original
|
|
22
|
+
* point and group objects.
|
|
23
|
+
*/
|
|
24
|
+
pointClick: EventEmitter<ITICPointClickDetail>;
|
|
7
25
|
private container?;
|
|
8
26
|
private chart?;
|
|
9
27
|
private resizeObserver?;
|
|
28
|
+
private parsedGroups;
|
|
29
|
+
private validTimeZone?;
|
|
30
|
+
/** Last `aria-label` set by the chart: any other value was set by the consumer and is kept. */
|
|
31
|
+
private defaultAriaLabel?;
|
|
10
32
|
onGroupsChange(): void;
|
|
33
|
+
onLocaleChange(): void;
|
|
34
|
+
onTimeZoneChange(): void;
|
|
11
35
|
connectedCallback(): void;
|
|
36
|
+
componentWillLoad(): void;
|
|
12
37
|
componentDidLoad(): void;
|
|
13
38
|
disconnectedCallback(): void;
|
|
39
|
+
private updateAriaLabel;
|
|
40
|
+
private validateTimeZone;
|
|
14
41
|
private initChart;
|
|
15
42
|
private updateChart;
|
|
16
43
|
render(): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import en from './i18n/en.json';
|
|
2
|
+
/** Texts of the chart. `en.json` is the reference: every other language must have the same keys. */
|
|
3
|
+
export type ITICMessages = typeof en;
|
|
4
|
+
export declare const LOCALES: readonly ["ca", "de", "en", "es", "fr", "pt"];
|
|
5
|
+
export type ITICLocale = (typeof LOCALES)[number];
|
|
6
|
+
export declare const DEFAULT_LOCALE: ITICLocale;
|
|
7
|
+
/** Keeps the language of a locale (`es-ES` → `es`), falling back to `en` when it isn't translated. */
|
|
8
|
+
export declare function normalizeLocale(locale: string | null | undefined): ITICLocale;
|
|
9
|
+
export declare const getMessages: (locale: ITICLocale) => ITICMessages;
|
|
10
|
+
/** Translated event type, or the code as is when it isn't in the catalog. */
|
|
11
|
+
export declare function translateEventType(messages: ITICMessages, code: string): string;
|
|
12
|
+
/** Translated name of a phase code that has one (`ALL`, `NONE`), or `undefined`. */
|
|
13
|
+
export declare function translatePhase(messages: ITICMessages, code: string): string | undefined;
|
|
@@ -1,19 +1,68 @@
|
|
|
1
1
|
import type { EChartsOption } from 'echarts';
|
|
2
|
+
import { type ITICLocale } from './itic-chart.i18n';
|
|
2
3
|
export type ITICPoint = {
|
|
4
|
+
/** Duration of the event, in ms. */
|
|
3
5
|
duration: number;
|
|
6
|
+
/** Voltage, in % of the nominal voltage. */
|
|
4
7
|
voltage: number;
|
|
8
|
+
/** Date of the event, ISO 8601. */
|
|
5
9
|
ts: string;
|
|
10
|
+
/** Whether clicking the point emits `pointClick` and shows a pointer cursor. Defaults to `true`. */
|
|
11
|
+
clickable?: boolean;
|
|
12
|
+
/** Event type code from the backend (e.g. `VOLTAGE_DIP`), translated in the tooltip. Unknown codes are shown as is. */
|
|
13
|
+
eventType?: string;
|
|
14
|
+
/** Status code from the backend, shown as is in the tooltip. */
|
|
15
|
+
status?: string;
|
|
16
|
+
/** Minimum voltage, in V. Hidden in the tooltip when missing or `0`. */
|
|
17
|
+
min?: number;
|
|
18
|
+
/** Maximum voltage, in V. Hidden in the tooltip when missing or `0`. */
|
|
19
|
+
max?: number;
|
|
20
|
+
/** Any other field is kept as is and passed back in `pointClick`. */
|
|
21
|
+
[key: string]: unknown;
|
|
6
22
|
};
|
|
7
23
|
export type ITICChartMarks = {
|
|
24
|
+
/** Phase code (`AN`, `AB,BC,CA`, `ALL`, `NONE`…): sets the group's name, color and order. */
|
|
25
|
+
phase: string;
|
|
26
|
+
/** Name of the asset, shown in the tooltip. */
|
|
27
|
+
assetName?: string;
|
|
8
28
|
points: ITICPoint[];
|
|
9
|
-
|
|
10
|
-
|
|
29
|
+
/** Any other field is kept as is and passed back in `pointClick`. */
|
|
30
|
+
[key: string]: unknown;
|
|
11
31
|
};
|
|
32
|
+
/** `detail` of the `pointClick` event: the objects passed in `groups`, not copies. */
|
|
33
|
+
export type ITICPointClickDetail = {
|
|
34
|
+
point: ITICPoint;
|
|
35
|
+
group: ITICChartMarks;
|
|
36
|
+
};
|
|
37
|
+
export type ITICChartSettings = {
|
|
38
|
+
locale: ITICLocale;
|
|
39
|
+
/** IANA time zone of the dates. `undefined` uses the browser's. Must be valid (see `isValidTimeZone`). */
|
|
40
|
+
timeZone?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare const DEFAULT_SETTINGS: ITICChartSettings;
|
|
12
43
|
/**
|
|
13
44
|
* Normalizes the `groups` prop, which arrives as an array from JS/React
|
|
14
45
|
* or as a JSON string when set as an HTML attribute.
|
|
15
46
|
*/
|
|
16
47
|
export declare function parseGroups(groups: ITICChartMarks[] | string | null | undefined): ITICChartMarks[];
|
|
48
|
+
export declare function isValidTimeZone(timeZone: string): boolean;
|
|
17
49
|
export declare function escapeHtml(value: string): string;
|
|
18
|
-
|
|
19
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Returns the tooltip HTML of a point: one row per field, in the chart's language. Rows without a value
|
|
52
|
+
* are left out, and every value is escaped, since it comes from the consumer's data.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createTooltipFormatter({ locale, timeZone }: ITICChartSettings): (point: ITICPoint, group: ITICChartMarks) => string;
|
|
55
|
+
/** Formats the axis labels in the chart's language; ECharts always uses English separators. */
|
|
56
|
+
export declare function createAxisLabelFormatter(locale: ITICLocale): (value: number) => string;
|
|
57
|
+
export declare const isClickable: (point: ITICPoint) => boolean;
|
|
58
|
+
export declare function buildChartOptions(groups: ITICChartMarks[], settings?: ITICChartSettings): EChartsOption;
|
|
59
|
+
/**
|
|
60
|
+
* Maps an ECharts click back to the original point and group. `buildChartOptions` draws the groups as
|
|
61
|
+
* scatter series after the ITIC curve series, sorted with `sortGroups`.
|
|
62
|
+
* Returns `undefined` for clicks outside the points and on points that aren't clickable.
|
|
63
|
+
*/
|
|
64
|
+
export declare function findClickedPoint(groups: ITICChartMarks[], { componentType, seriesIndex, dataIndex }: {
|
|
65
|
+
componentType?: string;
|
|
66
|
+
seriesIndex?: number;
|
|
67
|
+
dataIndex?: number;
|
|
68
|
+
}): ITICPointClickDetail | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ITICMessages } from './itic-chart.i18n';
|
|
2
|
+
export type ITICPhase = {
|
|
3
|
+
/** Name in the legend and the tooltip. Empty for `NONE`. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Fixed color, or `undefined` to use the ECharts palette. */
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Name, in the given language, and color of a phase code. */
|
|
9
|
+
export declare function getPhase(phase: unknown, messages: ITICMessages): ITICPhase;
|
|
10
|
+
/**
|
|
11
|
+
* Sorts groups by phase name, then by code (e.g. `AN` and `AB` are both "L1"), with `NONE` and `ALL` last.
|
|
12
|
+
* Compares characters, not with a locale's rules, so the legend is the same in every language.
|
|
13
|
+
* Returns a new array with the same group objects; groups with the same code keep their order.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sortGroups<T extends {
|
|
16
|
+
phase?: unknown;
|
|
17
|
+
}>(groups: T[]): T[];
|
|
@@ -5,18 +5,42 @@
|
|
|
5
5
|
* It contains typing information for all components that exist in this project.
|
|
6
6
|
*/
|
|
7
7
|
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
|
-
import { ITICChartMarks } from "./components/itic-chart/itic-chart.options";
|
|
9
|
-
export { ITICChartMarks } from "./components/itic-chart/itic-chart.options";
|
|
8
|
+
import { ITICChartMarks, ITICPointClickDetail } from "./components/itic-chart/itic-chart.options";
|
|
9
|
+
export { ITICChartMarks, ITICPointClickDetail } from "./components/itic-chart/itic-chart.options";
|
|
10
10
|
export namespace Components {
|
|
11
11
|
interface IticChart {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Point groups, as an array or a JSON string. Each group's `phase` code sets its name, color and order. Extra fields in groups and points are kept and passed back in `pointClick`.
|
|
14
14
|
*/
|
|
15
15
|
"groups": ITICChartMarks[] | string;
|
|
16
|
+
/**
|
|
17
|
+
* Language of the texts, dates and numbers: `ca`, `de`, `en`, `es`, `fr` or `pt`. Only the language is used (`es-ES` → `es`); any other value falls back to `en`.
|
|
18
|
+
* @default 'en'
|
|
19
|
+
*/
|
|
20
|
+
"locale": string;
|
|
21
|
+
/**
|
|
22
|
+
* IANA time zone of the dates in the tooltip (e.g. `Europe/Madrid`). Defaults to the browser's, which is also used, with a console error, when the value isn't valid.
|
|
23
|
+
*/
|
|
24
|
+
"timeZone"?: string;
|
|
16
25
|
}
|
|
17
26
|
}
|
|
27
|
+
export interface IticChartCustomEvent<T> extends CustomEvent<T> {
|
|
28
|
+
detail: T;
|
|
29
|
+
target: HTMLIticChartElement;
|
|
30
|
+
}
|
|
18
31
|
declare global {
|
|
32
|
+
interface HTMLIticChartElementEventMap {
|
|
33
|
+
"pointClick": ITICPointClickDetail;
|
|
34
|
+
}
|
|
19
35
|
interface HTMLIticChartElement extends Components.IticChart, HTMLStencilElement {
|
|
36
|
+
addEventListener<K extends keyof HTMLIticChartElementEventMap>(type: K, listener: (this: HTMLIticChartElement, ev: IticChartCustomEvent<HTMLIticChartElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
37
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
38
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
39
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
40
|
+
removeEventListener<K extends keyof HTMLIticChartElementEventMap>(type: K, listener: (this: HTMLIticChartElement, ev: IticChartCustomEvent<HTMLIticChartElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
|
41
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
42
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
43
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
20
44
|
}
|
|
21
45
|
var HTMLIticChartElement: {
|
|
22
46
|
prototype: HTMLIticChartElement;
|
|
@@ -29,13 +53,28 @@ declare global {
|
|
|
29
53
|
declare namespace LocalJSX {
|
|
30
54
|
interface IticChart {
|
|
31
55
|
/**
|
|
32
|
-
*
|
|
56
|
+
* Point groups, as an array or a JSON string. Each group's `phase` code sets its name, color and order. Extra fields in groups and points are kept and passed back in `pointClick`.
|
|
33
57
|
*/
|
|
34
58
|
"groups"?: ITICChartMarks[] | string;
|
|
59
|
+
/**
|
|
60
|
+
* Language of the texts, dates and numbers: `ca`, `de`, `en`, `es`, `fr` or `pt`. Only the language is used (`es-ES` → `es`); any other value falls back to `en`.
|
|
61
|
+
* @default 'en'
|
|
62
|
+
*/
|
|
63
|
+
"locale"?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Emitted when a clickable point is clicked (`clickable` isn't `false`). `detail` holds the original point and group objects.
|
|
66
|
+
*/
|
|
67
|
+
"onPointClick"?: (event: IticChartCustomEvent<ITICPointClickDetail>) => void;
|
|
68
|
+
/**
|
|
69
|
+
* IANA time zone of the dates in the tooltip (e.g. `Europe/Madrid`). Defaults to the browser's, which is also used, with a console error, when the value isn't valid.
|
|
70
|
+
*/
|
|
71
|
+
"timeZone"?: string;
|
|
35
72
|
}
|
|
36
73
|
|
|
37
74
|
interface IticChartAttributes {
|
|
38
75
|
"groups": ITICChartMarks[] | string;
|
|
76
|
+
"locale": string;
|
|
77
|
+
"timeZone": string;
|
|
39
78
|
}
|
|
40
79
|
|
|
41
80
|
interface IntrinsicElements {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
* to consume components of this package as outlined in the `README.md`.
|
|
9
9
|
*/
|
|
10
10
|
export type * from './components';
|
|
11
|
-
export type { ITICChartMarks, ITICPoint } from './components/itic-chart/itic-chart.options';
|
|
11
|
+
export type { ITICChartMarks, ITICPoint, ITICPointClickDetail, } from './components/itic-chart/itic-chart.options';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@circutor/charts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Charts used by the Circutor Cloud team, as framework-agnostic Web Components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -21,9 +21,13 @@
|
|
|
21
21
|
"types": "./dist/*",
|
|
22
22
|
"import": "./dist/*"
|
|
23
23
|
},
|
|
24
|
+
"./dist/bundler": {
|
|
25
|
+
"types": "./dist/bundler/index.d.ts",
|
|
26
|
+
"import": "./dist/bundler/index.js"
|
|
27
|
+
},
|
|
24
28
|
"./components/*": {
|
|
25
|
-
"types": "./dist/
|
|
26
|
-
"import": "./dist/
|
|
29
|
+
"types": "./dist/bundler/*.d.ts",
|
|
30
|
+
"import": "./dist/bundler/*.js"
|
|
27
31
|
},
|
|
28
32
|
"./loader": {
|
|
29
33
|
"types": "./loader/index.d.ts",
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
"loader/"
|
|
41
45
|
],
|
|
42
46
|
"scripts": {
|
|
43
|
-
"build": "stencil build",
|
|
47
|
+
"build": "stencil build && stencil build --config stencil.config.bundler.ts && node ../../scripts/check-dist.mjs",
|
|
44
48
|
"start": "stencil build --dev --watch --serve",
|
|
45
49
|
"test:unit": "vitest run --project spec",
|
|
46
50
|
"test:unit:watch": "vitest --project spec",
|
|
@@ -48,8 +52,7 @@
|
|
|
48
52
|
"test:visual": "vitest run --project visual",
|
|
49
53
|
"generate": "stencil generate"
|
|
50
54
|
},
|
|
51
|
-
"
|
|
52
|
-
"dayjs": "^1.11.13",
|
|
55
|
+
"peerDependencies": {
|
|
53
56
|
"echarts": "^6.1.0"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
@@ -59,9 +62,10 @@
|
|
|
59
62
|
"@types/node": "^22.20.5",
|
|
60
63
|
"@vitest/browser-playwright": "5.0.5",
|
|
61
64
|
"@vitest/coverage-v8": "^5.0.5",
|
|
65
|
+
"echarts": "^6.1.0",
|
|
62
66
|
"playwright": "1.64.1",
|
|
63
67
|
"vitest": "^5.0.5"
|
|
64
68
|
},
|
|
65
69
|
"license": "MIT",
|
|
66
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "00048fd4dea626e18224e8d3da1205d32f14e441"
|
|
67
71
|
}
|