@aquera/nile-visualization 2.9.46 → 2.9.47
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 +3 -0
- package/dist/src/nile-chart/nile-chart-empty.js +3 -3
- package/dist/src/nile-chart/nile-chart.css.js +0 -12
- package/dist/src/nile-chart/nile-chart.d.ts +5 -29
- package/dist/src/nile-chart/nile-chart.js +68 -190
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +6 -10
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +1 -2
- package/package.json +1 -1
- package/dist/src/internal/utils/lite-tooltip.d.ts +0 -5
- package/dist/src/internal/utils/lite-tooltip.js +0 -18
package/README.md
CHANGED
|
@@ -36,6 +36,9 @@ 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.47 (November 20, 2026)
|
|
40
|
+
- Nile Charts: Reverted the 2.9.44 changes (x-axis label options and lite tooltips, UIF-1426)
|
|
41
|
+
|
|
39
42
|
#### Version 2.9.46 (November 19, 2026)
|
|
40
43
|
- Nile Charts: Charts follow the page's light/dark colour scheme. Chart containers now inherit the page's `color-scheme` instead of always using light, so Highcharts' text, axis, legend and gridline colours go dark under `:root[data-theme="dark"]` (or `color-scheme: dark`) and switch live when the theme changes. Light-only pages look the same as before; a chart's own `palette.colorScheme` still wins (UIF-1429)
|
|
41
44
|
- Nile Heatmap: Default colours are theme-aware. With no `minColor` / `maxColor` set, the scale runs #ffffff → #1e40af in light mode (as before) and #1a2440 → #60a5fa in dark mode; the cell border is #e2e8f0 / #22262f. Re-theme from CSS with `--nile-heatmap-min-color`, `--nile-heatmap-max-color` and `--nile-heatmap-border-color`. Explicit `minColor` / `maxColor` are unchanged (UIF-1429)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
2
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
3
3
|
import { renderChartGhost } from './nile-chart-skeleton.js';
|
|
4
|
-
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
5
4
|
/** Default empty state for `<nile-chart>`: detection (`isChartEmpty`) and markup (`renderChartEmptyState`). */
|
|
6
5
|
export const EMPTY_STATE_TITLE = 'No data';
|
|
7
6
|
export const EMPTY_STATE_DESCRIPTION = 'There is nothing to show for this chart yet. Data will appear here once it is available.';
|
|
8
7
|
// Tooltip width cap; longer text wraps. The tooltip mounts on <body>, where :root tokens resolve.
|
|
8
|
+
const TOOLTIP_MAX_WIDTH = 'var(--ng-width-64)';
|
|
9
9
|
// Types whose `data` is `[{ name, data: [...] }]`.
|
|
10
10
|
const SERIES_TYPES = new Set([
|
|
11
11
|
'bar', 'line', 'area', 'column', 'spline', 'scatter', 'bubble', 'radar',
|
|
@@ -207,12 +207,12 @@ export function renderChartEmptyState(opts = {}) {
|
|
|
207
207
|
: html `<div class="nile-chart-empty__ghost" part="empty-ghost" aria-hidden="true">
|
|
208
208
|
<slot name="empty-ghost">${renderChartGhost(opts.type)}</slot>
|
|
209
209
|
</div>`}
|
|
210
|
-
<nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--title" placement="top" .maxWidth=${
|
|
210
|
+
<nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--title" placement="top" .maxWidth=${TOOLTIP_MAX_WIDTH} disabled>
|
|
211
211
|
<div class="nile-chart-empty__title" part="empty-title">
|
|
212
212
|
<span class="nile-chart-empty__badge" part="empty-badge"><slot name="empty-title">${EMPTY_STATE_TITLE}</slot></span>
|
|
213
213
|
</div>
|
|
214
214
|
</nile-lite-tooltip>
|
|
215
|
-
<nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--description" placement="top" .maxWidth=${
|
|
215
|
+
<nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--description" placement="top" .maxWidth=${TOOLTIP_MAX_WIDTH} disabled>
|
|
216
216
|
<div class="nile-chart-empty__description" part="empty-description">
|
|
217
217
|
<slot name="empty-description">${EMPTY_STATE_DESCRIPTION}</slot>
|
|
218
218
|
</div>
|
|
@@ -256,18 +256,6 @@ export const styles = css `
|
|
|
256
256
|
flex: 0 1 auto;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
/* <nile-lite-tooltip> wrappers around the header title / subtitle; they must not break the ellipsis. */
|
|
260
|
-
.nile-chart-header-tip {
|
|
261
|
-
display: block;
|
|
262
|
-
width: 100%;
|
|
263
|
-
min-width: 0;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.nile-chart-header-title-row .nile-chart-header-tip {
|
|
267
|
-
width: auto;
|
|
268
|
-
flex: 0 1 auto;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
259
|
.nile-chart-header-info-tip {
|
|
272
260
|
display: inline-flex;
|
|
273
261
|
align-items: center;
|
|
@@ -88,8 +88,7 @@ import '../nile-ai-panel/index.js';
|
|
|
88
88
|
*/
|
|
89
89
|
export declare class NileChart extends NileElement {
|
|
90
90
|
static styles: CSSResultGroup;
|
|
91
|
-
|
|
92
|
-
private _axisTipEl;
|
|
91
|
+
private _headerTipEl;
|
|
93
92
|
private _headerResizeObs;
|
|
94
93
|
/** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
|
|
95
94
|
config: NileChartConfig | NileChartConfigInputType | null;
|
|
@@ -133,12 +132,6 @@ export declare class NileChart extends NileElement {
|
|
|
133
132
|
* Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
|
|
134
133
|
*/
|
|
135
134
|
chartTypeAttr: string;
|
|
136
|
-
/** Long x-axis labels: `truncate` (ellipsis) or `wrap`, at `xAxisLabelMaxWidth`. */
|
|
137
|
-
xAxisLabelMode: 'truncate' | 'wrap';
|
|
138
|
-
/** Max width in px of an x-axis label before it truncates or wraps. */
|
|
139
|
-
xAxisLabelMaxWidth: number;
|
|
140
|
-
/** Rotation in degrees of x-axis labels (e.g. `-45`); `0` keeps them flat. */
|
|
141
|
-
xAxisLabelRotation: number;
|
|
142
135
|
/** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
|
|
143
136
|
summary: string;
|
|
144
137
|
aiBorder: boolean;
|
|
@@ -273,30 +266,13 @@ export declare class NileChart extends NileElement {
|
|
|
273
266
|
private _renderMenuItem;
|
|
274
267
|
private renderActionsMenu;
|
|
275
268
|
private renderAiTrigger;
|
|
269
|
+
private _showHeaderTip;
|
|
270
|
+
private _hideHeaderTip;
|
|
271
|
+
private _onViewportMove;
|
|
276
272
|
/** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
|
|
277
273
|
private renderHeaderInfo;
|
|
278
|
-
|
|
279
|
-
private _axisLabelFrom;
|
|
280
|
-
/** Finds an unrotated label by pointer coordinates, since some browsers report the wrong event target. */
|
|
281
|
-
private _axisLabelAt;
|
|
282
|
-
/** The x-axis label the tooltip belongs to. */
|
|
283
|
-
private _axisLabelActive;
|
|
284
|
-
/** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
|
|
285
|
-
private _onAxisLabelMove;
|
|
286
|
-
private _showAxisLabelTip;
|
|
287
|
-
private _axisTipHideTimer;
|
|
288
|
-
private _cancelAxisTipHide;
|
|
289
|
-
/** Brief grace period so crossing the gap between two labels doesn't close and reopen the tooltip. */
|
|
290
|
-
private _scheduleAxisTipHide;
|
|
291
|
-
/** Drop the current label tooltip: instantly, or after letting it fade out. */
|
|
292
|
-
private _removeAxisTip;
|
|
293
|
-
private _hideAxisLabelTip;
|
|
294
|
-
private _onAxisViewportMove;
|
|
295
|
-
private _onAxisLabelOut;
|
|
296
|
-
private _onAxisLabelLeave;
|
|
274
|
+
private _onHeaderTextEnter;
|
|
297
275
|
private _syncHeaderTruncationA11y;
|
|
298
|
-
/** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
|
|
299
|
-
private renderHeaderText;
|
|
300
276
|
private renderHeader;
|
|
301
277
|
private renderAiPanel;
|
|
302
278
|
private _echart;
|
|
@@ -4,7 +4,7 @@ import { customElement, property, query, state } from 'lit/decorators.js';
|
|
|
4
4
|
import { html, nothing } from 'lit';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import NileElement from '../internal/base/nile-element.js';
|
|
7
|
-
import { styles, injectGlobalChartMenuOverrides } from './nile-chart.css.js';
|
|
7
|
+
import { styles, tooltipCss, injectGlobalChartMenuOverrides } from './nile-chart.css.js';
|
|
8
8
|
import { HIGHCHARTS_PASSTHROUGH_KEYS } from '../internal/types/index.js';
|
|
9
9
|
import { nileChartConfig } from './nile-chart-config-builder.js';
|
|
10
10
|
import { renderChartSkeleton } from './nile-chart-skeleton.js';
|
|
@@ -13,7 +13,6 @@ import { isChartEmpty, renderChartEmptyState, syncChartEmptyTruncation } from '.
|
|
|
13
13
|
import { convertConfig } from '../internal/utils/chart-adapters.js';
|
|
14
14
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
15
15
|
import { initNileChartExporting, getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
16
|
-
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
17
16
|
import { getECharts, translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES } from '../internal/echarts/index.js';
|
|
18
17
|
import { getAxisExtremes, setAxisExtremes, } from '../internal/utils/chart-runtime.js';
|
|
19
18
|
import { resolveColorPaletteColors } from '../internal/color-palettes/index.js';
|
|
@@ -126,6 +125,16 @@ function chartTypeLabel(type) {
|
|
|
126
125
|
.replace(/-/g, ' ')
|
|
127
126
|
.replace(/\b\w/g, ch => ch.toUpperCase());
|
|
128
127
|
}
|
|
128
|
+
let _headerTooltipStylesInjected = false;
|
|
129
|
+
function ensureHeaderTooltipStyles() {
|
|
130
|
+
if (_headerTooltipStylesInjected || typeof document === 'undefined')
|
|
131
|
+
return;
|
|
132
|
+
const style = document.createElement('style');
|
|
133
|
+
style.dataset['nilechart'] = '';
|
|
134
|
+
style.textContent = tooltipCss;
|
|
135
|
+
document.head.appendChild(style);
|
|
136
|
+
_headerTooltipStylesInjected = true;
|
|
137
|
+
}
|
|
129
138
|
/**
|
|
130
139
|
* Universal chart wrapper. Renders a card with an optional header (titles +
|
|
131
140
|
* actions) and the active chart type below.
|
|
@@ -161,8 +170,7 @@ function chartTypeLabel(type) {
|
|
|
161
170
|
let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
162
171
|
constructor() {
|
|
163
172
|
super(...arguments);
|
|
164
|
-
|
|
165
|
-
this._axisTipEl = null;
|
|
173
|
+
this._headerTipEl = null;
|
|
166
174
|
this._headerResizeObs = null;
|
|
167
175
|
/** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
|
|
168
176
|
this.config = null;
|
|
@@ -206,12 +214,6 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
206
214
|
* Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
|
|
207
215
|
*/
|
|
208
216
|
this.chartTypeAttr = '';
|
|
209
|
-
/** Long x-axis labels: `truncate` (ellipsis) or `wrap`, at `xAxisLabelMaxWidth`. */
|
|
210
|
-
this.xAxisLabelMode = 'truncate';
|
|
211
|
-
/** Max width in px of an x-axis label before it truncates or wraps. */
|
|
212
|
-
this.xAxisLabelMaxWidth = 80;
|
|
213
|
-
/** Rotation in degrees of x-axis labels (e.g. `-45`); `0` keeps them flat. */
|
|
214
|
-
this.xAxisLabelRotation = 0;
|
|
215
217
|
/** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
|
|
216
218
|
this.summary = '';
|
|
217
219
|
this.aiBorder = false;
|
|
@@ -299,38 +301,15 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
299
301
|
this.onGridColumnOrderChange = () => {
|
|
300
302
|
this.requestUpdate();
|
|
301
303
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.
|
|
306
|
-
const el =
|
|
307
|
-
if (el
|
|
308
|
-
return;
|
|
309
|
-
this._axisLabelActive = el;
|
|
310
|
-
if (el && el.scrollWidth > el.clientWidth) {
|
|
311
|
-
this._cancelAxisTipHide();
|
|
312
|
-
this._showAxisLabelTip(el);
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
this._scheduleAxisTipHide();
|
|
316
|
-
}
|
|
317
|
-
};
|
|
318
|
-
this._axisTipHideTimer = null;
|
|
319
|
-
this._onAxisViewportMove = () => {
|
|
320
|
-
this._axisLabelActive = null;
|
|
321
|
-
this._hideAxisLabelTip();
|
|
322
|
-
};
|
|
323
|
-
this._onAxisLabelOut = (e) => {
|
|
324
|
-
if (!this._axisLabelFrom(e))
|
|
304
|
+
// The tooltip is fixed to the viewport and placed once, so any scroll (including a touch-drag while the
|
|
305
|
+
// finger is still down, when no leave/blur fires) would strand it away from its anchor. Hide it instead.
|
|
306
|
+
this._onViewportMove = () => this._hideHeaderTip();
|
|
307
|
+
this._onHeaderTextEnter = (e) => {
|
|
308
|
+
const el = e.currentTarget;
|
|
309
|
+
if (el.scrollWidth <= el.clientWidth)
|
|
325
310
|
return;
|
|
326
|
-
|
|
327
|
-
this.
|
|
328
|
-
};
|
|
329
|
-
this._onAxisLabelLeave = () => {
|
|
330
|
-
if (!this._axisLabelActive)
|
|
331
|
-
return;
|
|
332
|
-
this._axisLabelActive = null;
|
|
333
|
-
this._scheduleAxisTipHide();
|
|
311
|
+
const rect = el.getBoundingClientRect();
|
|
312
|
+
this._showHeaderTip(el.textContent ?? '', rect.left + rect.width / 2, rect.top, rect.height);
|
|
334
313
|
};
|
|
335
314
|
// ── ECharts engine path (NILE-005) ──────────────────────────────
|
|
336
315
|
this._echart = null;
|
|
@@ -404,13 +383,16 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
404
383
|
}
|
|
405
384
|
connectedCallback() {
|
|
406
385
|
super.connectedCallback();
|
|
386
|
+
ensureHeaderTooltipStyles();
|
|
407
387
|
injectGlobalChartMenuOverrides();
|
|
388
|
+
const tip = document.createElement('div');
|
|
389
|
+
tip.className = 'nile-chart-header-tooltip';
|
|
390
|
+
tip.setAttribute('role', 'tooltip');
|
|
391
|
+
document.body.appendChild(tip);
|
|
392
|
+
this._headerTipEl = tip;
|
|
408
393
|
document.addEventListener('click', this.handleOutsideClick);
|
|
409
394
|
this.addEventListener('nile-chart-ready', this.handleChartReady);
|
|
410
395
|
this.addEventListener('dblclick', this._onDoubleTap);
|
|
411
|
-
this.addEventListener('mousemove', this._onAxisLabelMove);
|
|
412
|
-
this.addEventListener('mouseout', this._onAxisLabelOut);
|
|
413
|
-
this.addEventListener('mouseleave', this._onAxisLabelLeave);
|
|
414
396
|
initNileChartExporting();
|
|
415
397
|
// Pick up config set before element upgrade (e.g. Angular ngAfterViewInit)
|
|
416
398
|
if (this.config && !this.resolvedConfig) {
|
|
@@ -424,11 +406,9 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
424
406
|
document.removeEventListener('click', this.handleOutsideClick);
|
|
425
407
|
this.removeEventListener('nile-chart-ready', this.handleChartReady);
|
|
426
408
|
this.removeEventListener('dblclick', this._onDoubleTap);
|
|
427
|
-
this.
|
|
428
|
-
this.
|
|
429
|
-
this.
|
|
430
|
-
this._hideAxisLabelTip();
|
|
431
|
-
this._removeAxisTip(true);
|
|
409
|
+
this._hideHeaderTip();
|
|
410
|
+
this._headerTipEl?.remove();
|
|
411
|
+
this._headerTipEl = null;
|
|
432
412
|
this._headerResizeObs?.disconnect();
|
|
433
413
|
this._headerResizeObs = null;
|
|
434
414
|
this._emptyObs?.disconnect();
|
|
@@ -897,13 +877,40 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
897
877
|
<slot name="nile-ai-trigger-after"></slot>
|
|
898
878
|
`;
|
|
899
879
|
}
|
|
880
|
+
_showHeaderTip(text, x, y, anchorHeight = 0) {
|
|
881
|
+
if (!this._headerTipEl)
|
|
882
|
+
return;
|
|
883
|
+
this._headerTipEl.textContent = text;
|
|
884
|
+
this._headerTipEl.style.left = `${x}px`;
|
|
885
|
+
this._headerTipEl.style.top = `${y}px`;
|
|
886
|
+
this._headerTipEl.style.display = 'block';
|
|
887
|
+
window.addEventListener('scroll', this._onViewportMove, { capture: true, passive: true });
|
|
888
|
+
window.addEventListener('resize', this._onViewportMove, { passive: true });
|
|
889
|
+
// Keep the tooltip inside the viewport; the arrow keeps pointing at the anchor.
|
|
890
|
+
const margin = 8;
|
|
891
|
+
const half = this._headerTipEl.offsetWidth / 2;
|
|
892
|
+
const cx = Math.min(Math.max(x, half + margin), Math.max(half + margin, window.innerWidth - half - margin));
|
|
893
|
+
this._headerTipEl.style.left = `${cx}px`;
|
|
894
|
+
this._headerTipEl.style.setProperty('--tip-arrow-x', `${half + x - cx}px`);
|
|
895
|
+
// Not enough room above the anchor: drop below it instead.
|
|
896
|
+
const above = y - this._headerTipEl.offsetHeight - 10 >= margin;
|
|
897
|
+
this._headerTipEl.classList.toggle('below', !above);
|
|
898
|
+
if (!above)
|
|
899
|
+
this._headerTipEl.style.top = `${y + anchorHeight}px`;
|
|
900
|
+
}
|
|
901
|
+
_hideHeaderTip() {
|
|
902
|
+
if (this._headerTipEl)
|
|
903
|
+
this._headerTipEl.style.display = 'none';
|
|
904
|
+
window.removeEventListener('scroll', this._onViewportMove, true);
|
|
905
|
+
window.removeEventListener('resize', this._onViewportMove);
|
|
906
|
+
}
|
|
900
907
|
/** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
|
|
901
908
|
renderHeaderInfo() {
|
|
902
909
|
const info = String(this.headerInfo('chartInfo') ?? '');
|
|
903
910
|
if (!info)
|
|
904
911
|
return nothing;
|
|
905
912
|
const size = this.headerInfo('chartInfoIconSize');
|
|
906
|
-
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"
|
|
913
|
+
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"><span
|
|
907
914
|
class="nile-chart-header-info"
|
|
908
915
|
part="header-info"
|
|
909
916
|
role="img"
|
|
@@ -916,118 +923,24 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
916
923
|
color=${this.headerInfo('chartInfoIconColor') || 'currentColor'}
|
|
917
924
|
></nile-glyph></span></nile-lite-tooltip>`;
|
|
918
925
|
}
|
|
919
|
-
/** The x-axis label span in the event's composed path, if any. */
|
|
920
|
-
_axisLabelFrom(e) {
|
|
921
|
-
const hit = e.composedPath().find((n) => n instanceof HTMLElement && n.classList.contains('nile-axis-label'));
|
|
922
|
-
return hit ?? null;
|
|
923
|
-
}
|
|
924
|
-
/** Finds an unrotated label by pointer coordinates, since some browsers report the wrong event target. */
|
|
925
|
-
_axisLabelAt(e) {
|
|
926
|
-
const m = e;
|
|
927
|
-
if (typeof m.clientX !== 'number')
|
|
928
|
-
return null;
|
|
929
|
-
const svg = e.composedPath().find((n) => n instanceof Element && n.classList.contains('highcharts-root'));
|
|
930
|
-
if (!svg)
|
|
931
|
-
return null;
|
|
932
|
-
for (const el of Array.from(svg.querySelectorAll('.nile-axis-label'))) {
|
|
933
|
-
const r = el.getBoundingClientRect();
|
|
934
|
-
const rotated = r.height > el.offsetHeight + 4 || r.width > el.offsetWidth + 4;
|
|
935
|
-
if (rotated)
|
|
936
|
-
continue; // rotated boxes are much larger than the text; their span target is reliable
|
|
937
|
-
if (m.clientX >= r.left && m.clientX <= r.right && m.clientY >= r.top && m.clientY <= r.bottom)
|
|
938
|
-
return el;
|
|
939
|
-
}
|
|
940
|
-
return null;
|
|
941
|
-
}
|
|
942
|
-
_showAxisLabelTip(el) {
|
|
943
|
-
const text = el.textContent ?? '';
|
|
944
|
-
const rect = el.getBoundingClientRect();
|
|
945
|
-
// A rotated label's box is taller than its text, so aim at its centre.
|
|
946
|
-
const rotated = rect.height > el.offsetHeight + 4 || rect.width > el.offsetWidth + 4;
|
|
947
|
-
if (!customElements.get('nile-lite-tooltip'))
|
|
948
|
-
return;
|
|
949
|
-
// A fresh tooltip per label: reopening a shared one inside its fade-out shows nothing.
|
|
950
|
-
this._removeAxisTip(true);
|
|
951
|
-
const tip = document.createElement('nile-lite-tooltip');
|
|
952
|
-
tip.setAttribute('placement', 'top');
|
|
953
|
-
tip.setAttribute('trigger', 'manual');
|
|
954
|
-
tip.maxWidth = LITE_TOOLTIP_MAX_WIDTH;
|
|
955
|
-
tip.addEventListener('nile-show', limitLiteTooltipHeight);
|
|
956
|
-
const anchor = document.createElement('div');
|
|
957
|
-
anchor.setAttribute('aria-hidden', 'true');
|
|
958
|
-
anchor.style.cssText = 'position:fixed;pointer-events:none;visibility:hidden;';
|
|
959
|
-
anchor.style.left = `${rotated ? rect.left + rect.width / 2 : rect.left}px`;
|
|
960
|
-
anchor.style.top = `${rotated ? rect.top + rect.height / 2 : rect.top}px`;
|
|
961
|
-
anchor.style.width = rotated ? '1px' : `${rect.width}px`;
|
|
962
|
-
anchor.style.height = rotated ? '1px' : `${rect.height}px`;
|
|
963
|
-
tip.appendChild(anchor);
|
|
964
|
-
document.body.appendChild(tip);
|
|
965
|
-
tip.content = text;
|
|
966
|
-
this._axisTipEl = tip;
|
|
967
|
-
// Open after the first render; opening at creation shows nothing.
|
|
968
|
-
void tip.updateComplete?.then(() => {
|
|
969
|
-
if (this._axisTipEl === tip)
|
|
970
|
-
tip.open = true;
|
|
971
|
-
});
|
|
972
|
-
// The anchor uses viewport coordinates and is placed once, so close on scroll/resize.
|
|
973
|
-
window.addEventListener('scroll', this._onAxisViewportMove, { capture: true, passive: true });
|
|
974
|
-
window.addEventListener('resize', this._onAxisViewportMove, { passive: true });
|
|
975
|
-
}
|
|
976
|
-
_cancelAxisTipHide() {
|
|
977
|
-
if (this._axisTipHideTimer !== null) {
|
|
978
|
-
window.clearTimeout(this._axisTipHideTimer);
|
|
979
|
-
this._axisTipHideTimer = null;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
/** Brief grace period so crossing the gap between two labels doesn't close and reopen the tooltip. */
|
|
983
|
-
_scheduleAxisTipHide() {
|
|
984
|
-
this._cancelAxisTipHide();
|
|
985
|
-
this._axisTipHideTimer = window.setTimeout(() => {
|
|
986
|
-
this._axisTipHideTimer = null;
|
|
987
|
-
this._hideAxisLabelTip();
|
|
988
|
-
}, 120);
|
|
989
|
-
}
|
|
990
|
-
/** Drop the current label tooltip: instantly, or after letting it fade out. */
|
|
991
|
-
_removeAxisTip(instant) {
|
|
992
|
-
const tip = this._axisTipEl;
|
|
993
|
-
this._axisTipEl = null;
|
|
994
|
-
if (!tip)
|
|
995
|
-
return;
|
|
996
|
-
if (instant) {
|
|
997
|
-
tip.remove();
|
|
998
|
-
return;
|
|
999
|
-
}
|
|
1000
|
-
tip.open = false;
|
|
1001
|
-
window.setTimeout(() => tip.remove(), 300);
|
|
1002
|
-
}
|
|
1003
|
-
_hideAxisLabelTip() {
|
|
1004
|
-
this._cancelAxisTipHide();
|
|
1005
|
-
this._removeAxisTip(false);
|
|
1006
|
-
window.removeEventListener('scroll', this._onAxisViewportMove, true);
|
|
1007
|
-
window.removeEventListener('resize', this._onAxisViewportMove);
|
|
1008
|
-
}
|
|
1009
926
|
_syncHeaderTruncationA11y() {
|
|
1010
927
|
const root = this.shadowRoot;
|
|
1011
928
|
if (!root)
|
|
1012
929
|
return;
|
|
1013
|
-
for (const
|
|
1014
|
-
const el = root.querySelector(
|
|
930
|
+
for (const sel of ['.nile-chart-header-title', '.nile-chart-header-subtitle']) {
|
|
931
|
+
const el = root.querySelector(sel);
|
|
1015
932
|
if (!el)
|
|
1016
933
|
continue;
|
|
1017
|
-
const tip = root.querySelector(`.nile-chart-header-tip[data-header-tip="${kind}"]`);
|
|
1018
934
|
const truncated = el.scrollWidth > el.clientWidth;
|
|
1019
|
-
if (truncated)
|
|
935
|
+
if (truncated) {
|
|
1020
936
|
el.setAttribute('tabindex', '0');
|
|
1021
|
-
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
1022
939
|
el.removeAttribute('tabindex');
|
|
1023
|
-
|
|
1024
|
-
|
|
940
|
+
this._hideHeaderTip();
|
|
941
|
+
}
|
|
1025
942
|
}
|
|
1026
943
|
}
|
|
1027
|
-
/** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
|
|
1028
|
-
renderHeaderText(kind, text, fontSize) {
|
|
1029
|
-
return html `<nile-lite-tooltip class="nile-chart-header-tip" data-header-tip=${kind} content=${text} placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} disabled><p class="nile-chart-header-${kind}" part="header-${kind}" style=${fontSize ? `font-size:${fontSize}` : nothing}>${text}</p></nile-lite-tooltip>`;
|
|
1030
|
-
}
|
|
1031
944
|
renderHeader() {
|
|
1032
945
|
if (!this.shouldShowHeader())
|
|
1033
946
|
return nothing;
|
|
@@ -1045,10 +958,10 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1045
958
|
? html `
|
|
1046
959
|
${title
|
|
1047
960
|
? this.headerInfo('chartInfo')
|
|
1048
|
-
? html `<div class="nile-chart-header-title-row" part="header-title-row">${
|
|
1049
|
-
:
|
|
961
|
+
? html `<div class="nile-chart-header-title-row" part="header-title-row">${html `<p class="nile-chart-header-title" part="header-title" style=${titleFontSize ? `font-size:${titleFontSize}` : nothing} @mouseenter=${this._onHeaderTextEnter} @mouseleave=${() => this._hideHeaderTip()} @focus=${this._onHeaderTextEnter} @blur=${() => this._hideHeaderTip()}>${title}</p>`}${this.renderHeaderInfo()}</div>`
|
|
962
|
+
: html `<p class="nile-chart-header-title" part="header-title" style=${titleFontSize ? `font-size:${titleFontSize}` : nothing} @mouseenter=${this._onHeaderTextEnter} @mouseleave=${() => this._hideHeaderTip()} @focus=${this._onHeaderTextEnter} @blur=${() => this._hideHeaderTip()}>${title}</p>`
|
|
1050
963
|
: nothing}
|
|
1051
|
-
${subtitle ?
|
|
964
|
+
${subtitle ? html `<p class="nile-chart-header-subtitle" part="header-subtitle" style=${subtitleFontSize ? `font-size:${subtitleFontSize}` : nothing} @mouseenter=${this._onHeaderTextEnter} @mouseleave=${() => this._hideHeaderTip()} @focus=${this._onHeaderTextEnter} @blur=${() => this._hideHeaderTip()}>${subtitle}</p>` : nothing}
|
|
1052
965
|
`
|
|
1053
966
|
: nothing}
|
|
1054
967
|
</div>
|
|
@@ -1154,32 +1067,6 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1154
1067
|
const { show, ...rest } = config.legend;
|
|
1155
1068
|
legendOptions.legend = { enabled: show ?? true, ...rest };
|
|
1156
1069
|
}
|
|
1157
|
-
const truncate = this.xAxisLabelMode !== 'wrap';
|
|
1158
|
-
const maxWidth = this.xAxisLabelMaxWidth;
|
|
1159
|
-
const labelOptions = {
|
|
1160
|
-
xAxis: {
|
|
1161
|
-
labels: {
|
|
1162
|
-
rotation: this.xAxisLabelRotation,
|
|
1163
|
-
// HTML labels allow the hover tooltip; defaultLabelFormatter keeps numeric/datetime axes formatted.
|
|
1164
|
-
useHTML: true,
|
|
1165
|
-
formatter() {
|
|
1166
|
-
const text = String(this.axis.defaultLabelFormatter.call(this));
|
|
1167
|
-
const esc = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
1168
|
-
// text-overflow isn't inherited, so the clipping styles go on the span.
|
|
1169
|
-
const clip = truncate
|
|
1170
|
-
? `display:inline-block;max-width:min(${maxWidth}px,100%);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:top;`
|
|
1171
|
-
: '';
|
|
1172
|
-
return `<span class="nile-axis-label" style="${clip}">${esc}</span>`;
|
|
1173
|
-
},
|
|
1174
|
-
style: {
|
|
1175
|
-
width: `${this.xAxisLabelMaxWidth}px`,
|
|
1176
|
-
...(this.xAxisLabelMode === 'wrap'
|
|
1177
|
-
? { whiteSpace: 'normal', textOverflow: 'clip' }
|
|
1178
|
-
: { whiteSpace: 'nowrap', textOverflow: 'ellipsis' }),
|
|
1179
|
-
},
|
|
1180
|
-
},
|
|
1181
|
-
},
|
|
1182
|
-
};
|
|
1183
1070
|
const spacingOptions = {};
|
|
1184
1071
|
if (config.chartSpacing) {
|
|
1185
1072
|
const { top, right, bottom, left } = config.chartSpacing;
|
|
@@ -1221,7 +1108,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1221
1108
|
const paletteOptions = paletteColors ? { colors: paletteColors } : {};
|
|
1222
1109
|
// Precedence (later wins): raw options → passthrough fields → legend →
|
|
1223
1110
|
// spacing → palette → title suppression → exporting.
|
|
1224
|
-
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(
|
|
1111
|
+
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(config.options ?? {}, passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
|
|
1225
1112
|
switch (config.type) {
|
|
1226
1113
|
case 'bar':
|
|
1227
1114
|
return html `<nile-bar-chart
|
|
@@ -2600,15 +2487,6 @@ __decorate([
|
|
|
2600
2487
|
__decorate([
|
|
2601
2488
|
property({ type: String, attribute: 'chart-type' })
|
|
2602
2489
|
], NileChart.prototype, "chartTypeAttr", void 0);
|
|
2603
|
-
__decorate([
|
|
2604
|
-
property({ type: String, attribute: true })
|
|
2605
|
-
], NileChart.prototype, "xAxisLabelMode", void 0);
|
|
2606
|
-
__decorate([
|
|
2607
|
-
property({ type: Number, attribute: true })
|
|
2608
|
-
], NileChart.prototype, "xAxisLabelMaxWidth", void 0);
|
|
2609
|
-
__decorate([
|
|
2610
|
-
property({ type: Number, attribute: true })
|
|
2611
|
-
], NileChart.prototype, "xAxisLabelRotation", void 0);
|
|
2612
2490
|
__decorate([
|
|
2613
2491
|
property({ type: String })
|
|
2614
2492
|
], NileChart.prototype, "summary", void 0);
|
|
@@ -5,7 +5,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
5
5
|
import NileElement from '../internal/base/nile-element.js';
|
|
6
6
|
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
7
7
|
import { styles, tooltipCss } from './nile-kpi-chart.css.js';
|
|
8
|
-
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
9
8
|
// Inject tooltip styles into document.head once per page load.
|
|
10
9
|
let _tooltipStylesInjected = false;
|
|
11
10
|
function ensureTooltipStyles() {
|
|
@@ -1255,9 +1254,6 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1255
1254
|
return nothing;
|
|
1256
1255
|
const [vertical, side] = (typeof this.valueInfoPlacement === 'string' ? this.valueInfoPlacement : 'top-right').split('-');
|
|
1257
1256
|
return html `<nile-lite-tooltip
|
|
1258
|
-
.maxWidth=${LITE_TOOLTIP_MAX_WIDTH}
|
|
1259
|
-
@nile-show=${limitLiteTooltipHeight}
|
|
1260
|
-
interactive
|
|
1261
1257
|
class="kpi-info-tip kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
|
|
1262
1258
|
content=${this.valueInfo}
|
|
1263
1259
|
placement="top"
|
|
@@ -1306,7 +1302,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1306
1302
|
const dir = this.trendDirection;
|
|
1307
1303
|
const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
|
|
1308
1304
|
const trendAriaLabel = `Trend ${dir === 'up' ? 'up' : dir === 'down' ? 'down' : 'neutral'} ${formatted}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
|
|
1309
|
-
return html `<nile-lite-tooltip
|
|
1305
|
+
return html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
|
|
1310
1306
|
class="kpi-trend kpi-trend--${dir}"
|
|
1311
1307
|
tabindex="0"
|
|
1312
1308
|
role="button"
|
|
@@ -1373,7 +1369,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1373
1369
|
*/
|
|
1374
1370
|
renderHeaderRow(extra, trendRow) {
|
|
1375
1371
|
return html `<div class="kpi-header">
|
|
1376
|
-
${this.label ? html `<nile-lite-tooltip
|
|
1372
|
+
${this.label ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
|
|
1377
1373
|
class="kpi-label"
|
|
1378
1374
|
tabindex="0"
|
|
1379
1375
|
><span class="kpi-label-text">${this.label}</span></p></nile-lite-tooltip>` : nothing}
|
|
@@ -1409,7 +1405,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1409
1405
|
<span class="kpi-value-group">
|
|
1410
1406
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1411
1407
|
${showTooltip
|
|
1412
|
-
? html `<nile-lite-tooltip
|
|
1408
|
+
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1413
1409
|
: valueEl}
|
|
1414
1410
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1415
1411
|
</span>
|
|
@@ -1417,7 +1413,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1417
1413
|
|
|
1418
1414
|
${this.renderForecast()}
|
|
1419
1415
|
|
|
1420
|
-
${this.description ? html `<nile-lite-tooltip
|
|
1416
|
+
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1421
1417
|
class="kpi-description"
|
|
1422
1418
|
tabindex="0"
|
|
1423
1419
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -1451,7 +1447,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1451
1447
|
<span class="kpi-value-group">
|
|
1452
1448
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1453
1449
|
${showTooltip
|
|
1454
|
-
? html `<nile-lite-tooltip
|
|
1450
|
+
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1455
1451
|
: valueEl}
|
|
1456
1452
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1457
1453
|
</span>
|
|
@@ -1463,7 +1459,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1463
1459
|
|
|
1464
1460
|
${this.renderForecast()}
|
|
1465
1461
|
|
|
1466
|
-
${this.description ? html `<nile-lite-tooltip
|
|
1462
|
+
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1467
1463
|
class="kpi-description"
|
|
1468
1464
|
tabindex="0"
|
|
1469
1465
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -7,7 +7,6 @@ import { applySeparatedChartConfig } from '../internal/utils/separated-chart-con
|
|
|
7
7
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
8
8
|
import { withResponsiveDefaults } from '../internal/utils/responsive-defaults.js';
|
|
9
9
|
import { styles } from './nile-master-detail-chart.css.js';
|
|
10
|
-
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
11
10
|
export const MASTER_DETAIL_STACKING = ['normal', 'percent'];
|
|
12
11
|
export const MASTER_DETAIL_SERIES_TYPES = [
|
|
13
12
|
'area',
|
|
@@ -556,7 +555,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
556
555
|
? null
|
|
557
556
|
: html `<div class="detail-container ${masterHidden ? 'detail-container--grow' : ''}" part="detail-container"></div>
|
|
558
557
|
${this.masterCollapsible
|
|
559
|
-
? html `<nile-lite-tooltip
|
|
558
|
+
? html `<nile-lite-tooltip content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
|
|
560
559
|
<button
|
|
561
560
|
type="button"
|
|
562
561
|
class="master-toggle"
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** Default size limits for every nile-lite-tooltip the charts render. */
|
|
2
|
-
export declare const LITE_TOOLTIP_MAX_WIDTH = "var(--ng-width-64)";
|
|
3
|
-
export declare const LITE_TOOLTIP_MAX_HEIGHT = 250;
|
|
4
|
-
/** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
|
|
5
|
-
export declare function limitLiteTooltipHeight(e: Event): void;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Default size limits for every nile-lite-tooltip the charts render. */
|
|
2
|
-
export const LITE_TOOLTIP_MAX_WIDTH = 'var(--ng-width-64)';
|
|
3
|
-
export const LITE_TOOLTIP_MAX_HEIGHT = 250;
|
|
4
|
-
/** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
|
|
5
|
-
export function limitLiteTooltipHeight(e) {
|
|
6
|
-
const popper = e.detail?.instance?.popper;
|
|
7
|
-
const box = popper?.querySelector('.tippy-box');
|
|
8
|
-
const content = popper?.querySelector('.tippy-content');
|
|
9
|
-
if (!box || !content)
|
|
10
|
-
return;
|
|
11
|
-
box.style.boxSizing = 'border-box';
|
|
12
|
-
box.style.maxHeight = `${LITE_TOOLTIP_MAX_HEIGHT}px`;
|
|
13
|
-
box.style.display = 'flex';
|
|
14
|
-
box.style.flexDirection = 'column';
|
|
15
|
-
content.style.minHeight = '0';
|
|
16
|
-
content.style.overflowY = 'auto';
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=lite-tooltip.js.map
|