@aquera/nile-visualization 2.9.30 → 2.9.32
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 +14 -0
- package/dist/src/index.d.ts +7 -8
- package/dist/src/index.js +2 -3
- package/dist/src/internal/base/forecastable-chart.d.ts +59 -0
- package/dist/src/internal/base/forecastable-chart.js +149 -0
- package/dist/src/internal/{nile-chart-base.d.ts → base/nile-chart-base.d.ts} +1 -1
- package/dist/src/internal/{nile-chart-base.js → base/nile-chart-base.js} +1 -1
- 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/internal/types/chart-area-config.type.d.ts +4 -2
- package/dist/src/internal/types/chart-area-spline-config.type.d.ts +4 -2
- package/dist/src/internal/types/chart-column-config.type.d.ts +3 -2
- package/dist/src/internal/types/chart-line-config.type.d.ts +3 -2
- package/dist/src/internal/types/chart-spline-config.type.d.ts +3 -2
- package/dist/src/internal/types/index.d.ts +0 -1
- package/dist/src/internal/types/primitive-chart-config.type.d.ts +1 -2
- package/dist/src/internal/{chart-adapters.d.ts → utils/chart-adapters.d.ts} +1 -1
- package/dist/src/internal/{chart-adapters.js → utils/chart-adapters.js} +15 -3
- package/dist/src/internal/utils/chart-forecast.d.ts +126 -0
- package/dist/src/internal/utils/chart-forecast.js +297 -0
- package/dist/src/internal/{dashboard-adapters.d.ts → utils/dashboard-adapters.d.ts} +1 -1
- package/dist/src/internal/{utils.js → utils/deep-merge.js} +1 -1
- package/dist/src/internal/{resolve-widget-kind.d.ts → utils/resolve-widget-kind.d.ts} +1 -1
- package/dist/src/internal/utils/separated-chart-config.d.ts +13 -0
- package/dist/src/internal/utils/separated-chart-config.js +30 -0
- package/dist/src/nile-ai-panel/nile-ai-panel.d.ts +1 -1
- package/dist/src/nile-ai-panel/nile-ai-panel.js +1 -1
- package/dist/src/nile-ai-sender/nile-ai-sender.d.ts +1 -1
- package/dist/src/nile-ai-sender/nile-ai-sender.js +1 -1
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.d.ts +1 -1
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.js +4 -4
- package/dist/src/nile-area-chart/nile-area-chart.d.ts +7 -6
- package/dist/src/nile-area-chart/nile-area-chart.js +37 -24
- package/dist/src/nile-area-negative-chart/nile-area-negative-chart.d.ts +1 -1
- package/dist/src/nile-area-negative-chart/nile-area-negative-chart.js +5 -5
- package/dist/src/nile-area-range-chart/nile-area-range-chart.d.ts +1 -1
- package/dist/src/nile-area-range-chart/nile-area-range-chart.js +5 -5
- package/dist/src/nile-area-spline-chart/nile-area-spline-chart.d.ts +10 -4
- package/dist/src/nile-area-spline-chart/nile-area-spline-chart.js +38 -27
- package/dist/src/nile-bar-chart/nile-bar-chart.d.ts +3 -3
- package/dist/src/nile-bar-chart/nile-bar-chart.js +4 -4
- package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.d.ts +3 -2
- package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.js +5 -5
- package/dist/src/nile-boxplot-chart/nile-boxplot-chart.d.ts +3 -2
- package/dist/src/nile-boxplot-chart/nile-boxplot-chart.js +5 -5
- package/dist/src/nile-bubble-chart/nile-bubble-chart.d.ts +3 -3
- package/dist/src/nile-bubble-chart/nile-bubble-chart.js +4 -4
- package/dist/src/nile-chart/index.d.ts +2 -2
- package/dist/src/nile-chart/index.js +1 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +23 -32
- package/dist/src/nile-chart/nile-chart.css.js +6 -1
- package/dist/src/nile-chart/nile-chart.d.ts +15 -8
- package/dist/src/nile-chart/nile-chart.js +128 -61
- 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-chart-list/nile-chart-list.d.ts +1 -1
- package/dist/src/nile-chart-list/nile-chart-list.js +1 -1
- package/dist/src/nile-chart-message/nile-chart-message.d.ts +1 -1
- package/dist/src/nile-chart-message/nile-chart-message.js +1 -1
- package/dist/src/nile-cluster-chart/nile-cluster-chart.d.ts +3 -2
- package/dist/src/nile-cluster-chart/nile-cluster-chart.js +5 -5
- package/dist/src/nile-column-chart/nile-column-chart.d.ts +13 -6
- package/dist/src/nile-column-chart/nile-column-chart.js +43 -24
- package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.d.ts +1 -1
- package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.js +5 -5
- package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.d.ts +1 -1
- package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.js +5 -5
- package/dist/src/nile-column-range-chart/nile-column-range-chart.d.ts +1 -1
- package/dist/src/nile-column-range-chart/nile-column-range-chart.js +5 -5
- package/dist/src/nile-dashboard-builder/nile-dashboard-builder.d.ts +1 -1
- package/dist/src/nile-dashboard-builder/nile-dashboard-builder.js +2 -2
- package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.d.ts +1 -1
- package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.js +1 -1
- package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +3 -3
- package/dist/src/nile-donut-chart/nile-donut-chart.js +4 -4
- package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.d.ts +1 -1
- package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.js +5 -5
- package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.d.ts +1 -1
- package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.js +5 -5
- package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.d.ts +1 -1
- package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.js +5 -5
- package/dist/src/nile-euler-chart/nile-euler-chart.d.ts +1 -1
- package/dist/src/nile-euler-chart/nile-euler-chart.js +5 -5
- package/dist/src/nile-executive-summary/nile-executive-summary.d.ts +1 -1
- package/dist/src/nile-executive-summary/nile-executive-summary.js +1 -1
- package/dist/src/nile-fan-chart/nile-fan-chart.d.ts +1 -1
- package/dist/src/nile-fan-chart/nile-fan-chart.js +5 -5
- package/dist/src/nile-filter-chart/nile-filter-chart.d.ts +1 -1
- package/dist/src/nile-filter-chart/nile-filter-chart.js +1 -1
- package/dist/src/nile-flame-chart/nile-flame-chart.d.ts +1 -1
- package/dist/src/nile-flame-chart/nile-flame-chart.js +5 -5
- package/dist/src/nile-funnel-chart/nile-funnel-chart.d.ts +1 -1
- package/dist/src/nile-funnel-chart/nile-funnel-chart.js +5 -5
- package/dist/src/nile-gauge-chart/nile-gauge-chart.d.ts +1 -1
- package/dist/src/nile-gauge-chart/nile-gauge-chart.js +4 -4
- package/dist/src/nile-heatmap-chart/nile-heatmap-chart.d.ts +3 -2
- package/dist/src/nile-heatmap-chart/nile-heatmap-chart.js +5 -5
- package/dist/src/nile-histogram-chart/nile-histogram-chart.d.ts +3 -2
- package/dist/src/nile-histogram-chart/nile-histogram-chart.js +5 -5
- package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.d.ts +1 -1
- package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.js +5 -5
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +41 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +31 -1
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +73 -3
- package/dist/src/nile-line-chart/nile-line-chart.d.ts +12 -6
- package/dist/src/nile-line-chart/nile-line-chart.js +44 -24
- package/dist/src/nile-line-column-chart/nile-line-column-chart.d.ts +1 -1
- package/dist/src/nile-line-column-chart/nile-line-column-chart.js +5 -5
- package/dist/src/nile-lollipop-chart/nile-lollipop-chart.d.ts +1 -1
- package/dist/src/nile-lollipop-chart/nile-lollipop-chart.js +5 -5
- package/dist/src/nile-map-chart/nile-map-chart.d.ts +2 -2
- package/dist/src/nile-map-chart/nile-map-chart.js +4 -4
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +1 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +5 -5
- package/dist/src/nile-organization-chart/nile-organization-chart.d.ts +1 -1
- package/dist/src/nile-organization-chart/nile-organization-chart.js +5 -5
- package/dist/src/nile-pie-chart/nile-pie-chart.d.ts +1 -1
- package/dist/src/nile-pie-chart/nile-pie-chart.js +4 -4
- package/dist/src/nile-polygon-chart/nile-polygon-chart.d.ts +1 -1
- package/dist/src/nile-polygon-chart/nile-polygon-chart.js +5 -5
- package/dist/src/nile-radar-chart/nile-radar-chart.d.ts +3 -3
- package/dist/src/nile-radar-chart/nile-radar-chart.js +4 -4
- package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.d.ts +3 -2
- package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.js +5 -5
- package/dist/src/nile-scatter-chart/nile-scatter-chart.d.ts +3 -3
- package/dist/src/nile-scatter-chart/nile-scatter-chart.js +4 -4
- package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.d.ts +3 -2
- package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.js +5 -5
- package/dist/src/nile-spline-chart/nile-spline-chart.d.ts +8 -6
- package/dist/src/nile-spline-chart/nile-spline-chart.js +36 -24
- package/dist/src/nile-stacked-chart/nile-stacked-chart.d.ts +3 -2
- package/dist/src/nile-stacked-chart/nile-stacked-chart.js +5 -5
- package/dist/src/nile-timeline-chart/nile-timeline-chart.d.ts +1 -1
- package/dist/src/nile-timeline-chart/nile-timeline-chart.js +5 -5
- package/dist/src/nile-trendline-chart/nile-trendline-chart.d.ts +1 -1
- package/dist/src/nile-trendline-chart/nile-trendline-chart.js +4 -4
- package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.d.ts +3 -2
- package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.js +5 -5
- package/dist/src/nile-vector-chart/nile-vector-chart.d.ts +1 -1
- package/dist/src/nile-vector-chart/nile-vector-chart.js +5 -5
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.d.ts +3 -3
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.js +4 -4
- package/dist/src/nile-widget-viewer/nile-widget-viewer.css.js +6 -2
- package/dist/src/nile-widget-viewer/nile-widget-viewer.d.ts +1 -1
- package/dist/src/nile-widget-viewer/nile-widget-viewer.js +2 -2
- package/dist/src/nile-xrange-chart/nile-xrange-chart.d.ts +3 -2
- package/dist/src/nile-xrange-chart/nile-xrange-chart.js +5 -5
- package/package.json +10 -6
- package/dist/src/internal/separated-chart-config.d.ts +0 -5
- package/dist/src/internal/separated-chart-config.js +0 -16
- package/dist/src/internal/types/chart-forecast-config.type.d.ts +0 -35
- package/dist/src/internal/types/chart-forecast-config.type.js +0 -2
- package/dist/src/nile-forecast-chart/index.d.ts +0 -2
- package/dist/src/nile-forecast-chart/index.js +0 -2
- package/dist/src/nile-forecast-chart/nile-forecast-chart.css.d.ts +0 -1
- package/dist/src/nile-forecast-chart/nile-forecast-chart.css.js +0 -46
- package/dist/src/nile-forecast-chart/nile-forecast-chart.d.ts +0 -90
- package/dist/src/nile-forecast-chart/nile-forecast-chart.js +0 -551
- /package/dist/src/internal/{nile-element.d.ts → base/nile-element.d.ts} +0 -0
- /package/dist/src/internal/{nile-element.js → base/nile-element.js} +0 -0
- /package/dist/src/internal/{chart-events.d.ts → utils/chart-events.d.ts} +0 -0
- /package/dist/src/internal/{chart-events.js → utils/chart-events.js} +0 -0
- /package/dist/src/internal/{chart-runtime.d.ts → utils/chart-runtime.d.ts} +0 -0
- /package/dist/src/internal/{chart-runtime.js → utils/chart-runtime.js} +0 -0
- /package/dist/src/internal/{dashboard-adapters.js → utils/dashboard-adapters.js} +0 -0
- /package/dist/src/internal/{utils.d.ts → utils/deep-merge.d.ts} +0 -0
- /package/dist/src/internal/{highcharts-provider.d.ts → utils/highcharts-provider.d.ts} +0 -0
- /package/dist/src/internal/{highcharts-provider.js → utils/highcharts-provider.js} +0 -0
- /package/dist/src/internal/{resolve-widget-kind.js → utils/resolve-widget-kind.js} +0 -0
- /package/dist/src/internal/{responsive-defaults.d.ts → utils/responsive-defaults.d.ts} +0 -0
- /package/dist/src/internal/{responsive-defaults.js → utils/responsive-defaults.js} +0 -0
|
@@ -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. */
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
+
import type { ForecastConfigFields, ForecastSeriesInput } from '../utils/chart-forecast.js';
|
|
2
3
|
import type { AreaChartSeriesData } from '../../nile-area-chart/nile-area-chart.js';
|
|
3
4
|
/** HighCharts area chart config. */
|
|
4
|
-
export interface ChartAreaConfigType {
|
|
5
|
+
export interface ChartAreaConfigType extends ForecastConfigFields {
|
|
5
6
|
type: 'area';
|
|
6
|
-
data: AreaChartSeriesData
|
|
7
|
+
data: Array<AreaChartSeriesData | ForecastSeriesInput>;
|
|
7
8
|
categories?: string[];
|
|
8
9
|
yAxisTitle?: string;
|
|
9
10
|
height?: string;
|
|
10
11
|
stacked?: boolean;
|
|
12
|
+
fillOpacity?: number;
|
|
11
13
|
loading?: boolean;
|
|
12
14
|
options?: Options;
|
|
13
15
|
chartBg?: string;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
+
import type { ForecastConfigFields, ForecastSeriesInput } from '../utils/chart-forecast.js';
|
|
2
3
|
import type { AreaSplineSeriesData } from '../../nile-area-spline-chart/nile-area-spline-chart.js';
|
|
3
4
|
/** Area spline (`<nile-area-spline-chart>`). */
|
|
4
|
-
export interface ChartAreaSplineConfigType {
|
|
5
|
+
export interface ChartAreaSplineConfigType extends ForecastConfigFields {
|
|
5
6
|
type: 'areaSpline';
|
|
6
|
-
data: AreaSplineSeriesData
|
|
7
|
+
data: Array<AreaSplineSeriesData | ForecastSeriesInput>;
|
|
7
8
|
categories?: string[];
|
|
8
9
|
yAxisTitle?: string;
|
|
9
10
|
height?: string;
|
|
10
11
|
stacked?: boolean;
|
|
12
|
+
fillOpacity?: number;
|
|
11
13
|
loading?: boolean;
|
|
12
14
|
options?: Options;
|
|
13
15
|
chartBg?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
+
import type { ForecastConfigFields, ForecastSeriesInput } from '../utils/chart-forecast.js';
|
|
2
3
|
import type { ColumnChartSeriesData } from '../../nile-column-chart/nile-column-chart.js';
|
|
3
4
|
/** HighCharts column chart config. */
|
|
4
|
-
export interface ChartColumnConfigType {
|
|
5
|
+
export interface ChartColumnConfigType extends ForecastConfigFields {
|
|
5
6
|
type: 'column';
|
|
6
|
-
data: ColumnChartSeriesData
|
|
7
|
+
data: Array<ColumnChartSeriesData | ForecastSeriesInput>;
|
|
7
8
|
categories?: string[];
|
|
8
9
|
yAxisTitle?: string;
|
|
9
10
|
height?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
+
import type { ForecastConfigFields, ForecastSeriesInput } from '../utils/chart-forecast.js';
|
|
2
3
|
import type { LineChartSeriesData } from '../../nile-line-chart/nile-line-chart.js';
|
|
3
4
|
/** HighCharts line chart config. */
|
|
4
|
-
export interface ChartLineConfigType {
|
|
5
|
+
export interface ChartLineConfigType extends ForecastConfigFields {
|
|
5
6
|
type: 'line';
|
|
6
|
-
data: LineChartSeriesData
|
|
7
|
+
data: Array<LineChartSeriesData | ForecastSeriesInput>;
|
|
7
8
|
categories?: string[];
|
|
8
9
|
yAxisTitle?: string;
|
|
9
10
|
height?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
+
import type { ForecastConfigFields, ForecastSeriesInput } from '../utils/chart-forecast.js';
|
|
2
3
|
import type { SplineChartSeriesData } from '../../nile-spline-chart/nile-spline-chart.js';
|
|
3
4
|
/** HighCharts spline chart config. */
|
|
4
|
-
export interface ChartSplineConfigType {
|
|
5
|
+
export interface ChartSplineConfigType extends ForecastConfigFields {
|
|
5
6
|
type: 'spline';
|
|
6
|
-
data: SplineChartSeriesData
|
|
7
|
+
data: Array<SplineChartSeriesData | ForecastSeriesInput>;
|
|
7
8
|
categories?: string[];
|
|
8
9
|
yAxisTitle?: string;
|
|
9
10
|
height?: string;
|
|
@@ -40,7 +40,6 @@ export type { ChartPolygonConfigType } from './chart-polygon-config.type.js';
|
|
|
40
40
|
export type { ChartVectorConfigType } from './chart-vector-config.type.js';
|
|
41
41
|
export type { ChartXrangeConfigType } from './chart-xrange-config.type.js';
|
|
42
42
|
export type { ChartFanConfigType } from './chart-fan-config.type.js';
|
|
43
|
-
export type { ChartForecastConfigType } from './chart-forecast-config.type.js';
|
|
44
43
|
export type { ChartFunnelConfigType } from './chart-funnel-config.type.js';
|
|
45
44
|
export type { ChartOrganizationConfigType } from './chart-organization-config.type.js';
|
|
46
45
|
export type { ChartLineColumnConfigType } from './chart-line-column-config.type.js';
|
|
@@ -7,7 +7,6 @@ import type { ChartTimelineConfigType } from './chart-timeline-config.type.js';
|
|
|
7
7
|
import type { ChartMasterDetailConfigType } from './chart-master-detail-config.type.js';
|
|
8
8
|
import type { ChartDumbbellConfigType } from './chart-dumbbell-config.type.js';
|
|
9
9
|
import type { ChartFanConfigType } from './chart-fan-config.type.js';
|
|
10
|
-
import type { ChartForecastConfigType } from './chart-forecast-config.type.js';
|
|
11
10
|
import type { ChartFunnelConfigType } from './chart-funnel-config.type.js';
|
|
12
11
|
import type { ChartOrganizationConfigType } from './chart-organization-config.type.js';
|
|
13
12
|
import type { ChartLineColumnConfigType } from './chart-line-column-config.type.js';
|
|
@@ -36,4 +35,4 @@ import type { ChartXrangeConfigType } from './chart-xrange-config.type.js';
|
|
|
36
35
|
* Chart configs for primitive `<nile-*-chart>` elements (`el.config = { chart, aq }`).
|
|
37
36
|
* Discriminated on `chart.type`.
|
|
38
37
|
*/
|
|
39
|
-
export type PrimitiveChartConfigType = ChartInvertedAreaConfigType | ChartColumnPyramidConfigType | ChartLollipopConfigType | ChartAreaSplineConfigType | ChartAreaNegativeConfigType | ChartAreaRangeConfigType | ChartColumnRangeConfigType | ChartColumnDrilldownConfigType | ChartRadialBarConfigType | ChartVariablePieConfigType | ChartDumbbellLowerConfigType | ChartDumbbellUpperConfigType | ChartEulerConfigType | ChartPolygonConfigType | ChartVectorConfigType | ChartXrangeConfigType | ChartClusterConfigType | ChartStackedConfigType | ChartHistogramConfigType | ChartBellcurveConfigType | ChartBoxplotConfigType | ChartTimelineConfigType | ChartMasterDetailConfigType | ChartDumbbellConfigType | ChartFanConfigType |
|
|
38
|
+
export type PrimitiveChartConfigType = ChartInvertedAreaConfigType | ChartColumnPyramidConfigType | ChartLollipopConfigType | ChartAreaSplineConfigType | ChartAreaNegativeConfigType | ChartAreaRangeConfigType | ChartColumnRangeConfigType | ChartColumnDrilldownConfigType | ChartRadialBarConfigType | ChartVariablePieConfigType | ChartDumbbellLowerConfigType | ChartDumbbellUpperConfigType | ChartEulerConfigType | ChartPolygonConfigType | ChartVectorConfigType | ChartXrangeConfigType | ChartClusterConfigType | ChartStackedConfigType | ChartHistogramConfigType | ChartBellcurveConfigType | ChartBoxplotConfigType | ChartTimelineConfigType | ChartMasterDetailConfigType | ChartDumbbellConfigType | ChartFanConfigType | ChartFunnelConfigType | ChartOrganizationConfigType | ChartLineColumnConfigType | ChartHeatmapConfigType | ChartFlameConfigType | ChartSpiderwebConfigType | ChartKpiConfigType | ChartFilterConfigType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NileChartConfig, ChartType } from '
|
|
1
|
+
import type { NileChartConfig, ChartType } from '../../nile-chart/nile-chart-config.js';
|
|
2
2
|
type AdapterFn = (config: NileChartConfig) => NileChartConfig;
|
|
3
3
|
/**
|
|
4
4
|
* Register a custom adapter for converting between chart types.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { flattenForecastSeries } from './chart-forecast.js';
|
|
1
2
|
// ── Bar → Pie helpers ───────────────────────────────────────────────
|
|
2
3
|
function barToPieByCategory(data, categories) {
|
|
3
4
|
return categories.map((cat, i) => ({
|
|
@@ -150,7 +151,13 @@ const adapters = {
|
|
|
150
151
|
'column->stacked': (config) => {
|
|
151
152
|
if (config.type !== 'column')
|
|
152
153
|
throw new Error('Expected column config');
|
|
153
|
-
|
|
154
|
+
// `stacked` has no forecast support, so a projection flattens into the series.
|
|
155
|
+
return {
|
|
156
|
+
...config,
|
|
157
|
+
type: 'stacked',
|
|
158
|
+
stackMode: 'normal',
|
|
159
|
+
data: flattenForecastSeries(config.data),
|
|
160
|
+
};
|
|
154
161
|
},
|
|
155
162
|
'stacked->column': (config) => {
|
|
156
163
|
if (config.type !== 'stacked')
|
|
@@ -165,7 +172,12 @@ const adapters = {
|
|
|
165
172
|
'column->bar': (config) => {
|
|
166
173
|
if (config.type !== 'column')
|
|
167
174
|
throw new Error('Expected column config');
|
|
168
|
-
|
|
175
|
+
// `bar` has no forecast support, so a projection flattens into the series.
|
|
176
|
+
return {
|
|
177
|
+
...config,
|
|
178
|
+
type: 'bar',
|
|
179
|
+
data: flattenForecastSeries(config.data),
|
|
180
|
+
};
|
|
169
181
|
},
|
|
170
182
|
// ── Stacked ↔ pie / trendline / anomaly (same as bar) ──
|
|
171
183
|
'stacked->pie': (config) => {
|
|
@@ -212,7 +224,7 @@ const adapters = {
|
|
|
212
224
|
return {
|
|
213
225
|
...config,
|
|
214
226
|
type: 'pie',
|
|
215
|
-
data: barLikeToPie(config.data, config.categories ?? [], agg),
|
|
227
|
+
data: barLikeToPie(flattenForecastSeries(config.data), config.categories ?? [], agg),
|
|
216
228
|
seriesName: config.chartTitle || 'Series',
|
|
217
229
|
};
|
|
218
230
|
},
|