@aquera/nile-visualization 2.9.52 → 2.9.53

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,9 @@ To run a local development server that serves the basic demo located in `demo/in
36
36
 
37
37
  In this section, you can find the updates for each release of `nile-visualization`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
38
38
 
39
+ #### Version 2.9.53 (November 21, 2026)
40
+ - Nile KPI Chart: `sparkline-position` for the compact variant. `right` gives a small card with the sparkline beside the value (about 45% of the width, 48–120 px, 32 px tall, not full-bleed), a 24–32 px value and no 160 px minimum height; `bottom` (default) is unchanged. Also `sparklinePosition` in `<nile-chart>` KPI config (UIF-1436)
41
+
39
42
  #### Version 2.9.52 (November 20, 2026)
40
43
  - Nile KPI Chart and Nile Chart: CSS parts at every level. Every element of `nile-kpi-chart` is now a part (`base`, `header`, `label`, `value`, `prefix`, `suffix`, `trend` + `trend-up` / `trend-down` / `trend-neutral`, `forecast-*`, `description`, `sparkline`, `gauge`, …; `value-info` and `forecast` unchanged). `nile-chart` tags every embedded chart `part="chart <type>"` (`kpi-chart`, `bar-chart`, …) and re-exports the parts of embedded elements under a prefix: `kpi-*`, `master-detail-*`, `grid-*`, `filter-*`, `list-*`, `message-*` — e.g. `nile-chart::part(kpi-value)`. New `header-info-tooltip` part. No visual change (UIF-1433)
41
44
  - Nile Master-Detail Chart: fine-grained navigator steps. `navigator-pan-step` sets how far ‹ / ›, ← / → and `panBy()` move (`25%` default, a fraction, data points such as `1pt`, or a datetime duration such as `1d`); `navigator-slider-step` makes the slider move in stops (`10%`, `1pt`, `1w`; empty stays smooth); `navigator-slider-live` moves the window while the thumb is dragged; `navigator-zoom-step` sets the + / − factor (default `2`). `panBy(direction, step?)` takes an optional one-off step. Changing any of them keeps the current window. Also `<nile-chart>` config keys (UIF-1433)
@@ -17,7 +17,7 @@ import type { RadarChartSeriesData } from '../nile-radar-chart/nile-radar-chart.
17
17
  import type { GaugeBand } from '../nile-gauge-chart/nile-gauge-chart.js';
18
18
  import type { WaterfallDataPoint } from '../nile-waterfall-chart/nile-waterfall-chart.js';
19
19
  import type { ForecastConfigFields, ForecastSeriesInput } from '../internal/utils/chart-forecast.js';
20
- import type { KpiVariant, KpiValueFormat, KpiNumberSystem, SparklineType, TrendDirection, KpiInfoPlacement } from '../nile-kpi-chart/nile-kpi-chart.js';
20
+ import type { KpiVariant, KpiValueFormat, KpiNumberSystem, SparklineType, TrendDirection, KpiInfoPlacement, KpiSparklinePosition } from '../nile-kpi-chart/nile-kpi-chart.js';
21
21
  import type { MapChartDataPoint } from '../nile-map-chart/nile-map-chart.js';
22
22
  import type { StatusLightConfig } from '../nile-chart-message/nile-chart-message.js';
23
23
  import type { ChartListVariant, ChartListItem, ChartListMarker } from '../nile-chart-list/nile-chart-list.js';
@@ -557,6 +557,8 @@ export interface NileKpiChartConfig extends NileChartConfigBase {
557
557
  sparklineHeight?: number;
558
558
  sparklineLineWidth?: number;
559
559
  sparklineMarkers?: boolean;
560
+ /** Compact variant: sparkline below the value or to its right (default: 'bottom'). */
561
+ sparklinePosition?: KpiSparklinePosition;
560
562
  gaugeValue?: number;
561
563
  gaugeMin?: number;
562
564
  gaugeMax?: number;
@@ -2340,6 +2340,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
2340
2340
  sparklineMarkers: k.sparklineMarkers,
2341
2341
  sparklineHeight: k.sparklineHeight,
2342
2342
  sparklineLineWidth: k.sparklineLineWidth,
2343
+ sparklinePosition: k.sparklinePosition,
2343
2344
  gaugeValue: k.gaugeValue,
2344
2345
  gaugeMin: k.gaugeMin,
2345
2346
  gaugeMax: k.gaugeMax,
@@ -993,6 +993,42 @@ export const styles = css `
993
993
  display: inline-flex;
