@aquera/nile-visualization 2.9.43 → 2.9.44
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 +4 -0
- package/dist/src/internal/utils/lite-tooltip.d.ts +5 -0
- package/dist/src/internal/utils/lite-tooltip.js +18 -0
- package/dist/src/nile-chart/nile-chart-empty.js +3 -3
- package/dist/src/nile-chart/nile-chart.css.js +12 -0
- package/dist/src/nile-chart/nile-chart.d.ts +29 -5
- package/dist/src/nile-chart/nile-chart.js +190 -68
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +10 -6
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,10 @@ 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.44 (November 18, 2026)
|
|
40
|
+
- Nile Charts: Long x-axis labels no longer rotate and shrink the plot. `xAxisLabelMode` (`truncate` by default, or `wrap`), `xAxisLabelMaxWidth` (default 80) and `xAxisLabelRotation` control how they fit, and a clipped label shows its full name in a tooltip (UIF-1426)
|
|
41
|
+
- Nile Charts: Lite tooltips in the charts are capped at `--ng-width-64` (256px) wide and 250px tall and scroll beyond that; the chart header title and subtitle tooltips now use `nile-lite-tooltip`, so they need `@aquera/nile-elements` loaded on the page (UIF-1426)
|
|
42
|
+
|
|
39
43
|
#### Version 2.9.43 (November 18, 2026)
|
|
40
44
|
- Nile Chart: The master-detail chart now takes several series and can stack them. Set `series` (`{ name, data, color? }[]`, replaces `data` when non-empty) and `stacking` (`normal` or `percent`) on `type: 'master-detail'` or `<nile-master-detail-chart>`; both panes stack, the detail pane shows a legend and a shared tooltip for 2+ series, and dragging the master selection now zooms every series instead of only the first. Single-series charts are unchanged (UIF-1425)
|
|
41
45
|
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -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';
|
|
4
5
|
/** Default empty state for `<nile-chart>`: detection (`isChartEmpty`) and markup (`renderChartEmptyState`). */
|
|
5
6
|
export const EMPTY_STATE_TITLE = 'No data';
|
|
6
7
|
export const EMPTY_STATE_DESCRIPTION = 'There is nothing to show for this chart yet. Data will appear here once it is available.';
|
|
7
8
|
// 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=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} 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=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} 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>
|
|
@@ -196,6 +196,18 @@ export const styles = css `
|
|
|
196
196
|
flex: 0 1 auto;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/* <nile-lite-tooltip> wrappers around the header title / subtitle; they must not break the ellipsis. */
|
|
200
|
+
.nile-chart-header-tip {
|
|
201
|
+
display: block;
|
|
202
|
+
width: 100%;
|
|
203
|
+
min-width: 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.nile-chart-header-title-row .nile-chart-header-tip {
|
|
207
|
+
width: auto;
|
|
208
|
+
flex: 0 1 auto;
|
|
209
|
+
}
|
|
210
|
+
|
|
199
211
|
.nile-chart-header-info-tip {
|
|
200
212
|
display: inline-flex;
|
|
201
213
|
align-items: center;
|
|
@@ -85,7 +85,8 @@ import '../nile-ai-panel/index.js';
|
|
|
85
85
|
*/
|
|
86
86
|
export declare class NileChart extends NileElement {
|
|
87
87
|
static styles: CSSResultGroup;
|
|
88
|
-
|
|
88
|
+
/** The nile-lite-tooltip shown for a clipped x-axis label. */
|
|
89
|
+
private _axisTipEl;
|
|
89
90
|
private _headerResizeObs;
|
|
90
91
|
/** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
|
|
91
92
|
config: NileChartConfig | NileChartConfigInputType | null;
|
|
@@ -129,6 +130,12 @@ export declare class NileChart extends NileElement {
|
|
|
129
130
|
* Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
|
|
130
131
|
*/
|
|
131
132
|
chartTypeAttr: string;
|
|
133
|
+
/** Long x-axis labels: `truncate` (ellipsis) or `wrap`, at `xAxisLabelMaxWidth`. */
|
|
134
|
+
xAxisLabelMode: 'truncate' | 'wrap';
|
|
135
|
+
/** Max width in px of an x-axis label before it truncates or wraps. */
|
|
136
|
+
xAxisLabelMaxWidth: number;
|
|
137
|
+
/** Rotation in degrees of x-axis labels (e.g. `-45`); `0` keeps them flat. */
|
|
138
|
+
xAxisLabelRotation: number;
|
|
132
139
|
/** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
|
|
133
140
|
summary: string;
|
|
134
141
|
aiBorder: boolean;
|
|
@@ -253,13 +260,30 @@ export declare class NileChart extends NileElement {
|
|
|
253
260
|
private _renderMenuItem;
|
|
254
261
|
private renderActionsMenu;
|
|
255
262
|
private renderAiTrigger;
|
|
256
|
-
private _showHeaderTip;
|
|
257
|
-
private _hideHeaderTip;
|
|
258
|
-
private _onViewportMove;
|
|
259
263
|
/** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
|
|
260
264
|
private renderHeaderInfo;
|
|
261
|
-
|
|
265
|
+
/** The x-axis label span in the event's composed path, if any. */
|
|
266
|
+
private _axisLabelFrom;
|
|
267
|
+
/** Finds an unrotated label by pointer coordinates, since some browsers report the wrong event target. */
|
|
268
|
+
private _axisLabelAt;
|
|
269
|
+
/** The x-axis label the tooltip belongs to. */
|
|
270
|
+
private _axisLabelActive;
|
|
271
|
+
/** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
|
|
272
|
+
private _onAxisLabelMove;
|
|
273
|
+
private _showAxisLabelTip;
|
|
274
|
+
private _axisTipHideTimer;
|
|
275
|
+
private _cancelAxisTipHide;
|
|
276
|
+
/** Brief grace period so crossing the gap between two labels doesn't close and reopen the tooltip. */
|
|
277
|
+
private _scheduleAxisTipHide;
|
|
278
|
+
/** Drop the current label tooltip: instantly, or after letting it fade out. */
|
|
279
|
+
private _removeAxisTip;
|
|
280
|
+
private _hideAxisLabelTip;
|
|
281
|
+
private _onAxisViewportMove;
|
|
282
|
+
private _onAxisLabelOut;
|
|
283
|
+
private _onAxisLabelLeave;
|
|
262
284
|
private _syncHeaderTruncationA11y;
|
|
285
|
+
/** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
|
|
286
|
+
private renderHeaderText;
|
|
263
287
|
private renderHeader;
|
|
264
288
|
private renderAiPanel;
|
|
265
289
|
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,
|
|
7
|
+
import { styles, 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';
|
|
@@ -12,6 +12,7 @@ import { isChartEmpty, renderChartEmptyState, syncChartEmptyTruncation } from '.
|
|
|
12
12
|
import { convertConfig } from '../internal/utils/chart-adapters.js';
|
|
13
13
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
14
14
|
import { initNileChartExporting, getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
15
|
+
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
15
16
|
import { getECharts, translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES } from '../internal/echarts/index.js';
|
|
16
17
|
import { getAxisExtremes, setAxisExtremes, } from '../internal/utils/chart-runtime.js';
|
|
17
18
|
import { resolveColorPaletteColors } from '../internal/color-palettes/index.js';
|
|
@@ -124,16 +125,6 @@ function chartTypeLabel(type) {
|
|
|
124
125
|
.replace(/-/g, ' ')
|
|
125
126
|
.replace(/\b\w/g, ch => ch.toUpperCase());
|
|
126
127
|
}
|
|
127
|
-
let _headerTooltipStylesInjected = false;
|
|
128
|
-
function ensureHeaderTooltipStyles() {
|
|
129
|
-
if (_headerTooltipStylesInjected || typeof document === 'undefined')
|
|
130
|
-
return;
|
|
131
|
-
const style = document.createElement('style');
|
|
132
|
-
style.dataset['nilechart'] = '';
|
|
133
|
-
style.textContent = tooltipCss;
|
|
134
|
-
document.head.appendChild(style);
|
|
135
|
-
_headerTooltipStylesInjected = true;
|
|
136
|
-
}
|
|
137
128
|
/**
|
|
138
129
|
* Universal chart wrapper. Renders a card with an optional header (titles +
|
|
139
130
|
* actions) and the active chart type below.
|
|
@@ -166,7 +157,8 @@ function ensureHeaderTooltipStyles() {
|
|
|
166
157
|
let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
167
158
|
constructor() {
|
|
168
159
|
super(...arguments);
|
|
169
|
-
|
|
160
|
+
/** The nile-lite-tooltip shown for a clipped x-axis label. */
|
|
161
|
+
this._axisTipEl = null;
|
|
170
162
|
this._headerResizeObs = null;
|
|
171
163
|
/** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
|
|
172
164
|
this.config = null;
|
|
@@ -210,6 +202,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
210
202
|
* Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
|
|
211
203
|
*/
|
|
212
204
|
this.chartTypeAttr = '';
|
|
205
|
+
/** Long x-axis labels: `truncate` (ellipsis) or `wrap`, at `xAxisLabelMaxWidth`. */
|
|
206
|
+
this.xAxisLabelMode = 'truncate';
|
|
207
|
+
/** Max width in px of an x-axis label before it truncates or wraps. */
|
|
208
|
+
this.xAxisLabelMaxWidth = 80;
|
|
209
|
+
/** Rotation in degrees of x-axis labels (e.g. `-45`); `0` keeps them flat. */
|
|
210
|
+
this.xAxisLabelRotation = 0;
|
|
213
211
|
/** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
|
|
214
212
|
this.summary = '';
|
|
215
213
|
this.aiBorder = false;
|
|
@@ -288,15 +286,38 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
288
286
|
this.gridLineStrengthFromConfig = false;
|
|
289
287
|
this._emptyEl = null;
|
|
290
288
|
this._emptyObs = null;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.
|
|
295
|
-
const el = e.
|
|
296
|
-
if (el
|
|
289
|
+
/** The x-axis label the tooltip belongs to. */
|
|
290
|
+
this._axisLabelActive = null;
|
|
291
|
+
/** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
|
|
292
|
+
this._onAxisLabelMove = (e) => {
|
|
293
|
+
const el = this._axisLabelFrom(e) ?? this._axisLabelAt(e);
|
|
294
|
+
if (el === this._axisLabelActive)
|
|
295
|
+
return;
|
|
296
|
+
this._axisLabelActive = el;
|
|
297
|
+
if (el && el.scrollWidth > el.clientWidth) {
|
|
298
|
+
this._cancelAxisTipHide();
|
|
299
|
+
this._showAxisLabelTip(el);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this._scheduleAxisTipHide();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
this._axisTipHideTimer = null;
|
|
306
|
+
this._onAxisViewportMove = () => {
|
|
307
|
+
this._axisLabelActive = null;
|
|
308
|
+
this._hideAxisLabelTip();
|
|
309
|
+
};
|
|
310
|
+
this._onAxisLabelOut = (e) => {
|
|
311
|
+
if (!this._axisLabelFrom(e))
|
|
297
312
|
return;
|
|
298
|
-
|
|
299
|
-
this.
|
|
313
|
+
this._axisLabelActive = null;
|
|
314
|
+
this._scheduleAxisTipHide();
|
|
315
|
+
};
|
|
316
|
+
this._onAxisLabelLeave = () => {
|
|
317
|
+
if (!this._axisLabelActive)
|
|
318
|
+
return;
|
|
319
|
+
this._axisLabelActive = null;
|
|
320
|
+
this._scheduleAxisTipHide();
|
|
300
321
|
};
|
|
301
322
|
// ── ECharts engine path (NILE-005) ──────────────────────────────
|
|
302
323
|
this._echart = null;
|
|
@@ -370,16 +391,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
370
391
|
}
|
|
371
392
|
connectedCallback() {
|
|
372
393
|
super.connectedCallback();
|
|
373
|
-
ensureHeaderTooltipStyles();
|
|
374
394
|
injectGlobalChartMenuOverrides();
|
|
375
|
-
const tip = document.createElement('div');
|
|
376
|
-
tip.className = 'nile-chart-header-tooltip';
|
|
377
|
-
tip.setAttribute('role', 'tooltip');
|
|
378
|
-
document.body.appendChild(tip);
|
|
379
|
-
this._headerTipEl = tip;
|
|
380
395
|
document.addEventListener('click', this.handleOutsideClick);
|
|
381
396
|
this.addEventListener('nile-chart-ready', this.handleChartReady);
|
|
382
397
|
this.addEventListener('dblclick', this._onDoubleTap);
|
|
398
|
+
this.addEventListener('mousemove', this._onAxisLabelMove);
|
|
399
|
+
this.addEventListener('mouseout', this._onAxisLabelOut);
|
|
400
|
+
this.addEventListener('mouseleave', this._onAxisLabelLeave);
|
|
383
401
|
initNileChartExporting();
|
|
384
402
|
// Pick up config set before element upgrade (e.g. Angular ngAfterViewInit)
|
|
385
403
|
if (this.config && !this.resolvedConfig) {
|
|
@@ -393,9 +411,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
393
411
|
document.removeEventListener('click', this.handleOutsideClick);
|
|
394
412
|
this.removeEventListener('nile-chart-ready', this.handleChartReady);
|
|
395
413
|
this.removeEventListener('dblclick', this._onDoubleTap);
|
|
396
|
-
this.
|
|
397
|
-
this.
|
|
398
|
-
this.
|
|
414
|
+
this.removeEventListener('mousemove', this._onAxisLabelMove);
|
|
415
|
+
this.removeEventListener('mouseout', this._onAxisLabelOut);
|
|
416
|
+
this.removeEventListener('mouseleave', this._onAxisLabelLeave);
|
|
417
|
+
this._hideAxisLabelTip();
|
|
418
|
+
this._removeAxisTip(true);
|
|
399
419
|
this._headerResizeObs?.disconnect();
|
|
400
420
|
this._headerResizeObs = null;
|
|
401
421
|
this._emptyObs?.disconnect();
|
|
@@ -814,40 +834,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
814
834
|
<slot name="nile-ai-trigger-after"></slot>
|
|
815
835
|
`;
|
|
816
836
|
}
|
|
817
|
-
_showHeaderTip(text, x, y, anchorHeight = 0) {
|
|
818
|
-
if (!this._headerTipEl)
|
|
819
|
-
return;
|
|
820
|
-
this._headerTipEl.textContent = text;
|
|
821
|
-
this._headerTipEl.style.left = `${x}px`;
|
|
822
|
-
this._headerTipEl.style.top = `${y}px`;
|
|
823
|
-
this._headerTipEl.style.display = 'block';
|
|
824
|
-
window.addEventListener('scroll', this._onViewportMove, { capture: true, passive: true });
|
|
825
|
-
window.addEventListener('resize', this._onViewportMove, { passive: true });
|
|
826
|
-
// Keep the tooltip inside the viewport; the arrow keeps pointing at the anchor.
|
|
827
|
-
const margin = 8;
|
|
828
|
-
const half = this._headerTipEl.offsetWidth / 2;
|
|
829
|
-
const cx = Math.min(Math.max(x, half + margin), Math.max(half + margin, window.innerWidth - half - margin));
|
|
830
|
-
this._headerTipEl.style.left = `${cx}px`;
|
|
831
|
-
this._headerTipEl.style.setProperty('--tip-arrow-x', `${half + x - cx}px`);
|
|
832
|
-
// Not enough room above the anchor: drop below it instead.
|
|
833
|
-
const above = y - this._headerTipEl.offsetHeight - 10 >= margin;
|
|
834
|
-
this._headerTipEl.classList.toggle('below', !above);
|
|
835
|
-
if (!above)
|
|
836
|
-
this._headerTipEl.style.top = `${y + anchorHeight}px`;
|
|
837
|
-
}
|
|
838
|
-
_hideHeaderTip() {
|
|
839
|
-
if (this._headerTipEl)
|
|
840
|
-
this._headerTipEl.style.display = 'none';
|
|
841
|
-
window.removeEventListener('scroll', this._onViewportMove, true);
|
|
842
|
-
window.removeEventListener('resize', this._onViewportMove);
|
|
843
|
-
}
|
|
844
837
|
/** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
|
|
845
838
|
renderHeaderInfo() {
|
|
846
839
|
const info = String(this.headerInfo('chartInfo') ?? '');
|
|
847
840
|
if (!info)
|
|
848
841
|
return nothing;
|
|
849
842
|
const size = this.headerInfo('chartInfoIconSize');
|
|
850
|
-
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"><span
|
|
843
|
+
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} interactive @nile-show=${limitLiteTooltipHeight}><span
|
|
851
844
|
class="nile-chart-header-info"
|
|
852
845
|
part="header-info"
|
|
853
846
|
role="img"
|
|
@@ -860,24 +853,118 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
860
853
|
color=${this.headerInfo('chartInfoIconColor') || 'currentColor'}
|
|
861
854
|
></nile-glyph></span></nile-lite-tooltip>`;
|
|
862
855
|
}
|
|
856
|
+
/** The x-axis label span in the event's composed path, if any. */
|
|
857
|
+
_axisLabelFrom(e) {
|
|
858
|
+
const hit = e.composedPath().find((n) => n instanceof HTMLElement && n.classList.contains('nile-axis-label'));
|
|
859
|
+
return hit ?? null;
|
|
860
|
+
}
|
|
861
|
+
/** Finds an unrotated label by pointer coordinates, since some browsers report the wrong event target. */
|
|
862
|
+
_axisLabelAt(e) {
|
|
863
|
+
const m = e;
|
|
864
|
+
if (typeof m.clientX !== 'number')
|
|
865
|
+
return null;
|
|
866
|
+
const svg = e.composedPath().find((n) => n instanceof Element && n.classList.contains('highcharts-root'));
|
|
867
|
+
if (!svg)
|
|
868
|
+
return null;
|
|
869
|
+
for (const el of Array.from(svg.querySelectorAll('.nile-axis-label'))) {
|
|
870
|
+
const r = el.getBoundingClientRect();
|
|
871
|
+
const rotated = r.height > el.offsetHeight + 4 || r.width > el.offsetWidth + 4;
|
|
872
|
+
if (rotated)
|
|
873
|
+
continue; // rotated boxes are much larger than the text; their span target is reliable
|
|
874
|
+
if (m.clientX >= r.left && m.clientX <= r.right && m.clientY >= r.top && m.clientY <= r.bottom)
|
|
875
|
+
return el;
|
|
876
|
+
}
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
_showAxisLabelTip(el) {
|
|
880
|
+
const text = el.textContent ?? '';
|
|
881
|
+
const rect = el.getBoundingClientRect();
|
|
882
|
+
// A rotated label's box is taller than its text, so aim at its centre.
|
|
883
|
+
const rotated = rect.height > el.offsetHeight + 4 || rect.width > el.offsetWidth + 4;
|
|
884
|
+
if (!customElements.get('nile-lite-tooltip'))
|
|
885
|
+
return;
|
|
886
|
+
// A fresh tooltip per label: reopening a shared one inside its fade-out shows nothing.
|
|
887
|
+
this._removeAxisTip(true);
|
|
888
|
+
const tip = document.createElement('nile-lite-tooltip');
|
|
889
|
+
tip.setAttribute('placement', 'top');
|
|
890
|
+
tip.setAttribute('trigger', 'manual');
|
|
891
|
+
tip.maxWidth = LITE_TOOLTIP_MAX_WIDTH;
|
|
892
|
+
tip.addEventListener('nile-show', limitLiteTooltipHeight);
|
|
893
|
+
const anchor = document.createElement('div');
|
|
894
|
+
anchor.setAttribute('aria-hidden', 'true');
|
|
895
|
+
anchor.style.cssText = 'position:fixed;pointer-events:none;visibility:hidden;';
|
|
896
|
+
anchor.style.left = `${rotated ? rect.left + rect.width / 2 : rect.left}px`;
|
|
897
|
+
anchor.style.top = `${rotated ? rect.top + rect.height / 2 : rect.top}px`;
|
|
898
|
+
anchor.style.width = rotated ? '1px' : `${rect.width}px`;
|
|
899
|
+
anchor.style.height = rotated ? '1px' : `${rect.height}px`;
|
|
900
|
+
tip.appendChild(anchor);
|
|
901
|
+
document.body.appendChild(tip);
|
|
902
|
+
tip.content = text;
|
|
903
|
+
this._axisTipEl = tip;
|
|
904
|
+
// Open after the first render; opening at creation shows nothing.
|
|
905
|
+
void tip.updateComplete?.then(() => {
|
|
906
|
+
if (this._axisTipEl === tip)
|
|
907
|
+
tip.open = true;
|
|
908
|
+
});
|
|
909
|
+
// The anchor uses viewport coordinates and is placed once, so close on scroll/resize.
|
|
910
|
+
window.addEventListener('scroll', this._onAxisViewportMove, { capture: true, passive: true });
|
|
911
|
+
window.addEventListener('resize', this._onAxisViewportMove, { passive: true });
|
|
912
|
+
}
|
|
913
|
+
_cancelAxisTipHide() {
|
|
914
|
+
if (this._axisTipHideTimer !== null) {
|
|
915
|
+
window.clearTimeout(this._axisTipHideTimer);
|
|
916
|
+
this._axisTipHideTimer = null;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/** Brief grace period so crossing the gap between two labels doesn't close and reopen the tooltip. */
|
|
920
|
+
_scheduleAxisTipHide() {
|
|
921
|
+
this._cancelAxisTipHide();
|
|
922
|
+
this._axisTipHideTimer = window.setTimeout(() => {
|
|
923
|
+
this._axisTipHideTimer = null;
|
|
924
|
+
this._hideAxisLabelTip();
|
|
925
|
+
}, 120);
|
|
926
|
+
}
|
|
927
|
+
/** Drop the current label tooltip: instantly, or after letting it fade out. */
|
|
928
|
+
_removeAxisTip(instant) {
|
|
929
|
+
const tip = this._axisTipEl;
|
|
930
|
+
this._axisTipEl = null;
|
|
931
|
+
if (!tip)
|
|
932
|
+
return;
|
|
933
|
+
if (instant) {
|
|
934
|
+
tip.remove();
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
tip.open = false;
|
|
938
|
+
window.setTimeout(() => tip.remove(), 300);
|
|
939
|
+
}
|
|
940
|
+
_hideAxisLabelTip() {
|
|
941
|
+
this._cancelAxisTipHide();
|
|
942
|
+
this._removeAxisTip(false);
|
|
943
|
+
window.removeEventListener('scroll', this._onAxisViewportMove, true);
|
|
944
|
+
window.removeEventListener('resize', this._onAxisViewportMove);
|
|
945
|
+
}
|
|
863
946
|
_syncHeaderTruncationA11y() {
|
|
864
947
|
const root = this.shadowRoot;
|
|
865
948
|
if (!root)
|
|
866
949
|
return;
|
|
867
|
-
for (const
|
|
868
|
-
const el = root.querySelector(
|
|
950
|
+
for (const kind of ['title', 'subtitle']) {
|
|
951
|
+
const el = root.querySelector(`.nile-chart-header-${kind}`);
|
|
869
952
|
if (!el)
|
|
870
953
|
continue;
|
|
954
|
+
const tip = root.querySelector(`.nile-chart-header-tip[data-header-tip="${kind}"]`);
|
|
871
955
|
const truncated = el.scrollWidth > el.clientWidth;
|
|
872
|
-
if (truncated)
|
|
956
|
+
if (truncated)
|
|
873
957
|
el.setAttribute('tabindex', '0');
|
|
874
|
-
|
|
875
|
-
else {
|
|
958
|
+
else
|
|
876
959
|
el.removeAttribute('tabindex');
|
|
877
|
-
|
|
878
|
-
|
|
960
|
+
if (tip)
|
|
961
|
+
tip.disabled = !truncated;
|
|
879
962
|
}
|
|
880
963
|
}
|
|
964
|
+
/** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
|
|
965
|
+
renderHeaderText(kind, text, fontSize) {
|
|
966
|
+
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>`;
|
|
967
|
+
}
|
|
881
968
|
renderHeader() {
|
|
882
969
|
if (!this.shouldShowHeader())
|
|
883
970
|
return nothing;
|
|
@@ -895,10 +982,10 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
895
982
|
? html `
|
|
896
983
|
${title
|
|
897
984
|
? this.headerInfo('chartInfo')
|
|
898
|
-
? html `<div class="nile-chart-header-title-row" part="header-title-row">${
|
|
899
|
-
:
|
|
985
|
+
? html `<div class="nile-chart-header-title-row" part="header-title-row">${this.renderHeaderText('title', title, titleFontSize)}${this.renderHeaderInfo()}</div>`
|
|
986
|
+
: this.renderHeaderText('title', title, titleFontSize)
|
|
900
987
|
: nothing}
|
|
901
|
-
${subtitle ?
|
|
988
|
+
${subtitle ? this.renderHeaderText('subtitle', subtitle, subtitleFontSize) : nothing}
|
|
902
989
|
`
|
|
903
990
|
: nothing}
|
|
904
991
|
</div>
|
|
@@ -1003,6 +1090,32 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1003
1090
|
const { show, ...rest } = config.legend;
|
|
1004
1091
|
legendOptions.legend = { enabled: show ?? true, ...rest };
|
|
1005
1092
|
}
|
|
1093
|
+
const truncate = this.xAxisLabelMode !== 'wrap';
|
|
1094
|
+
const maxWidth = this.xAxisLabelMaxWidth;
|
|
1095
|
+
const labelOptions = {
|
|
1096
|
+
xAxis: {
|
|
1097
|
+
labels: {
|
|
1098
|
+
rotation: this.xAxisLabelRotation,
|
|
1099
|
+
// HTML labels allow the hover tooltip; defaultLabelFormatter keeps numeric/datetime axes formatted.
|
|
1100
|
+
useHTML: true,
|
|
1101
|
+
formatter() {
|
|
1102
|
+
const text = String(this.axis.defaultLabelFormatter.call(this));
|
|
1103
|
+
const esc = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
1104
|
+
// text-overflow isn't inherited, so the clipping styles go on the span.
|
|
1105
|
+
const clip = truncate
|
|
1106
|
+
? `display:inline-block;max-width:min(${maxWidth}px,100%);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:top;`
|
|
1107
|
+
: '';
|
|
1108
|
+
return `<span class="nile-axis-label" style="${clip}">${esc}</span>`;
|
|
1109
|
+
},
|
|
1110
|
+
style: {
|
|
1111
|
+
width: `${this.xAxisLabelMaxWidth}px`,
|
|
1112
|
+
...(this.xAxisLabelMode === 'wrap'
|
|
1113
|
+
? { whiteSpace: 'normal', textOverflow: 'clip' }
|
|
1114
|
+
: { whiteSpace: 'nowrap', textOverflow: 'ellipsis' }),
|
|
1115
|
+
},
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
};
|
|
1006
1119
|
const spacingOptions = {};
|
|
1007
1120
|
if (config.chartSpacing) {
|
|
1008
1121
|
const { top, right, bottom, left } = config.chartSpacing;
|
|
@@ -1044,7 +1157,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1044
1157
|
const paletteOptions = paletteColors ? { colors: paletteColors } : {};
|
|
1045
1158
|
// Precedence (later wins): raw options → passthrough fields → legend →
|
|
1046
1159
|
// spacing → palette → title suppression → exporting.
|
|
1047
|
-
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(config.options ?? {}, passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
|
|
1160
|
+
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(labelOptions, config.options ?? {}), passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
|
|
1048
1161
|
switch (config.type) {
|
|
1049
1162
|
case 'bar':
|
|
1050
1163
|
return html `<nile-bar-chart
|
|
@@ -2421,6 +2534,15 @@ __decorate([
|
|
|
2421
2534
|
__decorate([
|
|
2422
2535
|
property({ type: String, attribute: 'chart-type' })
|
|
2423
2536
|
], NileChart.prototype, "chartTypeAttr", void 0);
|
|
2537
|
+
__decorate([
|
|
2538
|
+
property({ type: String, attribute: true })
|
|
2539
|
+
], NileChart.prototype, "xAxisLabelMode", void 0);
|
|
2540
|
+
__decorate([
|
|
2541
|
+
property({ type: Number, attribute: true })
|
|
2542
|
+
], NileChart.prototype, "xAxisLabelMaxWidth", void 0);
|
|
2543
|
+
__decorate([
|
|
2544
|
+
property({ type: Number, attribute: true })
|
|
2545
|
+
], NileChart.prototype, "xAxisLabelRotation", void 0);
|
|
2424
2546
|
__decorate([
|
|
2425
2547
|
property({ type: String })
|
|
2426
2548
|
], NileChart.prototype, "summary", void 0);
|
|
@@ -5,6 +5,7 @@ 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';
|
|
8
9
|
// Inject tooltip styles into document.head once per page load.
|
|
9
10
|
let _tooltipStylesInjected = false;
|
|
10
11
|
function ensureTooltipStyles() {
|
|
@@ -1254,6 +1255,9 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1254
1255
|
return nothing;
|
|
1255
1256
|
const [vertical, side] = (typeof this.valueInfoPlacement === 'string' ? this.valueInfoPlacement : 'top-right').split('-');
|
|
1256
1257
|
return html `<nile-lite-tooltip
|
|
1258
|
+
.maxWidth=${LITE_TOOLTIP_MAX_WIDTH}
|
|
1259
|
+
@nile-show=${limitLiteTooltipHeight}
|
|
1260
|
+
interactive
|
|
1257
1261
|
class="kpi-info-tip kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
|
|
1258
1262
|
content=${this.valueInfo}
|
|
1259
1263
|
placement="top"
|
|
@@ -1302,7 +1306,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1302
1306
|
const dir = this.trendDirection;
|
|
1303
1307
|
const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
|
|
1304
1308
|
const trendAriaLabel = `Trend ${dir === 'up' ? 'up' : dir === 'down' ? 'down' : 'neutral'} ${formatted}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
|
|
1305
|
-
return html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
|
|
1309
|
+
return html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
|
|
1306
1310
|
class="kpi-trend kpi-trend--${dir}"
|
|
1307
1311
|
tabindex="0"
|
|
1308
1312
|
role="button"
|
|
@@ -1369,7 +1373,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1369
1373
|
*/
|
|
1370
1374
|
renderHeaderRow(extra, trendRow) {
|
|
1371
1375
|
return html `<div class="kpi-header">
|
|
1372
|
-
${this.label ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
|
|
1376
|
+
${this.label ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
|
|
1373
1377
|
class="kpi-label"
|
|
1374
1378
|
tabindex="0"
|
|
1375
1379
|
><span class="kpi-label-text">${this.label}</span></p></nile-lite-tooltip>` : nothing}
|
|
@@ -1405,7 +1409,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1405
1409
|
<span class="kpi-value-group">
|
|
1406
1410
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1407
1411
|
${showTooltip
|
|
1408
|
-
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1412
|
+
? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1409
1413
|
: valueEl}
|
|
1410
1414
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1411
1415
|
</span>
|
|
@@ -1413,7 +1417,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1413
1417
|
|
|
1414
1418
|
${this.renderForecast()}
|
|
1415
1419
|
|
|
1416
|
-
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1420
|
+
${this.description ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1417
1421
|
class="kpi-description"
|
|
1418
1422
|
tabindex="0"
|
|
1419
1423
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -1447,7 +1451,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1447
1451
|
<span class="kpi-value-group">
|
|
1448
1452
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1449
1453
|
${showTooltip
|
|
1450
|
-
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1454
|
+
? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1451
1455
|
: valueEl}
|
|
1452
1456
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1453
1457
|
</span>
|
|
@@ -1459,7 +1463,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1459
1463
|
|
|
1460
1464
|
${this.renderForecast()}
|
|
1461
1465
|
|
|
1462
|
-
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1466
|
+
${this.description ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1463
1467
|
class="kpi-description"
|
|
1464
1468
|
tabindex="0"
|
|
1465
1469
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -7,6 +7,7 @@ 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';
|
|
10
11
|
export const MASTER_DETAIL_STACKING = ['normal', 'percent'];
|
|
11
12
|
export const MASTER_DETAIL_SERIES_TYPES = [
|
|
12
13
|
'area',
|
|
@@ -555,7 +556,7 @@ let NileMasterDetailChart = class NileMasterDetailChart extends NileElement {
|
|
|
555
556
|
? null
|
|
556
557
|
: html `<div class="detail-container ${masterHidden ? 'detail-container--grow' : ''}" part="detail-container"></div>
|
|
557
558
|
${this.masterCollapsible
|
|
558
|
-
? html `<nile-lite-tooltip content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
|
|
559
|
+
? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} content=${this.masterCollapsed ? 'Show master' : 'Hide master'} placement="top">
|
|
559
560
|
<button
|
|
560
561
|
type="button"
|
|
561
562
|
class="master-toggle"
|