@circutor/charts 0.1.0 → 0.2.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-943aa343.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 +86 -24
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/itic-chart/index.js +134 -8
- package/dist/collection/components/itic-chart/itic-chart.css +5 -0
- package/dist/collection/components/itic-chart/itic-chart.options.js +42 -16
- 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 +86 -24
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/itic-chart/index.d.ts +26 -3
- package/dist/types/components/itic-chart/itic-chart.options.d.ts +36 -2
- package/dist/types/components.d.ts +53 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +13 -6
- package/readme.md +178 -7
- package/dist/charts/p--cwjvYaF.js +0 -3
- package/dist/charts/p-35caac53.entry.js +0 -25
package/dist/esm/charts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as promiseResolve, b as bootstrapLazy } from './index
|
|
2
|
-
export { s as setNonce } from './index
|
|
1
|
+
import { p as promiseResolve, 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
|
/*
|
|
@@ -17,5 +17,5 @@ var patchBrowser = () => {
|
|
|
17
17
|
|
|
18
18
|
patchBrowser().then(async (options) => {
|
|
19
19
|
await globalScripts();
|
|
20
|
-
return bootstrapLazy([["itic-chart",[[1,"itic-chart",{"groups":[1]},null,{"groups":[{"
|
|
20
|
+
return bootstrapLazy([["itic-chart",[[1,"itic-chart",{"groups":[1],"xAxisName":[1,"x-axis-name"],"yAxisName":[1,"y-axis-name"],"tooltipFormatter":[16]},null,{"groups":[{"onOptionsChange":0}],"xAxisName":[{"onOptionsChange":0}],"yAxisName":[{"onOptionsChange":0}],"tooltipFormatter":[{"onOptionsChange":0}]}]]]], options);
|
|
21
21
|
});
|
|
@@ -471,6 +471,25 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
|
471
471
|
}
|
|
472
472
|
return propValue;
|
|
473
473
|
};
|
|
474
|
+
var getElement = (ref) => {
|
|
475
|
+
var _a;
|
|
476
|
+
return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/runtime/event-emitter.ts
|
|
480
|
+
var createEvent = (ref, name, flags) => {
|
|
481
|
+
const elm = getElement(ref);
|
|
482
|
+
return {
|
|
483
|
+
emit: (detail) => {
|
|
484
|
+
return emitEvent(elm, name, {
|
|
485
|
+
bubbles: true,
|
|
486
|
+
composed: true,
|
|
487
|
+
cancelable: true,
|
|
488
|
+
detail
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
};
|
|
474
493
|
var emitEvent = (elm, name, opts) => {
|
|
475
494
|
const ev = plt.ce(name, opts);
|
|
476
495
|
elm.dispatchEvent(ev);
|
|
@@ -1439,4 +1458,4 @@ function transformTag(tag) {
|
|
|
1439
1458
|
return tag;
|
|
1440
1459
|
}
|
|
1441
1460
|
|
|
1442
|
-
export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
1461
|
+
export { bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerInstance, h } from './index
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-BPCJmLvQ.js';
|
|
2
2
|
|
|
3
3
|
/*! *****************************************************************************
|
|
4
4
|
Copyright (c) Microsoft Corporation.
|
|
@@ -45141,36 +45141,63 @@ function escapeHtml(value) {
|
|
|
45141
45141
|
.replace(/"/g, '"')
|
|
45142
45142
|
.replace(/'/g, ''');
|
|
45143
45143
|
}
|
|
45144
|
-
|
|
45144
|
+
/** Default tooltip, in English. Escapes every value, since they come from the consumer. */
|
|
45145
|
+
const defaultTooltipFormatter = ({ duration, voltage, ts }, { groupName }) => {
|
|
45145
45146
|
const rows = {
|
|
45146
|
-
phase: escapeHtml(groupName),
|
|
45147
|
-
duration: `${duration} ms`,
|
|
45148
|
-
voltage: `${Math.round(voltage * 10) / 10}%`,
|
|
45149
|
-
ts: dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS'),
|
|
45147
|
+
phase: escapeHtml(String(groupName)),
|
|
45148
|
+
duration: `${escapeHtml(String(duration))} ms`,
|
|
45149
|
+
voltage: `${escapeHtml(String(Math.round(voltage * 10) / 10))}%`,
|
|
45150
|
+
ts: escapeHtml(dayjs(ts).locale('en').format('DD MMM, HH:mm:ss.SSS')),
|
|
45150
45151
|
};
|
|
45151
45152
|
return Object.entries(rows)
|
|
45152
45153
|
.map(([label, value]) => ` <strong>${label}</strong>: ${value}`)
|
|
45153
45154
|
.join('<br/>');
|
|
45154
|
-
}
|
|
45155
|
-
|
|
45156
|
-
|
|
45155
|
+
};
|
|
45156
|
+
const DEFAULT_SETTINGS = {
|
|
45157
|
+
xAxisName: 'Duration (ms)',
|
|
45158
|
+
yAxisName: 'Voltage (% of nominal voltage)',
|
|
45159
|
+
tooltipFormatter: defaultTooltipFormatter,
|
|
45160
|
+
};
|
|
45161
|
+
const isClickable = (point) => point.clickable !== false;
|
|
45162
|
+
function buildChartOptions(groups, settings = DEFAULT_SETTINGS) {
|
|
45163
|
+
return Object.assign(Object.assign({}, BASE_OPTIONS), { xAxis: Object.assign(Object.assign({}, BASE_OPTIONS.xAxis), { name: settings.xAxisName }), yAxis: Object.assign(Object.assign({}, BASE_OPTIONS.yAxis), { name: settings.yAxisName }), series: [
|
|
45157
45164
|
...CURVE_SERIES,
|
|
45158
|
-
...groups.map((
|
|
45165
|
+
...groups.map((group) => ({
|
|
45159
45166
|
type: 'scatter',
|
|
45160
|
-
name: groupName,
|
|
45161
|
-
|
|
45167
|
+
name: group.groupName,
|
|
45168
|
+
// ECharts 6 reads `cursor` per data item, although its types only declare it per series
|
|
45169
|
+
data: group.points.map(point => ({
|
|
45170
|
+
value: [point.duration, point.voltage],
|
|
45171
|
+
cursor: isClickable(point) ? 'pointer' : 'default',
|
|
45172
|
+
})),
|
|
45162
45173
|
symbolSize: 12,
|
|
45163
45174
|
z: 4,
|
|
45164
45175
|
itemStyle: {
|
|
45165
|
-
color,
|
|
45176
|
+
color: group.color,
|
|
45166
45177
|
opacity: 1,
|
|
45167
45178
|
},
|
|
45168
45179
|
tooltip: {
|
|
45169
|
-
formatter: params =>
|
|
45180
|
+
formatter: params => settings.tooltipFormatter(group.points[params.dataIndex], group),
|
|
45170
45181
|
},
|
|
45171
45182
|
})),
|
|
45172
45183
|
] });
|
|
45173
45184
|
}
|
|
45185
|
+
/**
|
|
45186
|
+
* Maps an ECharts click back to the original point and group, which `buildChartOptions` draws as
|
|
45187
|
+
* scatter series after the ITIC curve series, in the same order as `groups`.
|
|
45188
|
+
* Returns `undefined` for clicks outside the points and on points that aren't clickable.
|
|
45189
|
+
*/
|
|
45190
|
+
function findClickedPoint(groups, { componentType, seriesIndex, dataIndex }) {
|
|
45191
|
+
if (componentType !== 'series' || seriesIndex == null || dataIndex == null) {
|
|
45192
|
+
return undefined;
|
|
45193
|
+
}
|
|
45194
|
+
const group = groups[seriesIndex - CURVE_SERIES.length];
|
|
45195
|
+
const point = group === null || group === void 0 ? void 0 : group.points[dataIndex];
|
|
45196
|
+
if (!point || !isClickable(point)) {
|
|
45197
|
+
return undefined;
|
|
45198
|
+
}
|
|
45199
|
+
return { point, group };
|
|
45200
|
+
}
|
|
45174
45201
|
const ITIC_CURVE_PROHIBITED_REGION = [
|
|
45175
45202
|
[0.167, 500],
|
|
45176
45203
|
[1, 200],
|
|
@@ -45197,7 +45224,8 @@ const BASE_OPTIONS = {
|
|
|
45197
45224
|
},
|
|
45198
45225
|
// ECharts 6 moved the default legend to the bottom; keep it on top as in previous versions
|
|
45199
45226
|
legend: { top: 0 },
|
|
45200
|
-
|
|
45227
|
+
// Outside the shadow root, so containers with `overflow: hidden` don't clip it. Its styles are inline.
|
|
45228
|
+
tooltip: { appendTo: 'body' },
|
|
45201
45229
|
textStyle: {
|
|
45202
45230
|
fontFamily: 'CDS-Regular, Arial',
|
|
45203
45231
|
},
|
|
@@ -45205,7 +45233,6 @@ const BASE_OPTIONS = {
|
|
|
45205
45233
|
type: 'log',
|
|
45206
45234
|
min: 0.1,
|
|
45207
45235
|
max: 100000,
|
|
45208
|
-
name: 'Duration (ms)',
|
|
45209
45236
|
nameGap: 30,
|
|
45210
45237
|
nameLocation: 'middle',
|
|
45211
45238
|
nameTextStyle: {
|
|
@@ -45221,7 +45248,6 @@ const BASE_OPTIONS = {
|
|
|
45221
45248
|
fontSize: 16,
|
|
45222
45249
|
fontWeight: 'bold',
|
|
45223
45250
|
},
|
|
45224
|
-
name: 'Voltage (% of nominal voltage)',
|
|
45225
45251
|
nameRotate: 90,
|
|
45226
45252
|
nameGap: 40,
|
|
45227
45253
|
nameLocation: 'middle',
|
|
@@ -45326,18 +45352,32 @@ const CURVE_SERIES = [
|
|
|
45326
45352
|
},
|
|
45327
45353
|
];
|
|
45328
45354
|
|
|
45329
|
-
const iticChartCss = () => `:host{display:block;height:400px}.chart{width:100%;height:100%}`;
|
|
45355
|
+
const iticChartCss = () => `:host{display:block;height:400px;background:var(--itic-chart-background, transparent)}.chart{width:100%;height:100%}`;
|
|
45330
45356
|
|
|
45331
45357
|
// Register only what this chart uses, so bundles don't ship all of ECharts
|
|
45332
45358
|
use([install$9, install$7, install$5, install$1, install$4, install]);
|
|
45333
45359
|
const IticChart = class {
|
|
45334
45360
|
constructor(hostRef) {
|
|
45335
45361
|
registerInstance(this, hostRef);
|
|
45362
|
+
this.pointClick = createEvent(this, "pointClick");
|
|
45363
|
+
/**
|
|
45364
|
+
* Name of the duration (X) axis.
|
|
45365
|
+
*/
|
|
45366
|
+
this.xAxisName = DEFAULT_SETTINGS.xAxisName;
|
|
45367
|
+
/**
|
|
45368
|
+
* Name of the voltage (Y) axis.
|
|
45369
|
+
*/
|
|
45370
|
+
this.yAxisName = DEFAULT_SETTINGS.yAxisName;
|
|
45371
|
+
this.parsedGroups = [];
|
|
45336
45372
|
}
|
|
45337
|
-
|
|
45373
|
+
onOptionsChange() {
|
|
45338
45374
|
this.updateChart();
|
|
45339
45375
|
}
|
|
45340
45376
|
connectedCallback() {
|
|
45377
|
+
// The chart is a canvas: expose it as an image, labelled with `aria-label`, unless the consumer sets a role
|
|
45378
|
+
if (!this.el.hasAttribute('role')) {
|
|
45379
|
+
this.el.setAttribute('role', 'img');
|
|
45380
|
+
}
|
|
45341
45381
|
// componentDidLoad only fires once, so re-create the chart when the element is re-attached
|
|
45342
45382
|
this.initChart();
|
|
45343
45383
|
}
|
|
@@ -45356,6 +45396,12 @@ const IticChart = class {
|
|
|
45356
45396
|
return;
|
|
45357
45397
|
}
|
|
45358
45398
|
this.chart = init(this.container);
|
|
45399
|
+
this.chart.on('click', params => {
|
|
45400
|
+
const detail = findClickedPoint(this.parsedGroups, params);
|
|
45401
|
+
if (detail) {
|
|
45402
|
+
this.pointClick.emit(detail);
|
|
45403
|
+
}
|
|
45404
|
+
});
|
|
45359
45405
|
if (typeof ResizeObserver !== 'undefined') {
|
|
45360
45406
|
this.resizeObserver = new ResizeObserver(() => { var _a; return (_a = this.chart) === null || _a === void 0 ? void 0 : _a.resize(); });
|
|
45361
45407
|
this.resizeObserver.observe(this.container);
|
|
@@ -45363,24 +45409,40 @@ const IticChart = class {
|
|
|
45363
45409
|
this.updateChart();
|
|
45364
45410
|
}
|
|
45365
45411
|
updateChart() {
|
|
45412
|
+
var _a;
|
|
45366
45413
|
if (!this.chart) {
|
|
45367
45414
|
return;
|
|
45368
45415
|
}
|
|
45369
|
-
|
|
45416
|
+
this.parsedGroups = [];
|
|
45370
45417
|
try {
|
|
45371
|
-
|
|
45418
|
+
this.parsedGroups = parseGroups(this.groups);
|
|
45372
45419
|
}
|
|
45373
45420
|
catch (error) {
|
|
45374
45421
|
console.error('[itic-chart] Invalid "groups" prop:', error);
|
|
45375
45422
|
}
|
|
45376
|
-
this.
|
|
45423
|
+
const options = buildChartOptions(this.parsedGroups, {
|
|
45424
|
+
xAxisName: this.xAxisName,
|
|
45425
|
+
yAxisName: this.yAxisName,
|
|
45426
|
+
tooltipFormatter: (_a = this.tooltipFormatter) !== null && _a !== void 0 ? _a : DEFAULT_SETTINGS.tooltipFormatter,
|
|
45427
|
+
});
|
|
45428
|
+
this.chart.setOption(options, { notMerge: true });
|
|
45377
45429
|
}
|
|
45378
45430
|
render() {
|
|
45379
|
-
return h("div", { key: '
|
|
45431
|
+
return h("div", { key: '53914c2232775d69a35b846005931c5e20f2eee2', class: "chart", ref: el => (this.container = el) });
|
|
45380
45432
|
}
|
|
45433
|
+
get el() { return getElement(this); }
|
|
45381
45434
|
static get watchers() { return {
|
|
45382
45435
|
"groups": [{
|
|
45383
|
-
"
|
|
45436
|
+
"onOptionsChange": 0
|
|
45437
|
+
}],
|
|
45438
|
+
"xAxisName": [{
|
|
45439
|
+
"onOptionsChange": 0
|
|
45440
|
+
}],
|
|
45441
|
+
"yAxisName": [{
|
|
45442
|
+
"onOptionsChange": 0
|
|
45443
|
+
}],
|
|
45444
|
+
"tooltipFormatter": [{
|
|
45445
|
+
"onOptionsChange": 0
|
|
45384
45446
|
}]
|
|
45385
45447
|
}; }
|
|
45386
45448
|
};
|
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":[{"
|
|
8
|
+
return bootstrapLazy([["itic-chart",[[1,"itic-chart",{"groups":[1],"xAxisName":[1,"x-axis-name"],"yAxisName":[1,"y-axis-name"],"tooltipFormatter":[16]},null,{"groups":[{"onOptionsChange":0}],"xAxisName":[{"onOptionsChange":0}],"yAxisName":[{"onOptionsChange":0}],"tooltipFormatter":[{"onOptionsChange":0}]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
|
+
import { type ITICChartMarks, type ITICPointClickDetail, type ITICTooltipFormatter } 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. Extra fields in groups and points are kept and passed
|
|
7
|
+
* back in `pointClick` and `tooltipFormatter`.
|
|
5
8
|
*/
|
|
6
9
|
groups: ITICChartMarks[] | string;
|
|
10
|
+
/**
|
|
11
|
+
* Name of the duration (X) axis.
|
|
12
|
+
*/
|
|
13
|
+
xAxisName: string;
|
|
14
|
+
/**
|
|
15
|
+
* Name of the voltage (Y) axis.
|
|
16
|
+
*/
|
|
17
|
+
yAxisName: string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the HTML of a point's tooltip. JS/React property only (not an HTML attribute).
|
|
20
|
+
* The HTML is inserted as is: escaping the values is up to the formatter.
|
|
21
|
+
* Defaults to an English tooltip with phase, duration, voltage and timestamp.
|
|
22
|
+
*/
|
|
23
|
+
tooltipFormatter?: ITICTooltipFormatter;
|
|
24
|
+
/**
|
|
25
|
+
* Emitted when a clickable point is clicked (`clickable` isn't `false`). `detail` holds the original
|
|
26
|
+
* point and group objects.
|
|
27
|
+
*/
|
|
28
|
+
pointClick: EventEmitter<ITICPointClickDetail>;
|
|
7
29
|
private container?;
|
|
8
30
|
private chart?;
|
|
9
31
|
private resizeObserver?;
|
|
10
|
-
|
|
32
|
+
private parsedGroups;
|
|
33
|
+
onOptionsChange(): void;
|
|
11
34
|
connectedCallback(): void;
|
|
12
35
|
componentDidLoad(): void;
|
|
13
36
|
disconnectedCallback(): void;
|
|
@@ -3,11 +3,32 @@ export type ITICPoint = {
|
|
|
3
3
|
duration: number;
|
|
4
4
|
voltage: number;
|
|
5
5
|
ts: string;
|
|
6
|
+
/** Whether clicking the point emits `pointClick` and shows a pointer cursor. Defaults to `true`. */
|
|
7
|
+
clickable?: boolean;
|
|
8
|
+
/** Any other field is kept as is and passed back in `pointClick` and `tooltipFormatter`. */
|
|
9
|
+
[key: string]: unknown;
|
|
6
10
|
};
|
|
7
11
|
export type ITICChartMarks = {
|
|
8
12
|
points: ITICPoint[];
|
|
9
13
|
color: string;
|
|
10
14
|
groupName: string;
|
|
15
|
+
/** Any other field is kept as is and passed back in `pointClick` and `tooltipFormatter`. */
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** `detail` of the `pointClick` event: the objects passed in `groups`, not copies. */
|
|
19
|
+
export type ITICPointClickDetail = {
|
|
20
|
+
point: ITICPoint;
|
|
21
|
+
group: ITICChartMarks;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Returns the tooltip content of a point as HTML. The result is inserted as is: escape any value
|
|
25
|
+
* that may contain HTML.
|
|
26
|
+
*/
|
|
27
|
+
export type ITICTooltipFormatter = (point: ITICPoint, group: ITICChartMarks) => string;
|
|
28
|
+
export type ITICChartSettings = {
|
|
29
|
+
xAxisName: string;
|
|
30
|
+
yAxisName: string;
|
|
31
|
+
tooltipFormatter: ITICTooltipFormatter;
|
|
11
32
|
};
|
|
12
33
|
/**
|
|
13
34
|
* Normalizes the `groups` prop, which arrives as an array from JS/React
|
|
@@ -15,5 +36,18 @@ export type ITICChartMarks = {
|
|
|
15
36
|
*/
|
|
16
37
|
export declare function parseGroups(groups: ITICChartMarks[] | string | null | undefined): ITICChartMarks[];
|
|
17
38
|
export declare function escapeHtml(value: string): string;
|
|
18
|
-
|
|
19
|
-
export declare
|
|
39
|
+
/** Default tooltip, in English. Escapes every value, since they come from the consumer. */
|
|
40
|
+
export declare const defaultTooltipFormatter: ITICTooltipFormatter;
|
|
41
|
+
export declare const DEFAULT_SETTINGS: ITICChartSettings;
|
|
42
|
+
export declare const isClickable: (point: ITICPoint) => boolean;
|
|
43
|
+
export declare function buildChartOptions(groups: ITICChartMarks[], settings?: ITICChartSettings): EChartsOption;
|
|
44
|
+
/**
|
|
45
|
+
* Maps an ECharts click back to the original point and group, which `buildChartOptions` draws as
|
|
46
|
+
* scatter series after the ITIC curve series, in the same order as `groups`.
|
|
47
|
+
* Returns `undefined` for clicks outside the points and on points that aren't clickable.
|
|
48
|
+
*/
|
|
49
|
+
export declare function findClickedPoint(groups: ITICChartMarks[], { componentType, seriesIndex, dataIndex }: {
|
|
50
|
+
componentType?: string;
|
|
51
|
+
seriesIndex?: number;
|
|
52
|
+
dataIndex?: number;
|
|
53
|
+
}): ITICPointClickDetail | undefined;
|
|
@@ -5,18 +5,47 @@
|
|
|
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, ITICTooltipFormatter } from "./components/itic-chart/itic-chart.options";
|
|
9
|
+
export { ITICChartMarks, ITICPointClickDetail, ITICTooltipFormatter } 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. Extra fields in groups and points are kept and passed back in `pointClick` and `tooltipFormatter`.
|
|
14
14
|
*/
|
|
15
15
|
"groups": ITICChartMarks[] | string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the HTML of a point's tooltip. JS/React property only (not an HTML attribute). The HTML is inserted as is: escaping the values is up to the formatter. Defaults to an English tooltip with phase, duration, voltage and timestamp.
|
|
18
|
+
*/
|
|
19
|
+
"tooltipFormatter"?: ITICTooltipFormatter;
|
|
20
|
+
/**
|
|
21
|
+
* Name of the duration (X) axis.
|
|
22
|
+
* @default 'Duration (ms)'
|
|
23
|
+
*/
|
|
24
|
+
"xAxisName": string;
|
|
25
|
+
/**
|
|
26
|
+
* Name of the voltage (Y) axis.
|
|
27
|
+
* @default 'Voltage (% of nominal voltage)'
|
|
28
|
+
*/
|
|
29
|
+
"yAxisName": string;
|
|
16
30
|
}
|
|
17
31
|
}
|
|
32
|
+
export interface IticChartCustomEvent<T> extends CustomEvent<T> {
|
|
33
|
+
detail: T;
|
|
34
|
+
target: HTMLIticChartElement;
|
|
35
|
+
}
|
|
18
36
|
declare global {
|
|
37
|
+
interface HTMLIticChartElementEventMap {
|
|
38
|
+
"pointClick": ITICPointClickDetail;
|
|
39
|
+
}
|
|
19
40
|
interface HTMLIticChartElement extends Components.IticChart, HTMLStencilElement {
|
|
41
|
+
addEventListener<K extends keyof HTMLIticChartElementEventMap>(type: K, listener: (this: HTMLIticChartElement, ev: IticChartCustomEvent<HTMLIticChartElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
42
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
43
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
44
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
45
|
+
removeEventListener<K extends keyof HTMLIticChartElementEventMap>(type: K, listener: (this: HTMLIticChartElement, ev: IticChartCustomEvent<HTMLIticChartElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
|
46
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
47
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
48
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
20
49
|
}
|
|
21
50
|
var HTMLIticChartElement: {
|
|
22
51
|
prototype: HTMLIticChartElement;
|
|
@@ -29,13 +58,33 @@ declare global {
|
|
|
29
58
|
declare namespace LocalJSX {
|
|
30
59
|
interface IticChart {
|
|
31
60
|
/**
|
|
32
|
-
*
|
|
61
|
+
* Point groups, as an array or a JSON string. Extra fields in groups and points are kept and passed back in `pointClick` and `tooltipFormatter`.
|
|
33
62
|
*/
|
|
34
63
|
"groups"?: ITICChartMarks[] | 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
|
+
* Returns the HTML of a point's tooltip. JS/React property only (not an HTML attribute). The HTML is inserted as is: escaping the values is up to the formatter. Defaults to an English tooltip with phase, duration, voltage and timestamp.
|
|
70
|
+
*/
|
|
71
|
+
"tooltipFormatter"?: ITICTooltipFormatter;
|
|
72
|
+
/**
|
|
73
|
+
* Name of the duration (X) axis.
|
|
74
|
+
* @default 'Duration (ms)'
|
|
75
|
+
*/
|
|
76
|
+
"xAxisName"?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Name of the voltage (Y) axis.
|
|
79
|
+
* @default 'Voltage (% of nominal voltage)'
|
|
80
|
+
*/
|
|
81
|
+
"yAxisName"?: string;
|
|
35
82
|
}
|
|
36
83
|
|
|
37
84
|
interface IticChartAttributes {
|
|
38
85
|
"groups": ITICChartMarks[] | string;
|
|
86
|
+
"xAxisName": string;
|
|
87
|
+
"yAxisName": string;
|
|
39
88
|
}
|
|
40
89
|
|
|
41
90
|
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, ITICTooltipFormatter, } 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.2.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",
|
|
@@ -49,7 +53,9 @@
|
|
|
49
53
|
"generate": "stencil generate"
|
|
50
54
|
},
|
|
51
55
|
"dependencies": {
|
|
52
|
-
"dayjs": "^1.11.13"
|
|
56
|
+
"dayjs": "^1.11.13"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
53
59
|
"echarts": "^6.1.0"
|
|
54
60
|
},
|
|
55
61
|
"devDependencies": {
|
|
@@ -59,9 +65,10 @@
|
|
|
59
65
|
"@types/node": "^22.20.5",
|
|
60
66
|
"@vitest/browser-playwright": "5.0.5",
|
|
61
67
|
"@vitest/coverage-v8": "^5.0.5",
|
|
68
|
+
"echarts": "^6.1.0",
|
|
62
69
|
"playwright": "1.64.1",
|
|
63
70
|
"vitest": "^5.0.5"
|
|
64
71
|
},
|
|
65
72
|
"license": "MIT",
|
|
66
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "8a3014c8d5a5691aa784640a5ad5008c661e7a57"
|
|
67
74
|
}
|