@aquera/nile-visualization 2.9.35 → 2.9.36

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.36 (September 30, 2026)
40
+ - 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
+
39
42
  #### Version 2.9.35 (September 29, 2026)
40
43
  - Nile Chart: KPI tiles no longer get the `no-header` top padding on `nile-chart-inner`, with or without `aq` and `noHeader`. Other chart types are unchanged (UIF-1368)
41
44
 
@@ -306,7 +306,6 @@ export declare class NileKpiChart extends NileElement {
306
306
  disconnectedCallback(): void;
307
307
  protected firstUpdated(): void;
308
308
  protected updated(changedProperties: PropertyValues): void;
309
- private _lastSparkSize;
310
309
  private _lastGaugeSize;
311
310
  private _gaugeRafScheduled;
312
311
  private _scheduleGaugeSync;
@@ -174,7 +174,6 @@ let NileKpiChart = class NileKpiChart extends NileElement {
174
174
  this._hideTip();
175
175
  };
176
176
  // ── Chart sizing ─────────────────────────────────────────────────────────
177
- this._lastSparkSize = { w: 0, h: 0 };
178
177
  this._lastGaugeSize = { w: 0, h: 0 };
179
178
  this._gaugeRafScheduled = false;
180
179
  // ── Sparkline mousemove tooltip ──────────────────────────────────────────
@@ -686,6 +685,11 @@ let NileKpiChart = class NileKpiChart extends NileElement {
686
685
  }
687
686
  if (this.config)
688
687
  this.applyConfig(this.config);
688
+ if (this.hasUpdated) {
689
+ this.setupResizeObserver();
690
+ this.initSparkline();
691
+ this.initGauge();
692
+ }
689
693
  }
