@aquera/nile-visualization 2.9.43 → 2.9.45

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.
@@ -73,6 +73,9 @@ import '../nile-ai-panel/index.js';
73
73
  * @csspart ai-trigger-glyph - Glyph inside the "Ask AI" button.
74
74
  * @csspart ai-panel - The AI chat panel overlay.
75
75
  * @csspart ai-panel-content - The nile-ai-panel element inside the overlay.
76
+ * @csspart column-chooser-trigger - The column-chooser button (grid charts with `columnChooser`).
77
+ * @csspart column-chooser-glyph - Glyph inside the column-chooser button.
78
+ * @csspart column-chooser-indicator - Dot on the column-chooser button while any column is hidden.
76
79
  * @csspart menu-anchor - The actions-menu dropdown anchor.
77
80
  * @csspart menu-trigger - The actions-menu trigger button.
78
81
  * @csspart menu-trigger-glyph - Glyph inside the actions-menu trigger.
@@ -85,7 +88,8 @@ import '../nile-ai-panel/index.js';
85
88
  */
86
89
  export declare class NileChart extends NileElement {
87
90
  static styles: CSSResultGroup;
88
- private _headerTipEl;
91
+ /** The nile-lite-tooltip shown for a clipped x-axis label. */
92
+ private _axisTipEl;
89
93
  private _headerResizeObs;
90
94
  /** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
91
95
  config: NileChartConfig | NileChartConfigInputType | null;
@@ -129,6 +133,12 @@ export declare class NileChart extends NileElement {
129
133
  * Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
130
134
  */
131
135
  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;
132
142
  /** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
133
143
  summary: string;
134
144
  aiBorder: boolean;
@@ -150,6 +160,8 @@ export declare class NileChart extends NileElement {
150
160
  private hasHeaderSlotContent;
151
161
  /** True when elements are projected into `header-actions` (used to show the header row). */
152
162
  private hasHeaderActionsSlot;
163
+ private gridColumnVisibility;
164
+ private gridColumnVisibilitySeed;
153
165
  private aiPanel;
154
166
  private masterDetailChart;
155
167
  /** True while the inner master-detail chart is zoomed — drives the header
@@ -243,6 +255,14 @@ export declare class NileChart extends NileElement {
243
255
  /** Direct children with `slot=` — header row renders on first paint before slot assignment runs. */
244
256
  private lightDomHasSlot;
245
257
  private shouldShowHeader;
258
+ private get gridConfig();
259
+ private get columnChooser();
260
+ private get gridElement();
261
+ /** Seeds from `config.columnVisibility` whenever the app passes a new object; user toggles live here in between. */
262
+ private resolveGridColumnVisibility;
263
+ private onGridColumnVisibilityChange;
264
+ private onGridColumnOrderChange;
265
+ private renderColumnChooserTrigger;
246
266
  private buildExportingOptions;
247
267
  /** Ensures exporting modules are loaded and the chart's exporting/fullscreen instances exist. */
248
268
  private ensureExporting;
@@ -253,13 +273,30 @@ export declare class NileChart extends NileElement {
253
273
  private _renderMenuItem;
254
274
  private renderActionsMenu;
255
275
  private renderAiTrigger;
256
- private _showHeaderTip;
257
- private _hideHeaderTip;
258
- private _onViewportMove;
259
276
  /** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
260
277
  private renderHeaderInfo;
261
- private _onHeaderTextEnter;
278
+ /** The x-axis label span in the event's composed path, if any. */
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;
262
297
  private _syncHeaderTruncationA11y;
298
+ /** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
299
+ private renderHeaderText;
263
300
  private renderHeader;
264
301
  private renderAiPanel;
265
302
  private _echart;
@@ -4,14 +4,16 @@ 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, tooltipCss, injectGlobalChartMenuOverrides } from './nile-chart.css.js';
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';
11
+ import { COLUMN_CHOOSER_PANEL_CLASS, chooserEntries, renderColumnChooser, resolveColumnChooser, } from './nile-chart-column-chooser.js';
11
12
  import { isChartEmpty, renderChartEmptyState, syncChartEmptyTruncation } from './nile-chart-empty.js';
12
13
  import { convertConfig } from '../internal/utils/chart-adapters.js';
13
14
  import { deepMerge } from '../internal/utils/deep-merge.js';
14
15
  import { initNileChartExporting, getHighcharts } from '../internal/utils/highcharts-provider.js';
16
+ import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
15
17
  import { getECharts, translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES } from '../internal/echarts/index.js';
16
18
  import { getAxisExtremes, setAxisExtremes, } from '../internal/utils/chart-runtime.js';
17
19
  import { resolveColorPaletteColors } from '../internal/color-palettes/index.js';
@@ -124,16 +126,6 @@ function chartTypeLabel(type) {
124
126
  .replace(/-/g, ' ')
125
127
  .replace(/\b\w/g, ch => ch.toUpperCase());
126
128
  }
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
129
  /**
138
130
  * Universal chart wrapper. Renders a card with an optional header (titles +
139
131
  * actions) and the active chart type below.
@@ -153,6 +145,9 @@ function ensureHeaderTooltipStyles() {
153
145
  * @csspart ai-trigger-glyph - Glyph inside the "Ask AI" button.
154
146
  * @csspart ai-panel - The AI chat panel overlay.
155
147
  * @csspart ai-panel-content - The nile-ai-panel element inside the overlay.
148
+ * @csspart column-chooser-trigger - The column-chooser button (grid charts with `columnChooser`).
149
+ * @csspart column-chooser-glyph - Glyph inside the column-chooser button.
150
+ * @csspart column-chooser-indicator - Dot on the column-chooser button while any column is hidden.
156
151
  * @csspart menu-anchor - The actions-menu dropdown anchor.
157
152
  * @csspart menu-trigger - The actions-menu trigger button.
158
153
  * @csspart menu-trigger-glyph - Glyph inside the actions-menu trigger.
@@ -166,7 +161,8 @@ function ensureHeaderTooltipStyles() {
166
161
  let NileChart = NileChart_1 = class NileChart extends NileElement {
167
162
  constructor() {
168
163
  super(...arguments);
169
- this._headerTipEl = null;
164
+ /** The nile-lite-tooltip shown for a clipped x-axis label. */
165
+ this._axisTipEl = null;
170
166
  this._headerResizeObs = null;
171
167
  /** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
172
168
  this.config = null;
@@ -210,6 +206,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
210
206
  * Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
211
207
  */
212
208
  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;
213
215
  /** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
214
216
  this.summary = '';
215
217
  this.aiBorder = false;
@@ -231,6 +233,8 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
231
233
  this.hasHeaderSlotContent = false;
232
234
  /** True when elements are projected into `header-actions` (used to show the header row). */
233
235
  this.hasHeaderActionsSlot = false;
236
+ this.gridColumnVisibility = DEFAULT_GRID_COLUMN_VISIBILITY;
237
+ this.gridColumnVisibilitySeed = undefined;
234
238
  /** True while the inner master-detail chart is zoomed — drives the header
235
239
  * "Reset zoom" button. Reflected from the chart's `nile-master-detail-zoom`. */
236
240
  this.masterZoomed = false;
@@ -288,15 +292,45 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
288
292
  this.gridLineStrengthFromConfig = false;
289
293
  this._emptyEl = null;
290
294
  this._emptyObs = null;
291
- // The tooltip is fixed to the viewport and placed once, so any scroll (including a touch-drag while the
292
- // finger is still down, when no leave/blur fires) would strand it away from its anchor. Hide it instead.
293
- this._onViewportMove = () => this._hideHeaderTip();
294
- this._onHeaderTextEnter = (e) => {
295
- const el = e.currentTarget;
296
- if (el.scrollWidth <= el.clientWidth)
295
+ this.onGridColumnVisibilityChange = (e) => {
296
+ this.gridColumnVisibility = e.detail.columnVisibility;
297
+ this.requestUpdate();
298
+ };
299
+ this.onGridColumnOrderChange = () => {
300
+ this.requestUpdate();
301
+ };
302
+ /** The x-axis label the tooltip belongs to. */
303
+ this._axisLabelActive = null;
304
+ /** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
305
+ this._onAxisLabelMove = (e) => {
306
+ const el = this._axisLabelFrom(e) ?? this._axisLabelAt(e);
307
+ if (el === this._axisLabelActive)
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))
325
+ return;
326
+ this._axisLabelActive = null;
327
+ this._scheduleAxisTipHide();
328
+ };
329
+ this._onAxisLabelLeave = () => {
330
+ if (!this._axisLabelActive)
297
331
  return;
298
- const rect = el.getBoundingClientRect();
299
- this._showHeaderTip(el.textContent ?? '', rect.left + rect.width / 2, rect.top, rect.height);
332
+ this._axisLabelActive = null;
333
+ this._scheduleAxisTipHide();
300
334
  };
301
335
  // ── ECharts engine path (NILE-005) ──────────────────────────────
302
336
  this._echart = null;
@@ -370,16 +404,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
370
404
  }
371
405
  connectedCallback() {
372
406
  super.connectedCallback();
373
- ensureHeaderTooltipStyles();
374
407
  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
408
  document.addEventListener('click', this.handleOutsideClick);
381
409
  this.addEventListener('nile-chart-ready', this.handleChartReady);
382
410
  this.addEventListener('dblclick', this._onDoubleTap);
411
+ this.addEventListener('mousemove', this._onAxisLabelMove);
412
+ this.addEventListener('mouseout', this._onAxisLabelOut);
413
+ this.addEventListener('mouseleave', this._onAxisLabelLeave);
383
414
  initNileChartExporting();
384
415
  // Pick up config set before element upgrade (e.g. Angular ngAfterViewInit)
385
416
  if (this.config && !this.resolvedConfig) {
@@ -393,9 +424,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
393
424
  document.removeEventListener('click', this.handleOutsideClick);
394
425
  this.removeEventListener('nile-chart-ready', this.handleChartReady);
395
426
  this.removeEventListener('dblclick', this._onDoubleTap);
396
- this._hideHeaderTip();
397
- this._headerTipEl?.remove();
398
- this._headerTipEl = null;
427
+ this.removeEventListener('mousemove', this._onAxisLabelMove);
428
+ this.removeEventListener('mouseout', this._onAxisLabelOut);
429
+ this.removeEventListener('mouseleave', this._onAxisLabelLeave);
430
+ this._hideAxisLabelTip();
431
+ this._removeAxisTip(true);
399
432
  this._headerResizeObs?.disconnect();
400
433
  this._headerResizeObs = null;
401
434
  this._emptyObs?.disconnect();
@@ -672,7 +705,57 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
672
705
  this.lightDomHasSlot('header') ||
673
706
  this.lightDomHasSlot('header-actions') ||
674
707
  hasBuiltinActions ||
675
- this.showResetZoom);
708
+ this.showResetZoom ||
709
+ !!this.columnChooser);
710
+ }
711
+ get gridConfig() {
712
+ return this.activeConfig?.type === 'grid'
713
+ ? this.activeConfig
714
+ : null;
715
+ }
716
+ get columnChooser() {
717
+ return resolveColumnChooser(this.gridConfig?.columnChooser);
718
+ }
719
+ get gridElement() {
720
+ return this.shadowRoot?.querySelector('nile-data-grid.nile-chart-grid') ?? null;
721
+ }
722
+ /** Seeds from `config.columnVisibility` whenever the app passes a new object; user toggles live here in between. */
723
+ resolveGridColumnVisibility(config) {
724
+ const source = config.columnVisibility ?? DEFAULT_GRID_COLUMN_VISIBILITY;
725
+ if (source !== this.gridColumnVisibilitySeed) {
726
+ this.gridColumnVisibilitySeed = source;
727
+ this.gridColumnVisibility = source;
728
+ }
729
+ return this.gridColumnVisibility;
730
+ }
731
+ renderColumnChooserTrigger() {
732
+ const chooser = this.columnChooser;
733
+ const config = this.gridConfig;
734
+ if (!chooser || !config)
735
+ return nothing;
736
+ if (this.loading || config.loading)
737
+ return nothing;
738
+ const grid = this.gridElement;
739
+ const order = grid?.columnOrder?.length ? grid.columnOrder : config.columnOrder ?? [];
740
+ return renderColumnChooser({
741
+ chooser,
742
+ entries: chooserEntries(config.columns, order),
743
+ visibility: this.resolveGridColumnVisibility(config),
744
+ onToggle: (id, visible) => this.gridElement?.toggleColumnVisibility(id, visible),
745
+ onReset: () => this.gridElement?.showAllColumns(),
746
+ onShow: () => {
747
+ const first = document.querySelector(`.${COLUMN_CHOOSER_PANEL_CLASS} nile-checkbox:not([disabled])`);
748
+ first?.focus();
749
+ },
750
+ onHide: () => {
751
+ const panel = document.querySelector(`.${COLUMN_CHOOSER_PANEL_CLASS}`);
752
+ if (panel && panel.contains(document.activeElement)) {
753
+ this.shadowRoot
754
+ ?.querySelector('.nile-chart-column-chooser-trigger')
755
+ ?.focus();
756
+ }
757
+ },
758
+ });
676
759
  }
677
760
  buildExportingOptions() {
678
761
  return { exporting: { enabled: true, buttons: { contextButton: { enabled: false } } } };
@@ -814,40 +897,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
814
897
  <slot name="nile-ai-trigger-after"></slot>
815
898
  `;
816
899
  }
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
900
  /** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
845
901
  renderHeaderInfo() {
846
902
  const info = String(this.headerInfo('chartInfo') ?? '');
847
903
  if (!info)
848
904
  return nothing;
849
905
  const size = this.headerInfo('chartInfoIconSize');
850
- return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"><span
906
+ 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
907
  class="nile-chart-header-info"
852
908
  part="header-info"
853
909
  role="img"
@@ -860,24 +916,118 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
860
916
  color=${this.headerInfo('chartInfoIconColor') || 'currentColor'}
861
917
  ></nile-glyph></span></nile-lite-tooltip>`;
862
918
  }
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
+ }
863
1009
  _syncHeaderTruncationA11y() {
864
1010
  const root = this.shadowRoot;
865
1011
  if (!root)
866
1012
  return;
867
- for (const sel of ['.nile-chart-header-title', '.nile-chart-header-subtitle']) {
868
- const el = root.querySelector(sel);
1013
+ for (const kind of ['title', 'subtitle']) {
1014
+ const el = root.querySelector(`.nile-chart-header-${kind}`);
869
1015
  if (!el)
870
1016
  continue;
1017
+ const tip = root.querySelector(`.nile-chart-header-tip[data-header-tip="${kind}"]`);
871
1018
  const truncated = el.scrollWidth > el.clientWidth;
872
- if (truncated) {
1019
+ if (truncated)
873
1020
  el.setAttribute('tabindex', '0');
874
- }
875
- else {
1021
+ else
876
1022
  el.removeAttribute('tabindex');
877
- this._hideHeaderTip();
878
- }
1023
+ if (tip)
1024
+ tip.disabled = !truncated;
879
1025
  }
880
1026
  }
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
+ }
881
1031
  renderHeader() {
882
1032
  if (!this.shouldShowHeader())
883
1033
  return nothing;
@@ -895,15 +1045,16 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
895
1045
  ? html `
896
1046
  ${title
897
1047
  ? this.headerInfo('chartInfo')
898
- ? 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>`
899
- : 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>`
1048
+ ? html `<div class="nile-chart-header-title-row" part="header-title-row">${this.renderHeaderText('title', title, titleFontSize)}${this.renderHeaderInfo()}</div>`
1049
+ : this.renderHeaderText('title', title, titleFontSize)
900
1050
  : nothing}
901
- ${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}
1051
+ ${subtitle ? this.renderHeaderText('subtitle', subtitle, subtitleFontSize) : nothing}
902
1052
  `
903
1053
  : nothing}
904
1054
  </div>
905
1055
  <div class="nile-chart-header-actions" part="header-actions">
906
1056
  <slot name="header-actions" @slotchange=${this.onHeaderActionsSlotChange}></slot>
1057
+ ${this.renderColumnChooserTrigger()}
907
1058
  ${this.showResetZoom
908
1059
  ? html `<nile-tooltip content="Reset zoom" placement="top" part="reset-zoom-tooltip">
909
1060
  <button
@@ -1003,6 +1154,32 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
1003
1154
  const { show, ...rest } = config.legend;
1004
1155
  legendOptions.legend = { enabled: show ?? true, ...rest };
1005
1156
  }
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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
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
+ };
1006
1183
  const spacingOptions = {};
1007
1184
  if (config.chartSpacing) {
1008
1185
  const { top, right, bottom, left } = config.chartSpacing;
@@ -1044,7 +1221,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
1044
1221
  const paletteOptions = paletteColors ? { colors: paletteColors } : {};
1045
1222
  // Precedence (later wins): raw options → passthrough fields → legend →
1046
1223
  // spacing → palette → title suppression → exporting.
1047
- const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(config.options ?? {}, passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
1224
+ const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(labelOptions, config.options ?? {}), passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
1048
1225
  switch (config.type) {
1049
1226
  case 'bar':
1050
1227
  return html `<nile-bar-chart
@@ -2303,10 +2480,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
2303
2480
  .columnResizeDirection=${config.columnResizeDirection ?? 'ltr'}
2304
2481
  .columnSizing=${config.columnSizing ?? DEFAULT_GRID_COLUMN_SIZING}
2305
2482
  .columnPinning=${config.columnPinning ?? DEFAULT_GRID_COLUMN_PINNING}
2306
- .columnVisibility=${config.columnVisibility ?? DEFAULT_GRID_COLUMN_VISIBILITY}
2483
+ .columnVisibility=${this.resolveGridColumnVisibility(config)}
2307
2484
  .rowSelection=${config.rowSelection ?? DEFAULT_GRID_ROW_SELECTION}
2308
2485
  .columnOrder=${config.columnOrder ?? DEFAULT_GRID_COLUMN_ORDER}
2309
2486
  style=${gridChrome}
2487
+ @nile-column-visibility-change=${this.onGridColumnVisibilityChange}
2488
+ @nile-column-order-change=${this.onGridColumnOrderChange}
2310
2489
  ></nile-data-grid>`;
2311
2490
  }
2312
2491
  case 'filter': {
@@ -2421,6 +2600,15 @@ __decorate([
2421
2600
  __decorate([
2422
2601
  property({ type: String, attribute: 'chart-type' })
2423
2602
  ], 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);
2424
2612
  __decorate([
2425
2613
  property({ type: String })
2426
2614
  ], 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}