@aquera/nile-visualization 2.9.31 → 2.9.33
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 +6 -0
- package/dist/src/internal/echarts/echarts-provider.d.ts +28 -0
- package/dist/src/internal/echarts/echarts-provider.js +59 -0
- package/dist/src/internal/echarts/echarts-theme.d.ts +23 -0
- package/dist/src/internal/echarts/echarts-theme.js +91 -0
- package/dist/src/internal/echarts/index.d.ts +8 -0
- package/dist/src/internal/echarts/index.js +8 -0
- package/dist/src/internal/echarts/translate-config.d.ts +41 -0
- package/dist/src/internal/echarts/translate-config.js +460 -0
- package/dist/src/internal/types/aq-config.type.d.ts +2 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +2 -0
- package/dist/src/nile-chart/nile-chart.css.js +6 -0
- package/dist/src/nile-chart/nile-chart.d.ts +13 -0
- package/dist/src/nile-chart/nile-chart.js +74 -0
- package/dist/src/nile-chart/nile-chart.smoke.test.d.ts +1 -0
- package/dist/src/nile-chart/nile-chart.smoke.test.js +87 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +1 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +7 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -36,6 +36,12 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
|
36
36
|
|
|
37
37
|
In this section, you can find the updates for each release of `nile-visualization`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
|
|
38
38
|
|
|
39
|
+
#### Version 2.9.33 (September 15, 2026)
|
|
40
|
+
- Nile KPI Chart: Fixed the hover tooltip and marker sticking on screen after a scroll (UIF-1354)
|
|
41
|
+
|
|
42
|
+
#### Version 2.9.32 (September 10, 2026)
|
|
43
|
+
- Nile Chart: Added the `noBorder` config option — set `noBorder: true` on the chart config (root or `aq`) to remove the `border-bottom` divider under the card header, so the header and the plot read as one surface. Header padding, titles and actions are untouched; it composes with `noPadding` and has no effect when the header is hidden via `noHeader`. Reflected as the `no-border` attribute, so `<nile-chart no-border>` and `el.noBorder = true` work too, and the config is kept in sync both ways — assigning a config that omits `noBorder` clears it again, the same as `noHeader` / `noPadding`. Example at `examples/no-border.html` (UIF-1352)
|
|
44
|
+
|
|
39
45
|
#### Version 2.9.31 (August 3, 2026)
|
|
40
46
|
- Nile Charts: **Forecasting moved off the dedicated chart type and onto the ordinary ones.** `<nile-line-chart>`, `<nile-spline-chart>`, `<nile-area-chart>`, `<nile-area-spline-chart>` and `<nile-column-chart>` (and the matching `<nile-chart type="line" | "spline" | "area" | "areaSpline" | "column">`) each take `enableForecasting`, a `projection` config, and series shaped `{ actual, projected, interval }` — all five delegate to one shared util, `internal/chart-forecast.ts`, so the boundary marker, the dashed span, the tinted region and the confidence band are derived identically. Everything is index based: `actual` lines up with the leading `categories` and `projected` continues from where it stops. `projection` carries `start`, `color`, `dashStyle`, `showNowLine`, `nowLabel`, `nowLineColor`, `bandLabel`, `bandColor` and an `interval` block (`name`, `color`, `opacity`, `level`, `label`); per-series `forecastColor`, `forecastDashStyle`, `intervalName`, `intervalColor`, `intervalOpacity`, `intervalLevel` and `intervalLabel` override it. Confidence bands render as an `arearange` pinned to the boundary so the cone opens out of the last measured point, appended after the real series and painted underneath by `zIndex` (so a `chart.update()` that drops a band can't leak its `lineWidth: 0` onto the line), non-interactive with its bounds reaching the tooltip through a `pointFormatter` (`80% CI: 491 – 499`). Columns get no band and no dash — `projection.color` is their only cue, and their whole split (marker, plot band and zone) sits half a category later, since Highcharts assigns a discrete point at exactly the zone value to the next zone and would otherwise recolor the last measured column. `nile-chart-click` now reports `forecast: boolean` on these five charts, and `xAxisTitle` was added to all of them. Turning `enableForecasting` off plots `actual` only — the projection is dropped, not folded into the line — and clears the overlay with it. Gaining or losing a projection animates in both directions: `chart.update()` is passed `FORECAST_UPDATE_ANIMATION`, and because Highcharts morphs a graph path only when the point count is unchanged, the exit runs in two phases (`animateForecastExit`) — the projected values are first pinned to the boundary so the line folds back and the confidence cone closes, then the measured-only series replaces it. A series can take `axis: 'secondary'` to sit on an opposite y-axis (`secondaryAxisTitle`, `secondaryAxisMin`), which is only emitted when some series asks for it, and per-series `type` mixes shapes in one chart — a `column` series inside a `spline` chart keeps column behaviour. Documented in `src/internal/chart-forecast.md`; demo at `demo/forecast.html`, and a migration reference in the same doc (UIF-1316)
|
|
41
47
|
- Nile Forecast Chart: **Removed** `<nile-forecast-chart>`, `<nile-chart type="forecast">`, the `./nile-forecast-chart` package subpath, and the `NileForecastChartConfig` / `ChartForecastConfigType` / `ForecastSeriesData` / `ForecastPoint` types. Use `enableForecasting` on the chart type you actually want; the exported forecast types are now `ForecastSeriesInput`, `ForecastIntervalRange`, `ForecastIntervalConfig`, `ForecastProjectionConfig` and `ForecastConfigFields`. The datetime-axis form is gone — label your categories instead. Converting a forecast `column` config to `bar`, `stacked` or `pie` flattens the projection into the series, since those types can't draw one (UIF-1316)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECharts provider — the engine-swap twin of highcharts-provider.ts.
|
|
3
|
+
* SCAFFOLD (2026-08-11, unwired): nothing imports this yet; see
|
|
4
|
+
* ECHARTS-MIGRATION.md at the package root for the wiring steps.
|
|
5
|
+
*
|
|
6
|
+
* - npm users: their bundler resolves `import('echarts')` from node_modules
|
|
7
|
+
* (add `echarts` to this package's dependencies when wiring).
|
|
8
|
+
* - CDN users: the dynamic import fails (bare specifier), falls back to
|
|
9
|
+
* `window.echarts`. Consumer must load ECharts via <script> before
|
|
10
|
+
* nile-visualization.
|
|
11
|
+
*
|
|
12
|
+
* ECharts needs no per-chart-type module loading — one bundle covers every
|
|
13
|
+
* series type the migration uses (the 200-line module ladder in
|
|
14
|
+
* highcharts-provider.ts has no equivalent here; that's part of the win).
|
|
15
|
+
*/
|
|
16
|
+
export type EChartsStatic = any;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a promise resolving to the ECharts namespace with the `nile`
|
|
19
|
+
* theme registered. Initialization runs once and is shared by all callers —
|
|
20
|
+
* the exact contract of getHighcharts().
|
|
21
|
+
*/
|
|
22
|
+
export declare function getECharts(): Promise<EChartsStatic>;
|
|
23
|
+
/**
|
|
24
|
+
* Re-register the theme (call after a light/dark toggle so token values are
|
|
25
|
+
* re-read) and return the namespace. Charts must be re-initialized with
|
|
26
|
+
* echarts.init(el, 'nile') to pick the refreshed theme up.
|
|
27
|
+
*/
|
|
28
|
+
export declare function refreshNileEchartsTheme(): Promise<EChartsStatic>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECharts provider — the engine-swap twin of highcharts-provider.ts.
|
|
3
|
+
* SCAFFOLD (2026-08-11, unwired): nothing imports this yet; see
|
|
4
|
+
* ECHARTS-MIGRATION.md at the package root for the wiring steps.
|
|
5
|
+
*
|
|
6
|
+
* - npm users: their bundler resolves `import('echarts')` from node_modules
|
|
7
|
+
* (add `echarts` to this package's dependencies when wiring).
|
|
8
|
+
* - CDN users: the dynamic import fails (bare specifier), falls back to
|
|
9
|
+
* `window.echarts`. Consumer must load ECharts via <script> before
|
|
10
|
+
* nile-visualization.
|
|
11
|
+
*
|
|
12
|
+
* ECharts needs no per-chart-type module loading — one bundle covers every
|
|
13
|
+
* series type the migration uses (the 200-line module ladder in
|
|
14
|
+
* highcharts-provider.ts has no equivalent here; that's part of the win).
|
|
15
|
+
*/
|
|
16
|
+
let _echarts;
|
|
17
|
+
let _initPromise = null;
|
|
18
|
+
async function init() {
|
|
19
|
+
if (_echarts)
|
|
20
|
+
return _echarts;
|
|
21
|
+
try {
|
|
22
|
+
// Literal import — echarts is a real dependency since NILE-005 wiring.
|
|
23
|
+
const mod = await import('echarts');
|
|
24
|
+
_echarts = mod.default || mod;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
_echarts = globalThis.echarts;
|
|
28
|
+
}
|
|
29
|
+
if (!_echarts) {
|
|
30
|
+
throw new Error('ECharts is required for engine="echarts". Either install it via npm ' +
|
|
31
|
+
'(`npm i echarts`) or load it globally via <script> before nile-visualization.');
|
|
32
|
+
}
|
|
33
|
+
const { registerNileEchartsTheme } = await import('./echarts-theme.js');
|
|
34
|
+
registerNileEchartsTheme(_echarts);
|
|
35
|
+
return _echarts;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns a promise resolving to the ECharts namespace with the `nile`
|
|
39
|
+
* theme registered. Initialization runs once and is shared by all callers —
|
|
40
|
+
* the exact contract of getHighcharts().
|
|
41
|
+
*/
|
|
42
|
+
export function getECharts() {
|
|
43
|
+
if (!_initPromise) {
|
|
44
|
+
_initPromise = init();
|
|
45
|
+
}
|
|
46
|
+
return _initPromise;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Re-register the theme (call after a light/dark toggle so token values are
|
|
50
|
+
* re-read) and return the namespace. Charts must be re-initialized with
|
|
51
|
+
* echarts.init(el, 'nile') to pick the refreshed theme up.
|
|
52
|
+
*/
|
|
53
|
+
export async function refreshNileEchartsTheme() {
|
|
54
|
+
const e = await getECharts();
|
|
55
|
+
const { registerNileEchartsTheme } = await import('./echarts-theme.js');
|
|
56
|
+
registerNileEchartsTheme(e);
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=echarts-provider.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nile ECharts theme — token-driven at runtime, the web-component twin of
|
|
3
|
+
* Cascade's echarts-cascade-theme.js. SCAFFOLD (2026-08-11, unwired).
|
|
4
|
+
*
|
|
5
|
+
* Reads the design tokens from the document at registration time, so the
|
|
6
|
+
* same code themes correctly in light and dark and under either token
|
|
7
|
+
* prefix (--ng-* NxtGen, --nile-* enterprise). Re-register + re-init after
|
|
8
|
+
* a theme toggle (refreshNileEchartsTheme in the provider).
|
|
9
|
+
*
|
|
10
|
+
* Rules baked in (Cascade chart contract, docs/charts-map.md):
|
|
11
|
+
* - series colors come from the palette IN ORDER — never per-series colors
|
|
12
|
+
* - 8th+ series folds to the "other" gray (enforced in translate-config)
|
|
13
|
+
* - one y-axis; axis/grid ink stays on border/text tokens
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildNileEchartsTheme(): Record<string, any>;
|
|
16
|
+
/** The gray every series beyond the 7th must fold into ("Other"). */
|
|
17
|
+
export declare function nileVizOther(): string;
|
|
18
|
+
/** Categorical slot n (1-based) of the viz palette. */
|
|
19
|
+
export declare function nileViz(n: number): string;
|
|
20
|
+
/** The reserved status-bad token (negative regions, error series). */
|
|
21
|
+
export declare function nileBad(): string;
|
|
22
|
+
/** Register (or re-register) the runtime-valued theme as `nile`. */
|
|
23
|
+
export declare function registerNileEchartsTheme(echarts: any): void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nile ECharts theme — token-driven at runtime, the web-component twin of
|
|
3
|
+
* Cascade's echarts-cascade-theme.js. SCAFFOLD (2026-08-11, unwired).
|
|
4
|
+
*
|
|
5
|
+
* Reads the design tokens from the document at registration time, so the
|
|
6
|
+
* same code themes correctly in light and dark and under either token
|
|
7
|
+
* prefix (--ng-* NxtGen, --nile-* enterprise). Re-register + re-init after
|
|
8
|
+
* a theme toggle (refreshNileEchartsTheme in the provider).
|
|
9
|
+
*
|
|
10
|
+
* Rules baked in (Cascade chart contract, docs/charts-map.md):
|
|
11
|
+
* - series colors come from the palette IN ORDER — never per-series colors
|
|
12
|
+
* - 8th+ series folds to the "other" gray (enforced in translate-config)
|
|
13
|
+
* - one y-axis; axis/grid ink stays on border/text tokens
|
|
14
|
+
*/
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
+
function cssVar(names, fallback) {
|
|
17
|
+
const cs = getComputedStyle(document.documentElement);
|
|
18
|
+
for (const n of names) {
|
|
19
|
+
const v = cs.getPropertyValue(n).trim();
|
|
20
|
+
if (v)
|
|
21
|
+
return v;
|
|
22
|
+
}
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
export function buildNileEchartsTheme() {
|
|
26
|
+
const viz = [];
|
|
27
|
+
for (let i = 1; i <= 7; i++) {
|
|
28
|
+
viz.push(cssVar([`--ng-viz-${i}`, `--nile-viz-${i}`], '#2970FF'));
|
|
29
|
+
}
|
|
30
|
+
const text = cssVar(['--ng-text', '--ng-colors-text-primary-900', '--nile-colors-text-primary-900'], '#101828');
|
|
31
|
+
const text2 = cssVar(['--ng-text-2', '--ng-colors-text-tertiary-600', '--nile-colors-text-tertiary-600'], '#475467');
|
|
32
|
+
const border = cssVar(['--ng-border', '--ng-colors-border-secondary', '--nile-colors-border-secondary'], '#EAECF0');
|
|
33
|
+
const surface = cssVar(['--ng-surface', '--ng-colors-bg-primary', '--nile-colors-bg-primary'], '#FFFFFF');
|
|
34
|
+
const font = cssVar(['--ng-font', '--ng-font-family-body', '--nile-font-family-body'], 'system-ui, sans-serif');
|
|
35
|
+
const axis = {
|
|
36
|
+
axisLine: { lineStyle: { color: border } },
|
|
37
|
+
axisTick: { show: false },
|
|
38
|
+
axisLabel: { color: text2, fontFamily: font, fontSize: 11.5 },
|
|
39
|
+
splitLine: { lineStyle: { color: border, opacity: 0.6 } },
|
|
40
|
+
nameTextStyle: { color: text2, fontFamily: font },
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
color: viz,
|
|
44
|
+
backgroundColor: 'transparent',
|
|
45
|
+
textStyle: { color: text, fontFamily: font },
|
|
46
|
+
title: {
|
|
47
|
+
textStyle: { color: text, fontFamily: font, fontSize: 14, fontWeight: 650 },
|
|
48
|
+
subtextStyle: { color: text2, fontFamily: font, fontSize: 12 },
|
|
49
|
+
},
|
|
50
|
+
legend: {
|
|
51
|
+
textStyle: { color: text2, fontFamily: font, fontSize: 11.5 },
|
|
52
|
+
icon: 'circle', itemWidth: 8, itemHeight: 8,
|
|
53
|
+
},
|
|
54
|
+
tooltip: {
|
|
55
|
+
backgroundColor: surface,
|
|
56
|
+
borderColor: border,
|
|
57
|
+
textStyle: { color: text, fontFamily: font, fontSize: 12 },
|
|
58
|
+
extraCssText: 'border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.12);',
|
|
59
|
+
},
|
|
60
|
+
categoryAxis: axis,
|
|
61
|
+
valueAxis: axis,
|
|
62
|
+
logAxis: axis,
|
|
63
|
+
timeAxis: axis,
|
|
64
|
+
line: { symbolSize: 5, lineStyle: { width: 2 } },
|
|
65
|
+
bar: { itemStyle: { borderRadius: [3, 3, 0, 0] } },
|
|
66
|
+
pie: { itemStyle: { borderColor: surface, borderWidth: 2 } },
|
|
67
|
+
radar: { axisName: { color: text2, fontFamily: font } },
|
|
68
|
+
gauge: {
|
|
69
|
+
axisLine: { lineStyle: { color: [[1, border]] } },
|
|
70
|
+
title: { color: text2, fontFamily: font },
|
|
71
|
+
detail: { color: text, fontFamily: font },
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** The gray every series beyond the 7th must fold into ("Other"). */
|
|
76
|
+
export function nileVizOther() {
|
|
77
|
+
return cssVar(['--ng-viz-other', '--nile-viz-other'], '#98A2B3');
|
|
78
|
+
}
|
|
79
|
+
/** Categorical slot n (1-based) of the viz palette. */
|
|
80
|
+
export function nileViz(n) {
|
|
81
|
+
return cssVar([`--ng-viz-${n}`, `--nile-viz-${n}`], '#2970FF');
|
|
82
|
+
}
|
|
83
|
+
/** The reserved status-bad token (negative regions, error series). */
|
|
84
|
+
export function nileBad() {
|
|
85
|
+
return cssVar(['--ng-bad', '--ng-colors-fg-error-primary', '--nile-colors-fg-error-primary'], '#D92D20');
|
|
86
|
+
}
|
|
87
|
+
/** Register (or re-register) the runtime-valued theme as `nile`. */
|
|
88
|
+
export function registerNileEchartsTheme(echarts) {
|
|
89
|
+
echarts.registerTheme('nile', buildNileEchartsTheme());
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=echarts-theme.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECharts engine for nile-chart — SCAFFOLD (2026-08-11, unwired).
|
|
3
|
+
* Wiring steps + wave plan: ECHARTS-MIGRATION.md at the package root.
|
|
4
|
+
*/
|
|
5
|
+
export { getECharts, refreshNileEchartsTheme } from './echarts-provider.js';
|
|
6
|
+
export { buildNileEchartsTheme, registerNileEchartsTheme, nileVizOther } from './echarts-theme.js';
|
|
7
|
+
export { translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES, } from './translate-config.js';
|
|
8
|
+
export type { MinimalNileChartConfig } from './translate-config.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECharts engine for nile-chart — SCAFFOLD (2026-08-11, unwired).
|
|
3
|
+
* Wiring steps + wave plan: ECHARTS-MIGRATION.md at the package root.
|
|
4
|
+
*/
|
|
5
|
+
export { getECharts, refreshNileEchartsTheme } from './echarts-provider.js';
|
|
6
|
+
export { buildNileEchartsTheme, registerNileEchartsTheme, nileVizOther } from './echarts-theme.js';
|
|
7
|
+
export { translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES, } from './translate-config.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nile-chart config → ECharts option translator.
|
|
3
|
+
* Waves 1 (native) + 2 (config, 2026-08-12) — 33 chart types total; see
|
|
4
|
+
* docs/charts-map.md, i.e. every type with a direct ECharts series
|
|
5
|
+
* equivalent. Config/custom waves extend TRANSLATORS below; see
|
|
6
|
+
* ECHARTS-MIGRATION.md for the wave plan.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately structural about input types (a minimal shape, not the full
|
|
9
|
+
* NileChartConfig union) so this file compiles while unwired; when wiring,
|
|
10
|
+
* tighten the signature to the real union from nile-chart-config.ts.
|
|
11
|
+
*
|
|
12
|
+
* Contract enforced here, regardless of what the config asks for:
|
|
13
|
+
* - ONE value axis (dual axis is banned; line-column with two scales must
|
|
14
|
+
* become two charts)
|
|
15
|
+
* - series colors come from the theme; per-series color inputs are IGNORED
|
|
16
|
+
* - an 8th+ series folds into a single "Other" series (nileVizOther gray)
|
|
17
|
+
* - legend on for ≥2 series; tooltip always
|
|
18
|
+
*/
|
|
19
|
+
export interface MinimalNileChartConfig {
|
|
20
|
+
type: string;
|
|
21
|
+
data?: any;
|
|
22
|
+
categories?: string[];
|
|
23
|
+
chartTitle?: string;
|
|
24
|
+
chartSubtitle?: string;
|
|
25
|
+
yAxisTitle?: string;
|
|
26
|
+
xAxisTitle?: string;
|
|
27
|
+
seriesName?: string;
|
|
28
|
+
legend?: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
[k: string]: any;
|
|
31
|
+
};
|
|
32
|
+
[k: string]: any;
|
|
33
|
+
}
|
|
34
|
+
export declare class EngineNotMigratedError extends Error {
|
|
35
|
+
constructor(type: string);
|
|
36
|
+
}
|
|
37
|
+
export type FieldSemantic = 'Price' | 'Percent' | 'Ratio' | 'Count' | 'Duration' | 'Bytes';
|
|
38
|
+
export declare function semanticFormatter(sem: FieldSemantic, currency?: string): (v: any) => string;
|
|
39
|
+
/** Types wave 1 covers — everything else throws EngineNotMigratedError. */
|
|
40
|
+
export declare const ECHARTS_MIGRATED_TYPES: string[];
|
|
41
|
+
export declare function translateToECharts(cfg: MinimalNileChartConfig): Record<string, any>;
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nile-chart config → ECharts option translator.
|
|
3
|
+
* Waves 1 (native) + 2 (config, 2026-08-12) — 33 chart types total; see
|
|
4
|
+
* docs/charts-map.md, i.e. every type with a direct ECharts series
|
|
5
|
+
* equivalent. Config/custom waves extend TRANSLATORS below; see
|
|
6
|
+
* ECHARTS-MIGRATION.md for the wave plan.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately structural about input types (a minimal shape, not the full
|
|
9
|
+
* NileChartConfig union) so this file compiles while unwired; when wiring,
|
|
10
|
+
* tighten the signature to the real union from nile-chart-config.ts.
|
|
11
|
+
*
|
|
12
|
+
* Contract enforced here, regardless of what the config asks for:
|
|
13
|
+
* - ONE value axis (dual axis is banned; line-column with two scales must
|
|
14
|
+
* become two charts)
|
|
15
|
+
* - series colors come from the theme; per-series color inputs are IGNORED
|
|
16
|
+
* - an 8th+ series folds into a single "Other" series (nileVizOther gray)
|
|
17
|
+
* - legend on for ≥2 series; tooltip always
|
|
18
|
+
*/
|
|
19
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
|
+
import { nileVizOther, nileBad } from './echarts-theme.js';
|
|
21
|
+
export class EngineNotMigratedError extends Error {
|
|
22
|
+
constructor(type) {
|
|
23
|
+
super(`nile-chart type "${type}" is not on the ECharts engine yet — it renders ` +
|
|
24
|
+
`via Highcharts until its wave lands. Map + effort class: docs/charts-map.md.`);
|
|
25
|
+
this.name = 'EngineNotMigratedError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// ── shared helpers ──────────────────────────────────────────────────
|
|
29
|
+
const asSeriesArray = (data) => Array.isArray(data) ? data : data ? [data] : [];
|
|
30
|
+
/** >7 series → keep first 7, sum the rest into "Other" (numeric data only). */
|
|
31
|
+
function foldSeries(series) {
|
|
32
|
+
if (series.length <= 7)
|
|
33
|
+
return series;
|
|
34
|
+
const kept = series.slice(0, 7);
|
|
35
|
+
const rest = series.slice(7);
|
|
36
|
+
const len = Math.max(...rest.map((s) => (Array.isArray(s.data) ? s.data.length : 0)), 0);
|
|
37
|
+
const other = Array.from({ length: len }, (_, i) => rest.reduce((sum, s) => sum + (Number(s.data?.[i]) || 0), 0));
|
|
38
|
+
kept.push({ name: 'Other', data: other, itemStyle: { color: nileVizOther() }, lineStyle: { color: nileVizOther() } });
|
|
39
|
+
return kept;
|
|
40
|
+
}
|
|
41
|
+
function base(cfg, seriesCount) {
|
|
42
|
+
return {
|
|
43
|
+
title: cfg.chartTitle
|
|
44
|
+
? { text: cfg.chartTitle, subtext: cfg.chartSubtitle }
|
|
45
|
+
: undefined,
|
|
46
|
+
tooltip: { trigger: 'axis' },
|
|
47
|
+
legend: { show: cfg.legend?.enabled ?? seriesCount >= 2 },
|
|
48
|
+
grid: { left: 40, right: 16, top: cfg.chartTitle ? 48 : 30, bottom: 28, containLabel: true },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function cartesian(cfg, seriesType, extra = () => ({}), horizontal = false) {
|
|
52
|
+
const series = foldSeries(asSeriesArray(cfg.data).map((s) => ({
|
|
53
|
+
name: s.name,
|
|
54
|
+
type: seriesType,
|
|
55
|
+
data: s.data ?? s.values ?? [],
|
|
56
|
+
...extra(s),
|
|
57
|
+
})));
|
|
58
|
+
const catAxis = { type: 'category', data: cfg.categories ?? [], name: cfg.xAxisTitle };
|
|
59
|
+
const valAxis = { type: 'value', name: cfg.yAxisTitle }; // the ONE value axis
|
|
60
|
+
return {
|
|
61
|
+
...base(cfg, series.length),
|
|
62
|
+
xAxis: horizontal ? valAxis : catAxis,
|
|
63
|
+
yAxis: horizontal ? catAxis : valAxis,
|
|
64
|
+
series,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function pieLike(cfg, opts) {
|
|
68
|
+
const points = asSeriesArray(cfg.data).map((p) => ({ name: p.name ?? p.label, value: p.value ?? p.y }));
|
|
69
|
+
return {
|
|
70
|
+
...base(cfg, points.length >= 2 ? 2 : 1),
|
|
71
|
+
tooltip: { trigger: 'item' },
|
|
72
|
+
series: [{ name: cfg.seriesName, type: 'pie', data: points, ...opts }],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const TRANSLATORS = {
|
|
76
|
+
line: (c) => cartesian(c, 'line'),
|
|
77
|
+
spline: (c) => cartesian(c, 'line', () => ({ smooth: true })),
|
|
78
|
+
area: (c) => cartesian(c, 'line', () => ({ areaStyle: {} })),
|
|
79
|
+
areaspline: (c) => cartesian(c, 'line', () => ({ smooth: true, areaStyle: {} })),
|
|
80
|
+
invertedarea: (c) => {
|
|
81
|
+
const o = cartesian(c, 'line', () => ({ areaStyle: {} }));
|
|
82
|
+
o.yAxis.inverse = true;
|
|
83
|
+
return o;
|
|
84
|
+
},
|
|
85
|
+
column: (c) => cartesian(c, 'bar'),
|
|
86
|
+
bar: (c) => cartesian(c, 'bar', () => ({}), /* horizontal */ true),
|
|
87
|
+
stacked: (c) => cartesian(c, 'bar', () => ({ stack: 'total' })),
|
|
88
|
+
pie: (c) => pieLike(c, { radius: '68%' }),
|
|
89
|
+
donut: (c) => pieLike(c, { radius: ['42%', '68%'] }),
|
|
90
|
+
variablepie: (c) => pieLike(c, { radius: ['20%', '68%'], roseType: 'radius' }),
|
|
91
|
+
gauge: (c) => ({
|
|
92
|
+
...base(c, 1),
|
|
93
|
+
tooltip: { trigger: 'item' },
|
|
94
|
+
series: [{
|
|
95
|
+
type: 'gauge',
|
|
96
|
+
min: c.min ?? 0,
|
|
97
|
+
max: c.max ?? 100,
|
|
98
|
+
progress: { show: true, width: 10 },
|
|
99
|
+
axisLine: { lineStyle: { width: 10 } },
|
|
100
|
+
pointer: { show: false },
|
|
101
|
+
detail: { valueAnimation: true, formatter: c.valueSuffix ? `{value}${c.valueSuffix}` : '{value}' },
|
|
102
|
+
data: [{ value: c.value ?? asSeriesArray(c.data)[0]?.value ?? 0, name: c.seriesName }],
|
|
103
|
+
}],
|
|
104
|
+
}),
|
|
105
|
+
radar: (c) => radarLike(c),
|
|
106
|
+
spiderweb: (c) => radarLike(c),
|
|
107
|
+
scatter: (c) => xyLike(c, () => ({})),
|
|
108
|
+
bubble: (c) => xyLike(c, (p) => ({ symbolSize: sizeScale(p) })),
|
|
109
|
+
heatmap: (c) => {
|
|
110
|
+
const cells = asSeriesArray(c.data).map((p) => [p.x, p.y, p.value ?? p.v]);
|
|
111
|
+
const values = cells.map((p) => Number(p[2]) || 0);
|
|
112
|
+
return {
|
|
113
|
+
...base(c, 1),
|
|
114
|
+
tooltip: { trigger: 'item' },
|
|
115
|
+
xAxis: { type: 'category', data: c.xCategories ?? c.categories ?? [] },
|
|
116
|
+
yAxis: { type: 'category', data: c.yCategories ?? [] },
|
|
117
|
+
grid: { left: 40, right: 16, top: c.chartTitle ? 48 : 30, bottom: 64, containLabel: true },
|
|
118
|
+
visualMap: {
|
|
119
|
+
min: Math.min(...values, 0), max: Math.max(...values, 1),
|
|
120
|
+
orient: 'horizontal', left: 'center', bottom: 0, calculable: true,
|
|
121
|
+
},
|
|
122
|
+
series: [{ type: 'heatmap', data: cells }],
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
boxplot: (c) => ({
|
|
126
|
+
...base(c, 1),
|
|
127
|
+
xAxis: { type: 'category', data: c.categories ?? [] },
|
|
128
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
129
|
+
series: [{
|
|
130
|
+
type: 'boxplot',
|
|
131
|
+
data: asSeriesArray(c.data).map((p) => Array.isArray(p) ? p : [p.low, p.q1, p.median, p.q3, p.high]),
|
|
132
|
+
}],
|
|
133
|
+
}),
|
|
134
|
+
};
|
|
135
|
+
function radarLike(c) {
|
|
136
|
+
const series = foldSeries(asSeriesArray(c.data).map((s) => ({ name: s.name, value: s.data ?? s.values })));
|
|
137
|
+
const max = Math.max(...series.flatMap((s) => (s.value ?? []).map(Number)), 1);
|
|
138
|
+
return {
|
|
139
|
+
...base(c, series.length),
|
|
140
|
+
tooltip: { trigger: 'item' },
|
|
141
|
+
radar: { indicator: (c.categories ?? []).map((n) => ({ name: n, max })) },
|
|
142
|
+
series: [{ type: 'radar', data: series }],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function xyLike(c, extra) {
|
|
146
|
+
const series = foldSeries(asSeriesArray(c.data).map((s) => ({
|
|
147
|
+
name: s.name,
|
|
148
|
+
type: 'scatter',
|
|
149
|
+
data: (s.data ?? []).map((p) => (Array.isArray(p) ? p : [p.x, p.y, p.z])),
|
|
150
|
+
...extra(s),
|
|
151
|
+
})));
|
|
152
|
+
return {
|
|
153
|
+
...base(c, series.length),
|
|
154
|
+
tooltip: { trigger: 'item' },
|
|
155
|
+
xAxis: { type: 'value', name: c.xAxisTitle },
|
|
156
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
157
|
+
series,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const sizeScale = (s) => (v) => Math.max(6, Math.min(40, Math.sqrt(Number(v?.[2]) || 1) * (s.sizeFactor ?? 4)));
|
|
161
|
+
// ── wave-2 translators (charts-map.md "config" effort class, 2026-08-12) ──
|
|
162
|
+
const round2 = (n) => Math.round(n * 100) / 100;
|
|
163
|
+
function binSamples(xs, k) {
|
|
164
|
+
if (!xs.length)
|
|
165
|
+
return [];
|
|
166
|
+
const lo = Math.min(...xs), hi = Math.max(...xs) || lo + 1;
|
|
167
|
+
const w = (hi - lo) / k || 1;
|
|
168
|
+
const bins = Array.from({ length: k }, (_, i) => ({ x0: lo + i * w, x1: lo + (i + 1) * w, count: 0 }));
|
|
169
|
+
for (const x of xs)
|
|
170
|
+
bins[Math.min(k - 1, Math.floor((x - lo) / w))].count++;
|
|
171
|
+
return bins;
|
|
172
|
+
}
|
|
173
|
+
function treeFromNodes(nodes, links) {
|
|
174
|
+
const byId = {};
|
|
175
|
+
nodes.forEach((n) => { byId[n.id ?? n.name] = { name: n.name ?? n.id, value: n.value, children: [] }; });
|
|
176
|
+
const hasParent = new Set();
|
|
177
|
+
links.forEach((l) => {
|
|
178
|
+
const p = byId[l.source ?? l.from], ch = byId[l.target ?? l.to];
|
|
179
|
+
if (p && ch) {
|
|
180
|
+
p.children.push(ch);
|
|
181
|
+
hasParent.add(l.target ?? l.to);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const roots = nodes.filter((n) => !hasParent.has(n.id ?? n.name)).map((n) => byId[n.id ?? n.name]);
|
|
185
|
+
return roots.length === 1 ? roots[0] : { name: 'root', children: roots };
|
|
186
|
+
}
|
|
187
|
+
const WAVE2_TRANSLATORS = {
|
|
188
|
+
waterfall: (c) => {
|
|
189
|
+
const pts = asSeriesArray(c.data).map((p) => ({
|
|
190
|
+
name: p.name ?? p.label, value: Number(p.value ?? p.y) || 0, isSum: !!(p.isSum ?? p.total),
|
|
191
|
+
}));
|
|
192
|
+
let running = 0;
|
|
193
|
+
const invisible = [], visible = [];
|
|
194
|
+
for (const p of pts) {
|
|
195
|
+
if (p.isSum) {
|
|
196
|
+
invisible.push(0);
|
|
197
|
+
visible.push(running);
|
|
198
|
+
}
|
|
199
|
+
else if (p.value >= 0) {
|
|
200
|
+
invisible.push(running);
|
|
201
|
+
visible.push(p.value);
|
|
202
|
+
running += p.value;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
running += p.value;
|
|
206
|
+
invisible.push(running);
|
|
207
|
+
visible.push(-p.value);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
...base(c, 1),
|
|
212
|
+
xAxis: { type: 'category', data: pts.map((p) => p.name) },
|
|
213
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
214
|
+
series: [
|
|
215
|
+
{ type: 'bar', stack: 'wf', itemStyle: { color: 'transparent' }, emphasis: { itemStyle: { color: 'transparent' } }, tooltip: { show: false }, data: invisible },
|
|
216
|
+
{ name: c.seriesName ?? 'Change', type: 'bar', stack: 'wf', data: visible },
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
},
|
|
220
|
+
lollipop: (c) => {
|
|
221
|
+
const o = cartesian(c, 'bar', () => ({ barWidth: 2 }));
|
|
222
|
+
const dots = o.series.map((s) => ({ name: s.name, type: 'scatter', symbolSize: 10, data: s.data }));
|
|
223
|
+
o.series = [...o.series, ...dots];
|
|
224
|
+
o.legend.show = false; // dot series would duplicate legend entries
|
|
225
|
+
return o;
|
|
226
|
+
},
|
|
227
|
+
columnpyramid: (c) => cartesian(c, 'pictorialBar', () => ({ symbol: 'triangle', symbolClip: false })),
|
|
228
|
+
radialbar: (c) => {
|
|
229
|
+
const series = foldSeries(asSeriesArray(c.data).map((s) => ({ name: s.name, type: 'bar', coordinateSystem: 'polar', data: s.data ?? s.values ?? [] })));
|
|
230
|
+
return {
|
|
231
|
+
...base(c, series.length),
|
|
232
|
+
angleAxis: { max: c.max },
|
|
233
|
+
radiusAxis: { type: 'category', data: c.categories ?? [] },
|
|
234
|
+
polar: { radius: ['18%', '78%'] },
|
|
235
|
+
series: series.map((s) => ({ ...s, stack: c.stacked ? 'total' : undefined })),
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
arearange: (c) => {
|
|
239
|
+
const pts = asSeriesArray(c.data).map((p) => (Array.isArray(p) ? { low: p[0], high: p[1] } : p));
|
|
240
|
+
return {
|
|
241
|
+
...base(c, 1),
|
|
242
|
+
xAxis: { type: 'category', data: c.categories ?? [] },
|
|
243
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
244
|
+
series: [
|
|
245
|
+
{ name: 'low', type: 'line', stack: 'range', lineStyle: { opacity: 0 }, symbol: 'none', tooltip: { show: false }, data: pts.map((p) => p.low) },
|
|
246
|
+
{ name: c.seriesName ?? 'Range', type: 'line', stack: 'range', lineStyle: { opacity: 0 }, symbol: 'none', areaStyle: { opacity: 0.35 }, data: pts.map((p) => p.high - p.low) },
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
areanegative: (c) => {
|
|
251
|
+
// Two clamped series instead of a visualMap gradient (the gradient path
|
|
252
|
+
// is fragile in SSR): the positive region keeps the categorical slot,
|
|
253
|
+
// the negative region wears the reserved status-bad token — a status
|
|
254
|
+
// semantic, so the explicit color is allowed.
|
|
255
|
+
const src = asSeriesArray(c.data)[0] ?? { data: [] };
|
|
256
|
+
const ys = (src.data ?? []).map(Number);
|
|
257
|
+
const pos = ys.map((y) => (y >= 0 ? y : 0));
|
|
258
|
+
const neg = ys.map((y) => (y < 0 ? y : 0));
|
|
259
|
+
return {
|
|
260
|
+
...base(c, 1),
|
|
261
|
+
xAxis: { type: 'category', data: c.categories ?? [], name: c.xAxisTitle },
|
|
262
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
263
|
+
legend: { show: false },
|
|
264
|
+
series: [
|
|
265
|
+
{ name: src.name ?? 'Positive', type: 'line', areaStyle: { opacity: 0.3 }, data: pos },
|
|
266
|
+
{ name: 'Negative', type: 'line', areaStyle: { opacity: 0.3 }, itemStyle: { color: nileBad() }, lineStyle: { color: nileBad() }, data: neg },
|
|
267
|
+
],
|
|
268
|
+
};
|
|
269
|
+
},
|
|
270
|
+
histogram: (c) => {
|
|
271
|
+
const bins = c.bins ?? binSamples(asSeriesArray(c.data).map(Number), c.binCount ?? 10);
|
|
272
|
+
return {
|
|
273
|
+
...base(c, 1),
|
|
274
|
+
xAxis: { type: 'category', data: bins.map((b) => `${round2(b.x0)}–${round2(b.x1)}`) },
|
|
275
|
+
yAxis: { type: 'value', name: c.yAxisTitle ?? 'Count' },
|
|
276
|
+
series: [{ name: c.seriesName ?? 'Frequency', type: 'bar', barCategoryGap: '2%', data: bins.map((b) => b.count) }],
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
bellcurve: (c) => {
|
|
280
|
+
const xs = asSeriesArray(c.data).map(Number);
|
|
281
|
+
const mean = xs.reduce((a, b) => a + b, 0) / (xs.length || 1);
|
|
282
|
+
const sd = Math.sqrt(xs.reduce((a, b) => a + (b - mean) ** 2, 0) / (xs.length || 1)) || 1;
|
|
283
|
+
const curve = [];
|
|
284
|
+
for (let i = -3; i <= 3; i += 0.25) {
|
|
285
|
+
const x = mean + i * sd;
|
|
286
|
+
curve.push([round2(x), round2(Math.exp(-((x - mean) ** 2) / (2 * sd * sd)) / (sd * Math.sqrt(2 * Math.PI)))]);
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
...base(c, 1),
|
|
290
|
+
xAxis: { type: 'value', name: c.xAxisTitle },
|
|
291
|
+
yAxis: { type: 'value', name: c.yAxisTitle ?? 'Density' },
|
|
292
|
+
series: [{ name: c.seriesName ?? 'Distribution', type: 'line', smooth: true, symbol: 'none', areaStyle: { opacity: 0.25 }, data: curve }],
|
|
293
|
+
};
|
|
294
|
+
},
|
|
295
|
+
columndrilldown: (c) => {
|
|
296
|
+
// top level only — the click-swap recipe lives in the wrapper (ECHARTS-MIGRATION.md)
|
|
297
|
+
const parents = asSeriesArray(c.data).map((p) => ({ name: p.name, value: p.y ?? p.value }));
|
|
298
|
+
return {
|
|
299
|
+
...base(c, 1),
|
|
300
|
+
xAxis: { type: 'category', data: parents.map((p) => p.name) },
|
|
301
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
302
|
+
series: [{ name: c.seriesName ?? 'Total', type: 'bar', data: parents.map((p) => p.value) }],
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
trendline: (c) => {
|
|
306
|
+
const o = cartesian(c, 'line');
|
|
307
|
+
const first = o.series[0];
|
|
308
|
+
const ys = (first?.data ?? []).map(Number);
|
|
309
|
+
if (ys.length >= 2) {
|
|
310
|
+
const n = ys.length, sx = (n * (n - 1)) / 2, sxx = ys.reduce((a, _y, i) => a + i * i, 0);
|
|
311
|
+
const sy = ys.reduce((a, b) => a + b, 0), sxy = ys.reduce((a, b, i) => a + i * b, 0);
|
|
312
|
+
const m = (n * sxy - sx * sy) / (n * sxx - sx * sx || 1), b0 = (sy - m * sx) / n;
|
|
313
|
+
o.series.push({ name: 'Trend', type: 'line', symbol: 'none', lineStyle: { type: 'dashed', width: 1.5 }, data: ys.map((_y, i) => round2(m * i + b0)) });
|
|
314
|
+
}
|
|
315
|
+
return o;
|
|
316
|
+
},
|
|
317
|
+
anomaly: (c) => {
|
|
318
|
+
const o = cartesian(c, 'line');
|
|
319
|
+
const flagged = asSeriesArray(c.anomalies ?? c.flagged ?? []).map((a) => ({
|
|
320
|
+
coord: [a.x ?? a.index, a.y ?? a.value], value: a.label ?? '!',
|
|
321
|
+
}));
|
|
322
|
+
if (flagged.length && o.series.length) {
|
|
323
|
+
o.series[0].markPoint = { data: flagged, symbolSize: 34 };
|
|
324
|
+
}
|
|
325
|
+
return o;
|
|
326
|
+
},
|
|
327
|
+
'master-detail': (c) => {
|
|
328
|
+
const o = cartesian(c, 'line');
|
|
329
|
+
return { ...o, dataZoom: [{ type: 'slider', height: 22, bottom: 4 }, { type: 'inside' }], grid: { ...o.grid, bottom: 58 } };
|
|
330
|
+
},
|
|
331
|
+
'line-column': (c) => {
|
|
332
|
+
// ONE value axis (dual axis is banned) — series carry their own form
|
|
333
|
+
const series = foldSeries(asSeriesArray(c.data).map((s) => ({ name: s.name, type: (s.seriesType === 'column' || s.type === 'column') ? 'bar' : 'line', data: s.data ?? [] })));
|
|
334
|
+
return {
|
|
335
|
+
...base(c, series.length),
|
|
336
|
+
xAxis: { type: 'category', data: c.categories ?? [] },
|
|
337
|
+
yAxis: { type: 'value', name: c.yAxisTitle },
|
|
338
|
+
series,
|
|
339
|
+
};
|
|
340
|
+
},
|
|
341
|
+
cluster: (c) => ({
|
|
342
|
+
...base(c, 1),
|
|
343
|
+
tooltip: { trigger: 'item' },
|
|
344
|
+
series: [{
|
|
345
|
+
type: 'graph', layout: 'force', roam: true, label: { show: true },
|
|
346
|
+
force: { repulsion: 120, edgeLength: 60 },
|
|
347
|
+
data: asSeriesArray(c.nodes ?? c.data).map((n) => ({ name: n.name ?? n.id, value: n.value, symbolSize: Math.max(10, Math.min(40, Number(n.value) || 14)), category: n.group })),
|
|
348
|
+
links: asSeriesArray(c.links ?? []).map((l) => ({ source: l.source ?? l.from, target: l.target ?? l.to })),
|
|
349
|
+
categories: [...new Set(asSeriesArray(c.nodes ?? c.data).map((n) => n.group).filter(Boolean))].map((g) => ({ name: String(g) })),
|
|
350
|
+
}],
|
|
351
|
+
}),
|
|
352
|
+
organization: (c) => ({
|
|
353
|
+
...base(c, 1),
|
|
354
|
+
tooltip: { trigger: 'item' },
|
|
355
|
+
series: [{
|
|
356
|
+
type: 'tree', orient: 'TB', layout: 'orthogonal', symbolSize: 14,
|
|
357
|
+
label: { position: 'top' }, leaves: { label: { position: 'bottom' } },
|
|
358
|
+
expandAndCollapse: false,
|
|
359
|
+
data: [c.tree ?? treeFromNodes(asSeriesArray(c.nodes ?? c.data), asSeriesArray(c.links ?? []))],
|
|
360
|
+
}],
|
|
361
|
+
}),
|
|
362
|
+
fan: (c) => ({
|
|
363
|
+
...base(c, 1),
|
|
364
|
+
tooltip: { trigger: 'item' },
|
|
365
|
+
series: [{
|
|
366
|
+
type: 'gauge', startAngle: 180, endAngle: 0, min: c.min ?? 0, max: c.max ?? 100,
|
|
367
|
+
progress: { show: true, width: 14 }, axisLine: { lineStyle: { width: 14 } },
|
|
368
|
+
pointer: { show: false }, axisTick: { show: false }, splitLine: { show: false },
|
|
369
|
+
detail: { valueAnimation: true }, data: [{ value: c.value ?? 0, name: c.seriesName }],
|
|
370
|
+
}],
|
|
371
|
+
}),
|
|
372
|
+
map: (c) => {
|
|
373
|
+
// topology must be registered by the caller: echarts.registerMap(c.mapName, topo)
|
|
374
|
+
if (!c.mapName)
|
|
375
|
+
throw new EngineNotMigratedError('map (no mapName — register a topology first)');
|
|
376
|
+
const values = asSeriesArray(c.data).map((p) => Number(p.value) || 0);
|
|
377
|
+
return {
|
|
378
|
+
...base(c, 1),
|
|
379
|
+
tooltip: { trigger: 'item' },
|
|
380
|
+
visualMap: { min: Math.min(...values, 0), max: Math.max(...values, 1), left: 0, bottom: 0, calculable: true },
|
|
381
|
+
series: [{ type: 'map', map: c.mapName, data: asSeriesArray(c.data).map((p) => ({ name: p.name ?? p['hc-key'], value: p.value })) }],
|
|
382
|
+
};
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
Object.assign(TRANSLATORS, WAVE2_TRANSLATORS);
|
|
386
|
+
function abbrevNum(n) {
|
|
387
|
+
const a = Math.abs(n);
|
|
388
|
+
const f = (v) => {
|
|
389
|
+
const s = v.toFixed(1);
|
|
390
|
+
return s.endsWith('.0') ? s.slice(0, -2) : s;
|
|
391
|
+
};
|
|
392
|
+
if (a >= 1e9)
|
|
393
|
+
return f(n / 1e9) + 'B';
|
|
394
|
+
if (a >= 1e6)
|
|
395
|
+
return f(n / 1e6) + 'M';
|
|
396
|
+
if (a >= 1e3)
|
|
397
|
+
return f(n / 1e3) + 'k';
|
|
398
|
+
return f(n);
|
|
399
|
+
}
|
|
400
|
+
export function semanticFormatter(sem, currency = '$') {
|
|
401
|
+
const fmt = {
|
|
402
|
+
Price: (n) => currency + abbrevNum(n),
|
|
403
|
+
Percent: (n) => (Math.round(n * 10) / 10) + '%', // values on a 0–100 scale
|
|
404
|
+
Ratio: (n) => (Math.round(n * 1000) / 10) + '%', // values on a 0–1 scale
|
|
405
|
+
Count: (n) => abbrevNum(n),
|
|
406
|
+
Bytes: (n) => {
|
|
407
|
+
const u = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
408
|
+
let i = 0, v = Math.abs(n);
|
|
409
|
+
while (v >= 1024 && i < u.length - 1) {
|
|
410
|
+
v /= 1024;
|
|
411
|
+
i++;
|
|
412
|
+
}
|
|
413
|
+
return abbrevNum(n < 0 ? -v : v) + ' ' + u[i];
|
|
414
|
+
},
|
|
415
|
+
Duration: (n) => {
|
|
416
|
+
if (n < 60)
|
|
417
|
+
return Math.round(n) + 's';
|
|
418
|
+
if (n < 3600)
|
|
419
|
+
return Math.floor(n / 60) + 'm ' + String(Math.round(n % 60)).padStart(2, '0') + 's';
|
|
420
|
+
return Math.floor(n / 3600) + 'h ' + String(Math.floor((n % 3600) / 60)).padStart(2, '0') + 'm';
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
const f = fmt[sem];
|
|
424
|
+
return (v) => (typeof v === 'number' && f ? f(v) : String(v ?? ''));
|
|
425
|
+
}
|
|
426
|
+
/** Wire declared semantics into a built option (axis labels + tooltip). */
|
|
427
|
+
function applySemantics(option, cfg) {
|
|
428
|
+
const sems = cfg.semantics;
|
|
429
|
+
if (!sems)
|
|
430
|
+
return;
|
|
431
|
+
const currency = cfg.currency ?? '$';
|
|
432
|
+
const wire = (axis, sem) => {
|
|
433
|
+
if (!axis || !sem)
|
|
434
|
+
return;
|
|
435
|
+
(Array.isArray(axis) ? axis : [axis]).forEach((a) => {
|
|
436
|
+
if (a.type === 'value')
|
|
437
|
+
a.axisLabel = { ...(a.axisLabel ?? {}), formatter: semanticFormatter(sem, currency) };
|
|
438
|
+
});
|
|
439
|
+
};
|
|
440
|
+
wire(option.xAxis, sems.x);
|
|
441
|
+
wire(option.yAxis, sems.y);
|
|
442
|
+
const vSem = sems.value ?? sems.y ?? sems.x;
|
|
443
|
+
if (vSem && option.tooltip) {
|
|
444
|
+
option.tooltip.valueFormatter = semanticFormatter(vSem, currency);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// ── entry point ─────────────────────────────────────────────────────
|
|
448
|
+
/** Types wave 1 covers — everything else throws EngineNotMigratedError. */
|
|
449
|
+
export const ECHARTS_MIGRATED_TYPES = Object.keys(TRANSLATORS);
|
|
450
|
+
export function translateToECharts(cfg) {
|
|
451
|
+
const t = TRANSLATORS[cfg.type];
|
|
452
|
+
if (!t)
|
|
453
|
+
throw new EngineNotMigratedError(cfg.type);
|
|
454
|
+
const option = t(cfg);
|
|
455
|
+
applySemantics(option, cfg); // NILE-007
|
|
456
|
+
if (option.title === undefined)
|
|
457
|
+
delete option.title;
|
|
458
|
+
return option;
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=translate-config.js.map
|
|
@@ -11,6 +11,8 @@ export interface AqConfigType {
|
|
|
11
11
|
subtitleFontSize?: string | number;
|
|
12
12
|
/** Hide the chart header (title/subtitle/actions) entirely. */
|
|
13
13
|
noHeader?: boolean;
|
|
14
|
+
/** Remove the `border-bottom` divider under the header, keeping the header itself. */
|
|
15
|
+
noBorder?: boolean;
|
|
14
16
|
summary?: string;
|
|
15
17
|
toggleLabel?: string;
|
|
16
18
|
/** AI chat panel configuration. */
|
|
@@ -97,6 +97,8 @@ export interface NileChartConfigBase extends HighchartsPassthroughConfig {
|
|
|
97
97
|
subtitleFontSize?: string | number;
|
|
98
98
|
noHeader?: boolean;
|
|
99
99
|
noPadding?: boolean;
|
|
100
|
+
/** Remove the `border-bottom` divider under the header (maps to the `no-border` attribute). */
|
|
101
|
+
noBorder?: boolean;
|
|
100
102
|
height?: string;
|
|
101
103
|
loading?: boolean;
|
|
102
104
|
options?: HighchartsOptions;
|
|
@@ -155,6 +155,12 @@ export const styles = css `
|
|
|
155
155
|
padding: var(--nile-spacing-xl, var(--ng-spacing-xl)) var(--nile-spacing-3xl, var(--ng-spacing-3xl)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/* no-border - drop the divider between the header and the plot. The header
|
|
159
|
+
keeps its padding; only the 1px rule goes, so the card reads as one surface. */
|
|
160
|
+
:host([no-border]) .nile-chart-header {
|
|
161
|
+
border-bottom: none;
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
.nile-chart-header-titles {
|
|
159
165
|
display: flex;
|
|
160
166
|
flex-direction: column;
|
|
@@ -102,7 +102,15 @@ export declare class NileChart extends NileElement {
|
|
|
102
102
|
loading: boolean;
|
|
103
103
|
noHeader: boolean;
|
|
104
104
|
noPadding: boolean;
|
|
105
|
+
noBorder: boolean;
|
|
105
106
|
appearance: string | null;
|
|
107
|
+
/**
|
|
108
|
+
* Chart engine (NILE-005, ECHARTS-MIGRATION.md). Default 'highcharts'.
|
|
109
|
+
* 'echarts' renders migrated types via the ECharts engine; types not yet
|
|
110
|
+
* migrated log a warning and fall back to Highcharts automatically, so a
|
|
111
|
+
* flipped flag can never blank a chart.
|
|
112
|
+
*/
|
|
113
|
+
engine: 'highcharts' | 'echarts';
|
|
106
114
|
/**
|
|
107
115
|
* Opt-in double-tap-to-minimize gesture. Double-tap the header to hide it —
|
|
108
116
|
* the plot expands to fill the freed space; double-tap the chart again to
|
|
@@ -243,6 +251,11 @@ export declare class NileChart extends NileElement {
|
|
|
243
251
|
private _syncHeaderTruncationA11y;
|
|
244
252
|
private renderHeader;
|
|
245
253
|
private renderAiPanel;
|
|
254
|
+
private _echart;
|
|
255
|
+
private _echartsFallback;
|
|
256
|
+
private _echartsResizeObs;
|
|
257
|
+
private _disposeEcharts;
|
|
258
|
+
private _initEcharts;
|
|
246
259
|
private renderChartContent;
|
|
247
260
|
private renderSkeleton;
|
|
248
261
|
render(): TemplateResult;
|
|
@@ -10,6 +10,7 @@ import { renderChartSkeleton } from './nile-chart-skeleton.js';
|
|
|
10
10
|
import { convertConfig } from '../internal/utils/chart-adapters.js';
|
|
11
11
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
12
12
|
import { initNileChartExporting, getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
13
|
+
import { getECharts, translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES } from '../internal/echarts/index.js';
|
|
13
14
|
import { getAxisExtremes, setAxisExtremes, } from '../internal/utils/chart-runtime.js';
|
|
14
15
|
import { resolveColorPaletteColors } from '../internal/color-palettes/index.js';
|
|
15
16
|
initNileChartExporting();
|
|
@@ -180,7 +181,15 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
180
181
|
this.loading = false;
|
|
181
182
|
this.noHeader = false;
|
|
182
183
|
this.noPadding = false;
|
|
184
|
+
this.noBorder = false;
|
|
183
185
|
this.appearance = null;
|
|
186
|
+
/**
|
|
187
|
+
* Chart engine (NILE-005, ECHARTS-MIGRATION.md). Default 'highcharts'.
|
|
188
|
+
* 'echarts' renders migrated types via the ECharts engine; types not yet
|
|
189
|
+
* migrated log a warning and fall back to Highcharts automatically, so a
|
|
190
|
+
* flipped flag can never blank a chart.
|
|
191
|
+
*/
|
|
192
|
+
this.engine = 'highcharts';
|
|
184
193
|
/**
|
|
185
194
|
* Opt-in double-tap-to-minimize gesture. Double-tap the header to hide it —
|
|
186
195
|
* the plot expands to fill the freed space; double-tap the chart again to
|
|
@@ -283,6 +292,10 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
283
292
|
const rect = el.getBoundingClientRect();
|
|
284
293
|
this._showHeaderTip(el.textContent ?? '', rect.left + rect.width / 2, rect.top);
|
|
285
294
|
};
|
|
295
|
+
// ── ECharts engine path (NILE-005) ──────────────────────────────
|
|
296
|
+
this._echart = null;
|
|
297
|
+
this._echartsFallback = false;
|
|
298
|
+
this._echartsResizeObs = null;
|
|
286
299
|
}
|
|
287
300
|
onMasterZoom(e) {
|
|
288
301
|
this.masterZoomed = !!e.detail?.zoomed;
|
|
@@ -379,6 +392,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
379
392
|
this._headerResizeObs?.disconnect();
|
|
380
393
|
this._headerResizeObs = null;
|
|
381
394
|
this._teardownExtremesEvents();
|
|
395
|
+
this._disposeEcharts();
|
|
382
396
|
this._readyResolvers = [];
|
|
383
397
|
}
|
|
384
398
|
mergeChartTypeFromAttr(chart) {
|
|
@@ -398,6 +412,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
398
412
|
return this.mergeChartTypeFromAttr({ ...input });
|
|
399
413
|
}
|
|
400
414
|
updated(changedProperties) {
|
|
415
|
+
if (changedProperties.has('engine')) {
|
|
416
|
+
this._echartsFallback = false; // re-evaluate on every engine flip
|
|
417
|
+
if (this.engine !== 'echarts')
|
|
418
|
+
this._disposeEcharts();
|
|
419
|
+
}
|
|
401
420
|
if ((changedProperties.has('config') || changedProperties.has('chartTypeAttr')) && this.config) {
|
|
402
421
|
this.resolvedConfig = this.resolveConfig(this.config);
|
|
403
422
|
this.activeType = this.resolvedConfig.type;
|
|
@@ -413,6 +432,8 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
413
432
|
this.noHeader = cfgNoHeader;
|
|
414
433
|
if (this.noPadding !== (resolved.noPadding === true))
|
|
415
434
|
this.noPadding = resolved.noPadding === true;
|
|
435
|
+
if (this.noBorder !== (resolved.noBorder === true))
|
|
436
|
+
this.noBorder = resolved.noBorder === true;
|
|
416
437
|
if (resolved.appearance && this.appearance !== resolved.appearance)
|
|
417
438
|
this.appearance = resolved.appearance;
|
|
418
439
|
}
|
|
@@ -836,8 +857,55 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
836
857
|
</div>
|
|
837
858
|
`;
|
|
838
859
|
}
|
|
860
|
+
_disposeEcharts() {
|
|
861
|
+
this._echartsResizeObs?.disconnect();
|
|
862
|
+
this._echartsResizeObs = null;
|
|
863
|
+
try {
|
|
864
|
+
this._echart?.dispose?.();
|
|
865
|
+
}
|
|
866
|
+
catch { /* already disposed */ }
|
|
867
|
+
this._echart = null;
|
|
868
|
+
}
|
|
869
|
+
async _initEcharts(config) {
|
|
870
|
+
await this.updateComplete;
|
|
871
|
+
const host = this.shadowRoot?.querySelector('.nile-echarts-host');
|
|
872
|
+
if (!host)
|
|
873
|
+
return;
|
|
874
|
+
try {
|
|
875
|
+
const echarts = await getECharts();
|
|
876
|
+
if (!this.shadowRoot?.contains(host))
|
|
877
|
+
return; // re-rendered while loading
|
|
878
|
+
this._disposeEcharts();
|
|
879
|
+
this._echart = echarts.init(host, 'nile');
|
|
880
|
+
this._echart.setOption(translateToECharts(config));
|
|
881
|
+
this._echartsResizeObs = new ResizeObserver(() => this._echart?.resize());
|
|
882
|
+
this._echartsResizeObs.observe(host);
|
|
883
|
+
this.emit('nile-chart-ready', { chart: this._echart, engine: 'echarts' });
|
|
884
|
+
}
|
|
885
|
+
catch (err) {
|
|
886
|
+
const why = err instanceof EngineNotMigratedError ? err.message : String(err);
|
|
887
|
+
// eslint-disable-next-line no-console
|
|
888
|
+
console.warn(`[nile-chart] echarts engine failed (${why}) — falling back to Highcharts.`);
|
|
889
|
+
this._disposeEcharts();
|
|
890
|
+
this._echartsFallback = true;
|
|
891
|
+
this.requestUpdate();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
839
894
|
renderChartContent() {
|
|
840
895
|
const config = this.activeConfig;
|
|
896
|
+
if (this.engine === 'echarts' && !this._echartsFallback) {
|
|
897
|
+
if (ECHARTS_MIGRATED_TYPES.includes(config.type)) {
|
|
898
|
+
void this._initEcharts(config);
|
|
899
|
+
return html `<div
|
|
900
|
+
class="nile-echarts-host"
|
|
901
|
+
part="echarts-host"
|
|
902
|
+
style="width:100%;height:${config.height ?? '400px'}"
|
|
903
|
+
></div>`;
|
|
904
|
+
}
|
|
905
|
+
// eslint-disable-next-line no-console
|
|
906
|
+
console.warn(`[nile-chart] engine="echarts": type "${config.type}" is not on the ECharts engine yet — rendering via Highcharts (waves: ECHARTS-MIGRATION.md).`);
|
|
907
|
+
this._echartsFallback = true;
|
|
908
|
+
}
|
|
841
909
|
// Suppress inner Highcharts title/subtitle — the card header shows them
|
|
842
910
|
const noTitle = { title: { text: undefined }, subtitle: { text: undefined } };
|
|
843
911
|
// Translate config.legend → Highcharts legend options and merge early so every
|
|
@@ -2224,9 +2292,15 @@ __decorate([
|
|
|
2224
2292
|
__decorate([
|
|
2225
2293
|
property({ type: Boolean, reflect: true, attribute: 'no-padding' })
|
|
2226
2294
|
], NileChart.prototype, "noPadding", void 0);
|
|
2295
|
+
__decorate([
|
|
2296
|
+
property({ type: Boolean, reflect: true, attribute: 'no-border' })
|
|
2297
|
+
], NileChart.prototype, "noBorder", void 0);
|
|
2227
2298
|
__decorate([
|
|
2228
2299
|
property({ type: String, reflect: true })
|
|
2229
2300
|
], NileChart.prototype, "appearance", void 0);
|
|
2301
|
+
__decorate([
|
|
2302
|
+
property({ type: String, reflect: true })
|
|
2303
|
+
], NileChart.prototype, "engine", void 0);
|
|
2230
2304
|
__decorate([
|
|
2231
2305
|
property({ type: Boolean, reflect: true, attribute: 'minimize-on-double-tap' })
|
|
2232
2306
|
], NileChart.prototype, "minimizeOnDoubleTap", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './nile-chart';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NILE-001 smoke suite — nile-chart (house style: see nile-elements tests).
|
|
3
|
+
* Gate item AC-5: run on a dev machine via `yarn workspace @aquera/nile-visualization test`.
|
|
4
|
+
* Deep per-chart-type coverage (incl. ECharts translator parity) is NILE-003.
|
|
5
|
+
*/
|
|
6
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
7
|
+
import './nile-chart';
|
|
8
|
+
describe('NileChart (smoke)', () => {
|
|
9
|
+
it('1. is defined', () => { expect(customElements.get('nile-chart')).to.exist; });
|
|
10
|
+
it('2. renders', async () => { const el = await fixture(html `<nile-chart></nile-chart>`); expect(el).to.exist; });
|
|
11
|
+
it('3. shadow root open', async () => { const el = await fixture(html `<nile-chart></nile-chart>`); expect(el.shadowRoot).to.not.be.null; });
|
|
12
|
+
it('4. tag name', async () => { const el = await fixture(html `<nile-chart></nile-chart>`); expect(el.tagName.toLowerCase()).to.equal('nile-chart'); });
|
|
13
|
+
it('5. accepts a line config without throwing', async () => {
|
|
14
|
+
const el = await fixture(html `<nile-chart></nile-chart>`);
|
|
15
|
+
el.config = { chart: { type: 'line', data: [{ name: 'A', data: [1, 2, 3] }], categories: ['x', 'y', 'z'] } };
|
|
16
|
+
await el.updateComplete;
|
|
17
|
+
expect(el.isConnected).to.be.true;
|
|
18
|
+
});
|
|
19
|
+
it('6. removal disconnects', async () => { const el = await fixture(html `<nile-chart></nile-chart>`); el.remove(); expect(el.isConnected).to.be.false; });
|
|
20
|
+
describe('no-border', () => {
|
|
21
|
+
// Assigning `config` syncs noBorder/noHeader/noPadding from inside `updated()`,
|
|
22
|
+
// which schedules a second update — so one `updateComplete` is not enough for
|
|
23
|
+
// either the reflected attribute or the freshly-rendered header to be there.
|
|
24
|
+
const settle = async (el) => {
|
|
25
|
+
await el.updateComplete;
|
|
26
|
+
await el.updateComplete;
|
|
27
|
+
await new Promise(requestAnimationFrame);
|
|
28
|
+
};
|
|
29
|
+
// The header divider is token-valued. No token stylesheet is loaded in the
|
|
30
|
+
// test page, so an unresolved var() makes the whole `border-bottom` shorthand
|
|
31
|
+
// invalid and the style computes to `none` regardless of this flag — which
|
|
32
|
+
// would make the default case pass for the wrong reason. Supply the tokens on
|
|
33
|
+
// the host (custom properties inherit into the shadow root) so `solid` vs
|
|
34
|
+
// `none` measures the `no-border` rule and nothing else.
|
|
35
|
+
const withTokens = (el) => {
|
|
36
|
+
el.style.setProperty('--nile-border-width-1', '1px');
|
|
37
|
+
el.style.setProperty('--nile-colors-neutral-400', '#e6e9eb');
|
|
38
|
+
return el;
|
|
39
|
+
};
|
|
40
|
+
const headerBorder = (el) => {
|
|
41
|
+
const header = el.shadowRoot.querySelector('.nile-chart-header');
|
|
42
|
+
expect(header, 'header should be rendered').to.exist;
|
|
43
|
+
return getComputedStyle(header).borderBottomStyle;
|
|
44
|
+
};
|
|
45
|
+
const lineConfig = (extra = {}) => ({
|
|
46
|
+
chart: { type: 'line', data: [{ name: 'A', data: [1, 2, 3] }], categories: ['x', 'y', 'z'] },
|
|
47
|
+
aq: { chartTitle: 'T', ...extra },
|
|
48
|
+
});
|
|
49
|
+
it('7. defaults to off and keeps the header divider', async () => {
|
|
50
|
+
const el = withTokens(await fixture(html `<nile-chart></nile-chart>`));
|
|
51
|
+
el.config = lineConfig();
|
|
52
|
+
await settle(el);
|
|
53
|
+
expect(el.noBorder).to.be.false;
|
|
54
|
+
expect(el.hasAttribute('no-border')).to.be.false;
|
|
55
|
+
expect(headerBorder(el)).to.equal('solid');
|
|
56
|
+
});
|
|
57
|
+
it('8. removes the header border-bottom when set', async () => {
|
|
58
|
+
const el = withTokens(await fixture(html `<nile-chart no-border></nile-chart>`));
|
|
59
|
+
el.config = lineConfig({ noBorder: true });
|
|
60
|
+
await settle(el);
|
|
61
|
+
expect(el.noBorder).to.be.true;
|
|
62
|
+
expect(headerBorder(el)).to.equal('none');
|
|
63
|
+
});
|
|
64
|
+
it('9. reflects the attribute when set as a property', async () => {
|
|
65
|
+
const el = await fixture(html `<nile-chart></nile-chart>`);
|
|
66
|
+
el.noBorder = true;
|
|
67
|
+
await el.updateComplete;
|
|
68
|
+
expect(el.hasAttribute('no-border')).to.be.true;
|
|
69
|
+
el.noBorder = false;
|
|
70
|
+
await el.updateComplete;
|
|
71
|
+
expect(el.hasAttribute('no-border')).to.be.false;
|
|
72
|
+
});
|
|
73
|
+
it('10. picks noBorder up from the config, both ways', async () => {
|
|
74
|
+
const el = await fixture(html `<nile-chart></nile-chart>`);
|
|
75
|
+
el.config = lineConfig({ noBorder: true });
|
|
76
|
+
await settle(el);
|
|
77
|
+
expect(el.noBorder).to.be.true;
|
|
78
|
+
expect(el.hasAttribute('no-border')).to.be.true;
|
|
79
|
+
// A config that omits noBorder clears it again (same as noHeader/noPadding).
|
|
80
|
+
el.config = lineConfig();
|
|
81
|
+
await settle(el);
|
|
82
|
+
expect(el.noBorder).to.be.false;
|
|
83
|
+
expect(el.hasAttribute('no-border')).to.be.false;
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=nile-chart.smoke.test.js.map
|
|
@@ -166,6 +166,9 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
166
166
|
* Set by nile-chart: skip host border/shadow (variant card/gauge) so the parent chart-card is the only frame.
|
|
167
167
|
*/
|
|
168
168
|
this.embedInNileChart = false;
|
|
169
|
+
this._onViewportChange = () => {
|
|
170
|
+
this._hideTip();
|
|
171
|
+
};
|
|
169
172
|
// ── Chart sizing ─────────────────────────────────────────────────────────
|
|
170
173
|
this._lastSparkSize = { w: 0, h: 0 };
|
|
171
174
|
this._lastGaugeSize = { w: 0, h: 0 };
|
|
@@ -658,6 +661,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
658
661
|
super.connectedCallback();
|
|
659
662
|
ensureTooltipStyles();
|
|
660
663
|
this._createTipEl();
|
|
664
|
+
document.addEventListener('scroll', this._onViewportChange, { capture: true, passive: true });
|
|
665
|
+
window.addEventListener('resize', this._onViewportChange, { passive: true });
|
|
661
666
|
if (!this._hc) {
|
|
662
667
|
getHighcharts().then(hc => { this._hc = hc; this.requestUpdate(); });
|
|
663
668
|
}
|
|
@@ -666,6 +671,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
666
671
|
}
|
|
667
672
|
disconnectedCallback() {
|
|
668
673
|
super.disconnectedCallback();
|
|
674
|
+
document.removeEventListener('scroll', this._onViewportChange, { capture: true });
|
|
675
|
+
window.removeEventListener('resize', this._onViewportChange);
|
|
669
676
|
this._hideTip();
|
|
670
677
|
this._tipEl?.remove();
|
|
671
678
|
this._tipEl = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aquera/nile-visualization",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.33",
|
|
4
4
|
"description": "A visualization Library for the Nile Design System",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aquera Inc",
|
|
@@ -57,13 +57,15 @@
|
|
|
57
57
|
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
58
58
|
"build": "tsc",
|
|
59
59
|
"package": "rollup -c",
|
|
60
|
-
"clean": "rimraf dist/*"
|
|
60
|
+
"clean": "rimraf dist/*",
|
|
61
|
+
"test": "tsc && wtr"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"filtrex": "^3.0.0",
|
|
64
65
|
"gridstack": "12.6.0",
|
|
65
66
|
"jsep": "^1.3.9",
|
|
66
|
-
"lit": "^3.0.0"
|
|
67
|
+
"lit": "^3.0.0",
|
|
68
|
+
"echarts": "^6.1.0"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
69
71
|
"highcharts": "12.5.0",
|
|
@@ -83,6 +85,9 @@
|
|
|
83
85
|
"rollup-plugin-summary": "^2.0.0",
|
|
84
86
|
"rollup-plugin-terser": "^7.0.2",
|
|
85
87
|
"tslib": "^2.3.1",
|
|
86
|
-
"typescript": "^5.6.2"
|
|
88
|
+
"typescript": "^5.6.2",
|
|
89
|
+
"@open-wc/testing": "^3.1.6",
|
|
90
|
+
"@web/test-runner": "^0.14.0",
|
|
91
|
+
"@web/test-runner-puppeteer": "0.16.0"
|
|
87
92
|
}
|
|
88
93
|
}
|