@aquera/nile-visualization 2.9.30 → 2.9.31
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 +11 -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/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 +21 -32
- package/dist/src/nile-chart/nile-chart.css.js +0 -1
- package/dist/src/nile-chart/nile-chart.d.ts +2 -8
- package/dist/src/nile-chart/nile-chart.js +54 -61
- 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 +1 -2
- 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,297 @@
|
|
|
1
|
+
import { resolveColorPaletteColors } from '../color-palettes/index.js';
|
|
2
|
+
export const FORECAST_WATCHED_PROPS = Object.freeze([
|
|
3
|
+
'enableForecasting', 'projection',
|
|
4
|
+
'lineWidth', 'showMarkers', 'valueSuffix', 'xAxisTitle',
|
|
5
|
+
'secondaryAxisTitle', 'secondaryAxisMin',
|
|
6
|
+
]);
|
|
7
|
+
/** Copies the forecast fields of a separated `{ chart }` config onto a component. */
|
|
8
|
+
export function applyForecastConfig(target, c) {
|
|
9
|
+
const src = c;
|
|
10
|
+
const dst = target;
|
|
11
|
+
for (const key of FORECAST_WATCHED_PROPS) {
|
|
12
|
+
if (src[key] !== undefined)
|
|
13
|
+
dst[key] = src[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const FORECAST_NOW_LINE_COLOR = 'var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600))';
|
|
17
|
+
const FORECAST_BAND_COLOR = 'color-mix(in srgb, var(--nile-colors-primary-600, var(--ng-componentcolors-utility-brand-600)) 6%, transparent)';
|
|
18
|
+
const AXIS_LABEL_COLOR = 'var(--nile-colors-neutral-500, var(--ng-colors-text-tertiary-600))';
|
|
19
|
+
const AXIS_LABEL_FONT_SIZE = 'var(--nile-type-scale-2, var(--ng-font-size-text-xs))';
|
|
20
|
+
let escapeEl;
|
|
21
|
+
function escapeHtml(text) {
|
|
22
|
+
escapeEl ?? (escapeEl = document.createElement('span'));
|
|
23
|
+
escapeEl.textContent = text;
|
|
24
|
+
return escapeEl.innerHTML;
|
|
25
|
+
}
|
|
26
|
+
function boundaryLabelHtml(text) {
|
|
27
|
+
const escaped = escapeHtml(text);
|
|
28
|
+
const style = [
|
|
29
|
+
'display:inline-block',
|
|
30
|
+
'padding:var(--nile-spacing-2px, var(--ng-spacing-xxs)) var(--nile-spacing-sm, var(--ng-spacing-sm))',
|
|
31
|
+
'border-radius:var(--nile-radius-radius-sm, var(--ng-radius-sm))',
|
|
32
|
+
'background:var(--nile-colors-neutral-800, var(--ng-colors-bg-primary-solid))',
|
|
33
|
+
'color:var(--nile-colors-base-white, var(--ng-colors-text-white))',
|
|
34
|
+
`font-size:${AXIS_LABEL_FONT_SIZE}`,
|
|
35
|
+
'font-weight:var(--nile-font-weight-medium, var(--ng-font-weight-medium))',
|
|
36
|
+
'line-height:1.4',
|
|
37
|
+
'white-space:nowrap',
|
|
38
|
+
'pointer-events:none',
|
|
39
|
+
].join(';');
|
|
40
|
+
return `<span style="${style}">${escaped}</span>`;
|
|
41
|
+
}
|
|
42
|
+
const DEFAULT_INTERVAL_OPACITY = 0.18;
|
|
43
|
+
const AXIS_LABEL_STYLE = { color: AXIS_LABEL_COLOR, fontSize: AXIS_LABEL_FONT_SIZE };
|
|
44
|
+
function mixTransparent(color, pct) {
|
|
45
|
+
return `color-mix(in srgb, ${color} ${pct}%, transparent)`;
|
|
46
|
+
}
|
|
47
|
+
const measured = (s) => s.actual ?? s.data ?? [];
|
|
48
|
+
export function hasForecastSeries(data) {
|
|
49
|
+
return !!data?.some(s => !!s.projected?.length);
|
|
50
|
+
}
|
|
51
|
+
function buildIntervalPointFormatter(intervalMeta, boundary) {
|
|
52
|
+
return function pointFormatter() {
|
|
53
|
+
const { series } = this;
|
|
54
|
+
const format = series.chart.numberFormatter;
|
|
55
|
+
const suffix = series.options.tooltip?.valueSuffix ?? '';
|
|
56
|
+
const value = (v) => `${format(v, -1)}${suffix}`;
|
|
57
|
+
const row = `<span style="color:${this.color}">●</span> ${series.name}: `
|
|
58
|
+
+ `<b>${this.y === null || this.y === undefined ? '' : value(this.y)}</b><br/>`;
|
|
59
|
+
const forecastIndex = series.options.custom?.forecastIndex;
|
|
60
|
+
const meta = forecastIndex !== undefined ? intervalMeta.get(forecastIndex) : undefined;
|
|
61
|
+
const bounds = typeof this.x === 'number' ? meta?.bounds.get(this.x) : undefined;
|
|
62
|
+
if (!meta || !bounds || typeof this.x !== 'number' || this.x <= boundary)
|
|
63
|
+
return row;
|
|
64
|
+
const prefix = meta.level !== undefined
|
|
65
|
+
? `${meta.level}% CI: `
|
|
66
|
+
: (meta.label ? `${meta.label}: ` : '');
|
|
67
|
+
return row
|
|
68
|
+
+ `<span style="color:${AXIS_LABEL_COLOR};font-size:${AXIS_LABEL_FONT_SIZE}">`
|
|
69
|
+
+ `${prefix}${value(bounds[0])} – ${value(bounds[1])}`
|
|
70
|
+
+ '</span><br/>';
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function toPlainSeries(data, values) {
|
|
74
|
+
return (data ?? []).map((s, i) => ({
|
|
75
|
+
name: s.name ?? `Series ${i + 1}`,
|
|
76
|
+
data: values(s),
|
|
77
|
+
...(s.color ? { color: s.color } : {}),
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/** `actual + projected` as one plain series — for type conversions (column → pie). */
|
|
81
|
+
export function flattenForecastSeries(data) {
|
|
82
|
+
return toPlainSeries(data, s => [...measured(s), ...(s.projected ?? [])]);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The forecasting-off series: measured history only. Presentation keys are
|
|
86
|
+
* pinned because `chart.update()` leaves an omitted key in place.
|
|
87
|
+
*/
|
|
88
|
+
export function plainForecastSeries(type, data, presentation = {}) {
|
|
89
|
+
const { lineWidth, showMarkers, valueSuffix, fillOpacity } = presentation;
|
|
90
|
+
return toPlainSeries(data, s => [...measured(s)]).map((plain, i) => {
|
|
91
|
+
const s = (data ?? [])[i];
|
|
92
|
+
const resolvedType = s.type ?? type;
|
|
93
|
+
const isColumn = resolvedType === 'column';
|
|
94
|
+
const isArea = resolvedType === 'area' || resolvedType === 'areaspline';
|
|
95
|
+
const resolvedLineWidth = s.lineWidth ?? lineWidth;
|
|
96
|
+
const resolvedSuffix = s.valueSuffix ?? valueSuffix;
|
|
97
|
+
const resolvedFill = s.fillOpacity ?? fillOpacity;
|
|
98
|
+
return {
|
|
99
|
+
...plain,
|
|
100
|
+
type: resolvedType,
|
|
101
|
+
zones: [],
|
|
102
|
+
yAxis: s.axis === 'secondary' ? 1 : 0,
|
|
103
|
+
...(resolvedLineWidth !== undefined ? { lineWidth: resolvedLineWidth } : {}),
|
|
104
|
+
...(resolvedSuffix ? { tooltip: { valueSuffix: resolvedSuffix } } : {}),
|
|
105
|
+
...(isColumn ? { borderWidth: 0 } : { marker: { enabled: s.showMarkers ?? showMarkers ?? false } }),
|
|
106
|
+
...(isArea && resolvedFill !== undefined ? { fillOpacity: resolvedFill } : {}),
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** `chart.update()`'s 4th argument — updates don't animate unless told to. */
|
|
111
|
+
export const FORECAST_UPDATE_ANIMATION = {
|
|
112
|
+
duration: 450,
|
|
113
|
+
easing: 'easeOutQuad',
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Two-phase exit — Highcharts only morphs a path when the point count is
|
|
117
|
+
* unchanged: retract first, then settle. Pass the previous timer as `pending`.
|
|
118
|
+
*/
|
|
119
|
+
export function animateForecastExit(chart, frames, pending) {
|
|
120
|
+
clearTimeout(pending);
|
|
121
|
+
chart.update(frames.retracted, true, true, FORECAST_UPDATE_ANIMATION);
|
|
122
|
+
return setTimeout(() => {
|
|
123
|
+
chart.update(frames.settled, true, true);
|
|
124
|
+
}, FORECAST_UPDATE_ANIMATION.duration ?? 0);
|
|
125
|
+
}
|
|
126
|
+
/** The empty overlay — assigning it clears a previous one. */
|
|
127
|
+
export const NO_FORECAST = Object.freeze({ plotLines: [], plotBands: [], tooltip: {}, boundary: -1, hasSecondaryAxis: false });
|
|
128
|
+
/**
|
|
129
|
+
* Derives the forecast overlay: split series, boundary marker, region tint,
|
|
130
|
+
* interval tooltip. Behaviour notes: `chart-forecast.md`.
|
|
131
|
+
*/
|
|
132
|
+
export function buildForecast(input) {
|
|
133
|
+
const { seriesType, data = [], categories = [], projection, lineWidth, showMarkers, fillOpacity, valueSuffix, retract = false, } = input;
|
|
134
|
+
const p = projection ?? {};
|
|
135
|
+
const interval = p.interval ?? {};
|
|
136
|
+
const derivedStart = data.reduce((max, s) => Math.max(max, measured(s).length), 0);
|
|
137
|
+
const start = typeof p.start === 'number' && Number.isFinite(p.start) && p.start > 0
|
|
138
|
+
? p.start
|
|
139
|
+
: derivedStart;
|
|
140
|
+
const boundary = start - 1;
|
|
141
|
+
// Pinned colors — the appended band series would otherwise shift palette slots.
|
|
142
|
+
const paletteColors = resolveColorPaletteColors({ theme: 'default' }, data.length);
|
|
143
|
+
const colorAt = (i) => (paletteColors?.length ? paletteColors[i % paletteColors.length] : undefined);
|
|
144
|
+
const nameAt = (s, i) => s.name ?? `Series ${i + 1}`;
|
|
145
|
+
const typeAt = (s) => s.type ?? seriesType;
|
|
146
|
+
const axisAt = (s) => s.axis ?? 'primary';
|
|
147
|
+
const intervalMeta = new Map();
|
|
148
|
+
// Columns split at +0.5: Highcharts assigns a point at exactly the zone
|
|
149
|
+
// value to the NEXT zone, which would recolor the last measured column.
|
|
150
|
+
const splitAt = (isColumn) => (isColumn ? boundary + 0.5 : boundary);
|
|
151
|
+
const boundaryValue = (s) => {
|
|
152
|
+
const history = measured(s);
|
|
153
|
+
return boundary >= 0 && history.length > boundary ? history[boundary] : history[history.length - 1];
|
|
154
|
+
};
|
|
155
|
+
// Retract keeps the point count, so Highcharts morphs instead of redrawing.
|
|
156
|
+
const projectedValues = (s) => {
|
|
157
|
+
const projected = s.projected ?? [];
|
|
158
|
+
if (!retract)
|
|
159
|
+
return projected;
|
|
160
|
+
const flat = boundaryValue(s);
|
|
161
|
+
return flat === undefined ? projected : projected.map(() => flat);
|
|
162
|
+
};
|
|
163
|
+
const series = data.map((s, i) => {
|
|
164
|
+
const type = typeAt(s);
|
|
165
|
+
const isColumn = type === 'column';
|
|
166
|
+
const isArea = type === 'area' || type === 'areaspline';
|
|
167
|
+
const name = nameAt(s, i);
|
|
168
|
+
const seriesColor = s.color ?? colorAt(i);
|
|
169
|
+
const projectedColor = s.forecastColor ?? p.color;
|
|
170
|
+
const hasBand = !isColumn && !!s.interval?.length;
|
|
171
|
+
// Columns can't dash — recolor is their only cue.
|
|
172
|
+
const projectedZone = isColumn
|
|
173
|
+
? (projectedColor ? { color: projectedColor } : {})
|
|
174
|
+
: {
|
|
175
|
+
dashStyle: s.forecastDashStyle ?? p.dashStyle ?? 'Dash',
|
|
176
|
+
...(projectedColor
|
|
177
|
+
? {
|
|
178
|
+
color: projectedColor,
|
|
179
|
+
// Skipped with a band — it would darken the band's lower half.
|
|
180
|
+
...(isArea && !hasBand ? { fillColor: mixTransparent(projectedColor, 12) } : {}),
|
|
181
|
+
}
|
|
182
|
+
: {}),
|
|
183
|
+
};
|
|
184
|
+
const resolvedLineWidth = s.lineWidth ?? lineWidth;
|
|
185
|
+
const resolvedSuffix = s.valueSuffix ?? valueSuffix;
|
|
186
|
+
const resolvedMarkers = s.showMarkers ?? showMarkers ?? false;
|
|
187
|
+
const resolvedFill = s.fillOpacity ?? fillOpacity;
|
|
188
|
+
if (hasBand) {
|
|
189
|
+
const level = s.intervalLevel ?? interval.level;
|
|
190
|
+
const label = s.intervalLabel ?? interval.label;
|
|
191
|
+
intervalMeta.set(i, {
|
|
192
|
+
...(typeof level === 'number' ? { level } : {}),
|
|
193
|
+
...(label ? { label } : {}),
|
|
194
|
+
bounds: new Map((s.interval ?? []).map((range, j) => [start + j, range])),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
type: type,
|
|
199
|
+
name,
|
|
200
|
+
// Fresh array — Highcharts mutates the data it is handed.
|
|
201
|
+
data: [...measured(s), ...projectedValues(s)],
|
|
202
|
+
...(seriesColor ? { color: seriesColor } : {}),
|
|
203
|
+
legendIndex: i,
|
|
204
|
+
// Ties a hovered point back to its `intervalMeta` entry — `series.name`
|
|
205
|
+
// isn't unique when two series share a display name.
|
|
206
|
+
custom: { forecastIndex: i },
|
|
207
|
+
yAxis: axisAt(s) === 'secondary' ? 1 : 0,
|
|
208
|
+
zIndex: isColumn ? 1 : 2,
|
|
209
|
+
zoneAxis: 'x',
|
|
210
|
+
zones: boundary >= 0 ? [{ value: splitAt(isColumn) }, projectedZone] : [],
|
|
211
|
+
...(resolvedLineWidth !== undefined ? { lineWidth: resolvedLineWidth } : {}),
|
|
212
|
+
...(resolvedSuffix ? { tooltip: { valueSuffix: resolvedSuffix } } : {}),
|
|
213
|
+
...(isColumn ? { borderWidth: 0 } : { marker: { enabled: resolvedMarkers } }),
|
|
214
|
+
...(isArea && resolvedFill !== undefined ? { fillOpacity: resolvedFill } : {}),
|
|
215
|
+
};
|
|
216
|
+
});
|
|
217
|
+
// One `arearange` per series with an `interval`; columns get none.
|
|
218
|
+
const bands = data.flatMap((s, i) => {
|
|
219
|
+
const type = typeAt(s);
|
|
220
|
+
if (!s.interval?.length || type === 'column')
|
|
221
|
+
return [];
|
|
222
|
+
const name = nameAt(s, i);
|
|
223
|
+
const bandColor = s.intervalColor ?? interval.color ?? s.forecastColor ?? p.color ?? s.color ?? colorAt(i);
|
|
224
|
+
const history = measured(s);
|
|
225
|
+
const flat = retract ? boundaryValue(s) : undefined;
|
|
226
|
+
// Pinned at the boundary so the cone opens out of the last measured point.
|
|
227
|
+
const pin = boundary >= 0 && history.length > boundary
|
|
228
|
+
? [{ x: boundary, low: history[boundary], high: history[boundary] }]
|
|
229
|
+
: [];
|
|
230
|
+
return [{
|
|
231
|
+
type: 'arearange',
|
|
232
|
+
name: s.intervalName ?? interval.name ?? `${name} interval`,
|
|
233
|
+
data: [
|
|
234
|
+
...pin,
|
|
235
|
+
...s.interval.map((range, j) => (flat !== undefined
|
|
236
|
+
? { x: start + j, low: flat, high: flat }
|
|
237
|
+
: { x: start + j, low: range[0], high: range[1] })),
|
|
238
|
+
],
|
|
239
|
+
...(bandColor ? { color: bandColor } : {}),
|
|
240
|
+
fillOpacity: s.intervalOpacity ?? interval.opacity ?? DEFAULT_INTERVAL_OPACITY,
|
|
241
|
+
lineWidth: 0,
|
|
242
|
+
zIndex: 0,
|
|
243
|
+
legendIndex: data.length + i,
|
|
244
|
+
yAxis: axisAt(s) === 'secondary' ? 1 : 0,
|
|
245
|
+
marker: { enabled: false },
|
|
246
|
+
// Bounds reach the tooltip via the pointFormatter, not by hover.
|
|
247
|
+
enableMouseTracking: false,
|
|
248
|
+
states: { inactive: { enabled: false } },
|
|
249
|
+
}];
|
|
250
|
+
});
|
|
251
|
+
const columnAxis = data.some(s => typeAt(s) === 'column');
|
|
252
|
+
const edge = splitAt(columnAxis);
|
|
253
|
+
const lastCategory = Math.max(categories.length - 1, start + Math.max(...data.map(s => (s.projected?.length ?? 0)), 0) - 1);
|
|
254
|
+
const plotLines = (p.showNowLine ?? true) && boundary >= 0
|
|
255
|
+
? [{
|
|
256
|
+
value: edge,
|
|
257
|
+
color: p.nowLineColor || FORECAST_NOW_LINE_COLOR,
|
|
258
|
+
width: 2,
|
|
259
|
+
dashStyle: 'Dash',
|
|
260
|
+
zIndex: 5,
|
|
261
|
+
...(p.nowLabel !== ''
|
|
262
|
+
? {
|
|
263
|
+
label: {
|
|
264
|
+
useHTML: true,
|
|
265
|
+
text: boundaryLabelHtml(p.nowLabel ?? 'Now'),
|
|
266
|
+
rotation: 0,
|
|
267
|
+
y: 6,
|
|
268
|
+
x: 4,
|
|
269
|
+
verticalAlign: 'top',
|
|
270
|
+
},
|
|
271
|
+
}
|
|
272
|
+
: {}),
|
|
273
|
+
}]
|
|
274
|
+
: [];
|
|
275
|
+
const showBand = boundary >= 0 && (!!p.bandLabel || !!p.bandColor) && lastCategory > boundary;
|
|
276
|
+
const plotBands = showBand
|
|
277
|
+
? [{
|
|
278
|
+
from: edge,
|
|
279
|
+
to: columnAxis ? lastCategory + 0.5 : lastCategory,
|
|
280
|
+
color: p.bandColor || FORECAST_BAND_COLOR,
|
|
281
|
+
...(p.bandLabel ? { label: { text: p.bandLabel, style: AXIS_LABEL_STYLE } } : {}),
|
|
282
|
+
}]
|
|
283
|
+
: [];
|
|
284
|
+
return {
|
|
285
|
+
// Real series first, bands appended — `chart.update(…, oneToOne)` matches
|
|
286
|
+
// by index, so a band at index 0 would corrupt the series replacing it.
|
|
287
|
+
series: [...series, ...bands],
|
|
288
|
+
plotLines,
|
|
289
|
+
plotBands,
|
|
290
|
+
tooltip: (intervalMeta.size
|
|
291
|
+
? { pointFormatter: buildIntervalPointFormatter(intervalMeta, boundary) }
|
|
292
|
+
: {}),
|
|
293
|
+
boundary,
|
|
294
|
+
hasSecondaryAxis: data.some(s => axisAt(s) === 'secondary'),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=chart-forecast.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NileDashboardConfig } from '
|
|
1
|
+
import type { NileDashboardConfig } from '../types/dashboard-config.type.js';
|
|
2
2
|
/**
|
|
3
3
|
* Converts a raw API dashboard response into a `NileDashboardConfig` ready for
|
|
4
4
|
* `<nile-dashboard-viewer>`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SeparatedChartConfigInputType } from '../types/separated-chart-config-input.type.js';
|
|
2
|
+
/** Same shape as `<nile-chart>` input: chart props + Aquera metadata (for primitive `nile-*-chart` tags). */
|
|
3
|
+
export type SeparatedChartDemoConfig = SeparatedChartConfigInputType;
|
|
4
|
+
export interface NormalizedChartConfig {
|
|
5
|
+
chart?: Record<string, unknown>;
|
|
6
|
+
aq?: {
|
|
7
|
+
chartTitle?: string;
|
|
8
|
+
chartSubtitle?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeChartConfig(input: object | null | undefined): NormalizedChartConfig;
|
|
12
|
+
/** Applies `chart` fields (minus `type`) and `aq` titles onto a chart element. */
|
|
13
|
+
export declare function applySeparatedChartConfig(target: object, input: object): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function normalizeChartConfig(input) {
|
|
2
|
+
if (!input)
|
|
3
|
+
return {};
|
|
4
|
+
const candidate = input;
|
|
5
|
+
if (candidate.chart !== undefined || candidate.aq !== undefined) {
|
|
6
|
+
return candidate;
|
|
7
|
+
}
|
|
8
|
+
const { chartTitle, chartSubtitle, ...chart } = candidate;
|
|
9
|
+
const aq = {
|
|
10
|
+
...(chartTitle !== undefined ? { chartTitle: chartTitle } : {}),
|
|
11
|
+
...(chartSubtitle !== undefined ? { chartSubtitle: chartSubtitle } : {}),
|
|
12
|
+
};
|
|
13
|
+
return { chart, ...(Object.keys(aq).length ? { aq } : {}) };
|
|
14
|
+
}
|
|
15
|
+
/** Applies `chart` fields (minus `type`) and `aq` titles onto a chart element. */
|
|
16
|
+
export function applySeparatedChartConfig(target, input) {
|
|
17
|
+
const { chart, aq } = normalizeChartConfig(input);
|
|
18
|
+
if (!chart)
|
|
19
|
+
return;
|
|
20
|
+
const { type: _type, ...rest } = chart;
|
|
21
|
+
Object.assign(target, rest);
|
|
22
|
+
if (aq) {
|
|
23
|
+
const t = target;
|
|
24
|
+
if (aq.chartTitle != null)
|
|
25
|
+
t.chartTitle = aq.chartTitle;
|
|
26
|
+
if (aq.chartSubtitle != null)
|
|
27
|
+
t.chartSubtitle = aq.chartSubtitle;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=separated-chart-config.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import NileElement from '../internal/nile-element.js';
|
|
2
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
3
3
|
import type { NileAiPanelConfigInputType } from '../internal/types/nile-ai-widgets-config-input.type.js';
|
|
4
4
|
import '../nile-ai-sender/index.js';
|
|
5
5
|
export declare class NileAiPanel extends NileElement {
|
|
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { html, nothing } from 'lit';
|
|
4
4
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
5
|
-
import NileElement from '../internal/nile-element.js';
|
|
5
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
6
6
|
import { styles } from './nile-ai-panel.css.js';
|
|
7
7
|
import '../nile-ai-sender/index.js';
|
|
8
8
|
let NileAiPanel = class NileAiPanel extends NileElement {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import NileElement from '../internal/nile-element.js';
|
|
2
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
3
3
|
import type { NileAiSenderConfigInputType } from '../internal/types/nile-ai-widgets-config-input.type.js';
|
|
4
4
|
export declare class NileAiSender extends NileElement {
|
|
5
5
|
static styles: CSSResultGroup;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import NileElement from '../internal/nile-element.js';
|
|
4
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
5
5
|
import { styles } from './nile-ai-sender.css.js';
|
|
6
6
|
let NileAiSender = class NileAiSender extends NileElement {
|
|
7
7
|
constructor() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import type Highcharts from 'highcharts';
|
|
3
|
-
import NileElement from '../internal/nile-element.js';
|
|
3
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
4
4
|
import type { NileChartConfigInputType } from '../internal/types/index.js';
|
|
5
5
|
import type { LegendConfig } from '../internal/types/index.js';
|
|
6
6
|
export interface AnomalySeriesData {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { getHighcharts } from '../internal/highcharts-provider.js';
|
|
5
|
-
import NileElement from '../internal/nile-element.js';
|
|
6
|
-
import { deepMerge } from '../internal/utils.js';
|
|
7
|
-
import { withResponsiveDefaults } from '../internal/responsive-defaults.js';
|
|
4
|
+
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
5
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
6
|
+
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
7
|
+
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
8
8
|
import { styles } from './nile-anomaly-chart.css.js';
|
|
9
9
|
let NileAnomalyChart = class NileAnomalyChart extends NileElement {
|
|
10
10
|
constructor() {
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import type Highcharts from 'highcharts';
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
3
|
+
import NileForecastableChart from '../internal/base/forecastable-chart.js';
|
|
4
|
+
import type { ForecastSeriesInput } from '../internal/utils/chart-forecast.js';
|
|
5
|
+
import type { LegendConfig, NileChartConfigInputType } from '../internal/types/index.js';
|
|
5
6
|
export interface AreaChartSeriesData {
|
|
6
7
|
name: string;
|
|
7
8
|
data: number[];
|
|
8
9
|
color?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare class NileAreaChart extends
|
|
11
|
+
export declare class NileAreaChart extends NileForecastableChart {
|
|
12
|
+
protected chartSeriesType: "area";
|
|
11
13
|
static styles: CSSResultGroup;
|
|
12
14
|
private _hc;
|
|
13
|
-
private chart;
|
|
14
15
|
private resizeObserver;
|
|
15
16
|
private chartContainer;
|
|
16
17
|
/** Full chart configuration. Accepts separated { chart, aq } input. */
|
|
17
18
|
config: NileChartConfigInputType | null;
|
|
18
19
|
chartTitle: string;
|
|
19
20
|
chartSubtitle: string;
|
|
20
|
-
data: AreaChartSeriesData
|
|
21
|
+
data: Array<AreaChartSeriesData | ForecastSeriesInput>;
|
|
21
22
|
categories: string[];
|
|
22
23
|
options: Highcharts.Options;
|
|
23
24
|
noResponsive: boolean;
|
|
@@ -27,7 +28,7 @@ export declare class NileAreaChart extends NileElement {
|
|
|
27
28
|
stacked: boolean;
|
|
28
29
|
showLegend: boolean;
|
|
29
30
|
/** Full legend configuration — all Highcharts legend options in one object. */
|
|
30
|
-
legend:
|
|
31
|
+
legend: LegendConfig | null;
|
|
31
32
|
chartBg: string;
|
|
32
33
|
chartBorderRadius: string | number;
|
|
33
34
|
chartBorder: string;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import { getHighcharts } from '../internal/highcharts-provider.js';
|
|
5
|
-
import
|
|
6
|
-
import { deepMerge } from '../internal/utils.js';
|
|
7
|
-
import {
|
|
4
|
+
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
5
|
+
import NileForecastableChart from '../internal/base/forecastable-chart.js';
|
|
6
|
+
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
7
|
+
import { normalizeChartConfig } from '../internal/utils/separated-chart-config.js';
|
|
8
|
+
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
8
9
|
import { styles } from './nile-area-chart.css.js';
|
|
9
|
-
let NileAreaChart = class NileAreaChart extends
|
|
10
|
+
let NileAreaChart = class NileAreaChart extends NileForecastableChart {
|
|
10
11
|
constructor() {
|
|
11
12
|
super(...arguments);
|
|
13
|
+
this.chartSeriesType = 'area';
|
|
12
14
|
this._hc = null;
|
|
13
|
-
this.chart = null;
|
|
14
15
|
this.resizeObserver = null;
|
|
15
16
|
/** Full chart configuration. Accepts separated { chart, aq } input. */
|
|
16
17
|
this.config = null;
|
|
@@ -64,7 +65,9 @@ let NileAreaChart = class NileAreaChart extends NileElement {
|
|
|
64
65
|
}
|
|
65
66
|
/** Apply { chart, aq } config to individual properties. */
|
|
66
67
|
applyConfig(cfg) {
|
|
67
|
-
|
|
68
|
+
// Accepts the flat `<nile-chart>` shape as well as `{ chart, aq }` —
|
|
69
|
+
// the flat form used to render nothing at all, silently.
|
|
70
|
+
const { chart: c, aq } = normalizeChartConfig(cfg);
|
|
68
71
|
if (c) {
|
|
69
72
|
const area = c;
|
|
70
73
|
if (area.data)
|
|
@@ -73,6 +76,7 @@ let NileAreaChart = class NileAreaChart extends NileElement {
|
|
|
73
76
|
this.categories = area.categories;
|
|
74
77
|
if (area.yAxisTitle)
|
|
75
78
|
this.yAxisTitle = area.yAxisTitle;
|
|
79
|
+
this.applyForecastableConfig(area);
|
|
76
80
|
if (area.height)
|
|
77
81
|
this.height = area.height;
|
|
78
82
|
if (area.loading !== undefined)
|
|
@@ -138,19 +142,18 @@ let NileAreaChart = class NileAreaChart extends NileElement {
|
|
|
138
142
|
'loadingText', 'loadingColor', 'loadingFontSize', 'loadingFontFamily', 'loadingBg'];
|
|
139
143
|
if (cssVarProps.some(p => changedProperties.has(p)))
|
|
140
144
|
this._syncCssVars();
|
|
141
|
-
const props = ['data', 'categories', 'chartTitle', 'chartSubtitle', 'options', 'height', 'yAxisTitle', 'stacked', 'loading', 'showLegend'];
|
|
145
|
+
const props = ['data', 'categories', 'chartTitle', 'chartSubtitle', 'options', 'height', 'yAxisTitle', 'stacked', 'loading', 'showLegend', ...NileForecastableChart.FORECASTABLE_PROPS];
|
|
142
146
|
if (!props.some(p => changedProperties.has(p)))
|
|
143
147
|
return;
|
|
144
148
|
if (this.loading) {
|
|
145
149
|
this.destroyChart();
|
|
146
150
|
return;
|
|
147
151
|
}
|
|
148
|
-
if (this.chart) {
|
|
149
|
-
this.chart.update(this.buildOptions(), true, true);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
+
if (!this.chart) {
|
|
152
153
|
this.initChart();
|
|
154
|
+
return;
|
|
153
155
|
}
|
|
156
|
+
this.updateChart(this.chart, changedProperties, r => this.buildOptions(r));
|
|
154
157
|
}
|
|
155
158
|
setupResizeObserver() {
|
|
156
159
|
if (!this.chartContainer)
|
|
@@ -158,20 +161,29 @@ let NileAreaChart = class NileAreaChart extends NileElement {
|
|
|
158
161
|
this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
|
|
159
162
|
this.resizeObserver.observe(this.chartContainer);
|
|
160
163
|
}
|
|
161
|
-
buildOptions() {
|
|
164
|
+
buildOptions(retract = false) {
|
|
162
165
|
const self = this;
|
|
166
|
+
const overlay = this.forecastOverlay(retract);
|
|
163
167
|
const merged = deepMerge({
|
|
164
|
-
chart: {
|
|
168
|
+
chart: {
|
|
169
|
+
type: this.chartSeriesType,
|
|
170
|
+
...(this.height ? { height: this.height } : {}),
|
|
171
|
+
},
|
|
165
172
|
title: { text: this.chartTitle || undefined },
|
|
166
173
|
subtitle: { text: this.chartSubtitle || undefined },
|
|
167
|
-
xAxis: {
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
xAxis: {
|
|
175
|
+
categories: this.categories,
|
|
176
|
+
title: { text: this.xAxisTitle || undefined },
|
|
177
|
+
plotLines: overlay.plotLines,
|
|
178
|
+
plotBands: overlay.plotBands,
|
|
179
|
+
},
|
|
180
|
+
yAxis: this.forecastYAxis({ title: { text: this.yAxisTitle || undefined } }, overlay.hasSecondaryAxis),
|
|
181
|
+
tooltip: { shared: true, ...overlay.tooltip },
|
|
170
182
|
plotOptions: {
|
|
171
183
|
area: { stacking: this.stacked ? 'normal' : undefined, fillOpacity: 0.25 },
|
|
172
|
-
series: { cursor: 'pointer', point: { events: { click() { self.emit('nile-chart-click', { point: this, category: this.category, value: this.y, seriesName: this.series.name }); } } } },
|
|
184
|
+
series: { cursor: 'pointer', point: { events: { click() { self.emit('nile-chart-click', { point: this, category: this.category, value: this.y, seriesName: this.series.name, forecast: self.isForecastPoint(this.x, overlay.boundary) }); } } } },
|
|
173
185
|
},
|
|
174
|
-
series: this.
|
|
186
|
+
series: this.forecastSeries(overlay),
|
|
175
187
|
legend: (() => { const { show, ...rest } = this.legend ?? {}; return { enabled: show ?? this.showLegend, ...rest }; })(),
|
|
176
188
|
credits: { enabled: false },
|
|
177
189
|
}, this.options);
|
|
@@ -182,12 +194,13 @@ let NileAreaChart = class NileAreaChart extends NileElement {
|
|
|
182
194
|
return;
|
|
183
195
|
if (!this._hc)
|
|
184
196
|
this._hc = await getHighcharts();
|
|
185
|
-
this.
|
|
186
|
-
this.
|
|
197
|
+
this._chart = this._hc.chart(this.chartContainer, this.buildOptions());
|
|
198
|
+
this._notifyChartReady();
|
|
199
|
+
this.emit('nile-chart-ready', { chart: this._chart });
|
|
187
200
|
}
|
|
188
|
-
destroyChart() { if (this.
|
|
189
|
-
this.
|
|
190
|
-
this.
|
|
201
|
+
destroyChart() { if (this._chart) {
|
|
202
|
+
this._chart.destroy();
|
|
203
|
+
this._clearChart();
|
|
191
204
|
} }
|
|
192
205
|
render() {
|
|
193
206
|
if (this.loading)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import type Highcharts from 'highcharts';
|
|
3
|
-
import NileElement from '../internal/nile-element.js';
|
|
3
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
4
4
|
import type { SeparatedChartConfigInputType } from '../internal/types/separated-chart-config-input.type.js';
|
|
5
5
|
import type { LegendConfig } from '../internal/types/index.js';
|
|
6
6
|
export interface AreaNegativeSeriesData {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import NileElement from '../internal/nile-element.js';
|
|
5
|
-
import { applySeparatedChartConfig } from '../internal/separated-chart-config.js';
|
|
6
|
-
import { getHighcharts } from '../internal/highcharts-provider.js';
|
|
7
|
-
import { deepMerge } from '../internal/utils.js';
|
|
8
|
-
import { withResponsiveDefaults } from '../internal/responsive-defaults.js';
|
|
4
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
5
|
+
import { applySeparatedChartConfig } from '../internal/utils/separated-chart-config.js';
|
|
6
|
+
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
7
|
+
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
8
|
+
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
9
9
|
import { styles } from './nile-area-negative-chart.css.js';
|
|
10
10
|
let NileAreaNegativeChart = class NileAreaNegativeChart extends NileElement {
|
|
11
11
|
constructor() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import type Highcharts from 'highcharts';
|
|
3
|
-
import NileElement from '../internal/nile-element.js';
|
|
3
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
4
4
|
import type { SeparatedChartConfigInputType } from '../internal/types/separated-chart-config-input.type.js';
|
|
5
5
|
import type { LegendConfig } from '../internal/types/index.js';
|
|
6
6
|
export interface AreaRangeSeriesData {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
3
|
import { html } from 'lit';
|
|
4
|
-
import NileElement from '../internal/nile-element.js';
|
|
5
|
-
import { applySeparatedChartConfig } from '../internal/separated-chart-config.js';
|
|
6
|
-
import { getHighcharts } from '../internal/highcharts-provider.js';
|
|
7
|
-
import { deepMerge } from '../internal/utils.js';
|
|
8
|
-
import { withResponsiveDefaults } from '../internal/responsive-defaults.js';
|
|
4
|
+
import NileElement from '../internal/base/nile-element.js';
|
|
5
|
+
import { applySeparatedChartConfig } from '../internal/utils/separated-chart-config.js';
|
|
6
|
+
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
7
|
+
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
8
|
+
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
9
9
|
import { styles } from './nile-area-range-chart.css.js';
|
|
10
10
|
let NileAreaRangeChart = class NileAreaRangeChart extends NileElement {
|
|
11
11
|
constructor() {
|