994
994
  }
995
995
 
996
+ /* Compact, sparkline on the right: a small card with the chart beside the value. */
997
+ :host([variant='compact'][sparkline-position='right']) {
998
+ --nile-kpi-value-font-size: clamp(24px, 12cqi, 32px);
999
+ min-height: 0;
1000
+ }
1001
+
1002
+ :host([variant='compact'][sparkline-position='right'][has-sparkline]:not([embed-in-nile-chart])) {
1003
+ border-width: var(--nile-kpi-card-border-width);
1004
+ box-shadow: var(--nile-kpi-card-shadow);
1005
+ }
1006
+
1007
+ :host([variant='compact'][sparkline-position='right'][has-sparkline]:not([embed-in-nile-chart]):hover) {
1008
+ box-shadow: var(--nile-kpi-card-shadow-hover);
1009
+ }
1010
+
1011
+ :host([sparkline-position='right']) .kpi--compact .kpi-value-row {
1012
+ align-items: flex-end;
1013
+ justify-content: space-between;
1014
+ }
1015
+
1016
+ :host([sparkline-position='right']) .kpi--compact .kpi-value-group {
1017
+ flex: 0 1 auto;
1018
+ min-width: 0;
1019
+ }
1020
+
1021
+ :host([sparkline-position='right']) .kpi--compact .kpi-sparkline {
1022
+ flex: 0 1 45%;
1023
+ width: auto;
1024
+ max-width: 120px;
1025
+ min-width: 48px;
1026
+ height: 32px;
1027
+ min-height: 0;
1028
+ max-height: 32px;
1029
+ margin: 0;
1030
+ }
1031
+
996
1032
  /* 1. The sparkline stays at every size; it only goes when the card is too short for anything else. */
