@swimlane/ngx-charts 25.0.0 → 25.0.2

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.
@@ -688,7 +688,13 @@ class LegendEntryComponent {
688
688
  }
689
689
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LegendEntryComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
690
690
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: LegendEntryComponent, isStandalone: false, selector: "ngx-charts-legend-entry", inputs: { color: "color", label: "label", formattedLabel: "formattedLabel", isActive: "isActive" }, outputs: { select: "select", activate: "activate", deactivate: "deactivate", toggle: "toggle" }, host: { listeners: { "mouseenter": "onMouseEnter()", "mouseleave": "onMouseLeave()" } }, ngImport: i0, template: `
691
- <span [title]="formattedLabel" tabindex="-1" [class.active]="isActive" (click)="select.emit(formattedLabel)">
691
+ <span
692
+ [title]="formattedLabel"
693
+ tabindex="-1"
694
+ class="legend-entry"
695
+ [class.active]="isActive"
696
+ (click)="select.emit(formattedLabel)"
697
+ >
692
698
  <span class="legend-label-color" [style.background-color]="color" (click)="toggle.emit(formattedLabel)"> </span>
693
699
  <span class="legend-label-text">
694
700
  {{ trimmedLabel }}
@@ -701,7 +707,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
701
707
  args: [{
702
708
  selector: 'ngx-charts-legend-entry',
703
709
  template: `
704
- <span [title]="formattedLabel" tabindex="-1" [class.active]="isActive" (click)="select.emit(formattedLabel)">
710
+ <span
711
+ [title]="formattedLabel"
712
+ tabindex="-1"
713
+ class="legend-entry"
714
+ [class.active]="isActive"
715
+ (click)="select.emit(formattedLabel)"
716
+ >
705
717
  <span class="legend-label-color" [style.background-color]="color" (click)="toggle.emit(formattedLabel)"> </span>
706
718
  <span class="legend-label-text">
707
719
  {{ trimmedLabel }}
@@ -792,7 +804,13 @@ class LegendComponent {
792
804
  <span class="legend-title-text">{{ title }}</span>
793
805
  </header>
794
806
  <div class="legend-wrap">
795
- <ul class="legend-labels" [class.horizontal-legend]="horizontal" [style.max-height.px]="height - 45">
807
+ <ul
808
+ class="legend-labels"
809
+ [class.horizontal-legend]="horizontal"
810
+ [class.vertical-legend]="!horizontal"
811
+ [style.max-height.px]="!horizontal ? height - 45 : null"
812
+ [style.max-width.px]="horizontal && width ? width - 10 : null"
813
+ >
796
814
  <li *ngFor="let entry of legendEntries; trackBy: trackBy" class="legend-label">
797
815
  <ngx-charts-legend-entry
798
816
  [label]="entry.label"
@@ -808,7 +826,7 @@ class LegendComponent {
808
826
  </ul>
809
827
  </div>
810
828
  </div>
811
- `, isInline: true, styles: [".chart-legend{display:inline-block;padding:0;width:auto!important}.chart-legend .legend-title{white-space:nowrap;overflow:hidden;margin-left:10px;margin-bottom:5px;font-size:14px;font-weight:700}.chart-legend ul,.chart-legend li{padding:0;margin:0;list-style:none}.chart-legend .horizontal-legend li{display:inline-block}.chart-legend .legend-wrap{width:calc(100% - 10px)}.chart-legend .legend-labels{line-height:85%;list-style:none;text-align:left;float:left;width:100%;border-radius:3px;overflow-y:auto;overflow-x:hidden;white-space:nowrap;background:#0000000d}.chart-legend .legend-label{cursor:pointer;font-size:90%;margin:8px;color:#afb7c8}.chart-legend .legend-label:hover{color:#000;-webkit-transition:.2s;-moz-transition:.2s;transition:.2s}.chart-legend .legend-label .active .legend-label-text{color:#000}.chart-legend .legend-label-color{display:inline-block;height:15px;width:15px;margin-right:5px;color:#5b646b;border-radius:3px}.chart-legend .legend-label-text{display:inline-block;vertical-align:top;line-height:15px;font-size:12px;width:calc(100% - 20px);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .legend-title-text{vertical-align:bottom;display:inline-block;line-height:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LegendEntryComponent, selector: "ngx-charts-legend-entry", inputs: ["color", "label", "formattedLabel", "isActive"], outputs: ["select", "activate", "deactivate", "toggle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
829
+ `, isInline: true, styles: [".chart-legend{display:inline-block;padding:0;max-width:100%;box-sizing:border-box;overflow:hidden;vertical-align:top}.chart-legend .legend-title{white-space:nowrap;overflow:hidden;margin-left:10px;margin-bottom:5px;font-size:14px;font-weight:700}.chart-legend ul,.chart-legend li{padding:0;margin:0;list-style:none}.chart-legend .vertical-legend .legend-label{width:100%;max-width:calc(100% - 20px)}.chart-legend .vertical-legend .legend-entry{display:flex;flex-grow:1;align-items:center;overflow:hidden}.chart-legend .legend-wrap{width:calc(100% - 10px);min-width:0}.chart-legend .legend-labels{line-height:85%;list-style:none;text-align:left;display:flex;flex-wrap:wrap;white-space:nowrap;border-radius:3px;background:#0000000d}.chart-legend .legend-labels.vertical-legend{overflow-x:hidden;overflow-y:auto}.chart-legend .legend-labels.horizontal-legend{max-width:100%;overflow-x:auto;overflow-y:hidden}.chart-legend .legend-labels.horizontal-legend li{display:inline-block}.chart-legend .legend-label{cursor:pointer;font-size:90%;margin:8px;color:#afb7c8}.chart-legend .legend-label:hover{color:#000;-webkit-transition:.2s;-moz-transition:.2s;transition:.2s}.chart-legend .legend-label .active .legend-label-text{color:#000}.chart-legend .legend-label-color{display:inline-block;height:15px;width:15px;min-width:15px;margin-right:5px;color:#5b646b;border-radius:3px}.chart-legend .legend-label-text{display:inline-block;vertical-align:top;line-height:15px;font-size:12px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .legend-title-text{vertical-align:bottom;display:inline-block;line-height:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LegendEntryComponent, selector: "ngx-charts-legend-entry", inputs: ["color", "label", "formattedLabel", "isActive"], outputs: ["select", "activate", "deactivate", "toggle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
812
830
  }
813
831
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: LegendComponent, decorators: [{
814
832
  type: Component,
@@ -818,7 +836,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
818
836
  <span class="legend-title-text">{{ title }}</span>
819
837
  </header>
820
838
  <div class="legend-wrap">
821
- <ul class="legend-labels" [class.horizontal-legend]="horizontal" [style.max-height.px]="height - 45">
839
+ <ul
840
+ class="legend-labels"
841
+ [class.horizontal-legend]="horizontal"
842
+ [class.vertical-legend]="!horizontal"
843
+ [style.max-height.px]="!horizontal ? height - 45 : null"
844
+ [style.max-width.px]="horizontal && width ? width - 10 : null"
845
+ >
822
846
  <li *ngFor="let entry of legendEntries; trackBy: trackBy" class="legend-label">
823
847
  <ngx-charts-legend-entry
824
848
  [label]="entry.label"
@@ -834,7 +858,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
834
858
  </ul>
835
859
  </div>
836
860
  </div>
837
- `, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, styles: [".chart-legend{display:inline-block;padding:0;width:auto!important}.chart-legend .legend-title{white-space:nowrap;overflow:hidden;margin-left:10px;margin-bottom:5px;font-size:14px;font-weight:700}.chart-legend ul,.chart-legend li{padding:0;margin:0;list-style:none}.chart-legend .horizontal-legend li{display:inline-block}.chart-legend .legend-wrap{width:calc(100% - 10px)}.chart-legend .legend-labels{line-height:85%;list-style:none;text-align:left;float:left;width:100%;border-radius:3px;overflow-y:auto;overflow-x:hidden;white-space:nowrap;background:#0000000d}.chart-legend .legend-label{cursor:pointer;font-size:90%;margin:8px;color:#afb7c8}.chart-legend .legend-label:hover{color:#000;-webkit-transition:.2s;-moz-transition:.2s;transition:.2s}.chart-legend .legend-label .active .legend-label-text{color:#000}.chart-legend .legend-label-color{display:inline-block;height:15px;width:15px;margin-right:5px;color:#5b646b;border-radius:3px}.chart-legend .legend-label-text{display:inline-block;vertical-align:top;line-height:15px;font-size:12px;width:calc(100% - 20px);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .legend-title-text{vertical-align:bottom;display:inline-block;line-height:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n"] }]
861
+ `, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, styles: [".chart-legend{display:inline-block;padding:0;max-width:100%;box-sizing:border-box;overflow:hidden;vertical-align:top}.chart-legend .legend-title{white-space:nowrap;overflow:hidden;margin-left:10px;margin-bottom:5px;font-size:14px;font-weight:700}.chart-legend ul,.chart-legend li{padding:0;margin:0;list-style:none}.chart-legend .vertical-legend .legend-label{width:100%;max-width:calc(100% - 20px)}.chart-legend .vertical-legend .legend-entry{display:flex;flex-grow:1;align-items:center;overflow:hidden}.chart-legend .legend-wrap{width:calc(100% - 10px);min-width:0}.chart-legend .legend-labels{line-height:85%;list-style:none;text-align:left;display:flex;flex-wrap:wrap;white-space:nowrap;border-radius:3px;background:#0000000d}.chart-legend .legend-labels.vertical-legend{overflow-x:hidden;overflow-y:auto}.chart-legend .legend-labels.horizontal-legend{max-width:100%;overflow-x:auto;overflow-y:hidden}.chart-legend .legend-labels.horizontal-legend li{display:inline-block}.chart-legend .legend-label{cursor:pointer;font-size:90%;margin:8px;color:#afb7c8}.chart-legend .legend-label:hover{color:#000;-webkit-transition:.2s;-moz-transition:.2s;transition:.2s}.chart-legend .legend-label .active .legend-label-text{color:#000}.chart-legend .legend-label-color{display:inline-block;height:15px;width:15px;min-width:15px;margin-right:5px;color:#5b646b;border-radius:3px}.chart-legend .legend-label-text{display:inline-block;vertical-align:top;line-height:15px;font-size:12px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .legend-title-text{vertical-align:bottom;display:inline-block;line-height:16px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}\n"] }]
838
862
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { data: [{
839
863
  type: Input
840
864
  }], title: [{
@@ -973,6 +997,8 @@ class ChartComponent {
973
997
  <ngx-charts-scale-legend
974
998
  *ngIf="showLegend && legendType === LegendType.ScaleLegend"
975
999
  class="chart-legend"
1000
+ [style.width.px]="legendWidth"
1001
+ [style.maxWidth.px]="legendWidth"
976
1002
  [horizontal]="legendOptions && legendOptions.position === LegendPosition.Below"
977
1003
  [valueRange]="legendOptions.domain"
978
1004
  [colors]="legendOptions.colors"
@@ -983,6 +1009,8 @@ class ChartComponent {
983
1009
  <ngx-charts-legend
984
1010
  *ngIf="showLegend && legendType === LegendType.Legend"
985
1011
  class="chart-legend"
1012
+ [style.width.px]="legendWidth"
1013
+ [style.maxWidth.px]="legendWidth"
986
1014
  [horizontal]="legendOptions && legendOptions.position === LegendPosition.Below"
987
1015
  [data]="legendOptions.domain"
988
1016
  [title]="legendOptions.title"
@@ -1011,6 +1039,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
1011
1039
  <ngx-charts-scale-legend
1012
1040
  *ngIf="showLegend && legendType === LegendType.ScaleLegend"
1013
1041
  class="chart-legend"
1042
+ [style.width.px]="legendWidth"
1043
+ [style.maxWidth.px]="legendWidth"
1014
1044
  [horizontal]="legendOptions && legendOptions.position === LegendPosition.Below"
1015
1045
  [valueRange]="legendOptions.domain"
1016
1046
  [colors]="legendOptions.colors"
@@ -1021,6 +1051,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
1021
1051
  <ngx-charts-legend
1022
1052
  *ngIf="showLegend && legendType === LegendType.Legend"
1023
1053
  class="chart-legend"
1054
+ [style.width.px]="legendWidth"
1055
+ [style.maxWidth.px]="legendWidth"
1024
1056
  [horizontal]="legendOptions && legendOptions.position === LegendPosition.Below"
1025
1057
  [data]="legendOptions.domain"
1026
1058
  [title]="legendOptions.title"
@@ -1282,6 +1314,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
1282
1314
  args: [{
1283
1315
  selector: 'base-chart',
1284
1316
  template: ` <div></div> `,
1317
+ // eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection -- preserve pre-Angular-22 Default CD behavior
1285
1318
  changeDetection: ChangeDetectionStrategy.Eager,
1286
1319
  standalone: false
1287
1320
  }]
@@ -1390,6 +1423,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
1390
1423
  type: Input
1391
1424
  }] } });
1392
1425
 
1426
+ /** Max whole characters that fit in a pixel width (SSR / axis layout). */
1427
+ function maxCharsForPixelWidth(maxWidthPx, charWidth = 6) {
1428
+ if (maxWidthPx <= 0 || charWidth <= 0) {
1429
+ return 0;
1430
+ }
1431
+ return Math.floor(maxWidthPx / charWidth);
1432
+ }
1393
1433
  function trimLabel(s, max = 16) {
1394
1434
  if (typeof s !== 'string') {
1395
1435
  if (typeof s === 'number') {
@@ -2041,6 +2081,172 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
2041
2081
  args: [XAxisTicksComponent]
2042
2082
  }] } });