690
694
  disconnectedCallback() {
691
695
  super.disconnectedCallback();
@@ -718,12 +722,20 @@ let NileKpiChart = class NileKpiChart extends NileElement {
718
722
  }
719
723
  const sparklineProps = ['sparkline', 'sparklineColor', 'sparklineHeight', 'sparklineLineWidth',
720
724
  'sparklineType', 'sparklineFillOpacity', 'sparklineMarkers', 'options'];
721
- if (sparklineProps.some(p => changedProperties.has(p))) {
722
- if (this.sparklineChart) {
723
- this.sparklineChart.update(this.buildSparklineOptions(), true, true);
725
+ const spark = this.sparklineChart;
726
+ const sparkStale = !!spark && spark.renderTo !== this.sparklineContainer;
727
+ if (sparkStale || sparklineProps.some(p => changedProperties.has(p))) {
728
+ if (spark && !sparkStale) {
729
+ // Size is owned by syncSparklineChartSize(). Leaving chart.height in
730
+ // would resize the chart back to sparklineHeight and clip the plot.
731
+ const opts = this.buildSparklineOptions();
732
+ opts.chart = { ...opts.chart };
733
+ delete opts.chart.height;
734
+ spark.update(opts, true, true);
724
735
  requestAnimationFrame(() => this.syncSparklineChartSize());
725
736
  }
726
737
  else {
738
+ this.destroySparkline();
727
739
  this.initSparkline();
728
740
  }
729
741
  }
@@ -739,12 +751,15 @@ let NileKpiChart = class NileKpiChart extends NileElement {
739
751
  'gaugeStartAngle', 'gaugeEndAngle', 'gaugeInnerRadius', 'gaugeOuterRadius', 'gaugeRounded',
740
752
  'gaugeHeight', 'gaugeLabelFontSize', 'gaugeLabelColor', 'gaugeLabelFontWeight',
741
753
  'gaugeLabelYOffset', 'options', 'variant'];
742
- if (gaugeProps.some(p => changedProperties.has(p))) {
743
- if (this.gaugeChart) {
744
- this.gaugeChart.update(this.buildGaugeOptions(), true, true);
754
+ const gauge = this.gaugeChart;
755
+ const gaugeStale = !!gauge && gauge.renderTo !== this.gaugeContainer;
756
+ if (gaugeStale || gaugeProps.some(p => changedProperties.has(p))) {
757
+ if (gauge && !gaugeStale) {
758
+ gauge.update(this.buildGaugeOptions(), true, true);
745
759
  requestAnimationFrame(() => this.syncGaugeChartSize());
746
760
  }
747
761
  else {
762
+ this.destroyGauge();
748
763
  this.initGauge();
749
764
  }
750
765
  }
@@ -790,22 +805,19 @@ let NileKpiChart = class NileKpiChart extends NileElement {
790
805
  this._scheduleGaugeSync();
791
806
  }
792
807
  syncSparklineChartSize() {
793
- if (!this.sparklineChart || !this.sparklineContainer)
808
+ const chart = this.sparklineChart;
809
+ if (!chart || !this.sparklineContainer)
794
810
  return;
811
+ const drawn = chart.container;
812
+ const prevDisplay = drawn.style.display;
813
+ drawn.style.display = 'none';
795
814
  const rect = this.sparklineContainer.getBoundingClientRect();
815
+ drawn.style.display = prevDisplay;
796
816
  const w = Math.max(1, Math.round(rect.width));
797
817
  const h = Math.max(22, Math.round(rect.height));
798
- if (w === this._lastSparkSize.w && h === this._lastSparkSize.h)
799
- return;
800
- this._lastSparkSize = { w, h };
801
- // Rebuild the chart
802
- this.destroySparkline();
803
- if (!this._hc)
818
+ if (w === chart.chartWidth && h === chart.chartHeight)
804
819
  return;
805
- this.sparklineChart = this._hc.chart(this.sparklineContainer, this.buildSparklineOptions());
806
- this.sparklineChart.setSize(w, h, false);
807
- this.sparklineContainer.addEventListener('mousemove', this._onSparklineMouseMove);
808
- this.sparklineContainer.addEventListener('mouseleave', this._onSparklineMouseLeave);
820
+ chart.update({ chart: { width: w, height: h } }, true, false, false);
809
821
  }
810
822
  _reconcileFit() {
811
823
  if (!this.hasAttribute('fit')) {
@@ -848,7 +860,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
848
860
  // Pie variant — a compact pie with no slice labels / connectors.
849
861
  if (seriesType === 'pie') {
850
862
  const defaults = {
851
- chart: { type: 'pie', height: this.sparklineHeight, margin: [0, 0, 0, 0], backgroundColor: 'transparent' },
863
+ // animation: false — see the non-pie defaults below.
864
+ chart: { type: 'pie', height: this.sparklineHeight, margin: [0, 0, 0, 0], backgroundColor: 'transparent', animation: false },
852
865
  title: { text: undefined },
853
866
  subtitle: { text: undefined },
854
867
  legend: { enabled: false },
@@ -922,7 +935,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
922
935
  states: { hover: { lineWidth, halo: null } },
923
936
  };
924
937
  const defaults = {
925
- chart: { type: seriesType, height: this.sparklineHeight, margin: [2, 0, 2, 0], backgroundColor: 'transparent' },
938
+ chart: { type: seriesType, height: this.sparklineHeight, margin: [2, 0, 2, 0], backgroundColor: 'transparent', animation: false },
926
939
  title: { text: undefined },
927
940
  subtitle: { text: undefined },
928
941
  xAxis: { visible: false },
@@ -1030,7 +1043,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1030
1043
  this._hc = await getHighcharts();
1031
1044
  this.destroySparkline();
1032
1045
  this.sparklineChart = this._hc.chart(this.sparklineContainer, this.buildSparklineOptions());
1033
- // Force a reflow after the next layout pass
1046
+ this.resizeObserver?.observe(this.sparklineContainer);
1047
+ // Force a reflow after the next layout pass
1034
1048
  requestAnimationFrame(() => {
1035
1049
  this.syncSparklineChartSize();
1036
1050
  requestAnimationFrame(() => this.syncSparklineChartSize());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.35",
3
+ "version": "2.9.36",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",