@aquera/nile-visualization 2.9.36 → 2.9.38

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 CHANGED
@@ -36,6 +36,14 @@ 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.38 (November 16, 2026)
40
+ - Nile Chart: The header info icon now uses `nile-lite-tooltip` (UIF-1416)
41
+ - Nile KPI Chart: The value info icon and the trend, value, label and description tooltips now use `nile-lite-tooltip`, shown only when the text is truncated (UIF-1416)
42
+
43
+ #### Version 2.9.37 (October 12, 2026)
44
+ - Nile KPI Chart: The value info icon is now configurable with `valueInfoIcon`, `valueInfoIconMethod`, `valueInfoIconSize` and `valueInfoIconColor` (`nile-glyph` icons only). Defaults are unchanged (UIF-1379)
45
+ - Nile Chart: Added a header info icon for all chart types. Set `chartInfo` (with a `chartTitle`), and optionally `chartInfoIcon`, `chartInfoIconMethod`, `chartInfoIconSize` and `chartInfoIconColor` (UIF-1379)
46
+
39
47
  #### Version 2.9.36 (September 30, 2026)
40
48
  - Nile KPI Chart: Fixed the sparkline getting partly cut off after a data refresh or resize. The chart is now resized to match its box instead of resetting to `sparklineHeight`, and sparkline resize animation is turned off (UIF-1370)
41
49
 