2043
2083
 
2084
+ /** Must stay in sync with y-axis.component padding and calculateViewDimensions y-axis spacer. */
2085
+ const CATEGORY_AXIS_Y_PADDING = 5;
2086
+ const CATEGORY_AXIS_VIEW_DIMS_SPACER = 10;
2087
+ const CATEGORY_AXIS_INNER_TICK_SIZE = 6;
2088
+ const CATEGORY_AXIS_TICK_PADDING = 3;
2089
+ const CATEGORY_AXIS_LAYOUT_INSET = CATEGORY_AXIS_Y_PADDING + CATEGORY_AXIS_INNER_TICK_SIZE + CATEGORY_AXIS_TICK_PADDING - CATEGORY_AXIS_VIEW_DIMS_SPACER;
2090
+ const CATEGORY_AXIS_TRIM_CHAR_WIDTH = 7;
2091
+ /** Hard display cap per line (including ellipsis), matching SSR/print clip budget. */
2092
+ const CATEGORY_AXIS_MAX_LINE_CHARS = 23;
2093
+ /** trimLabel content budget so content + '...' fits in CATEGORY_AXIS_MAX_LINE_CHARS. */
2094
+ const CATEGORY_AXIS_MAX_CONTENT_CHARS = CATEGORY_AXIS_MAX_LINE_CHARS - 3;
2095
+ const DEFAULT_CATEGORY_WRAP_MAX_LINES = 2;
2096
+ function requiredCategoryAxisWidth(textWidth) {
2097
+ return Math.max(0, textWidth + CATEGORY_AXIS_LAYOUT_INSET);
2098
+ }
2099
+ const CATEGORY_AXIS_MAX_WIDTH = requiredCategoryAxisWidth(CATEGORY_AXIS_MAX_LINE_CHARS * CATEGORY_AXIS_TRIM_CHAR_WIDTH);
2100
+ function charsPerLine(yAxisWidth, charWidth = CATEGORY_AXIS_TRIM_CHAR_WIDTH) {
2101
+ if (yAxisWidth <= 0) {
2102
+ return 0;
2103
+ }
2104
+ return Math.min(CATEGORY_AXIS_MAX_LINE_CHARS, maxCharsForPixelWidth(yAxisWidth - CATEGORY_AXIS_LAYOUT_INSET, charWidth));
2105
+ }
2106
+ function displayWidthForLines(lines, charWidth = CATEGORY_AXIS_TRIM_CHAR_WIDTH) {
2107
+ if (!lines?.length) {
2108
+ return 0;
2109
+ }
2110
+ const maxChars = Math.max(0, ...lines.map(line => Math.min(line.length, CATEGORY_AXIS_MAX_LINE_CHARS)));
2111
+ return maxChars * charWidth;
2112
+ }
2113
+ function cappedCharsPerLine(pixelOrLayoutLimit) {
2114
+ if (pixelOrLayoutLimit <= 0) {
2115
+ return 0;
2116
+ }
2117
+ return Math.min(CATEGORY_AXIS_MAX_LINE_CHARS, pixelOrLayoutLimit);
2118
+ }
2119
+ /** Content chars for trimLabel so the rendered string (with ...) stays within displayLimit. */
2120
+ function contentCharsForDisplayLimit(displayLimit) {
2121
+ if (displayLimit <= 0) {
2122
+ return 0;
2123
+ }
2124
+ return Math.min(CATEGORY_AXIS_MAX_CONTENT_CHARS, Math.max(0, displayLimit - 3));
2125
+ }
2126
+ function effectiveCharsPerLine(yAxisWidth, trimTicks = true, label) {
2127
+ const slots = charsPerLine(yAxisWidth);
2128
+ if (!trimTicks || slots <= 0) {
2129
+ return slots;
2130
+ }
2131
+ if (label === undefined) {
2132
+ return slots;
2133
+ }
2134
+ const labelLength = String(label).trim().length;
2135
+ return labelLength > slots ? contentCharsForDisplayLimit(slots) : slots;
2136
+ }
2137
+ /** Greedy word-wrap for category y-axis labels; ellipsis only on the final line. */
2138
+ function wrapCategoryLabel(label, charsPerLineLimit, maxLines, trimTicks = true) {
2139
+ const text = String(label ?? '').trim();
2140
+ const displayLimit = cappedCharsPerLine(charsPerLineLimit);
2141
+ const contentLimit = contentCharsForDisplayLimit(displayLimit);
2142
+ if (!text) {
2143
+ return [''];
2144
+ }
2145
+ if (!trimTicks || displayLimit <= 0 || maxLines <= 0) {
2146
+ return [text];
2147
+ }
2148
+ if (maxLines === 1 || text.length <= displayLimit) {
2149
+ return text.length <= displayLimit ? [text] : [trimLabel(text, contentLimit)];
2150
+ }
2151
+ const words = text.split(/\s+/).filter(Boolean);
2152
+ const lines = [];
2153
+ let currentLine = '';
2154
+ const pushLine = (line) => {
2155
+ if (line) {
2156
+ lines.push(line);
2157
+ }
2158
+ };
2159
+ const trimRemaining = (remainingWords) => {
2160
+ // If we already filled maxLines, fold the last packed line into the truncated remainder.
2161
+ const overflowStart = lines.length >= maxLines ? maxLines - 1 : lines.length;
2162
+ const kept = lines.slice(0, overflowStart);
2163
+ const remainder = [...lines.slice(overflowStart), currentLine, ...remainingWords].filter(Boolean).join(' ').trim();
2164
+ kept.push(trimLabel(remainder, contentLimit));
2165
+ return kept;
2166
+ };
2167
+ for (let i = 0; i < words.length; i++) {
2168
+ const word = words[i];
2169
+ if (word.length > displayLimit) {
2170
+ pushLine(currentLine);
2171
+ currentLine = '';
2172
+ if (lines.length >= maxLines || lines.length === maxLines - 1) {
2173
+ return trimRemaining(words.slice(i));
2174
+ }
2175
+ lines.push(trimLabel(word, contentLimit));
2176
+ continue;
2177
+ }
2178
+ const candidate = currentLine ? `${currentLine} ${word}` : word;
2179
+ if (candidate.length <= displayLimit) {
2180
+ currentLine = candidate;
2181
+ continue;
2182
+ }
2183
+ pushLine(currentLine);
2184
+ currentLine = word;
2185
+ if (lines.length >= maxLines) {
2186
+ return trimRemaining(words.slice(i + 1));
2187
+ }
2188
+ }
2189
+ pushLine(currentLine);
2190
+ if (lines.length > maxLines) {
2191
+ const kept = lines.slice(0, maxLines - 1);
2192
+ const remainder = lines.slice(maxLines - 1).join(' ');
2193
+ kept.push(trimLabel(remainder, contentLimit));
2194
+ return kept;
2195
+ }
2196
+ return lines;
2197
+ }
2198
+ function displayLinesForLabel(label, yAxisWidth, trimTicks, wrapTicks, maxLines = DEFAULT_CATEGORY_WRAP_MAX_LINES) {
2199
+ const text = String(label).trim();
2200
+ if (!trimTicks) {
2201
+ return [text];
2202
+ }
2203
+ const limit = charsPerLine(yAxisWidth);
2204
+ if (limit <= 0) {
2205
+ return [trimLabel(text, CATEGORY_AXIS_MAX_CONTENT_CHARS)];
2206
+ }
2207
+ if (!wrapTicks || !/\s/.test(text)) {
2208
+ const contentMax = effectiveCharsPerLine(yAxisWidth, trimTicks, text);
2209
+ return text.length <= contentMax ? [text] : [trimLabel(text, contentMax)];
2210
+ }
2211
+ const wrapped = wrapCategoryLabel(text, limit, Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES), trimTicks);
2212
+ return wrapped.length ? wrapped : [text];
2213
+ }
2214
+ function resolveCategoryAxisLayout(labels, trimTicks = true, wrapTicks = true, maxLines = DEFAULT_CATEGORY_WRAP_MAX_LINES, initialYAxisWidth = 0) {
2215
+ if (!labels?.length) {
2216
+ return { yAxisWidth: 0, charsPerLine: 0 };
2217
+ }
2218
+ const wrapLineLimit = Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES);
2219
+ let yAxisWidth = initialYAxisWidth > 0
2220
+ ? Math.min(initialYAxisWidth, CATEGORY_AXIS_MAX_WIDTH)
2221
+ : requiredCategoryAxisWidth(Math.max(0, ...labels.map(label => {
2222
+ const text = String(label).trim();
2223
+ if (!trimTicks) {
2224
+ return Math.min(text.length, CATEGORY_AXIS_MAX_LINE_CHARS) * CATEGORY_AXIS_TRIM_CHAR_WIDTH;
2225
+ }
2226
+ const displayChars = text.length <= CATEGORY_AXIS_MAX_LINE_CHARS ? text.length : CATEGORY_AXIS_MAX_LINE_CHARS;
2227
+ return displayChars * CATEGORY_AXIS_TRIM_CHAR_WIDTH;
2228
+ })));
2229
+ yAxisWidth = Math.min(yAxisWidth, CATEGORY_AXIS_MAX_WIDTH);
2230
+ for (let i = 0; i < 5; i++) {
2231
+ let maxTextWidth = 0;
2232
+ for (const label of labels) {
2233
+ const lines = displayLinesForLabel(label, yAxisWidth, trimTicks, wrapTicks, wrapLineLimit);
2234
+ maxTextWidth = Math.max(maxTextWidth, displayWidthForLines(lines));
2235
+ }
2236
+ const nextYAxisWidth = Math.min(requiredCategoryAxisWidth(maxTextWidth), CATEGORY_AXIS_MAX_WIDTH);
2237
+ if (nextYAxisWidth === yAxisWidth) {
2238
+ break;
2239
+ }
2240
+ yAxisWidth = nextYAxisWidth;
2241
+ }
2242
+ return { yAxisWidth, charsPerLine: charsPerLine(yAxisWidth) };
2243
+ }
2244
+ /** Left edge of longest tick label given layout inputs (horizontal left y-axis). */
2245
+ function categoryLabelLeftFromLayout(marginsLeft, yAxisWidth, textWidth) {
2246
+ const tickOffset = CATEGORY_AXIS_Y_PADDING + CATEGORY_AXIS_INNER_TICK_SIZE + CATEGORY_AXIS_TICK_PADDING;
2247
+ return marginsLeft + yAxisWidth + CATEGORY_AXIS_VIEW_DIMS_SPACER - tickOffset - textWidth;
2248
+ }
2249
+
2044
2250
  class YAxisTicksComponent {
2045
2251
  constructor(platformId) {
2046
2252
  this.platformId = platformId;
@@ -2061,26 +2267,25 @@ class YAxisTicksComponent {
2061
2267
  this.outerTickSize = 6;
2062
2268
  this.rotateLabels = false;
2063
2269
  this.referenceLineLength = 0;
2270
+ /** Stable axis width for truncation/wrapping; never updated from DOM measurement. */
2271
+ this.layoutAxisWidth = 0;
2272
+ this.lastEmittedWidth = null;
2064
2273
  this.Orientation = Orientation;
2065
2274
  }
2066
2275
  ngOnChanges(changes) {
2067
2276
  this.update();
2068
2277
  }
2069
2278
  ngAfterViewInit() {
2070
- setTimeout(() => this.updateDims());
2279
+ if (isPlatformBrowser(this.platformId)) {
2280
+ setTimeout(() => this.updateDims());
2281
+ }
2071
2282
  }
2072
2283
  updateDims() {
2073
- if (!isPlatformBrowser(this.platformId)) {
2074
- // for SSR, use approximate value instead of measured
2075
- this.width = this.getApproximateAxisWidth();
2076
- this.dimensionsChanged.emit({ width: this.width });
2077
- return;
2078
- }
2079
- const width = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().width, 10);
2080
- if (width !== this.width) {
2284
+ const width = Math.min(this.getMeasuredAxisWidth(), CATEGORY_AXIS_MAX_WIDTH);
2285
+ if (width > 0 && width !== this.lastEmittedWidth) {
2286
+ this.lastEmittedWidth = width;
2081
2287
  this.width = width;
2082
2288
  this.dimensionsChanged.emit({ width });
2083
- setTimeout(() => this.updateDims());
2084
2289
  }
2085
2290
  }
2086
2291
  update() {
@@ -2103,9 +2308,9 @@ class YAxisTicksComponent {
2103
2308
  return d.toLocaleString();
2104
2309
  };
2105
2310
  }
2311
+ this.resolveLayoutAxisWidth();
2106
2312
  this.adjustedScale = scale.bandwidth
2107
2313
  ? d => {
2108
- // position the tick to middle considering number of lines of the tick
2109
2314
  const positionMiddle = scale(d) + scale.bandwidth() * 0.5;
2110
2315
  if (this.wrapTicks && d.toString().length > this.maxTickLength) {
2111
2316
  const chunksLength = this.tickChunks(d).length;
@@ -2162,7 +2367,30 @@ class YAxisTicksComponent {
2162
2367
  break;
2163
2368
  default:
2164
2369
  }
2165
- setTimeout(() => this.updateDims());
2370
+ if (!isPlatformBrowser(this.platformId)) {
2371
+ this.applySsrAxisLayout();
2372
+ }
2373
+ else {
2374
+ setTimeout(() => this.updateDims());
2375
+ }
2376
+ }
2377
+ resolveLayoutAxisWidth() {
2378
+ if (!this.ticks?.length || !this.tickFormat) {
2379
+ return;
2380
+ }
2381
+ const labels = this.ticks.map(t => String(this.tickFormat(t)));
2382
+ const layout = YAxisTicksComponent.resolveAxisLayout(labels, this.trimTicks, this.maxTickLength, this.wrapTicks);
2383
+ this.layoutAxisWidth = layout.yAxisWidth;
2384
+ }
2385
+ applySsrAxisLayout() {
2386
+ if (this.layoutAxisWidth > 0 && this.layoutAxisWidth !== this.lastEmittedWidth) {
2387
+ this.lastEmittedWidth = this.layoutAxisWidth;
2388
+ this.width = this.layoutAxisWidth;
2389
+ this.dimensionsChanged.emit({ width: this.layoutAxisWidth });
2390
+ }
2391
+ else if (this.layoutAxisWidth > 0) {
2392
+ this.width = this.layoutAxisWidth;
2393
+ }
2166
2394
  }
2167
2395
  setReferencelines() {
2168
2396
  this.refMin = this.adjustedScale(Math.min.apply(null, this.referenceLines.map(item => item.value)));
@@ -2201,24 +2429,98 @@ class YAxisTicksComponent {
2201
2429
  return `translate(5,0)`;
2202
2430
  }
2203
2431
  tickTrim(label) {
2204
- return this.trimTicks ? trimLabel(label, this.maxTickLength) : label;
2432
+ if (!this.trimTicks) {
2433
+ return label;
2434
+ }
2435
+ return trimLabel(label, this.getEffectiveMaxTickLength(label));
2436
+ }
2437
+ getEffectiveMaxTickLength(label) {
2438
+ if (this.orient !== Orientation.Left && this.orient !== Orientation.Right) {
2439
+ return this.maxTickLength;
2440
+ }
2441
+ if (this.layoutAxisWidth <= 0) {
2442
+ return this.maxTickLength;
2443
+ }
2444
+ return YAxisTicksComponent.effectiveMaxTickLength(this.layoutAxisWidth, this.maxTickLength, this.trimTicks, label);
2445
+ }
2446
+ static { this.Y_AXIS_PADDING = CATEGORY_AXIS_Y_PADDING; }
2447
+ static { this.VIEW_DIMS_Y_AXIS_SPACER = CATEGORY_AXIS_VIEW_DIMS_SPACER; }
2448
+ static { this.INNER_TICK_SIZE = CATEGORY_AXIS_INNER_TICK_SIZE; }
2449
+ static { this.TICK_PADDING = CATEGORY_AXIS_TICK_PADDING; }
2450
+ static { this.AXIS_LAYOUT_INSET = CATEGORY_AXIS_LAYOUT_INSET; }
2451
+ static { this.APPROX_CHAR_WIDTH = 6; }
2452
+ static { this.TRIM_CHAR_WIDTH = CATEGORY_AXIS_TRIM_CHAR_WIDTH; }
2453
+ static effectiveMaxTickLength(yAxisWidth, maxTickLength, trimTicks = true, label) {
2454
+ if (!trimTicks || yAxisWidth <= 0) {
2455
+ return maxTickLength;
2456
+ }
2457
+ const limit = charsPerLine(yAxisWidth);
2458
+ if (limit <= 0) {
2459
+ return maxTickLength;
2460
+ }
2461
+ if (label === undefined) {
2462
+ return limit;
2463
+ }
2464
+ const labelLength = String(label).trim().length;
2465
+ return labelLength > limit ? Math.max(0, limit - 3) : limit;
2466
+ }
2467
+ static approximateTickLabelsWidth(labels, trimTicks = true, maxTickLength = 16, wrapTicks = true) {
2468
+ return YAxisTicksComponent.resolveAxisLayout(labels, trimTicks, maxTickLength, wrapTicks).yAxisWidth;
2469
+ }
2470
+ static resolveAxisLayout(labels, trimTicks = true, maxTickLength = 16, wrapTicks = true) {
2471
+ const layout = resolveCategoryAxisLayout(labels, trimTicks, wrapTicks);
2472
+ return { yAxisWidth: layout.yAxisWidth, maxTickLength };
2473
+ }
2474
+ static requiredYAxisWidth(textWidth) {
2475
+ return requiredCategoryAxisWidth(textWidth);
2476
+ }
2477
+ static labelLeftFromLayout(marginsLeft, yAxisWidth, textWidth) {
2478
+ return categoryLabelLeftFromLayout(marginsLeft, yAxisWidth, textWidth);
2205
2479
  }
2206
2480
  getApproximateAxisWidth() {
2207
- const maxChars = Math.max(...this.ticks.map(t => this.tickTrim(this.tickFormat(t)).length));
2208
- const charWidth = 7;
2209
- return maxChars * charWidth;
2481
+ if (!this.ticks?.length || !this.tickFormat) {
2482
+ return 0;
2483
+ }
2484
+ const labels = this.ticks.map(t => String(this.tickFormat(t)));
2485
+ return YAxisTicksComponent.resolveAxisLayout(labels, this.trimTicks, this.maxTickLength, this.wrapTicks).yAxisWidth;
2486
+ }
2487
+ getMeasuredAxisWidth() {
2488
+ if (!isPlatformBrowser(this.platformId)) {
2489
+ return this.getApproximateAxisWidth();
2490
+ }
2491
+ if (!this.ticksElement?.nativeElement) {
2492
+ return 0;
2493
+ }
2494
+ const bboxWidth = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().width, 10);
2495
+ const tickSpacing = this.tickSpacing ?? YAxisTicksComponent.INNER_TICK_SIZE + YAxisTicksComponent.TICK_PADDING;
2496
+ const textWidth = Math.max(0, bboxWidth - tickSpacing);
2497
+ return YAxisTicksComponent.requiredYAxisWidth(textWidth);
2210
2498
  }
2211
2499
  tickChunks(label) {
2212
- if (label.toString().length > this.maxTickLength && this.scale.bandwidth) {
2213
- // for y-axis the width of the tick is fixed
2214
- const preferredWidth = this.maxTickLength;
2500
+ const formatted = String(this.tickFormat(label));
2501
+ if (this.orient === Orientation.Left || this.orient === Orientation.Right) {
2502
+ if (!this.wrapTicks || !this.scale.bandwidth) {
2503
+ return [this.tickTrim(formatted)];
2504
+ }
2505
+ const maxLines = Math.min(Math.floor(this.scale.bandwidth() / 15), DEFAULT_CATEGORY_WRAP_MAX_LINES);
2506
+ if (maxLines <= 1) {
2507
+ return [this.tickTrim(formatted)];
2508
+ }
2509
+ const perLine = cappedCharsPerLine(this.layoutAxisWidth > 0 ? charsPerLine(this.layoutAxisWidth) : this.getEffectiveMaxTickLength(formatted));
2510
+ if (perLine <= 0 || formatted.length <= perLine) {
2511
+ return [formatted];
2512
+ }
2513
+ const lines = wrapCategoryLabel(formatted, perLine, maxLines, this.trimTicks);
2514
+ return lines.length > 1 ? lines : [this.tickTrim(formatted)];
2515
+ }
2516
+ if (formatted.length > this.maxTickLength && this.scale.bandwidth) {
2215
2517
  const maxLines = Math.floor(this.scale.bandwidth() / 15);
2216
2518
  if (maxLines <= 1) {
2217
- return [this.tickTrim(label)];
2519
+ return [this.tickTrim(formatted)];
2218
2520
  }
2219
- return getTickLines(label, preferredWidth, Math.min(maxLines, 5));
2521
+ return getTickLines(formatted, this.maxTickLength, Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES));
2220
2522
  }
2221
- return [this.tickFormat(label)];
2523
+ return [formatted];
2222
2524
  }
2223
2525
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: YAxisTicksComponent, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
2224
2526
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: YAxisTicksComponent, isStandalone: false, selector: "g[ngx-charts-y-axis-ticks]", inputs: { scale: "scale", orient: "orient", tickArguments: "tickArguments", tickValues: "tickValues", tickStroke: "tickStroke", trimTicks: "trimTicks", maxTickLength: "maxTickLength", tickFormatting: "tickFormatting", showGridLines: "showGridLines", gridLineWidth: "gridLineWidth", height: "height", referenceLines: "referenceLines", showRefLabels: "showRefLabels", showRefLines: "showRefLines", wrapTicks: "wrapTicks" }, outputs: { dimensionsChanged: "dimensionsChanged" }, viewQueries: [{ propertyName: "ticksElement", first: true, predicate: ["ticksel"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
@@ -2431,6 +2733,8 @@ class YAxisComponent {
2431
2733
  this.tickStroke = '#CCC';
2432
2734
  this.strokeWidth = 1;
2433
2735
  this.padding = 5;
2736
+ /** Last tick-label width emitted to the parent chart (not conflated with labelOffset). */
2737
+ this.emittedTickWidth = null;
2434
2738
  }
2435
2739
  ngOnChanges(changes) {
2436
2740
  this.update();
@@ -2449,18 +2753,18 @@ class YAxisComponent {
2449
2753
  }
2450
2754
  }
2451
2755
  emitTicksWidth({ width }) {
2452
- if (width !== this.labelOffset && this.yOrient === Orientation.Right) {
2453
- this.labelOffset = width + this.labelOffset;
2454
- setTimeout(() => {
2455
- this.dimensionsChanged.emit({ width });
2456
- }, 0);
2756
+ if (width == null || width === this.emittedTickWidth) {
2757
+ return;
2758
+ }
2759
+ this.emittedTickWidth = width;
2760
+ if (this.yOrient === Orientation.Right) {
2761
+ this.labelOffset = width + 65;
2457
2762
  }
2458
- else if (width !== this.labelOffset) {
2763
+ else {
2459
2764
  this.labelOffset = width;
2460
- setTimeout(() => {
2461
- this.dimensionsChanged.emit({ width });
2462
- }, 0);
2463
2765
  }
2766
+ // Sync emit so SSR HTML serializes with reserved y-axis width (no setTimeout).
2767
+ this.dimensionsChanged.emit({ width });
2464
2768
  }
2465
2769
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: YAxisComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2466
2770
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: YAxisComponent, isStandalone: false, selector: "g[ngx-charts-y-axis]", inputs: { yScale: "yScale", dims: "dims", trimTicks: "trimTicks", maxTickLength: "maxTickLength", tickFormatting: "tickFormatting", ticks: "ticks", showGridLines: "showGridLines", showLabel: "showLabel", labelText: "labelText", yAxisTickCount: "yAxisTickCount", yOrient: "yOrient", referenceLines: "referenceLines", showRefLines: "showRefLines", showRefLabels: "showRefLabels", yAxisOffset: "yAxisOffset", wrapTicks: "wrapTicks" }, outputs: { dimensionsChanged: "dimensionsChanged" }, viewQueries: [{ propertyName: "ticksComponent", first: true, predicate: YAxisTicksComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
@@ -3775,6 +4079,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
3775
4079
  args: [{
3776
4080
  selector: '[ngx-charts-count-up]',
3777
4081
  template: ` {{ value }} `,
4082
+ // eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection -- preserve pre-Angular-22 Default CD behavior
3778
4083
  changeDetection: ChangeDetectionStrategy.Eager,
3779
4084
  standalone: false
3780
4085
  }]
@@ -3835,6 +4140,12 @@ class TooltipArea {
3835
4140
  this.showPercentage = false;
3836
4141
  this.tooltipDisabled = false;
3837
4142
  this.hover = new EventEmitter();
4143
+ this.isSSR = false;
4144
+ }
4145
+ ngOnInit() {
4146
+ if (isPlatformServer(this.platformId)) {
4147
+ this.isSSR = true;
4148
+ }
3838
4149
  }
3839
4150
  getValues(xVal) {
3840
4151
  const results = [];
@@ -3967,7 +4278,7 @@ class TooltipArea {
3967
4278
  return result;
3968
4279
  }
3969
4280
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: TooltipArea, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
3970
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: TooltipArea, isStandalone: false, selector: "g[ngx-charts-tooltip-area]", inputs: { dims: "dims", xSet: "xSet", xScale: "xScale", yScale: "yScale", results: "results", colors: "colors", showPercentage: "showPercentage", tooltipDisabled: "tooltipDisabled", tooltipTemplate: "tooltipTemplate" }, outputs: { hover: "hover" }, viewQueries: [{ propertyName: "tooltipAnchor", first: true, predicate: ["tooltipAnchor"], descendants: true }], ngImport: i0, template: `
4281
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: TooltipArea, isStandalone: false, selector: "g[ngx-charts-tooltip-area]", inputs: { dims: "dims", xSet: "xSet", xScale: "xScale", yScale: "yScale", results: "results", colors: "colors", showPercentage: "showPercentage", tooltipDisabled: "tooltipDisabled", tooltipTemplate: "tooltipTemplate" }, outputs: { hover: "hover" }, viewQueries: [{ propertyName: "tooltipAnchor", first: true, predicate: ["tooltipAnchor"], descendants: true }], ngImport: i0, template: `
3971
4282
  <svg:g>
3972
4283
  <svg:rect
3973
4284
  class="tooltip-area"
@@ -3987,6 +4298,7 @@ class TooltipArea {
3987
4298
  </xhtml:div>
3988
4299
  </xhtml:div>
3989
4300
  </ng-template>
4301
+ @if (!isSSR) {
3990
4302
  <svg:rect
3991
4303
  #tooltipAnchor
3992
4304
  [@animationState]="anchorOpacity !== 0 ? 'active' : 'inactive'"
@@ -4006,6 +4318,26 @@ class TooltipArea {
4006
4318
  [tooltipContext]="anchorValues"
4007
4319
  [tooltipImmediateExit]="true"
4008
4320
  />
4321
+ } @else {
4322
+ <svg:rect
4323
+ #tooltipAnchor
4324
+ class="tooltip-anchor"
4325
+ [attr.x]="anchorPos"
4326
+ y="0"
4327
+ [attr.width]="1"
4328
+ [attr.height]="dims.height"
4329
+ [style.opacity]="anchorOpacity"
4330
+ [style.pointer-events]="'none'"
4331
+ ngx-tooltip
4332
+ [tooltipDisabled]="tooltipDisabled"
4333
+ [tooltipPlacement]="placementTypes.Right"
4334
+ [tooltipType]="styleTypes.tooltip"
4335
+ [tooltipSpacing]="15"
4336
+ [tooltipTemplate]="tooltipTemplate ? tooltipTemplate : defaultTooltipTemplate"
4337
+ [tooltipContext]="anchorValues"
4338
+ [tooltipImmediateExit]="true"
4339
+ />
4340
+ }
4009
4341
  </svg:g>
4010
4342
  `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: TooltipDirective, selector: "[ngx-tooltip]", inputs: ["tooltipCssClass", "tooltipTitle", "tooltipAppendToBody", "tooltipSpacing", "tooltipDisabled", "tooltipShowCaret", "tooltipPlacement", "tooltipAlignment", "tooltipType", "tooltipCloseOnClickOutside", "tooltipCloseOnMouseLeave", "tooltipHideTimeout", "tooltipShowTimeout", "tooltipTemplate", "tooltipShowEvent", "tooltipContext", "tooltipImmediateExit"], outputs: ["show", "hide"] }], animations: [
4011
4343
  trigger('animationState', [
@@ -4048,6 +4380,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
4048
4380
  </xhtml:div>
4049
4381
  </xhtml:div>
4050
4382
  </ng-template>
4383
+ @if (!isSSR) {
4051
4384
  <svg:rect
4052
4385
  #tooltipAnchor
4053
4386
  [@animationState]="anchorOpacity !== 0 ? 'active' : 'inactive'"
@@ -4067,6 +4400,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
4067
4400
  [tooltipContext]="anchorValues"
4068
4401
  [tooltipImmediateExit]="true"
4069
4402
  />
4403
+ } @else {
4404
+ <svg:rect
4405
+ #tooltipAnchor
4406
+ class="tooltip-anchor"
4407
+ [attr.x]="anchorPos"
4408
+ y="0"
4409
+ [attr.width]="1"
4410
+ [attr.height]="dims.height"
4411
+ [style.opacity]="anchorOpacity"
4412
+ [style.pointer-events]="'none'"
4413
+ ngx-tooltip
4414
+ [tooltipDisabled]="tooltipDisabled"
4415
+ [tooltipPlacement]="placementTypes.Right"
4416
+ [tooltipType]="styleTypes.tooltip"
4417
+ [tooltipSpacing]="15"
4418
+ [tooltipTemplate]="tooltipTemplate ? tooltipTemplate : defaultTooltipTemplate"
4419
+ [tooltipContext]="anchorValues"
4420
+ [tooltipImmediateExit]="true"
4421
+ />
4422
+ }
4070
4423
  </svg:g>
4071
4424
  `,
4072
4425
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -7498,7 +7851,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
7498
7851
  }] } });
7499
7852
 
7500
7853
  class SeriesHorizontal {
7501
- constructor() {
7854
+ constructor(platformId) {
7855
+ this.platformId = platformId;
7502
7856
  this.type = BarChartType.Standard;
7503
7857
  this.tooltipDisabled = false;
7504
7858
  this.animations = true;
@@ -7510,6 +7864,12 @@ class SeriesHorizontal {
7510
7864
  this.dataLabelWidthChanged = new EventEmitter();
7511
7865
  this.barsForDataLabels = [];
7512
7866
  this.barOrientation = BarOrientation;
7867
+ this.isSSR = false;
7868
+ }
7869
+ ngOnInit() {
7870
+ if (isPlatformServer(this.platformId)) {
7871
+ this.isSSR = true;
7872
+ }
7513
7873
  }
7514
7874
  ngOnChanges() {
7515
7875
  this.update();
@@ -7670,38 +8030,73 @@ class SeriesHorizontal {
7670
8030
  click(data) {
7671
8031
  this.select.emit(data);
7672
8032
  }
7673
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SeriesHorizontal, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
7674
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: SeriesHorizontal, isStandalone: false, selector: "g[ngx-charts-series-horizontal]", inputs: { dims: "dims", type: "type", series: "series", xScale: "xScale", yScale: "yScale", colors: "colors", tooltipDisabled: "tooltipDisabled", gradient: "gradient", activeEntries: "activeEntries", seriesName: "seriesName", tooltipTemplate: "tooltipTemplate", roundEdges: "roundEdges", animations: "animations", showDataLabel: "showDataLabel", dataLabelFormatting: "dataLabelFormatting", noBarWhenZero: "noBarWhenZero" }, outputs: { select: "select", activate: "activate", deactivate: "deactivate", dataLabelWidthChanged: "dataLabelWidthChanged" }, usesOnChanges: true, ngImport: i0, template: `
7675
- <svg:g
7676
- ngx-charts-bar
7677
- *ngFor="let bar of bars; trackBy: trackBy"
7678
- [@animationState]="'active'"
7679
- [width]="bar.width"
7680
- [height]="bar.height"
7681
- [x]="bar.x"
7682
- [y]="bar.y"
7683
- [fill]="bar.color"
7684
- [stops]="bar.gradientStops"
7685
- [data]="bar.data"
7686
- [orientation]="barOrientation.Horizontal"
7687
- [roundEdges]="bar.roundEdges"
7688
- (select)="click($event)"
7689
- [gradient]="gradient"
7690
- [isActive]="isActive(bar.data)"
7691
- [ariaLabel]="bar.ariaLabel"
7692
- [animations]="animations"
7693
- (activate)="activate.emit($event)"
7694
- (deactivate)="deactivate.emit($event)"
7695
- ngx-tooltip
7696
- [tooltipDisabled]="tooltipDisabled"
7697
- [tooltipPlacement]="tooltipPlacement"
7698
- [tooltipType]="tooltipType"
7699
- [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
7700
- [tooltipTemplate]="tooltipTemplate"
7701
- [tooltipContext]="bar.data"
7702
- [noBarWhenZero]="noBarWhenZero"
7703
- ></svg:g>
7704
- <svg:g *ngIf="showDataLabel">
8033
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SeriesHorizontal, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
8034
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SeriesHorizontal, isStandalone: false, selector: "g[ngx-charts-series-horizontal]", inputs: { dims: "dims", type: "type", series: "series", xScale: "xScale", yScale: "yScale", colors: "colors", tooltipDisabled: "tooltipDisabled", gradient: "gradient", activeEntries: "activeEntries", seriesName: "seriesName", tooltipTemplate: "tooltipTemplate", roundEdges: "roundEdges", animations: "animations", showDataLabel: "showDataLabel", dataLabelFormatting: "dataLabelFormatting", noBarWhenZero: "noBarWhenZero" }, outputs: { select: "select", activate: "activate", deactivate: "deactivate", dataLabelWidthChanged: "dataLabelWidthChanged" }, usesOnChanges: true, ngImport: i0, template: `
8035
+ @if (!isSSR) {
8036
+ <svg:g>
8037
+ <svg:g
8038
+ ngx-charts-bar
8039
+ *ngFor="let bar of bars; trackBy: trackBy"
8040
+ [@animationState]="'active'"
8041
+ [width]="bar.width"
8042
+ [height]="bar.height"
8043
+ [x]="bar.x"
8044
+ [y]="bar.y"
8045
+ [fill]="bar.color"
8046
+ [stops]="bar.gradientStops"
8047
+ [data]="bar.data"
8048
+ [orientation]="barOrientation.Horizontal"
8049
+ [roundEdges]="bar.roundEdges"
8050
+ (select)="click($event)"
8051
+ [gradient]="gradient"
8052
+ [isActive]="isActive(bar.data)"
8053
+ [ariaLabel]="bar.ariaLabel"
8054
+ [animations]="animations"
8055
+ (activate)="activate.emit($event)"
8056
+ (deactivate)="deactivate.emit($event)"
8057
+ ngx-tooltip
8058
+ [tooltipDisabled]="tooltipDisabled"
8059
+ [tooltipPlacement]="tooltipPlacement"
8060
+ [tooltipType]="tooltipType"
8061
+ [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
8062
+ [tooltipTemplate]="tooltipTemplate"
8063
+ [tooltipContext]="bar.data"
8064
+ [noBarWhenZero]="noBarWhenZero"
8065
+ ></svg:g>
8066
+ </svg:g>
8067
+ } @else {
8068
+ <svg:g>
8069
+ <svg:g
8070
+ ngx-charts-bar
8071
+ *ngFor="let bar of bars; trackBy: trackBy"
8072
+ [width]="bar.width"
8073
+ [height]="bar.height"
8074
+ [x]="bar.x"
8075
+ [y]="bar.y"
8076
+ [fill]="bar.color"
8077
+ [stops]="bar.gradientStops"
8078
+ [data]="bar.data"
8079
+ [orientation]="barOrientation.Horizontal"
8080
+ [roundEdges]="bar.roundEdges"
8081
+ (select)="click($event)"
8082
+ [gradient]="gradient"
8083
+ [isActive]="isActive(bar.data)"
8084
+ [ariaLabel]="bar.ariaLabel"
8085
+ [animations]="animations"
8086
+ (activate)="activate.emit($event)"
8087
+ (deactivate)="deactivate.emit($event)"
8088
+ ngx-tooltip
8089
+ [tooltipDisabled]="tooltipDisabled"
8090
+ [tooltipPlacement]="tooltipPlacement"
8091
+ [tooltipType]="tooltipType"
8092
+ [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
8093
+ [tooltipTemplate]="tooltipTemplate"
8094
+ [tooltipContext]="bar.data"
8095
+ [noBarWhenZero]="noBarWhenZero"
8096
+ ></svg:g>
8097
+ </svg:g>
8098
+ } @if (showDataLabel) {
8099
+ <svg:g>
7705
8100
  <svg:g
7706
8101
  ngx-charts-bar-label
7707
8102
  *ngFor="let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy"
@@ -7715,7 +8110,8 @@ class SeriesHorizontal {
7715
8110
  (dimensionsChanged)="dataLabelWidthChanged.emit({ size: $event, index: i })"
7716
8111
  />
7717
8112
  </svg:g>
7718
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: TooltipDirective, selector: "[ngx-tooltip]", inputs: ["tooltipCssClass", "tooltipTitle", "tooltipAppendToBody", "tooltipSpacing", "tooltipDisabled", "tooltipShowCaret", "tooltipPlacement", "tooltipAlignment", "tooltipType", "tooltipCloseOnClickOutside", "tooltipCloseOnMouseLeave", "tooltipHideTimeout", "tooltipShowTimeout", "tooltipTemplate", "tooltipShowEvent", "tooltipContext", "tooltipImmediateExit"], outputs: ["show", "hide"] }, { kind: "component", type: BarComponent, selector: "g[ngx-charts-bar]", inputs: ["fill", "data", "width", "height", "x", "y", "orientation", "roundEdges", "gradient", "offset", "isActive", "stops", "animations", "ariaLabel", "noBarWhenZero"], outputs: ["select", "activate", "deactivate"] }, { kind: "component", type: BarLabelComponent, selector: "g[ngx-charts-bar-label]", inputs: ["value", "valueFormatting", "barX", "barY", "barWidth", "barHeight", "orientation"], outputs: ["dimensionsChanged"] }], animations: [
8113
+ }
8114
+ `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: TooltipDirective, selector: "[ngx-tooltip]", inputs: ["tooltipCssClass", "tooltipTitle", "tooltipAppendToBody", "tooltipSpacing", "tooltipDisabled", "tooltipShowCaret", "tooltipPlacement", "tooltipAlignment", "tooltipType", "tooltipCloseOnClickOutside", "tooltipCloseOnMouseLeave", "tooltipHideTimeout", "tooltipShowTimeout", "tooltipTemplate", "tooltipShowEvent", "tooltipContext", "tooltipImmediateExit"], outputs: ["show", "hide"] }, { kind: "component", type: BarComponent, selector: "g[ngx-charts-bar]", inputs: ["fill", "data", "width", "height", "x", "y", "orientation", "roundEdges", "gradient", "offset", "isActive", "stops", "animations", "ariaLabel", "noBarWhenZero"], outputs: ["select", "activate", "deactivate"] }, { kind: "component", type: BarLabelComponent, selector: "g[ngx-charts-bar-label]", inputs: ["value", "valueFormatting", "barX", "barY", "barWidth", "barHeight", "orientation"], outputs: ["dimensionsChanged"] }], animations: [
7719
8115
  trigger('animationState', [
7720
8116
  transition(':leave', [
7721
8117
  style({
@@ -7731,36 +8127,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
7731
8127
  args: [{
7732
8128
  selector: 'g[ngx-charts-series-horizontal]',
7733
8129
  template: `
7734
- <svg:g
7735
- ngx-charts-bar
7736
- *ngFor="let bar of bars; trackBy: trackBy"
7737
- [@animationState]="'active'"
7738
- [width]="bar.width"
7739
- [height]="bar.height"
7740
- [x]="bar.x"
7741
- [y]="bar.y"
7742
- [fill]="bar.color"
7743
- [stops]="bar.gradientStops"
7744
- [data]="bar.data"
7745
- [orientation]="barOrientation.Horizontal"
7746
- [roundEdges]="bar.roundEdges"
7747
- (select)="click($event)"
7748
- [gradient]="gradient"
7749
- [isActive]="isActive(bar.data)"
7750
- [ariaLabel]="bar.ariaLabel"
7751
- [animations]="animations"
7752
- (activate)="activate.emit($event)"
7753
- (deactivate)="deactivate.emit($event)"
7754
- ngx-tooltip
7755
- [tooltipDisabled]="tooltipDisabled"
7756
- [tooltipPlacement]="tooltipPlacement"
7757
- [tooltipType]="tooltipType"
7758
- [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
7759
- [tooltipTemplate]="tooltipTemplate"
7760
- [tooltipContext]="bar.data"
7761
- [noBarWhenZero]="noBarWhenZero"
7762
- ></svg:g>
7763
- <svg:g *ngIf="showDataLabel">
8130
+ @if (!isSSR) {
8131
+ <svg:g>
8132
+ <svg:g
8133
+ ngx-charts-bar
8134
+ *ngFor="let bar of bars; trackBy: trackBy"
8135
+ [@animationState]="'active'"
8136
+ [width]="bar.width"
8137
+ [height]="bar.height"
8138
+ [x]="bar.x"
8139
+ [y]="bar.y"
8140
+ [fill]="bar.color"
8141
+ [stops]="bar.gradientStops"
8142
+ [data]="bar.data"
8143
+ [orientation]="barOrientation.Horizontal"
8144
+ [roundEdges]="bar.roundEdges"
8145
+ (select)="click($event)"
8146
+ [gradient]="gradient"
8147
+ [isActive]="isActive(bar.data)"
8148
+ [ariaLabel]="bar.ariaLabel"
8149
+ [animations]="animations"
8150
+ (activate)="activate.emit($event)"
8151
+ (deactivate)="deactivate.emit($event)"
8152
+ ngx-tooltip
8153
+ [tooltipDisabled]="tooltipDisabled"
8154
+ [tooltipPlacement]="tooltipPlacement"
8155
+ [tooltipType]="tooltipType"
8156
+ [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
8157
+ [tooltipTemplate]="tooltipTemplate"
8158
+ [tooltipContext]="bar.data"
8159
+ [noBarWhenZero]="noBarWhenZero"
8160
+ ></svg:g>
8161
+ </svg:g>
8162
+ } @else {
8163
+ <svg:g>
8164
+ <svg:g
8165
+ ngx-charts-bar
8166
+ *ngFor="let bar of bars; trackBy: trackBy"
8167
+ [width]="bar.width"
8168
+ [height]="bar.height"
8169
+ [x]="bar.x"
8170
+ [y]="bar.y"
8171
+ [fill]="bar.color"
8172
+ [stops]="bar.gradientStops"
8173
+ [data]="bar.data"
8174
+ [orientation]="barOrientation.Horizontal"
8175
+ [roundEdges]="bar.roundEdges"
8176
+ (select)="click($event)"
8177
+ [gradient]="gradient"
8178
+ [isActive]="isActive(bar.data)"
8179
+ [ariaLabel]="bar.ariaLabel"
8180
+ [animations]="animations"
8181
+ (activate)="activate.emit($event)"
8182
+ (deactivate)="deactivate.emit($event)"
8183
+ ngx-tooltip
8184
+ [tooltipDisabled]="tooltipDisabled"
8185
+ [tooltipPlacement]="tooltipPlacement"
8186
+ [tooltipType]="tooltipType"
8187
+ [tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
8188
+ [tooltipTemplate]="tooltipTemplate"
8189
+ [tooltipContext]="bar.data"
8190
+ [noBarWhenZero]="noBarWhenZero"
8191
+ ></svg:g>
8192
+ </svg:g>
8193
+ } @if (showDataLabel) {
8194
+ <svg:g>
7764
8195
  <svg:g
7765
8196
  ngx-charts-bar-label
7766
8197
  *ngFor="let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy"
@@ -7774,6 +8205,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
7774
8205
  (dimensionsChanged)="dataLabelWidthChanged.emit({ size: $event, index: i })"
7775
8206
  />
7776
8207
  </svg:g>
8208
+ }
7777
8209
  `,
7778
8210
  changeDetection: ChangeDetectionStrategy.OnPush,
7779
8211
  animations: [
@@ -7788,7 +8220,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
7788
8220
  ],
7789
8221
  standalone: false
7790
8222
  }]
7791
- }], propDecorators: { dims: [{
8223
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
8224
+ type: Inject,
8225
+ args: [PLATFORM_ID]
8226
+ }] }], propDecorators: { dims: [{
7792
8227
  type: Input
7793
8228
  }], type: [{
7794
8229
  type: Input
@@ -7868,6 +8303,8 @@ class BarHorizontalComponent extends BaseChartComponent {
7868
8303
  this.dataLabelMaxWidth = { negative: 0, positive: 0 };
7869
8304
  }
7870
8305
  this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
8306
+ // Seed axis width before first measure so SSR/print HTML reserves label space.
8307
+ this.seedYAxisWidthFromResults();
7871
8308
  this.dims = calculateViewDimensions({
7872
8309
  width: this.width,
7873
8310
  height: this.height,
@@ -7894,6 +8331,14 @@ class BarHorizontalComponent extends BaseChartComponent {
7894
8331
  refLines.forEach(line => parent.appendChild(line));
7895
8332
  }
7896
8333
  }
8334
+ /** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
8335
+ seedYAxisWidthFromResults() {
8336
+ if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
8337
+ return;
8338
+ }
8339
+ const labels = this.results.map(d => formatLabel(d.name ?? d.label));
8340
+ this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
8341
+ }
7897
8342
  getXScale() {
7898
8343
  this.xDomain = this.getXDomain();
7899
8344
  const scale = scaleLinear().range([0, this.dims.width]).domain(this.xDomain);
@@ -7946,10 +8391,16 @@ class BarHorizontalComponent extends BaseChartComponent {
7946
8391
  return opts;
7947
8392
  }
7948
8393
  updateYAxisWidth({ width }) {
8394
+ if (Math.abs(width - this.yAxisWidth) <= 1) {
8395
+ return;
8396
+ }
7949
8397
  this.yAxisWidth = width;
7950
8398
  this.update();
7951
8399
  }
7952
8400
  updateXAxisHeight({ height }) {
8401
+ if (height === this.xAxisHeight) {
8402
+ return;
8403
+ }
7953
8404
  this.xAxisHeight = height;
7954
8405
  this.update();
7955
8406
  }
@@ -8268,6 +8719,8 @@ class BarHorizontal2DComponent extends BaseChartComponent {
8268
8719
  this.dataLabelMaxWidth = { negative: 0, positive: 0 };
8269
8720
  }
8270
8721
  this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
8722
+ // Seed axis width before first measure so SSR/print HTML reserves label space.
8723
+ this.seedYAxisWidthFromResults();
8271
8724
  this.dims = calculateViewDimensions({
8272
8725
  width: this.width,
8273
8726
  height: this.height,
@@ -8293,6 +8746,14 @@ class BarHorizontal2DComponent extends BaseChartComponent {
8293
8746
  this.legendOptions = this.getLegendOptions();
8294
8747
  this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
8295
8748
  }
8749
+ /** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
8750
+ seedYAxisWidthFromResults() {
8751
+ if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
8752
+ return;
8753
+ }
8754
+ const labels = this.results.map(d => formatLabel(d.name ?? d.label));
8755
+ this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
8756
+ }
8296
8757
  getGroupScale() {
8297
8758
  const spacing = this.groupDomain.length / (this.dims.height / this.groupPadding + 1);
8298
8759
  return scaleBand()
@@ -8382,10 +8843,16 @@ class BarHorizontal2DComponent extends BaseChartComponent {
8382
8843
  return opts;
8383
8844
  }
8384
8845
  updateYAxisWidth({ width }) {
8846
+ if (Math.abs(width - this.yAxisWidth) <= 1) {
8847
+ return;
8848
+ }
8385
8849
  this.yAxisWidth = width;
8386
8850
  this.update();
8387
8851
  }
8388
8852
  updateXAxisHeight({ height }) {
8853
+ if (height === this.xAxisHeight) {
8854
+ return;
8855
+ }
8389
8856
  this.xAxisHeight = height;
8390
8857
  this.update();
8391
8858
  }
@@ -8796,6 +9263,8 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
8796
9263
  }
8797
9264
  update() {
8798
9265
  super.update();
9266
+ // Seed axis width before first measure so SSR/print HTML reserves label space.
9267
+ this.seedYAxisWidthFromResults();
8799
9268
  this.dims = calculateViewDimensions({
8800
9269
  width: this.width,
8801
9270
  height: this.height,
@@ -8819,6 +9288,14 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
8819
9288
  this.legendOptions = this.getLegendOptions();
8820
9289
  this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
8821
9290
  }
9291
+ /** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
9292
+ seedYAxisWidthFromResults() {
9293
+ if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
9294
+ return;
9295
+ }
9296
+ const labels = this.results.map(d => formatLabel(d.name ?? d.label));
9297
+ this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
9298
+ }
8822
9299
  getGroupDomain() {
8823
9300
  const domain = [];
8824
9301
  for (const group of this.results) {
@@ -8886,10 +9363,16 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
8886
9363
  return opts;
8887
9364
  }
8888
9365
  updateYAxisWidth({ width }) {
9366
+ if (Math.abs(width - this.yAxisWidth) <= 1) {
9367
+ return;
9368
+ }
8889
9369
  this.yAxisWidth = width;
8890
9370
  this.update();
8891
9371
  }
8892
9372
  updateXAxisHeight({ height }) {
9373
+ if (height === this.xAxisHeight) {
9374
+ return;
9375
+ }
8893
9376
  this.xAxisHeight = height;
8894
9377
  this.update();
8895
9378
  }
@@ -9246,6 +9729,8 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
9246
9729
  this.dataLabelMaxWidth = { negative: 0, positive: 0 };
9247
9730
  }
9248
9731
  this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
9732
+ // Seed axis width before first measure so SSR/print HTML reserves label space.
9733
+ this.seedYAxisWidthFromResults();
9249
9734
  this.dims = calculateViewDimensions({
9250
9735
  width: this.width,
9251
9736
  height: this.height,
@@ -9270,6 +9755,14 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
9270
9755
  this.legendOptions = this.getLegendOptions();
9271
9756
  this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
9272
9757
  }
9758
+ /** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
9759
+ seedYAxisWidthFromResults() {
9760
+ if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
9761
+ return;
9762
+ }
9763
+ const labels = this.results.map(d => formatLabel(d.name ?? d.label));
9764
+ this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
9765
+ }
9273
9766
  getGroupDomain() {
9274
9767
  const domain = [];
9275
9768
  for (const group of this.results) {
@@ -9363,10 +9856,16 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
9363
9856
  return opts;
9364
9857
  }
9365
9858
  updateYAxisWidth({ width }) {
9859
+ if (Math.abs(width - this.yAxisWidth) <= 1) {
9860
+ return;
9861
+ }
9366
9862
  this.yAxisWidth = width;
9367
9863
  this.update();
9368
9864
  }
9369
9865
  updateXAxisHeight({ height }) {
9866
+ if (height === this.xAxisHeight) {
9867
+ return;
9868
+ }
9370
9869
  this.xAxisHeight = height;
9371
9870
  this.update();
9372
9871
  }
@@ -12476,13 +12975,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
12476
12975
  }] } });
12477
12976
 
12478
12977
  class BoxSeriesComponent {
12479
- constructor() {
12978
+ constructor(platformId) {
12979
+ this.platformId = platformId;
12480
12980
  this.animations = true;
12481
12981
  this.tooltipDisabled = false;
12482
12982
  this.gradient = false;
12483
12983
  this.select = new EventEmitter();
12484
12984
  this.activate = new EventEmitter();
12485
12985
  this.deactivate = new EventEmitter();
12986
+ this.isSSR = false;
12987
+ }
12988
+ ngOnInit() {
12989
+ if (isPlatformServer(this.platformId)) {
12990
+ this.isSSR = true;
12991
+ }
12486
12992
  }
12487
12993
  ngOnChanges(changes) {
12488
12994
  this.update();
@@ -12583,37 +13089,71 @@ class BoxSeriesComponent {
12583
13089
  }
12584
13090
  }
12585
13091
  }
12586
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BoxSeriesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
12587
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.8", type: BoxSeriesComponent, isStandalone: false, selector: "g[ngx-charts-box-series]", inputs: { dims: "dims", series: "series", xScale: "xScale", yScale: "yScale", colors: "colors", animations: "animations", strokeColor: "strokeColor", strokeWidth: "strokeWidth", tooltipDisabled: "tooltipDisabled", tooltipTemplate: "tooltipTemplate", tooltipPlacement: "tooltipPlacement", tooltipType: "tooltipType", roundEdges: "roundEdges", gradient: "gradient" }, outputs: { select: "select", activate: "activate", deactivate: "deactivate" }, usesOnChanges: true, ngImport: i0, template: `
12588
- <svg:g
12589
- ngx-charts-box
12590
- [@animationState]="'active'"
12591
- [@.disabled]="!animations"
12592
- [width]="box.width"
12593
- [height]="box.height"
12594
- [x]="box.x"
12595
- [y]="box.y"
12596
- [roundEdges]="box.roundEdges"
12597
- [fill]="box.color"
12598
- [gradientStops]="box.gradientStops"
12599
- [strokeColor]="strokeColor"
12600
- [strokeWidth]="strokeWidth"
12601
- [data]="box.data"
12602
- [lineCoordinates]="box.lineCoordinates"
12603
- [gradient]="gradient"
12604
- [ariaLabel]="box.ariaLabel"
12605
- (select)="onClick($event)"
12606
- (activate)="activate.emit($event)"
12607
- (deactivate)="deactivate.emit($event)"
12608
- ngx-tooltip
12609
- [tooltipDisabled]="tooltipDisabled"
12610
- [tooltipPlacement]="tooltipPlacement"
12611
- [tooltipType]="tooltipType"
12612
- [tooltipTitle]="tooltipTitle"
12613
- [tooltipTemplate]="tooltipTemplate"
12614
- [tooltipContext]="box.data"
12615
- [animations]="animations"
12616
- ></svg:g>
13092
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BoxSeriesComponent, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Component }); }
13093
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: BoxSeriesComponent, isStandalone: false, selector: "g[ngx-charts-box-series]", inputs: { dims: "dims", series: "series", xScale: "xScale", yScale: "yScale", colors: "colors", animations: "animations", strokeColor: "strokeColor", strokeWidth: "strokeWidth", tooltipDisabled: "tooltipDisabled", tooltipTemplate: "tooltipTemplate", tooltipPlacement: "tooltipPlacement", tooltipType: "tooltipType", roundEdges: "roundEdges", gradient: "gradient" }, outputs: { select: "select", activate: "activate", deactivate: "deactivate" }, usesOnChanges: true, ngImport: i0, template: `
13094
+ @if (!isSSR) {
13095
+ <svg:g>
13096
+ <svg:g
13097
+ ngx-charts-box
13098
+ [@animationState]="'active'"
13099
+ [@.disabled]="!animations"
13100
+ [width]="box.width"
13101
+ [height]="box.height"
13102
+ [x]="box.x"
13103
+ [y]="box.y"
13104
+ [roundEdges]="box.roundEdges"
13105
+ [fill]="box.color"
13106
+ [gradientStops]="box.gradientStops"
13107
+ [strokeColor]="strokeColor"
13108
+ [strokeWidth]="strokeWidth"
13109
+ [data]="box.data"
13110
+ [lineCoordinates]="box.lineCoordinates"
13111
+ [gradient]="gradient"
13112
+ [ariaLabel]="box.ariaLabel"
13113
+ (select)="onClick($event)"
13114
+ (activate)="activate.emit($event)"
13115
+ (deactivate)="deactivate.emit($event)"
13116
+ ngx-tooltip
13117
+ [tooltipDisabled]="tooltipDisabled"
13118
+ [tooltipPlacement]="tooltipPlacement"
13119
+ [tooltipType]="tooltipType"
13120
+ [tooltipTitle]="tooltipTitle"
13121
+ [tooltipTemplate]="tooltipTemplate"
13122
+ [tooltipContext]="box.data"
13123
+ [animations]="animations"
13124
+ ></svg:g>
13125
+ </svg:g>
13126
+ } @else {
13127
+ <svg:g>
13128
+ <svg:g
13129
+ ngx-charts-box
13130
+ [width]="box.width"
13131
+ [height]="box.height"
13132
+ [x]="box.x"
13133
+ [y]="box.y"
13134
+ [roundEdges]="box.roundEdges"
13135
+ [fill]="box.color"
13136
+ [gradientStops]="box.gradientStops"
13137
+ [strokeColor]="strokeColor"
13138
+ [strokeWidth]="strokeWidth"
13139
+ [data]="box.data"
13140
+ [lineCoordinates]="box.lineCoordinates"
13141
+ [gradient]="gradient"
13142
+ [ariaLabel]="box.ariaLabel"
13143
+ (select)="onClick($event)"
13144
+ (activate)="activate.emit($event)"
13145
+ (deactivate)="deactivate.emit($event)"
13146
+ ngx-tooltip
13147
+ [tooltipDisabled]="tooltipDisabled"
13148
+ [tooltipPlacement]="tooltipPlacement"
13149
+ [tooltipType]="tooltipType"
13150
+ [tooltipTitle]="tooltipTitle"
13151
+ [tooltipTemplate]="tooltipTemplate"
13152
+ [tooltipContext]="box.data"
13153
+ [animations]="animations"
13154
+ ></svg:g>
13155
+ </svg:g>
13156
+ }
12617
13157
  `, isInline: true, dependencies: [{ kind: "directive", type: TooltipDirective, selector: "[ngx-tooltip]", inputs: ["tooltipCssClass", "tooltipTitle", "tooltipAppendToBody", "tooltipSpacing", "tooltipDisabled", "tooltipShowCaret", "tooltipPlacement", "tooltipAlignment", "tooltipType", "tooltipCloseOnClickOutside", "tooltipCloseOnMouseLeave", "tooltipHideTimeout", "tooltipShowTimeout", "tooltipTemplate", "tooltipShowEvent", "tooltipContext", "tooltipImmediateExit"], outputs: ["show", "hide"] }, { kind: "component", type: BoxComponent, selector: "g[ngx-charts-box]", inputs: ["strokeColor", "strokeWidth", "fill", "data", "width", "height", "x", "y", "lineCoordinates", "roundEdges", "gradient", "gradientStops", "offset", "isActive", "animations", "ariaLabel", "noBarWhenZero"], outputs: ["select", "activate", "deactivate"] }], animations: [
12618
13158
  trigger('animationState', [
12619
13159
  transition(':leave', [
@@ -12630,35 +13170,69 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
12630
13170
  args: [{
12631
13171
  selector: 'g[ngx-charts-box-series]',
12632
13172
  template: `
12633
- <svg:g
12634
- ngx-charts-box
12635
- [@animationState]="'active'"
12636
- [@.disabled]="!animations"
12637
- [width]="box.width"
12638
- [height]="box.height"
12639
- [x]="box.x"
12640
- [y]="box.y"
12641
- [roundEdges]="box.roundEdges"
12642
- [fill]="box.color"
12643
- [gradientStops]="box.gradientStops"
12644
- [strokeColor]="strokeColor"
12645
- [strokeWidth]="strokeWidth"
12646
- [data]="box.data"
12647
- [lineCoordinates]="box.lineCoordinates"
12648
- [gradient]="gradient"
12649
- [ariaLabel]="box.ariaLabel"
12650
- (select)="onClick($event)"
12651
- (activate)="activate.emit($event)"
12652
- (deactivate)="deactivate.emit($event)"
12653
- ngx-tooltip
12654
- [tooltipDisabled]="tooltipDisabled"
12655
- [tooltipPlacement]="tooltipPlacement"
12656
- [tooltipType]="tooltipType"
12657
- [tooltipTitle]="tooltipTitle"
12658
- [tooltipTemplate]="tooltipTemplate"
12659
- [tooltipContext]="box.data"
12660
- [animations]="animations"
12661
- ></svg:g>
13173
+ @if (!isSSR) {
13174
+ <svg:g>
13175
+ <svg:g
13176
+ ngx-charts-box
13177
+ [@animationState]="'active'"
13178
+ [@.disabled]="!animations"
13179
+ [width]="box.width"
13180
+ [height]="box.height"
13181
+ [x]="box.x"
13182
+ [y]="box.y"
13183
+ [roundEdges]="box.roundEdges"
13184
+ [fill]="box.color"
13185
+ [gradientStops]="box.gradientStops"
13186
+ [strokeColor]="strokeColor"
13187
+ [strokeWidth]="strokeWidth"
13188
+ [data]="box.data"
13189
+ [lineCoordinates]="box.lineCoordinates"
13190
+ [gradient]="gradient"
13191
+ [ariaLabel]="box.ariaLabel"
13192
+ (select)="onClick($event)"
13193
+ (activate)="activate.emit($event)"
13194
+ (deactivate)="deactivate.emit($event)"
13195
+ ngx-tooltip
13196
+ [tooltipDisabled]="tooltipDisabled"
13197
+ [tooltipPlacement]="tooltipPlacement"
13198
+ [tooltipType]="tooltipType"
13199
+ [tooltipTitle]="tooltipTitle"
13200
+ [tooltipTemplate]="tooltipTemplate"
13201
+ [tooltipContext]="box.data"
13202
+ [animations]="animations"
13203
+ ></svg:g>
13204
+ </svg:g>
13205
+ } @else {
13206
+ <svg:g>
13207
+ <svg:g
13208
+ ngx-charts-box
13209
+ [width]="box.width"
13210
+ [height]="box.height"
13211
+ [x]="box.x"
13212
+ [y]="box.y"
13213
+ [roundEdges]="box.roundEdges"
13214
+ [fill]="box.color"
13215
+ [gradientStops]="box.gradientStops"
13216
+ [strokeColor]="strokeColor"
13217
+ [strokeWidth]="strokeWidth"
13218
+ [data]="box.data"
13219
+ [lineCoordinates]="box.lineCoordinates"
13220
+ [gradient]="gradient"
13221
+ [ariaLabel]="box.ariaLabel"
13222
+ (select)="onClick($event)"
13223
+ (activate)="activate.emit($event)"
13224
+ (deactivate)="deactivate.emit($event)"
13225
+ ngx-tooltip
13226
+ [tooltipDisabled]="tooltipDisabled"
13227
+ [tooltipPlacement]="tooltipPlacement"
13228
+ [tooltipType]="tooltipType"
13229
+ [tooltipTitle]="tooltipTitle"
13230
+ [tooltipTemplate]="tooltipTemplate"
13231
+ [tooltipContext]="box.data"
13232
+ [animations]="animations"
13233
+ ></svg:g>
13234
+ </svg:g>
13235
+ }
12662
13236
  `,
12663
13237
  changeDetection: ChangeDetectionStrategy.OnPush,
12664
13238
  animations: [
@@ -12673,7 +13247,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
12673
13247
  ],
12674
13248
  standalone: false
12675
13249
  }]
12676
- }], propDecorators: { dims: [{
13250
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
13251
+ type: Inject,
13252
+ args: [PLATFORM_ID]
13253
+ }] }], propDecorators: { dims: [{
12677
13254
  type: Input
12678
13255
  }], series: [{
12679
13256
  type: Input
@@ -20989,5 +21566,5 @@ function tickFormat(fieldType, groupByType) {
20989
21566
  * Generated bundle index. Do not edit.
20990
21567
  */
20991
21568
 
20992
- export { AdvancedLegendComponent, AdvancedPieChartComponent, AreaChartComponent, AreaChartModule, AreaChartNormalizedComponent, AreaChartStackedComponent, AreaComponent, AreaSeriesComponent, AxesModule, AxisLabelComponent, BarChartModule, BarChartType, BarComponent, BarHorizontal2DComponent, BarHorizontalComponent, BarHorizontalNormalizedComponent, BarHorizontalStackedComponent, BarLabelComponent, BarOrientation, BarVertical2DComponent, BarVerticalComponent, BarVerticalNormalizedComponent, BarVerticalStackedComponent, BaseChartComponent, BoxChartComponent, BoxChartModule, BoxComponent, BoxSeriesComponent, BubbleChartComponent, BubbleChartModule, BubbleSeriesComponent, CardComponent, CardSeriesComponent, ChartCommonModule, ChartComponent, CircleComponent, CircleSeriesComponent, ColorHelper, CountUpDirective, D0Types, GaugeArcComponent, GaugeAxisComponent, GaugeComponent, GaugeModule, GridPanelComponent, GridPanelSeriesComponent, HeatCellSeriesComponent, HeatMapCellComponent, HeatMapComponent, HeatMapModule, LegendComponent, LegendEntryComponent, LegendPosition, LegendType, LineChartComponent, LineChartModule, LineComponent, LineSeriesComponent, LinearGaugeComponent, NgxChartsModule, NumberCardComponent, NumberCardModule, Orientation, PercentGaugeComponent, PieArcComponent, PieChartComponent, PieChartModule, PieGridComponent, PieGridSeriesComponent, PieLabelComponent, PieSeriesComponent, PlacementTypes, PolarChartComponent, PolarChartModule, PolarSeriesComponent, SankeyComponent, SankeyModule, ScaleLegendComponent, ScaleType, SeriesHorizontal, SeriesType, SeriesVerticalComponent, ShowTypes, StyleTypes, SvgLinearGradientComponent, SvgRadialGradientComponent, TextAnchor, Timeline, TooltipArea, TooltipContentComponent, TooltipDirective, TooltipModule, TooltipService, TreeMapCellComponent, TreeMapCellSeriesComponent, TreeMapComponent, TreeMapModule, VisibilityObserver, XAxisComponent, XAxisTicksComponent, YAxisComponent, YAxisTicksComponent, calculateViewDimensions, cloneLineCoordinates, clonePoint, cloneVector2d, colorSets, count, decimalChecker, escapeLabel, formatLabel, getDomain, getScale, getScaleType, getTickLines, getUniqueXDomainValues, getXDomainArray, gridLayout, gridSize, hexToRgb, id, invertColor, reduceTicks, shadeRGBColor, sortByDomain, sortByTime, sortLinear, throttle, throttleable, tickFormat, trimLabel };
21569
+ export { AdvancedLegendComponent, AdvancedPieChartComponent, AreaChartComponent, AreaChartModule, AreaChartNormalizedComponent, AreaChartStackedComponent, AreaComponent, AreaSeriesComponent, AxesModule, AxisLabelComponent, BarChartModule, BarChartType, BarComponent, BarHorizontal2DComponent, BarHorizontalComponent, BarHorizontalNormalizedComponent, BarHorizontalStackedComponent, BarLabelComponent, BarOrientation, BarVertical2DComponent, BarVerticalComponent, BarVerticalNormalizedComponent, BarVerticalStackedComponent, BaseChartComponent, BoxChartComponent, BoxChartModule, BoxComponent, BoxSeriesComponent, BubbleChartComponent, BubbleChartModule, BubbleSeriesComponent, CardComponent, CardSeriesComponent, ChartCommonModule, ChartComponent, CircleComponent, CircleSeriesComponent, ColorHelper, CountUpDirective, D0Types, GaugeArcComponent, GaugeAxisComponent, GaugeComponent, GaugeModule, GridPanelComponent, GridPanelSeriesComponent, HeatCellSeriesComponent, HeatMapCellComponent, HeatMapComponent, HeatMapModule, LegendComponent, LegendEntryComponent, LegendPosition, LegendType, LineChartComponent, LineChartModule, LineComponent, LineSeriesComponent, LinearGaugeComponent, NgxChartsModule, NumberCardComponent, NumberCardModule, Orientation, PercentGaugeComponent, PieArcComponent, PieChartComponent, PieChartModule, PieGridComponent, PieGridSeriesComponent, PieLabelComponent, PieSeriesComponent, PlacementTypes, PolarChartComponent, PolarChartModule, PolarSeriesComponent, SankeyComponent, SankeyModule, ScaleLegendComponent, ScaleType, SeriesHorizontal, SeriesType, SeriesVerticalComponent, ShowTypes, StyleTypes, SvgLinearGradientComponent, SvgRadialGradientComponent, TextAnchor, Timeline, TooltipArea, TooltipContentComponent, TooltipDirective, TooltipModule, TooltipService, TreeMapCellComponent, TreeMapCellSeriesComponent, TreeMapComponent, TreeMapModule, VisibilityObserver, XAxisComponent, XAxisTicksComponent, YAxisComponent, YAxisTicksComponent, calculateViewDimensions, cloneLineCoordinates, clonePoint, cloneVector2d, colorSets, count, decimalChecker, escapeLabel, formatLabel, getDomain, getScale, getScaleType, getTickLines, getUniqueXDomainValues, getXDomainArray, gridLayout, gridSize, hexToRgb, id, invertColor, maxCharsForPixelWidth, reduceTicks, shadeRGBColor, sortByDomain, sortByTime, sortLinear, throttle, throttleable, tickFormat, trimLabel };
20993
21570
  //# sourceMappingURL=swimlane-ngx-charts.mjs.map