997
1033
  @container (max-height: 72px) {
998
1034
  :host([variant='compact']) .kpi-sparkline {
@@ -10,6 +10,8 @@ export type KpiNumberSystem = 'indian' | 'international';
10
10
  export type KpiInfoPlacement = 'top-right' | 'center-right' | 'bottom-right' | 'top-left' | 'center-left' | 'bottom-left';
11
11
  /** How compact titles handle an oversized word: `'ellipsis'` cuts it with `…`, `'break'` splits it. */
12
12
  export type KpiTitleOverflow = 'ellipsis' | 'break';
13
+ /** Where the compact variant places its sparkline: `'bottom'` (full-bleed strip) or `'right'` (small chart beside the value). */
14
+ export type KpiSparklinePosition = 'bottom' | 'right';
13
15
  /** `chart` slice for `<nile-kpi-chart>.config` (discriminated by `type: 'kpi'`). */
14
16
  export interface ChartKpiSeparatedPayload {
15
17
  type: 'kpi';
@@ -86,6 +88,8 @@ export interface ChartKpiSeparatedPayload {
86
88
  tooltipEnabled?: boolean;
87
89
  /** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
88
90
  titleOverflow?: KpiTitleOverflow;
91
+ /** Compact variant: sparkline below the value or to its right (default: 'bottom'). */
92
+ sparklinePosition?: KpiSparklinePosition;
89
93
  /** Accent bar colour for the 'accent' variant (default: brand blue). */
90
94
  accentColor?: string;
91
95
  cardBackground?: string;
@@ -317,6 +321,8 @@ export declare class NileKpiChart extends NileElement {
317
321
  tooltipEnabled: boolean;
318
322
  /** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
319
323
  titleOverflow: KpiTitleOverflow;
324
+ /** Compact variant: `'bottom'` runs the sparkline along the card bottom; `'right'` gives a small card with the sparkline beside the value. */
325
+ sparklinePosition: KpiSparklinePosition;
320
326
  cardBackground: string;
321
327
  cardBorderColor: string;
322
328
  cardBorderWidth: string | number;
@@ -401,6 +407,8 @@ export declare class NileKpiChart extends NileElement {
401
407
  * nothing is half-cut. Re-evaluated only when the card's size changes, so hiding them
402
408
  * (which frees space) can't make it flip back and forth.
403
409
  */
410
+ private get _sparkRight();
411
+ private get _sparkBleeds();
404
412
  private _fitDescription;
405
413
  /**
406
414
  * True when `el` shows less than its full text. Chrome hides -webkit-line-clamp lines without reporting overflow, so the clamp is lifted for one measurement.
@@ -224,6 +224,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
224
224
  this.tooltipEnabled = true;
225
225
  /** How the compact title handles text that doesn't fit; see `KpiTitleOverflow`. */
226
226
  this.titleOverflow = 'ellipsis';
227
+ /** Compact variant: `'bottom'` runs the sparkline along the card bottom; `'right'` gives a small card with the sparkline beside the value. */
228
+ this.sparklinePosition = 'bottom';
227
229
  // ── Card chrome ──
228
230
  this.cardBackground = '';
229
231
  this.cardBorderColor = '';
@@ -692,6 +694,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
692
694
  this.tooltipEnabled = c.tooltipEnabled;
693
695
  if (c.titleOverflow !== undefined)
694
696
  this.titleOverflow = c.titleOverflow;
697
+ if (c.sparklinePosition !== undefined)
698
+ this.sparklinePosition = c.sparklinePosition;
695
699
  if (c.accentColor !== undefined)
696
700
  this.accentColor = c.accentColor;
697
701
  if (c.cardBackground !== undefined)
@@ -824,7 +828,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
824
828
  return;
825
829
  }
826
830
  const sparklineProps = ['sparkline', 'sparklineColor', 'sparklineHeight', 'sparklineLineWidth',
827
- 'sparklineType', 'sparklineFillOpacity', 'sparklineMarkers', 'options', 'trendDirection', 'variant'];
831
+ 'sparklineType', 'sparklineFillOpacity', 'sparklineMarkers', 'options', 'trendDirection', 'variant', 'sparklinePosition'];
828
832
  const spark = this.sparklineChart;
829
833
  const sparkStale = !!spark && spark.renderTo !== this.sparklineContainer;
830
834
  if (sparkStale || sparklineProps.some(p => changedProperties.has(p))) {
@@ -1008,7 +1012,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1008
1012
  // Compact bleeds to the card edge, so keep the lowest point ~20px above the bottom: flat or low
1009
1013
  // data then starts well above the edge instead of sitting on it (capped at half the height).
1010
1014
  let padBottom = pad;
1011
- if (this.variant === 'compact' && span > 0) {
1015
+ if (this._sparkBleeds && span > 0) {
1012
1016
  const h = this.sparklineContainer?.clientHeight || 40;
1013
1017
  const f = Math.min(0.5, 20 / h);
1014
1018
  padBottom = ((dMax + pad - dMin) * f) / (1 - f);
@@ -1017,7 +1021,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1017
1021
  areaThreshold = dMin - padBottom; // area fills from the line down to the plot bottom
1018
1022
  }
1019
1023
  // Compact sparklines bleed to the card edge, so the fill keeps a faint tint all the way down instead of fading to nothing.
1020
- const bottomAlpha = this.variant === 'compact'
1024
+ const bottomAlpha = this._sparkBleeds
1021
1025
  ? Math.round(Math.min(1, Math.max(0, this.sparklineFillOpacity)) * 255 * 0.4).toString(16).padStart(2, '0')
1022
1026
  : '00';
1023
1027
  const fillColor = isAreaLike
@@ -1058,10 +1062,10 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1058
1062
  };
1059
1063
  const defaults = {
1060
1064
  // Compact sparklines run full-bleed: no bottom margin and no x-axis padding, so the fill reaches every card edge.
1061
- chart: { type: seriesType, height: this.sparklineHeight, margin: this.variant === 'compact' && !isBarLike && !isScatter ? [2, 0, 0, 0] : [2, 0, 2, 0], backgroundColor: 'transparent', animation: false },
1065
+ chart: { type: seriesType, height: this.sparklineHeight, margin: this._sparkBleeds && !isBarLike && !isScatter ? [2, 0, 0, 0] : [2, 0, 2, 0], backgroundColor: 'transparent', animation: false },
1062
1066
  title: { text: undefined },
1063
1067
  subtitle: { text: undefined },
1064
- xAxis: this.variant === 'compact' && !isBarLike && !isScatter ? { visible: false, minPadding: 0, maxPadding: 0 } : { visible: false },
1068
+ xAxis: this._sparkBleeds && !isBarLike && !isScatter ? { visible: false, minPadding: 0, maxPadding: 0 } : { visible: false },
1065
1069
  yAxis: yAxisOptions,
1066
1070
  legend: { enabled: false },
1067
1071
  tooltip: { enabled: false },
@@ -1241,6 +1245,12 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1241
1245
  * nothing is half-cut. Re-evaluated only when the card's size changes, so hiding them
1242
1246
  * (which frees space) can't make it flip back and forth.
1243
1247
  */
1248
+ get _sparkRight() {
1249
+ return this.variant === 'compact' && this.sparklinePosition === 'right';
1250
+ }
1251
+ get _sparkBleeds() {
1252
+ return this.variant === 'compact' && !this._sparkRight;
1253
+ }
1244
1254
  _fitDescription(force = false) {
1245
1255
  const kpi = this.shadowRoot?.querySelector('.kpi');
1246
1256
  if (!kpi || this.variant === 'gauge')
@@ -1486,6 +1496,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1486
1496
  ${this.prefix ? html `<span class="kpi-prefix" part="prefix">${this.prefix}</span>` : nothing}${displayValue}${this.suffix ? html `<span class="kpi-suffix" part="suffix">${this.suffix}</span>` : nothing}
1487
1497
  </h2>`;
1488
1498
  if (this.variant === 'compact') {
1499
+ const sparkRight = this._sparkRight;
1489
1500
  return html `
1490
1501
  <div class="kpi kpi--compact" part="base">
1491
1502
  ${this.renderHeaderRow(this.renderTrend(), this.renderTrend())}
@@ -1498,6 +1509,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1498
1509
  : valueEl}
1499
1510
  ${infoLeft ? nothing : this.renderValueInfo()}
1500
1511
  </span>
1512
+ ${sparkRight && this.sparkline.length ? html `<div class="kpi-sparkline" part="sparkline"></div>` : nothing}
1501
1513
  </div>
1502
1514
 
1503
1515
  ${this.renderForecast()}
@@ -1508,7 +1520,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1508
1520
  tabindex="0"
1509
1521
  >${this.description}</p></nile-lite-tooltip>` : nothing}
1510
1522
 
1511
- ${this.sparkline.length ? html `<div class="kpi-sparkline" part="sparkline"></div>` : nothing}
1523
+ ${!sparkRight && this.sparkline.length ? html `<div class="kpi-sparkline" part="sparkline"></div>` : nothing}
1512
1524
  </div>
1513
1525
  `;
1514
1526
  }
@@ -1712,6 +1724,9 @@ __decorate([
1712
1724
  __decorate([
1713
1725
  property({ type: String, attribute: 'title-overflow', reflect: true })
1714
1726
  ], NileKpiChart.prototype, "titleOverflow", void 0);
1727
+ __decorate([
1728
+ property({ type: String, attribute: 'sparkline-position', reflect: true })
1729
+ ], NileKpiChart.prototype, "sparklinePosition", void 0);
1715
1730
  __decorate([
1716
1731
  property({ type: String, attribute: 'card-background' })
1717
1732
  ], NileKpiChart.prototype, "cardBackground", void 0);
@@ -317,6 +317,89 @@ describe('NileKpiChart title overflow', () => {
317
317
  });
318
318
  });
319
319
  });
320
+ describe('NileKpiChart compact sparkline position', () => {
321
+ const mount = async (attrs, spark = [1, 3, 2, 5, 4, 6, 5, 7, 6, 8]) => {
322
+ const el = await fixture(html `<nile-kpi-chart variant="compact" .sparkline=${spark}></nile-kpi-chart>`);
323
+ if (attrs) {
324
+ for (const [k, v] of Object.entries(JSON.parse(attrs)))
325
+ el.setAttribute(k, String(v));
326
+ }
327
+ await el.updateComplete;
328
+ await el.updateComplete;
329
+ return el;
330
+ };
331
+ const compact = (el) => el.shadowRoot.querySelector('.kpi--compact');
332
+ const valueRow = (el) => el.shadowRoot.querySelector('.kpi-value-row');
333
+ const spark = (el) => el.shadowRoot.querySelector('.kpi-sparkline');
334
+ it("1. defaults to 'bottom'", async () => {
335
+ const el = await mount('');
336
+ expect(el.sparklinePosition).to.equal('bottom');
337
+ });
338
+ it("2. reflects the default to the sparkline-position attribute", async () => {
339
+ const el = await mount('');
340
+ expect(el.getAttribute('sparkline-position')).to.equal('bottom');
341
+ });
342
+ it("3. 'bottom': sparkline is a direct child of .kpi--compact, not inside .kpi-value-row", async () => {
343
+ const el = await mount('');
344
+ const s = spark(el);
345
+ expect(s).to.exist;
346
+ expect(s.parentElement).to.equal(compact(el));
347
+ expect(valueRow(el).querySelector('.kpi-sparkline')).to.be.null;
348
+ });
349
+ it("4. 'right': sparkline moves inside .kpi-value-row after the value group", async () => {
350
+ const el = await mount('{"sparkline-position":"right"}');
351
+ const s = spark(el);
352
+ expect(s).to.exist;
353
+ expect(s.parentElement).to.equal(valueRow(el));
354
+ const group = valueRow(el).querySelector('.kpi-value-group');
355
+ expect(group.compareDocumentPosition(s) & Node.DOCUMENT_POSITION_FOLLOWING).to.be.greaterThan(0);
356
+ });
357
+ it("5. 'right' reflects to the sparkline-position attribute", async () => {
358
+ const el = await mount('');
359
+ el.sparklinePosition = 'right';
360
+ await el.updateComplete;
361
+ expect(el.getAttribute('sparkline-position')).to.equal('right');
362
+ expect(spark(el).parentElement).to.equal(valueRow(el));
363
+ });
364
+ it("6. config.chart.sparklinePosition applies and reflects", async () => {
365
+ const el = await mount('');
366
+ el.config = {
367
+ chart: {
368
+ type: 'kpi',
369
+ variant: 'compact',
370
+ value: '285K',
371
+ sparkline: [1, 2, 3, 4, 5],
372
+ sparklinePosition: 'right',
373
+ },
374
+ aq: {},
375
+ };
376
+ await el.updateComplete;
377
+ await el.updateComplete;
378
+ expect(el.sparklinePosition).to.equal('right');
379
+ expect(el.getAttribute('sparkline-position')).to.equal('right');
380
+ expect(spark(el).parentElement).to.equal(valueRow(el));
381
+ });
382
+ it("7. non-compact variants ignore sparkline-position (sparkline stays at the card end)", async () => {
383
+ const el = await fixture(html `<nile-kpi-chart
384
+ variant="default"
385
+ sparkline-position="right"
386
+ .sparkline=${[1, 2, 3, 4, 5]}
387
+ ></nile-kpi-chart>`);
388
+ await el.updateComplete;
389
+ const s = el.shadowRoot.querySelector('.kpi-sparkline');
390
+ expect(s).to.exist;
391
+ expect(s.closest('.kpi-value-row')).to.be.null;
392
+ expect(s.parentElement).to.equal(el.shadowRoot.querySelector('.kpi'));
393
+ });
394
+ it("8. switching back to 'bottom' returns the sparkline to a direct child of .kpi--compact", async () => {
395
+ const el = await mount('{"sparkline-position":"right"}');
396
+ expect(spark(el).parentElement).to.equal(valueRow(el));
397
+ el.sparklinePosition = 'bottom';
398
+ await el.updateComplete;
399
+ expect(spark(el).parentElement).to.equal(compact(el));
400
+ expect(valueRow(el).querySelector('.kpi-sparkline')).to.be.null;
401
+ });
402
+ });
320
403
  describe('NileKpiChart sparkline size under a transform', () => {
321
404
  const setup = async (scale) => {
322
405
  const wrap = await fixture(html ` <div
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.52",
3
+ "version": "2.9.53",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",