@@ -5,6 +5,16 @@ import type { NileChartMenuConfig, NileChartMenuItem } from '../../nile-chart/ni
5
5
  export interface AqConfigType {
6
6
  chartTitle?: string;
7
7
  chartSubtitle?: string;
8
+ /** Info text shown on hover/focus of an icon beside the header title. Empty → no icon (needs a title). */
9
+ chartInfo?: string;
10
+ /** `nile-glyph` name for the header info icon (default: 'ng-info-circle'). */
11
+ chartInfoIcon?: string;
12
+ /** `nile-glyph` `method` for the header info icon (default: 'stroke'). */
13
+ chartInfoIconMethod?: string;
14
+ /** `nile-glyph` `size` for the header info icon (default: unset, so `nile-glyph`'s own 16). The hover/focus target keeps a 16px token minimum. */
15
+ chartInfoIconSize?: string | number;
16
+ /** `nile-glyph` `color` for the header info icon, passed through unchanged. An explicit colour overrides the hover colour. */
17
+ chartInfoIconColor?: string;
8
18
  /** Font size for the header title (number → px, or any CSS length string). */
9
19
  titleFontSize?: string | number;
10
20
  /** Font size for the header subtitle (number → px, or any CSS length string). */
@@ -16,7 +16,7 @@ import type { RadarChartSeriesData } from '../nile-radar-chart/nile-radar-chart.
16
16
  import type { GaugeBand } from '../nile-gauge-chart/nile-gauge-chart.js';
17
17
  import type { WaterfallDataPoint } from '../nile-waterfall-chart/nile-waterfall-chart.js';
18
18
  import type { ForecastConfigFields, ForecastSeriesInput } from '../internal/utils/chart-forecast.js';
19
- import type { KpiVariant, KpiValueFormat, KpiNumberSystem, SparklineType, TrendDirection } from '../nile-kpi-chart/nile-kpi-chart.js';
19
+ import type { KpiVariant, KpiValueFormat, KpiNumberSystem, SparklineType, TrendDirection, KpiInfoPlacement } from '../nile-kpi-chart/nile-kpi-chart.js';
20
20
  import type { MapChartDataPoint } from '../nile-map-chart/nile-map-chart.js';
21
21
  import type { StatusLightConfig } from '../nile-chart-message/nile-chart-message.js';
22
22
  import type { ChartListVariant, ChartListItem, ChartListMarker } from '../nile-chart-list/nile-chart-list.js';
@@ -93,6 +93,16 @@ export interface NileAiConfig {
93
93
  export interface NileChartConfigBase extends HighchartsPassthroughConfig {
94
94
  chartTitle?: string;
95
95
  chartSubtitle?: string;
96
+ /** Info text shown on hover/focus of an icon beside the header title. Empty → no icon (needs a title). */
97
+ chartInfo?: string;
98
+ /** `nile-glyph` name for the header info icon (default: 'ng-info-circle'). */
99
+ chartInfoIcon?: string;
100
+ /** `nile-glyph` `method` for the header info icon (default: 'stroke'). */
101
+ chartInfoIconMethod?: string;
102
+ /** `nile-glyph` `size` for the header info icon (default: unset, so `nile-glyph`'s own 16). The hover/focus target keeps a 16px token minimum. */
103
+ chartInfoIconSize?: string | number;
104
+ /** `nile-glyph` `color` for the header info icon, passed through unchanged. An explicit colour overrides the hover colour. */
105
+ chartInfoIconColor?: string;
96
106
  titleFontSize?: string | number;
97
107
  subtitleFontSize?: string | number;
98
108
  noHeader?: boolean;
@@ -538,6 +548,18 @@ export interface NileKpiChartConfig extends NileChartConfigBase {
538
548
  gaugeLabelYOffset?: number;
539
549
  valueFontSize?: string | number;
540
550
  valueColor?: string;
551
+ /** Info text for an icon beside the value. Empty → no icon. */
552
+ valueInfo?: string;
553
+ /** Info icon position relative to the value (default: 'top-right'). */
554
+ valueInfoPlacement?: KpiInfoPlacement;
555
+ /** `nile-glyph` name for the info icon (default: 'ng-info-circle'). */
556
+ valueInfoIcon?: string;
557
+ /** `nile-glyph` `method` for the info icon (default: 'stroke'). */
558
+ valueInfoIconMethod?: string;
559
+ /** `nile-glyph` `size` for the info icon (default: unset, so `nile-glyph`'s own 16). Changes the glyph only; the hover/focus target keeps the 16px token minimum. */
560
+ valueInfoIconSize?: string | number;
561
+ /** `nile-glyph` `color` for the info icon, passed through as-is. An explicit colour overrides the hover colour. Default: follows `--nile-kpi-info-color`. */
562
+ valueInfoIconColor?: string;
541
563
  labelColor?: string;
542
564
  labelFontSize?: string | number;
543
565
  labelFontWeight?: string | number;
@@ -1,3 +1,3 @@
1
- export declare const tooltipCss = "\n .nile-chart-header-tooltip {\n position: fixed;\n display: none;\n transform: translate(-50%, calc(-100% - 10px));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));\n font-family: var(--nile-font-family-serif, var(--ng-font-family-body));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));\n font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));\n line-height: 1.4;\n padding: 4px 10px;\n border-radius: 6px;\n border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n pointer-events: none;\n white-space: nowrap;\n z-index: 2147483647;\n box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));\n }\n .nile-chart-header-tooltip::after {\n content: '';\n position: absolute;\n top: 100%;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-top-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n }\n";
1
+ export declare const tooltipCss = "\n .nile-chart-header-tooltip {\n position: fixed;\n display: none;\n transform: translate(-50%, calc(-100% - 10px));\n background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));\n color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));\n font-family: var(--nile-font-family-serif, var(--ng-font-family-body));\n font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));\n font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));\n line-height: 1.4;\n padding: 4px 10px;\n border-radius: 6px;\n border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n pointer-events: none;\n white-space: normal;\n width: max-content;\n max-width: min(320px, calc(100vw - 16px));\n overflow-wrap: anywhere;\n z-index: 2147483647;\n box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));\n }\n .nile-chart-header-tooltip.below {\n transform: translate(-50%, 10px);\n }\n .nile-chart-header-tooltip.below::after {\n top: auto;\n bottom: 100%;\n border-top-color: transparent;\n border-bottom-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n }\n .nile-chart-header-tooltip::after {\n content: '';\n position: absolute;\n top: 100%;\n left: var(--tip-arrow-x, 50%);\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-top-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));\n }\n";
2
2
  export declare function injectGlobalChartMenuOverrides(): void;
3
3
  export declare const styles: import("lit").CSSResult;
@@ -14,15 +14,27 @@ export const tooltipCss = `
14
14
  border-radius: 6px;
15
15
  border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
16
16
  pointer-events: none;
17
- white-space: nowrap;
17
+ white-space: normal;
18
+ width: max-content;
19
+ max-width: min(320px, calc(100vw - 16px));
20
+ overflow-wrap: anywhere;
18
21
  z-index: 2147483647;
19
22
  box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));
20
23
  }
24
+ .nile-chart-header-tooltip.below {
25
+ transform: translate(-50%, 10px);
26
+ }
27
+ .nile-chart-header-tooltip.below::after {
28
+ top: auto;
29
+ bottom: 100%;
30
+ border-top-color: transparent;
31
+ border-bottom-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
32
+ }
21
33
  .nile-chart-header-tooltip::after {
22
34
  content: '';
23
35
  position: absolute;
24
36
  top: 100%;
25
- left: 50%;
37
+ left: var(--tip-arrow-x, 50%);
26
38
  transform: translateX(-50%);
27
39
  border: 5px solid transparent;
28
40
  border-top-color: var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
@@ -170,6 +182,56 @@ export const styles = css `
170
182
  flex: 1 1 auto;
171
183
  }
172
184
 
185
+ /* Only rendered when chartInfo is set; otherwise the title <p> sits directly in the titles column. */
186
+ .nile-chart-header-title-row {
187
+ display: flex;
188
+ align-items: center;
189
+ gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
190
+ min-width: 0;
191
+ width: 100%;
192
+ }
193
+
194
+ .nile-chart-header-title-row .nile-chart-header-title {
195
+ width: auto;
196
+ flex: 0 1 auto;
197
+ }
198
+
199
+ .nile-chart-header-info-tip {
200
+ display: inline-flex;
201
+ align-items: center;
202
+ flex: 0 0 auto;
203
+ }
204
+
205
+ .nile-chart-header-info {
206
+ display: inline-flex;
207
+ align-items: center;
208
+ justify-content: center;
209
+ flex: 0 0 auto;
210
+ /* Hover/focus target never shrinks below the default glyph size, whatever chartInfoIconSize is. */
211
+ min-width: var(--nile-height-16px, var(--ng-height-16px));
212
+ min-height: var(--nile-height-16px, var(--ng-height-16px));
213
+ color: var(--nile-chart-header-info-color, var(--nile-colors-neutral-700, var(--ng-colors-fg-tertiary-600)));
214
+ border-radius: 50%;
215
+ cursor: pointer;
216
+ outline: none;
217
+ transition: color var(--nile-transition-duration-default, var(--ng-transition-duration-default)) ease;
218
+ }
219
+
220
+ /* currentColor follows .nile-chart-header-info's colour. */
221
+ .nile-chart-header-info nile-glyph {
222
+ display: block;
223
+ --nile-svg-fill: currentColor;
224
+ }
225
+
226
+ .nile-chart-header-info:hover,
227
+ .nile-chart-header-info:focus-visible {
228
+ color: var(--nile-chart-header-info-hover-color, var(--nile-colors-dark-900, var(--ng-colors-fg-tertiary-hover)));
229
+ }
230
+
231
+ .nile-chart-header-info:focus-visible {
232
+ box-shadow: 0 0 0 2px var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
233
+ }
234
+
173
235
  .nile-chart-header-title {
174
236
  margin: 0;
175
237
  font-family: var(--nile-font-family-serif-colfax-medium, var(--ng-font-family-display));
@@ -227,6 +227,7 @@ export declare class NileChart extends NileElement {
227
227
  /** Normalize a numeric (→px) or string dimension to a CSS length. */
228
228
  private static toCssSize;
229
229
  private get titleFontSize();
230
+ private headerInfo;
230
231
  private get subtitleFontSize();
231
232
  private onHeaderSlotChange;
232
233
  private onHeaderActionsSlotChange;
@@ -247,6 +248,9 @@ export declare class NileChart extends NileElement {
247
248
  private renderAiTrigger;
248
249
  private _showHeaderTip;
249
250
  private _hideHeaderTip;
251
+ private _onViewportMove;
252
+ /** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
253
+ private renderHeaderInfo;
250
254
  private _onHeaderTextEnter;
251
255
  private _syncHeaderTruncationA11y;
252
256
  private renderHeader;
@@ -2,6 +2,7 @@ var NileChart_1;
2
2
  import { __decorate } from "tslib";
3
3
  import { customElement, property, query, state } from 'lit/decorators.js';
4
4
  import { html, nothing } from 'lit';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
5
6
  import NileElement from '../internal/base/nile-element.js';
6
7
  import { styles, tooltipCss, injectGlobalChartMenuOverrides } from './nile-chart.css.js';
7
8
  import { HIGHCHARTS_PASSTHROUGH_KEYS } from '../internal/types/index.js';
@@ -283,14 +284,15 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
283
284
  }
284
285
  };
285
286
  this.resolvedConfig = null;
286
- // Reveal the full text when a title/subtitle is truncated. Accepts any Event
287
- // so it works for BOTH pointer (mouseenter) and keyboard (focus) users.
287
+ // The tooltip is fixed to the viewport and placed once, so any scroll (including a touch-drag while the
288
+ // finger is still down, when no leave/blur fires) would strand it away from its anchor. Hide it instead.
289
+ this._onViewportMove = () => this._hideHeaderTip();
288
290
  this._onHeaderTextEnter = (e) => {
289
291
  const el = e.currentTarget;
290
292
  if (el.scrollWidth <= el.clientWidth)
291
293
  return;
292
294
  const rect = el.getBoundingClientRect();
293
- this._showHeaderTip(el.textContent ?? '', rect.left + rect.width / 2, rect.top);
295
+ this._showHeaderTip(el.textContent ?? '', rect.left + rect.width / 2, rect.top, rect.height);
294
296
  };
295
297
  // ── ECharts engine path (NILE-005) ──────────────────────────────
296
298
  this._echart = null;
@@ -387,6 +389,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
387
389
  document.removeEventListener('click', this.handleOutsideClick);
388
390
  this.removeEventListener('nile-chart-ready', this.handleChartReady);
389
391
  this.removeEventListener('dblclick', this._onDoubleTap);
392
+ this._hideHeaderTip();
390
393
  this._headerTipEl?.remove();
391
394
  this._headerTipEl = null;
392
395
  this._headerResizeObs?.disconnect();
@@ -551,6 +554,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
551
554
  get titleFontSize() {
552
555
  return NileChart_1.toCssSize(this.activeConfig?.titleFontSize ?? this.resolvedConfig?.titleFontSize);
553
556
  }
557
+ headerInfo(key) {
558
+ // The info keys travel as a unit: once the active config sets chartInfo (even '' to clear it) all
559
+ // five keys come from it, so its text is never paired with another config's icon, size or colour.
560
+ const source = this.activeConfig?.chartInfo !== undefined ? this.activeConfig : this.resolvedConfig;
561
+ return source?.[key];
562
+ }
554
563
  get subtitleFontSize() {
555
564
  return NileChart_1.toCssSize(this.activeConfig?.subtitleFontSize ?? this.resolvedConfig?.subtitleFontSize);
556
565
  }
@@ -764,17 +773,51 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
764
773
  <slot name="nile-ai-trigger-after"></slot>
765
774
  `;
766
775
  }
767
- _showHeaderTip(text, x, y) {
776
+ _showHeaderTip(text, x, y, anchorHeight = 0) {
768
777
  if (!this._headerTipEl)
769
778
  return;
770
779
  this._headerTipEl.textContent = text;
771
780
  this._headerTipEl.style.left = `${x}px`;
772
781
  this._headerTipEl.style.top = `${y}px`;
773
782
  this._headerTipEl.style.display = 'block';
783
+ window.addEventListener('scroll', this._onViewportMove, { capture: true, passive: true });
784
+ window.addEventListener('resize', this._onViewportMove, { passive: true });
785
+ // Keep the tooltip inside the viewport; the arrow keeps pointing at the anchor.
786
+ const margin = 8;
787
+ const half = this._headerTipEl.offsetWidth / 2;
788
+ const cx = Math.min(Math.max(x, half + margin), Math.max(half + margin, window.innerWidth - half - margin));
789
+ this._headerTipEl.style.left = `${cx}px`;
790
+ this._headerTipEl.style.setProperty('--tip-arrow-x', `${half + x - cx}px`);
791
+ // Not enough room above the anchor: drop below it instead.
792
+ const above = y - this._headerTipEl.offsetHeight - 10 >= margin;
793
+ this._headerTipEl.classList.toggle('below', !above);
794
+ if (!above)
795
+ this._headerTipEl.style.top = `${y + anchorHeight}px`;
774
796
  }
775
797
  _hideHeaderTip() {
776
798
  if (this._headerTipEl)
777
799
  this._headerTipEl.style.display = 'none';
800
+ window.removeEventListener('scroll', this._onViewportMove, true);
801
+ window.removeEventListener('resize', this._onViewportMove);
802
+ }
803
+ /** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
804
+ renderHeaderInfo() {
805
+ const info = String(this.headerInfo('chartInfo') ?? '');
806
+ if (!info)
807
+ return nothing;
808
+ const size = this.headerInfo('chartInfoIconSize');
809
+ return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"><span
810
+ class="nile-chart-header-info"
811
+ part="header-info"
812
+ role="img"
813
+ tabindex="0"
814
+ aria-label=${info}
815
+ ><nile-glyph
816
+ name=${this.headerInfo('chartInfoIcon') || 'ng-info-circle'}
817
+ method=${this.headerInfo('chartInfoIconMethod') || 'stroke'}
818
+ size=${ifDefined(size === '' || size == null ? undefined : size)}
819
+ color=${this.headerInfo('chartInfoIconColor') || 'currentColor'}
820
+ ></nile-glyph></span></nile-lite-tooltip>`;
778
821
  }
779
822
  _syncHeaderTruncationA11y() {
780
823
  const root = this.shadowRoot;
@@ -809,7 +852,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
809
852
  <slot name="header" @slotchange=${this.onHeaderSlotChange}></slot>
810
853
  ${showDefaultTitles
811
854
  ? html `
812
- ${title ? 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>` : nothing}
855
+ ${title
856
+ ? this.headerInfo('chartInfo')
857
+ ? 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>`
858
+ : 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>`
859
+ : nothing}
813
860
  ${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}
814
861
  `
815
862
  : nothing}
@@ -2130,6 +2177,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
2130
2177
  gaugeLabelYOffset: k.gaugeLabelYOffset,
2131
2178
  valueFontSize: k.valueFontSize,
2132
2179
  valueColor: k.valueColor,
2180
+ valueInfo: k.valueInfo,
2181
+ valueInfoPlacement: k.valueInfoPlacement,
2182
+ valueInfoIcon: k.valueInfoIcon,
2183
+ valueInfoIconMethod: k.valueInfoIconMethod,
2184
+ valueInfoIconSize: k.valueInfoIconSize,
2185
+ valueInfoIconColor: k.valueInfoIconColor,
2133
2186
  labelColor: k.labelColor,
2134
2187
  labelFontSize: k.labelFontSize,
2135
2188
  labelFontWeight: k.labelFontWeight,
@@ -70,7 +70,7 @@ export const styles = css `
70
70
  --nile-kpi-forecast-font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
71
71
  --nile-kpi-description-font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
72
72
  --nile-kpi-description-color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
73
- /* Value info icon (fixed 16px via the glyph's size attribute). */
73
+ /* Value info icon (default size is nile-glyph's own 16). */
74
74
  --nile-kpi-info-color: var(--nile-colors-neutral-700, var(--ng-colors-fg-tertiary-600));
75
75
  --nile-kpi-info-hover-color: var(--nile-colors-dark-900, var(--ng-colors-fg-tertiary-hover));
76
76
  display: flex;
@@ -196,9 +196,23 @@ export const styles = css `
196
196
  min-width: 0;
197
197
  }
198
198
 
199
+ .kpi-tip {
200
+ display: contents;
201
+ }
202
+
203
+ .kpi-info-tip {
204
+ display: inline-flex;
205
+ flex: 0 0 auto;
206
+ }
207
+
199
208
  .kpi-info {
200
209
  display: inline-flex;
210
+ align-items: center;
211
+ justify-content: center;
201
212
  flex: 0 0 auto;
213
+ /* Hover/focus target never shrinks below the default glyph size, whatever valueInfoIconSize is. */
214
+ min-width: var(--nile-height-16px, var(--ng-height-16px));
215
+ min-height: var(--nile-height-16px, var(--ng-height-16px));
202
216
  color: var(--nile-kpi-info-color);
203
217
  border-radius: 50%;
204
218
  cursor: pointer;
@@ -226,6 +240,10 @@ export const styles = css `
226
240
  align-self: flex-start;
227
241
  }
228
242
 
243
+ .kpi-info--center {
244
+ align-self: center;
245
+ }
246
+
229
247
  .kpi-info--bottom {
230
248
  align-self: flex-end;
231
249
  }
@@ -7,7 +7,7 @@ export type KpiVariant = 'default' | 'card' | 'gauge' | 'accent';
7
7
  export type SparklineType = 'area' | 'line' | 'column' | 'bar' | 'spline' | 'areaspline' | 'pie' | 'scatter';
8
8
  export type KpiValueFormat = 'auto' | 'K' | 'M' | 'B' | 'T' | 'none';
9
9
  export type KpiNumberSystem = 'indian' | 'international';
10
- export type KpiInfoPlacement = 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left';
10
+ export type KpiInfoPlacement = 'top-right' | 'center-right' | 'bottom-right' | 'top-left' | 'center-left' | 'bottom-left';
11
11
  /** `chart` slice for `<nile-kpi-chart>.config` (discriminated by `type: 'kpi'`). */
12
12
  export interface ChartKpiSeparatedPayload {
13
13
  type: 'kpi';
@@ -70,6 +70,14 @@ export interface ChartKpiSeparatedPayload {
70
70
  valueInfo?: string;
71
71
  /** Info icon position relative to the value (default: 'top-right'). */
72
72
  valueInfoPlacement?: KpiInfoPlacement;
73
+ /** `nile-glyph` name for the info icon (default: 'ng-info-circle'). */
74
+ valueInfoIcon?: string;
75
+ /** `nile-glyph` `method` for the info icon (default: 'stroke'). */
76
+ valueInfoIconMethod?: string;
77
+ /** `nile-glyph` `size` for the info icon (default: the 16px height token)*/
78
+ valueInfoIconSize?: string | number;
79
+ /** nile-glyph` `color` for the info icon, passed through unchanged */
80
+ valueInfoIconColor?: string;
73
81
  /** Custom text shown in the loading state (default: 'Loading...'). */
74
82
  loadingText?: string;
75
83
  /** Whether the hover tooltip is shown on value / sparkline / gauge (default: true). */
@@ -241,8 +249,16 @@ export declare class NileKpiChart extends NileElement {
241
249
  valueColor: string;
242
250
  /** Info text shown on hover/focus of an icon beside the value. Empty → no icon. */
243
251
  valueInfo: string;
244
- /** Info icon position: top-/bottom- (superscript/subscript), -left (before prefix) / -right (after suffix). */
252
+ /** Info icon position: top-/center-/bottom- (superscript/vertically centred/subscript), -left (before prefix) / -right (after suffix). */
245
253
  valueInfoPlacement: KpiInfoPlacement;
254
+ /** `nile-glyph` name used for the info icon. Empty → 'ng-info-circle'. */
255
+ valueInfoIcon: string;
256
+ /** `nile-glyph` `method` for the info icon. */
257
+ valueInfoIconMethod: string;
258
+ /** `nile-glyph` `size` for the info icon. Changes the glyph only, not the hover/focus target (min: the 16px height token). Empty → not passed, so `nile-glyph` uses its own default (16). */
259
+ valueInfoIconSize: string | number;
260
+ /** `nile-glyph` `color` for the info icon */
261
+ valueInfoIconColor: string;
246
262
  /** Custom text shown in the loading state. */
247
263
  loadingText: string;
248
264
  /** Whether the hover tooltip is shown on value / sparkline / gauge. */
@@ -287,7 +303,6 @@ export declare class NileKpiChart extends NileElement {
287
303
  */
288
304
  embedInNileChart: boolean;
289
305
  private _createTipEl;
290
- /** `force` bypasses `tooltipEnabled` — for the value info icon, whose only job is the tooltip. */
291
306
  private _showTip;
292
307
  private _showMarker;
293
308
  private _hideTip;
@@ -323,11 +338,9 @@ export declare class NileKpiChart extends NileElement {
323
338
  private destroySparkline;
324
339
  private destroyGauge;
325
340
  private destroyCharts;
326
- private _onValueEnter;
327
- private _onDescEnter;
328
- private _onLabelEnter;
329
- private _onTrendEnter;
330
- private _onInfoEnter;
341
+ private _valueTooltipText;
342
+ private _trendTooltipText;
343
+ private _syncTruncationTips;
331
344
  private _onGaugeEnter;
332
345
  private _onTrendKeydown;
333
346
  private _onTipLeave;
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { customElement, property, query } from 'lit/decorators.js';
3
3
  import { html, nothing } from 'lit';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
5
  import NileElement from '../internal/base/nile-element.js';
5
6
  import { getHighcharts } from '../internal/utils/highcharts-provider.js';
6
7
  import { styles, tooltipCss } from './nile-kpi-chart.css.js';
@@ -120,8 +121,16 @@ let NileKpiChart = class NileKpiChart extends NileElement {
120
121
  this.valueColor = '';
121
122
  /** Info text shown on hover/focus of an icon beside the value. Empty → no icon. */
122
123
  this.valueInfo = '';
123
- /** Info icon position: top-/bottom- (superscript/subscript), -left (before prefix) / -right (after suffix). */
124
+ /** Info icon position: top-/center-/bottom- (superscript/vertically centred/subscript), -left (before prefix) / -right (after suffix). */
124
125
  this.valueInfoPlacement = 'top-right';
126
+ /** `nile-glyph` name used for the info icon. Empty → 'ng-info-circle'. */
127
+ this.valueInfoIcon = 'ng-info-circle';
128
+ /** `nile-glyph` `method` for the info icon. */
129
+ this.valueInfoIconMethod = 'stroke';
130
+ /** `nile-glyph` `size` for the info icon. Changes the glyph only, not the hover/focus target (min: the 16px height token). Empty → not passed, so `nile-glyph` uses its own default (16). */
131
+ this.valueInfoIconSize = '';
132
+ /** `nile-glyph` `color` for the info icon */
133
+ this.valueInfoIconColor = '';
125
134
  /** Custom text shown in the loading state. */
126
135
  this.loadingText = 'Loading...';
127
136
  /** Whether the hover tooltip is shown on value / sparkline / gauge. */
@@ -221,48 +230,6 @@ let NileKpiChart = class NileKpiChart extends NileElement {
221
230
  this._onSparklineMouseLeave = () => {
222
231
  this._hideTip();
223
232
  };
224
- // ── Value / Gauge hover handlers ─────────────────────────────────────────
225
- this._onValueEnter = (e) => {
226
- const rect = e.currentTarget.getBoundingClientRect();
227
- const rawNum = this.parseNumericValue(this.value);
228
- const full = rawNum != null ? this.formatValue(rawNum).full : String(this.value ?? '');
229
- const prefix = this.prefix ?? '';
230
- const suffix = this.suffix ?? '';
231
- this._showTip(`${prefix}${full}${suffix}`.trim(), rect.left + rect.width / 2, rect.top);
232
- };
233
- this._onDescEnter = (e) => {
234
- const el = e.currentTarget;
235
- if (el.scrollWidth <= el.clientWidth)
236
- return;
237
- const rect = el.getBoundingClientRect();
238
- this._showTip(this.description ?? '', rect.left + rect.width / 2, rect.top);
239
- };
240
- this._onLabelEnter = (e) => {
241
- const el = e.currentTarget;
242
- if (el.scrollWidth <= el.clientWidth)
243
- return;
244
- const rect = el.getBoundingClientRect();
245
- this._showTip(this.label ?? '', rect.left + rect.width / 2, rect.top);
246
- };
247
- this._onTrendEnter = (e) => {
248
- const el = e.currentTarget;
249
- // Only show a tooltip when the trend is actually clipped/ellipsized.
250
- const hasEllipsis = getComputedStyle(el).textOverflow === 'ellipsis';
251
- if (!hasEllipsis)
252
- return;
253
- if (el.scrollWidth <= el.clientWidth + 2)
254
- return;
255
- const rect = el.getBoundingClientRect();
256
- const dir = this.trendDirection;
257
- const arrow = dir === 'up' ? '▲' : dir === 'down' ? '▼' : '–';
258
- const pct = this.trendValue !== null ? `${Math.abs(this.trendValue).toFixed(1)}%` : '';
259
- const text = `${arrow} ${pct}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
260
- this._showTip(text, rect.left + rect.width / 2, rect.top);
261
- };
262
- this._onInfoEnter = (e) => {
263
- const rect = e.currentTarget.getBoundingClientRect();
264
- this._showTip(this.valueInfo, rect.left + rect.width / 2, rect.top, true);
265
- };
266
233
  this._onGaugeEnter = (e) => {
267
234
  const rect = e.currentTarget.getBoundingClientRect();
268
235
  this._showTip(this.getTooltipContent(), rect.left + rect.width / 2, rect.top + rect.height / 2);
@@ -288,9 +255,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
288
255
  document.body.appendChild(marker);
289
256
  this._markerEl = marker;
290
257
  }
291
- /** `force` bypasses `tooltipEnabled` — for the value info icon, whose only job is the tooltip. */
292
- _showTip(text, x, y, force = false) {
293
- if (!this._tipEl || (!this.tooltipEnabled && !force))
258
+ _showTip(text, x, y) {
259
+ if (!this._tipEl || !this.tooltipEnabled)
294
260
  return;
295
261
  this._tipEl.textContent = text;
296
262
  this._tipEl.style.left = `${x}px`;
@@ -591,8 +557,16 @@ let NileKpiChart = class NileKpiChart extends NileElement {
591
557
  this.valueColor = c.valueColor;
592
558
  if (c.valueInfo !== undefined)
593
559
  this.valueInfo = c.valueInfo;
594
- if (c.valueInfoPlacement !== undefined)
560
+ if (c.valueInfoPlacement != null)
595
561
  this.valueInfoPlacement = c.valueInfoPlacement;
562
+ if (c.valueInfoIcon != null)
563
+ this.valueInfoIcon = c.valueInfoIcon;
564
+ if (c.valueInfoIconMethod != null)
565
+ this.valueInfoIconMethod = c.valueInfoIconMethod;
566
+ if (c.valueInfoIconSize != null)
567
+ this.valueInfoIconSize = c.valueInfoIconSize;
568
+ if (c.valueInfoIconColor != null)
569
+ this.valueInfoIconColor = c.valueInfoIconColor;
596
570
  if (c.loadingText !== undefined)
597
571
  this.loadingText = c.loadingText;
598
572
  if (c.tooltipEnabled !== undefined)
@@ -711,11 +685,13 @@ let NileKpiChart = class NileKpiChart extends NileElement {
711
685
  this.initGauge();
712
686
  this.setupResizeObserver();
713
687
  requestAnimationFrame(() => this._reconcileFit());
688
+ void document.fonts?.ready.then(() => this._syncTruncationTips());
714
689
  }
715
690
  updated(changedProperties) {
716
691
  const hasValue = this.value !== '' && this.value !== null && this.value !== undefined;
717
692
  this.toggleAttribute('has-value', hasValue);
718
693
  this.toggleAttribute('has-sparkline', this.sparkline.length > 0);
694
+ this._syncTruncationTips();
719
695
  if (changedProperties.has('config') && this.config) {
720
696
  this.applyConfig(this.config);
721
697
  return;
@@ -842,6 +818,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
842
818
  this._reconcileFit();
843
819
  this.syncSparklineChartSize();
844
820
  this.syncGaugeChartSize();
821
+ this._syncTruncationTips();
845
822
  });
846
823
  this.resizeObserver.observe(this);
847
824
  if (this.sparklineContainer)
@@ -1089,23 +1066,54 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1089
1066
  this.destroySparkline();
1090
1067
  this.destroyGauge();
1091
1068
  }
1069
+ _valueTooltipText() {
1070
+ const rawNum = this.parseNumericValue(this.value);
1071
+ const full = rawNum != null ? this.formatValue(rawNum).full : String(this.value ?? '');
1072
+ return `${this.prefix ?? ''}${full}${this.suffix ?? ''}`.trim();
1073
+ }
1074
+ _trendTooltipText() {
1075
+ const dir = this.trendDirection;
1076
+ const arrow = dir === 'up' ? '▲' : dir === 'down' ? '▼' : '–';
1077
+ const pct = this.trendValue !== null ? `${Math.abs(this.trendValue).toFixed(1)}%` : '';
1078
+ return `${arrow} ${pct}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
1079
+ }
1080
+ _syncTruncationTips() {
1081
+ const root = this.shadowRoot;
1082
+ if (!root)
1083
+ return;
1084
+ root.querySelectorAll('nile-lite-tooltip[data-kpi-tip]').forEach(tip => {
1085
+ const el = tip.firstElementChild;
1086
+ if (!el)
1087
+ return;
1088
+ const truncated = tip.dataset['kpiTip'] === 'trend'
1089
+ ? getComputedStyle(el).textOverflow === 'ellipsis' && el.scrollWidth > el.clientWidth + 2
1090
+ : el.scrollWidth > el.clientWidth;
1091
+ const disabled = !this.tooltipEnabled || !truncated;
1092
+ if (tip.disabled !== disabled)
1093
+ tip.disabled = disabled;
1094
+ });
1095
+ }
1092
1096
  // ── Render ───────────────────────────────────────────────────────────────
1093
1097
  renderValueInfo() {
1094
1098
  if (!this.valueInfo)
1095
1099
  return nothing;
1096
- const [vertical, side] = this.valueInfoPlacement.split('-');
1097
- return html `<span
1098
- class="kpi-info kpi-info--${vertical === 'bottom' ? 'bottom' : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
1100
+ const [vertical, side] = (typeof this.valueInfoPlacement === 'string' ? this.valueInfoPlacement : 'top-right').split('-');
1101
+ return html `<nile-lite-tooltip
1102
+ class="kpi-info-tip kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
1103
+ content=${this.valueInfo}
1104
+ placement="top"
1105
+ ><span
1106
+ class="kpi-info"
1099
1107
  part="value-info"
1100
1108
  role="img"
1101
1109
  tabindex="0"
1102
1110
  aria-label=${this.valueInfo}
1103
- @mouseenter=${this._onInfoEnter}
1104
- @mouseleave=${this._onTipLeave}
1105
- @focus=${this._onInfoEnter}
1106
- @blur=${this._onTipLeave}
1107
- @keydown=${this._onTrendKeydown}
1108
- ><nile-glyph name="ng-info-circle" method="stroke" size="16"></nile-glyph></span>`;
1111
+ ><nile-glyph
1112
+ name=${this.valueInfoIcon || 'ng-info-circle'}
1113
+ method=${this.valueInfoIconMethod || 'stroke'}
1114
+ size=${ifDefined(this.valueInfoIconSize === '' || this.valueInfoIconSize == null ? undefined : this.valueInfoIconSize)}
1115
+ color=${this.valueInfoIconColor || 'currentColor'}
1116
+ ></nile-glyph></span></nile-lite-tooltip>`;
1109
1117
  }
1110
1118
  renderTrend() {
1111
1119
  if (this.trendValue === null)
@@ -1113,17 +1121,11 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1113
1121
  const dir = this.trendDirection;
1114
1122
  const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
1115
1123
  const trendAriaLabel = `Trend ${dir === 'up' ? 'up' : dir === 'down' ? 'down' : 'neutral'} ${formatted}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
1116
- return html `
1117
- <span
1124
+ return html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
1118
1125
  class="kpi-trend kpi-trend--${dir}"
1119
1126
  tabindex="0"
1120
1127
  role="button"
1121
1128
  aria-label=${trendAriaLabel}
1122
- @mouseenter=${this._onTrendEnter}
1123
- @mouseleave=${this._onTipLeave}
1124
- @focus=${this._onTrendEnter}
1125
- @blur=${this._onTipLeave}
1126
- @keydown=${this._onTrendKeydown}
1127
1129
  >
1128
1130
  <span class="kpi-trend-arrow">
1129
1131
  ${dir === 'up'
@@ -1133,8 +1135,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1133
1135
  : html `<svg viewBox="0 0 12 12"><path d="M2 6.5h8" stroke="currentColor" stroke-width="1.5" fill="none"/></svg>`}
1134
1136
  </span>
1135
1137
  <span class="kpi-trend-value">${formatted}</span>${this.trendLabel ? html ` <span class="kpi-trend-label">${this.trendLabel}</span>` : nothing}
1136
- </span>
1137
- `;
1138
+ </span></nile-lite-tooltip>`;
1138
1139
  }
1139
1140
  /**
1140
1141
  * The projected-value line. Rendered only when `forecastValue` is set, so a
@@ -1170,18 +1171,19 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1170
1171
  const fmt = rawNum != null ? this.formatValue(rawNum) : null;
1171
1172
  const displayValue = fmt ? fmt.display : String(this.value ?? '');
1172
1173
  const showTooltip = !!fmt && fmt.display !== fmt.full;
1173
- const infoLeft = this.valueInfoPlacement.endsWith('-left');
1174
+ const infoLeft = typeof this.valueInfoPlacement === 'string' && this.valueInfoPlacement.endsWith('-left');
1175
+ const valueEl = html `<h2
1176
+ class="kpi-value"
1177
+ tabindex=${showTooltip ? '0' : nothing}
1178
+ >
1179
+ ${this.prefix ? html `<span class="kpi-prefix">${this.prefix}</span>` : nothing}${displayValue}${this.suffix ? html `<span class="kpi-suffix">${this.suffix}</span>` : nothing}
1180
+ </h2>`;
1174
1181
  return html `
1175
1182
  <div class="kpi ${isGauge ? 'kpi--gauge' : ''}">
1176
- ${this.label ? html `<p
1183
+ ${this.label ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
1177
1184
  class="kpi-label"
1178
1185
  tabindex="0"
1179
- @mouseenter=${this._onLabelEnter}
1180
- @mouseleave=${this._onTipLeave}
1181
- @focus=${this._onLabelEnter}
1182
- @blur=${this._onTipLeave}
1183
- @keydown=${this._onTrendKeydown}
1184
- >${this.label}</p>` : nothing}
1186
+ >${this.label}</p></nile-lite-tooltip>` : nothing}
1185
1187
 
1186
1188
  ${isGauge ? html `
1187
1189
  <div class="kpi-gauge-slot">
@@ -1203,17 +1205,9 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1203
1205
  ${!isGauge ? html `
1204
1206
  <span class="kpi-value-group">
1205
1207
  ${infoLeft ? this.renderValueInfo() : nothing}
1206
- <h2
1207
- class="kpi-value"
1208
- tabindex=${showTooltip ? '0' : nothing}
1209
- @mouseenter=${showTooltip ? this._onValueEnter : nothing}
1210
- @mouseleave=${showTooltip ? this._onTipLeave : nothing}
1211
- @focus=${showTooltip ? this._onValueEnter : nothing}
1212
- @blur=${showTooltip ? this._onTipLeave : nothing}
1213
- @keydown=${showTooltip ? this._onTrendKeydown : nothing}
1214
- >
1215
- ${this.prefix ? html `<span class="kpi-prefix">${this.prefix}</span>` : nothing}${displayValue}${this.suffix ? html `<span class="kpi-suffix">${this.suffix}</span>` : nothing}
1216
- </h2>
1208
+ ${showTooltip
1209
+ ? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
1210
+ : valueEl}
1217
1211
  ${infoLeft ? nothing : this.renderValueInfo()}
1218
1212
  </span>
1219
1213
  ` : nothing}
@@ -1224,15 +1218,10 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1224
1218
 
1225
1219
  ${this.renderForecast()}
1226
1220
 
1227
- ${this.description ? html `<p
1221
+ ${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
1228
1222
  class="kpi-description"
1229
1223
  tabindex="0"
1230
- @mouseenter=${this._onDescEnter}
1231
- @mouseleave=${this._onTipLeave}
1232
- @focus=${this._onDescEnter}
1233
- @blur=${this._onTipLeave}
1234
- @keydown=${this._onTrendKeydown}
1235
- >${this.description}</p>` : nothing}
1224
+ >${this.description}</p></nile-lite-tooltip>` : nothing}
1236
1225
 
1237
1226
  ${this.sparkline.length && !isGauge ? html `<div class="kpi-sparkline"></div>` : nothing}
1238
1227
  </div>
@@ -1369,6 +1358,18 @@ __decorate([
1369
1358
  __decorate([
1370
1359
  property({ type: String, attribute: 'value-info-placement' })
1371
1360
  ], NileKpiChart.prototype, "valueInfoPlacement", void 0);
1361
+ __decorate([
1362
+ property({ type: String, attribute: true })
1363
+ ], NileKpiChart.prototype, "valueInfoIcon", void 0);
1364
+ __decorate([
1365
+ property({ type: String, attribute: true })
1366
+ ], NileKpiChart.prototype, "valueInfoIconMethod", void 0);
1367
+ __decorate([
1368
+ property({ attribute: true })
1369
+ ], NileKpiChart.prototype, "valueInfoIconSize", void 0);
1370
+ __decorate([
1371
+ property({ type: String, attribute: true })
1372
+ ], NileKpiChart.prototype, "valueInfoIconColor", void 0);
1372
1373
  __decorate([
1373
1374
  property({ type: String, attribute: 'loading-text' })
1374
1375
  ], NileKpiChart.prototype, "loadingText", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.36",
3
+ "version": "2.9.38",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",
@@ -73,6 +73,7 @@
73
73
  "@aquera/nile-elements": ">=0.1.0"
74
74
  },
75
75
  "devDependencies": {
76
+ "@aquera/nile-glyph": "^1.0.9",
76
77
  "@rollup/plugin-babel": "^6.0.3",
77
78
  "@rollup/plugin-commonjs": "^25.0.3",
78
79
  "@rollup/plugin-node-resolve": "^15.0.1",