@swimlane/ngx-charts 25.0.1 → 25.0.3
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.
|
@@ -1423,6 +1423,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
1423
1423
|
type: Input
|
|
1424
1424
|
}] } });
|
|
1425
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
|
+
}
|
|
1426
1433
|
function trimLabel(s, max = 16) {
|
|
1427
1434
|
if (typeof s !== 'string') {
|
|
1428
1435
|
if (typeof s === 'number') {
|
|
@@ -1555,6 +1562,7 @@ class XAxisTicksComponent {
|
|
|
1555
1562
|
this.maxAllowedLength = 16;
|
|
1556
1563
|
this.height = 0;
|
|
1557
1564
|
this.approxHeight = 10;
|
|
1565
|
+
this.ssrHeight = 10;
|
|
1558
1566
|
this.maxPossibleLengthForTickIfWrapped = 16;
|
|
1559
1567
|
this.referenceLineLength = 0;
|
|
1560
1568
|
}
|
|
@@ -1567,7 +1575,7 @@ class XAxisTicksComponent {
|
|
|
1567
1575
|
updateDims() {
|
|
1568
1576
|
if (!isPlatformBrowser(this.platformId)) {
|
|
1569
1577
|
// for SSR, use approximate value instead of measured
|
|
1570
|
-
this.dimensionsChanged.emit({ height: this.
|
|
1578
|
+
this.dimensionsChanged.emit({ height: this.ssrHeight });
|
|
1571
1579
|
return;
|
|
1572
1580
|
}
|
|
1573
1581
|
const height = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().height, 10);
|
|
@@ -1577,7 +1585,25 @@ class XAxisTicksComponent {
|
|
|
1577
1585
|
setTimeout(() => this.updateDims());
|
|
1578
1586
|
}
|
|
1579
1587
|
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Tick label height without DOM measurement. SSR serializes before the deferred `dimensionsChanged`
|
|
1590
|
+
* emission is applied, so charts seed their x-axis height from this during `update()`.
|
|
1591
|
+
*/
|
|
1592
|
+
static approximateTicksHeight(options) {
|
|
1593
|
+
const ticks = new XAxisTicksComponent('server');
|
|
1594
|
+
for (const [key, value] of Object.entries(options)) {
|
|
1595
|
+
if (value !== undefined && value !== null) {
|
|
1596
|
+
ticks[key] = value;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
ticks.layout();
|
|
1600
|
+
return ticks.ssrHeight;
|
|
1601
|
+
}
|
|
1580
1602
|
update() {
|
|
1603
|
+
this.layout();
|
|
1604
|
+
setTimeout(() => this.updateDims());
|
|
1605
|
+
}
|
|
1606
|
+
layout() {
|
|
1581
1607
|
const scale = this.scale;
|
|
1582
1608
|
this.adjustedScale = this.scale.bandwidth
|
|
1583
1609
|
? function (d) {
|
|
@@ -1651,7 +1677,26 @@ class XAxisTicksComponent {
|
|
|
1651
1677
|
else {
|
|
1652
1678
|
this.textAnchor = TextAnchor.Middle;
|
|
1653
1679
|
}
|
|
1654
|
-
|
|
1680
|
+
this.ssrHeight = this.getSsrHeight(angle);
|
|
1681
|
+
}
|
|
1682
|
+
/**
|
|
1683
|
+
* Estimated rendered height of the tick labels, matching what getBoundingClientRect reports in the
|
|
1684
|
+
* browser: the rotated text run plus the projected glyph height, or the wrapped line stack.
|
|
1685
|
+
*/
|
|
1686
|
+
getSsrHeight(angle) {
|
|
1687
|
+
const lineHeight = 14;
|
|
1688
|
+
const charWidth = 7;
|
|
1689
|
+
let height = lineHeight;
|
|
1690
|
+
if (angle) {
|
|
1691
|
+
const radians = (Math.abs(angle) * Math.PI) / 180;
|
|
1692
|
+
const textWidth = this.maxTicksLength * charWidth;
|
|
1693
|
+
height = Math.ceil(Math.sin(radians) * textWidth + Math.cos(radians) * lineHeight);
|
|
1694
|
+
}
|
|
1695
|
+
else if (this.isWrapTicksSupported && this.ticks?.length) {
|
|
1696
|
+
const longestTick = this.ticks.reduce((earlier, current) => (current.length > earlier.length ? current : earlier), '');
|
|
1697
|
+
height = lineHeight * (this.tickChunks(longestTick).length || 1);
|
|
1698
|
+
}
|
|
1699
|
+
return Math.min(Math.max(height, this.approxHeight), 200);
|
|
1655
1700
|
}
|
|
1656
1701
|
setReferencelines() {
|
|
1657
1702
|
this.refMin = this.adjustedScale(Math.min.apply(null, this.referenceLines.map(item => item.value)));
|
|
@@ -2074,6 +2119,172 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
2074
2119
|
args: [XAxisTicksComponent]
|
|
2075
2120
|
}] } });
|
|
2076
2121
|
|
|
2122
|
+
/** Must stay in sync with y-axis.component padding and calculateViewDimensions y-axis spacer. */
|
|
2123
|
+
const CATEGORY_AXIS_Y_PADDING = 5;
|
|
2124
|
+
const CATEGORY_AXIS_VIEW_DIMS_SPACER = 10;
|
|
2125
|
+
const CATEGORY_AXIS_INNER_TICK_SIZE = 6;
|
|
2126
|
+
const CATEGORY_AXIS_TICK_PADDING = 3;
|
|
2127
|
+
const CATEGORY_AXIS_LAYOUT_INSET = CATEGORY_AXIS_Y_PADDING + CATEGORY_AXIS_INNER_TICK_SIZE + CATEGORY_AXIS_TICK_PADDING - CATEGORY_AXIS_VIEW_DIMS_SPACER;
|
|
2128
|
+
const CATEGORY_AXIS_TRIM_CHAR_WIDTH = 7;
|
|
2129
|
+
/** Hard display cap per line (including ellipsis), matching SSR/print clip budget. */
|
|
2130
|
+
const CATEGORY_AXIS_MAX_LINE_CHARS = 23;
|
|
2131
|
+
/** trimLabel content budget so content + '...' fits in CATEGORY_AXIS_MAX_LINE_CHARS. */
|
|
2132
|
+
const CATEGORY_AXIS_MAX_CONTENT_CHARS = CATEGORY_AXIS_MAX_LINE_CHARS - 3;
|
|
2133
|
+
const DEFAULT_CATEGORY_WRAP_MAX_LINES = 2;
|
|
2134
|
+
function requiredCategoryAxisWidth(textWidth) {
|
|
2135
|
+
return Math.max(0, textWidth + CATEGORY_AXIS_LAYOUT_INSET);
|
|
2136
|
+
}
|
|
2137
|
+
const CATEGORY_AXIS_MAX_WIDTH = requiredCategoryAxisWidth(CATEGORY_AXIS_MAX_LINE_CHARS * CATEGORY_AXIS_TRIM_CHAR_WIDTH);
|
|
2138
|
+
function charsPerLine(yAxisWidth, charWidth = CATEGORY_AXIS_TRIM_CHAR_WIDTH) {
|
|
2139
|
+
if (yAxisWidth <= 0) {
|
|
2140
|
+
return 0;
|
|
2141
|
+
}
|
|
2142
|
+
return Math.min(CATEGORY_AXIS_MAX_LINE_CHARS, maxCharsForPixelWidth(yAxisWidth - CATEGORY_AXIS_LAYOUT_INSET, charWidth));
|
|
2143
|
+
}
|
|
2144
|
+
function displayWidthForLines(lines, charWidth = CATEGORY_AXIS_TRIM_CHAR_WIDTH) {
|
|
2145
|
+
if (!lines?.length) {
|
|
2146
|
+
return 0;
|
|
2147
|
+
}
|
|
2148
|
+
const maxChars = Math.max(0, ...lines.map(line => Math.min(line.length, CATEGORY_AXIS_MAX_LINE_CHARS)));
|
|
2149
|
+
return maxChars * charWidth;
|
|
2150
|
+
}
|
|
2151
|
+
function cappedCharsPerLine(pixelOrLayoutLimit) {
|
|
2152
|
+
if (pixelOrLayoutLimit <= 0) {
|
|
2153
|
+
return 0;
|
|
2154
|
+
}
|
|
2155
|
+
return Math.min(CATEGORY_AXIS_MAX_LINE_CHARS, pixelOrLayoutLimit);
|
|
2156
|
+
}
|
|
2157
|
+
/** Content chars for trimLabel so the rendered string (with ...) stays within displayLimit. */
|
|
2158
|
+
function contentCharsForDisplayLimit(displayLimit) {
|
|
2159
|
+
if (displayLimit <= 0) {
|
|
2160
|
+
return 0;
|
|
2161
|
+
}
|
|
2162
|
+
return Math.min(CATEGORY_AXIS_MAX_CONTENT_CHARS, Math.max(0, displayLimit - 3));
|
|
2163
|
+
}
|
|
2164
|
+
function effectiveCharsPerLine(yAxisWidth, trimTicks = true, label) {
|
|
2165
|
+
const slots = charsPerLine(yAxisWidth);
|
|
2166
|
+
if (!trimTicks || slots <= 0) {
|
|
2167
|
+
return slots;
|
|
2168
|
+
}
|
|
2169
|
+
if (label === undefined) {
|
|
2170
|
+
return slots;
|
|
2171
|
+
}
|
|
2172
|
+
const labelLength = String(label).trim().length;
|
|
2173
|
+
return labelLength > slots ? contentCharsForDisplayLimit(slots) : slots;
|
|
2174
|
+
}
|
|
2175
|
+
/** Greedy word-wrap for category y-axis labels; ellipsis only on the final line. */
|
|
2176
|
+
function wrapCategoryLabel(label, charsPerLineLimit, maxLines, trimTicks = true) {
|
|
2177
|
+
const text = String(label ?? '').trim();
|
|
2178
|
+
const displayLimit = cappedCharsPerLine(charsPerLineLimit);
|
|
2179
|
+
const contentLimit = contentCharsForDisplayLimit(displayLimit);
|
|
2180
|
+
if (!text) {
|
|
2181
|
+
return [''];
|
|
2182
|
+
}
|
|
2183
|
+
if (!trimTicks || displayLimit <= 0 || maxLines <= 0) {
|
|
2184
|
+
return [text];
|
|
2185
|
+
}
|
|
2186
|
+
if (maxLines === 1 || text.length <= displayLimit) {
|
|
2187
|
+
return text.length <= displayLimit ? [text] : [trimLabel(text, contentLimit)];
|
|
2188
|
+
}
|
|
2189
|
+
const words = text.split(/\s+/).filter(Boolean);
|
|
2190
|
+
const lines = [];
|
|
2191
|
+
let currentLine = '';
|
|
2192
|
+
const pushLine = (line) => {
|
|
2193
|
+
if (line) {
|
|
2194
|
+
lines.push(line);
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
const trimRemaining = (remainingWords) => {
|
|
2198
|
+
// If we already filled maxLines, fold the last packed line into the truncated remainder.
|
|
2199
|
+
const overflowStart = lines.length >= maxLines ? maxLines - 1 : lines.length;
|
|
2200
|
+
const kept = lines.slice(0, overflowStart);
|
|
2201
|
+
const remainder = [...lines.slice(overflowStart), currentLine, ...remainingWords].filter(Boolean).join(' ').trim();
|
|
2202
|
+
kept.push(trimLabel(remainder, contentLimit));
|
|
2203
|
+
return kept;
|
|
2204
|
+
};
|
|
2205
|
+
for (let i = 0; i < words.length; i++) {
|
|
2206
|
+
const word = words[i];
|
|
2207
|
+
if (word.length > displayLimit) {
|
|
2208
|
+
pushLine(currentLine);
|
|
2209
|
+
currentLine = '';
|
|
2210
|
+
if (lines.length >= maxLines || lines.length === maxLines - 1) {
|
|
2211
|
+
return trimRemaining(words.slice(i));
|
|
2212
|
+
}
|
|
2213
|
+
lines.push(trimLabel(word, contentLimit));
|
|
2214
|
+
continue;
|
|
2215
|
+
}
|
|
2216
|
+
const candidate = currentLine ? `${currentLine} ${word}` : word;
|
|
2217
|
+
if (candidate.length <= displayLimit) {
|
|
2218
|
+
currentLine = candidate;
|
|
2219
|
+
continue;
|
|
2220
|
+
}
|
|
2221
|
+
pushLine(currentLine);
|
|
2222
|
+
currentLine = word;
|
|
2223
|
+
if (lines.length >= maxLines) {
|
|
2224
|
+
return trimRemaining(words.slice(i + 1));
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
pushLine(currentLine);
|
|
2228
|
+
if (lines.length > maxLines) {
|
|
2229
|
+
const kept = lines.slice(0, maxLines - 1);
|
|
2230
|
+
const remainder = lines.slice(maxLines - 1).join(' ');
|
|
2231
|
+
kept.push(trimLabel(remainder, contentLimit));
|
|
2232
|
+
return kept;
|
|
2233
|
+
}
|
|
2234
|
+
return lines;
|
|
2235
|
+
}
|
|
2236
|
+
function displayLinesForLabel(label, yAxisWidth, trimTicks, wrapTicks, maxLines = DEFAULT_CATEGORY_WRAP_MAX_LINES) {
|
|
2237
|
+
const text = String(label).trim();
|
|
2238
|
+
if (!trimTicks) {
|
|
2239
|
+
return [text];
|
|
2240
|
+
}
|
|
2241
|
+
const limit = charsPerLine(yAxisWidth);
|
|
2242
|
+
if (limit <= 0) {
|
|
2243
|
+
return [trimLabel(text, CATEGORY_AXIS_MAX_CONTENT_CHARS)];
|
|
2244
|
+
}
|
|
2245
|
+
if (!wrapTicks || !/\s/.test(text)) {
|
|
2246
|
+
const contentMax = effectiveCharsPerLine(yAxisWidth, trimTicks, text);
|
|
2247
|
+
return text.length <= contentMax ? [text] : [trimLabel(text, contentMax)];
|
|
2248
|
+
}
|
|
2249
|
+
const wrapped = wrapCategoryLabel(text, limit, Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES), trimTicks);
|
|
2250
|
+
return wrapped.length ? wrapped : [text];
|
|
2251
|
+
}
|
|
2252
|
+
function resolveCategoryAxisLayout(labels, trimTicks = true, wrapTicks = true, maxLines = DEFAULT_CATEGORY_WRAP_MAX_LINES, initialYAxisWidth = 0) {
|
|
2253
|
+
if (!labels?.length) {
|
|
2254
|
+
return { yAxisWidth: 0, charsPerLine: 0 };
|
|
2255
|
+
}
|
|
2256
|
+
const wrapLineLimit = Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES);
|
|
2257
|
+
let yAxisWidth = initialYAxisWidth > 0
|
|
2258
|
+
? Math.min(initialYAxisWidth, CATEGORY_AXIS_MAX_WIDTH)
|
|
2259
|
+
: requiredCategoryAxisWidth(Math.max(0, ...labels.map(label => {
|
|
2260
|
+
const text = String(label).trim();
|
|
2261
|
+
if (!trimTicks) {
|
|
2262
|
+
return Math.min(text.length, CATEGORY_AXIS_MAX_LINE_CHARS) * CATEGORY_AXIS_TRIM_CHAR_WIDTH;
|
|
2263
|
+
}
|
|
2264
|
+
const displayChars = text.length <= CATEGORY_AXIS_MAX_LINE_CHARS ? text.length : CATEGORY_AXIS_MAX_LINE_CHARS;
|
|
2265
|
+
return displayChars * CATEGORY_AXIS_TRIM_CHAR_WIDTH;
|
|
2266
|
+
})));
|
|
2267
|
+
yAxisWidth = Math.min(yAxisWidth, CATEGORY_AXIS_MAX_WIDTH);
|
|
2268
|
+
for (let i = 0; i < 5; i++) {
|
|
2269
|
+
let maxTextWidth = 0;
|
|
2270
|
+
for (const label of labels) {
|
|
2271
|
+
const lines = displayLinesForLabel(label, yAxisWidth, trimTicks, wrapTicks, wrapLineLimit);
|
|
2272
|
+
maxTextWidth = Math.max(maxTextWidth, displayWidthForLines(lines));
|
|
2273
|
+
}
|
|
2274
|
+
const nextYAxisWidth = Math.min(requiredCategoryAxisWidth(maxTextWidth), CATEGORY_AXIS_MAX_WIDTH);
|
|
2275
|
+
if (nextYAxisWidth === yAxisWidth) {
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
yAxisWidth = nextYAxisWidth;
|
|
2279
|
+
}
|
|
2280
|
+
return { yAxisWidth, charsPerLine: charsPerLine(yAxisWidth) };
|
|
2281
|
+
}
|
|
2282
|
+
/** Left edge of longest tick label given layout inputs (horizontal left y-axis). */
|
|
2283
|
+
function categoryLabelLeftFromLayout(marginsLeft, yAxisWidth, textWidth) {
|
|
2284
|
+
const tickOffset = CATEGORY_AXIS_Y_PADDING + CATEGORY_AXIS_INNER_TICK_SIZE + CATEGORY_AXIS_TICK_PADDING;
|
|
2285
|
+
return marginsLeft + yAxisWidth + CATEGORY_AXIS_VIEW_DIMS_SPACER - tickOffset - textWidth;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2077
2288
|
class YAxisTicksComponent {
|
|
2078
2289
|
constructor(platformId) {
|
|
2079
2290
|
this.platformId = platformId;
|
|
@@ -2094,32 +2305,25 @@ class YAxisTicksComponent {
|
|
|
2094
2305
|
this.outerTickSize = 6;
|
|
2095
2306
|
this.rotateLabels = false;
|
|
2096
2307
|
this.referenceLineLength = 0;
|
|
2308
|
+
/** Stable axis width for truncation/wrapping; never updated from DOM measurement. */
|
|
2309
|
+
this.layoutAxisWidth = 0;
|
|
2310
|
+
this.lastEmittedWidth = null;
|
|
2097
2311
|
this.Orientation = Orientation;
|
|
2098
2312
|
}
|
|
2099
2313
|
ngOnChanges(changes) {
|
|
2100
2314
|
this.update();
|
|
2101
2315
|
}
|
|
2102
2316
|
ngAfterViewInit() {
|
|
2103
|
-
// Browser: measure after paint. SSR width is applied synchronously in update().
|
|
2104
2317
|
if (isPlatformBrowser(this.platformId)) {
|
|
2105
2318
|
setTimeout(() => this.updateDims());
|
|
2106
2319
|
}
|
|
2107
2320
|
}
|
|
2108
2321
|
updateDims() {
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
if (width > 0 && width !== this.width) {
|
|
2113
|
-
this.width = width;
|
|
2114
|
-
this.dimensionsChanged.emit({ width: this.width });
|
|
2115
|
-
}
|
|
2116
|
-
return;
|
|
2117
|
-
}
|
|
2118
|
-
const width = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().width, 10);
|
|
2119
|
-
if (width !== this.width) {
|
|
2322
|
+
const width = Math.min(this.getMeasuredAxisWidth(), CATEGORY_AXIS_MAX_WIDTH);
|
|
2323
|
+
if (width > 0 && width !== this.lastEmittedWidth) {
|
|
2324
|
+
this.lastEmittedWidth = width;
|
|
2120
2325
|
this.width = width;
|
|
2121
2326
|
this.dimensionsChanged.emit({ width });
|
|
2122
|
-
setTimeout(() => this.updateDims());
|
|
2123
2327
|
}
|
|
2124
2328
|
}
|
|
2125
2329
|
update() {
|
|
@@ -2142,9 +2346,9 @@ class YAxisTicksComponent {
|
|
|
2142
2346
|
return d.toLocaleString();
|
|
2143
2347
|
};
|
|
2144
2348
|
}
|
|
2349
|
+
this.resolveLayoutAxisWidth();
|
|
2145
2350
|
this.adjustedScale = scale.bandwidth
|
|
2146
2351
|
? d => {
|
|
2147
|
-
// position the tick to middle considering number of lines of the tick
|
|
2148
2352
|
const positionMiddle = scale(d) + scale.bandwidth() * 0.5;
|
|
2149
2353
|
if (this.wrapTicks && d.toString().length > this.maxTickLength) {
|
|
2150
2354
|
const chunksLength = this.tickChunks(d).length;
|
|
@@ -2201,14 +2405,31 @@ class YAxisTicksComponent {
|
|
|
2201
2405
|
break;
|
|
2202
2406
|
default:
|
|
2203
2407
|
}
|
|
2204
|
-
// SSR must reserve axis width before HTML serialize (no deferred setTimeout).
|
|
2205
2408
|
if (!isPlatformBrowser(this.platformId)) {
|
|
2206
|
-
this.
|
|
2409
|
+
this.applySsrAxisLayout();
|
|
2207
2410
|
}
|
|
2208
2411
|
else {
|
|
2209
2412
|
setTimeout(() => this.updateDims());
|
|
2210
2413
|
}
|
|
2211
2414
|
}
|
|
2415
|
+
resolveLayoutAxisWidth() {
|
|
2416
|
+
if (!this.ticks?.length || !this.tickFormat) {
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
const labels = this.ticks.map(t => String(this.tickFormat(t)));
|
|
2420
|
+
const layout = YAxisTicksComponent.resolveAxisLayout(labels, this.trimTicks, this.maxTickLength, this.wrapTicks);
|
|
2421
|
+
this.layoutAxisWidth = layout.yAxisWidth;
|
|
2422
|
+
}
|
|
2423
|
+
applySsrAxisLayout() {
|
|
2424
|
+
if (this.layoutAxisWidth > 0 && this.layoutAxisWidth !== this.lastEmittedWidth) {
|
|
2425
|
+
this.lastEmittedWidth = this.layoutAxisWidth;
|
|
2426
|
+
this.width = this.layoutAxisWidth;
|
|
2427
|
+
this.dimensionsChanged.emit({ width: this.layoutAxisWidth });
|
|
2428
|
+
}
|
|
2429
|
+
else if (this.layoutAxisWidth > 0) {
|
|
2430
|
+
this.width = this.layoutAxisWidth;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2212
2433
|
setReferencelines() {
|
|
2213
2434
|
this.refMin = this.adjustedScale(Math.min.apply(null, this.referenceLines.map(item => item.value)));
|
|
2214
2435
|
this.refMax = this.adjustedScale(Math.max.apply(null, this.referenceLines.map(item => item.value)));
|
|
@@ -2246,35 +2467,115 @@ class YAxisTicksComponent {
|
|
|
2246
2467
|
return `translate(5,0)`;
|
|
2247
2468
|
}
|
|
2248
2469
|
tickTrim(label) {
|
|
2249
|
-
|
|
2470
|
+
if (!this.trimTicks) {
|
|
2471
|
+
return label;
|
|
2472
|
+
}
|
|
2473
|
+
return trimLabel(label, this.getEffectiveMaxTickLength(label));
|
|
2250
2474
|
}
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2475
|
+
getEffectiveMaxTickLength(label) {
|
|
2476
|
+
if (this.orient !== Orientation.Left && this.orient !== Orientation.Right) {
|
|
2477
|
+
return this.maxTickLength;
|
|
2478
|
+
}
|
|
2479
|
+
if (this.layoutAxisWidth <= 0) {
|
|
2480
|
+
return this.maxTickLength;
|
|
2481
|
+
}
|
|
2482
|
+
return YAxisTicksComponent.effectiveMaxTickLength(this.layoutAxisWidth, this.maxTickLength, this.trimTicks, label);
|
|
2483
|
+
}
|
|
2484
|
+
static { this.Y_AXIS_PADDING = CATEGORY_AXIS_Y_PADDING; }
|
|
2485
|
+
static { this.VIEW_DIMS_Y_AXIS_SPACER = CATEGORY_AXIS_VIEW_DIMS_SPACER; }
|
|
2486
|
+
static { this.INNER_TICK_SIZE = CATEGORY_AXIS_INNER_TICK_SIZE; }
|
|
2487
|
+
static { this.TICK_PADDING = CATEGORY_AXIS_TICK_PADDING; }
|
|
2488
|
+
static { this.AXIS_LAYOUT_INSET = CATEGORY_AXIS_LAYOUT_INSET; }
|
|
2489
|
+
static { this.APPROX_CHAR_WIDTH = 6; }
|
|
2490
|
+
static { this.TRIM_CHAR_WIDTH = CATEGORY_AXIS_TRIM_CHAR_WIDTH; }
|
|
2491
|
+
static effectiveMaxTickLength(yAxisWidth, maxTickLength, trimTicks = true, label) {
|
|
2492
|
+
if (!trimTicks || yAxisWidth <= 0) {
|
|
2493
|
+
return maxTickLength;
|
|
2494
|
+
}
|
|
2495
|
+
const limit = charsPerLine(yAxisWidth);
|
|
2496
|
+
if (limit <= 0) {
|
|
2497
|
+
return maxTickLength;
|
|
2498
|
+
}
|
|
2499
|
+
if (label === undefined) {
|
|
2500
|
+
return limit;
|
|
2501
|
+
}
|
|
2502
|
+
const labelLength = String(label).trim().length;
|
|
2503
|
+
return labelLength > limit ? Math.max(0, limit - 3) : limit;
|
|
2504
|
+
}
|
|
2505
|
+
/**
|
|
2506
|
+
* Tick label width without DOM measurement. SSR serializes before the tick component's
|
|
2507
|
+
* `dimensionsChanged` emission is applied, so charts seed their y-axis width from this during `update()`.
|
|
2508
|
+
*/
|
|
2509
|
+
static approximateTicksWidth(options) {
|
|
2510
|
+
const ticks = new YAxisTicksComponent('server');
|
|
2511
|
+
ticks.orient = Orientation.Left;
|
|
2512
|
+
for (const [key, value] of Object.entries(options)) {
|
|
2513
|
+
if (value !== undefined && value !== null) {
|
|
2514
|
+
ticks[key] = value;
|
|
2515
|
+
}
|
|
2256
2516
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2517
|
+
ticks.ticks = ticks.getTicks();
|
|
2518
|
+
ticks.tickFormat = ticks.tickFormatting ?? ticks.scale.tickFormat(...ticks.tickArguments);
|
|
2519
|
+
ticks.resolveLayoutAxisWidth();
|
|
2520
|
+
return ticks.layoutAxisWidth;
|
|
2521
|
+
}
|
|
2522
|
+
static approximateTickLabelsWidth(labels, trimTicks = true, maxTickLength = 16, wrapTicks = true) {
|
|
2523
|
+
return YAxisTicksComponent.resolveAxisLayout(labels, trimTicks, maxTickLength, wrapTicks).yAxisWidth;
|
|
2524
|
+
}
|
|
2525
|
+
static resolveAxisLayout(labels, trimTicks = true, maxTickLength = 16, wrapTicks = true) {
|
|
2526
|
+
const layout = resolveCategoryAxisLayout(labels, trimTicks, wrapTicks);
|
|
2527
|
+
return { yAxisWidth: layout.yAxisWidth, maxTickLength };
|
|
2528
|
+
}
|
|
2529
|
+
static requiredYAxisWidth(textWidth) {
|
|
2530
|
+
return requiredCategoryAxisWidth(textWidth);
|
|
2531
|
+
}
|
|
2532
|
+
static labelLeftFromLayout(marginsLeft, yAxisWidth, textWidth) {
|
|
2533
|
+
return categoryLabelLeftFromLayout(marginsLeft, yAxisWidth, textWidth);
|
|
2259
2534
|
}
|
|
2260
2535
|
getApproximateAxisWidth() {
|
|
2261
2536
|
if (!this.ticks?.length || !this.tickFormat) {
|
|
2262
2537
|
return 0;
|
|
2263
2538
|
}
|
|
2264
|
-
const labels = this.ticks.map(t =>
|
|
2265
|
-
return YAxisTicksComponent.
|
|
2539
|
+
const labels = this.ticks.map(t => String(this.tickFormat(t)));
|
|
2540
|
+
return YAxisTicksComponent.resolveAxisLayout(labels, this.trimTicks, this.maxTickLength, this.wrapTicks).yAxisWidth;
|
|
2541
|
+
}
|
|
2542
|
+
getMeasuredAxisWidth() {
|
|
2543
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
2544
|
+
return this.getApproximateAxisWidth();
|
|
2545
|
+
}
|
|
2546
|
+
if (!this.ticksElement?.nativeElement) {
|
|
2547
|
+
return 0;
|
|
2548
|
+
}
|
|
2549
|
+
const bboxWidth = parseInt(this.ticksElement.nativeElement.getBoundingClientRect().width, 10);
|
|
2550
|
+
const tickSpacing = this.tickSpacing ?? YAxisTicksComponent.INNER_TICK_SIZE + YAxisTicksComponent.TICK_PADDING;
|
|
2551
|
+
const textWidth = Math.max(0, bboxWidth - tickSpacing);
|
|
2552
|
+
return YAxisTicksComponent.requiredYAxisWidth(textWidth);
|
|
2266
2553
|
}
|
|
2267
2554
|
tickChunks(label) {
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2555
|
+
const formatted = String(this.tickFormat(label));
|
|
2556
|
+
if (this.orient === Orientation.Left || this.orient === Orientation.Right) {
|
|
2557
|
+
if (!this.wrapTicks || !this.scale.bandwidth) {
|
|
2558
|
+
return [this.tickTrim(formatted)];
|
|
2559
|
+
}
|
|
2560
|
+
const maxLines = Math.min(Math.floor(this.scale.bandwidth() / 15), DEFAULT_CATEGORY_WRAP_MAX_LINES);
|
|
2561
|
+
if (maxLines <= 1) {
|
|
2562
|
+
return [this.tickTrim(formatted)];
|
|
2563
|
+
}
|
|
2564
|
+
const perLine = cappedCharsPerLine(this.layoutAxisWidth > 0 ? charsPerLine(this.layoutAxisWidth) : this.getEffectiveMaxTickLength(formatted));
|
|
2565
|
+
if (perLine <= 0 || formatted.length <= perLine) {
|
|
2566
|
+
return [formatted];
|
|
2567
|
+
}
|
|
2568
|
+
const lines = wrapCategoryLabel(formatted, perLine, maxLines, this.trimTicks);
|
|
2569
|
+
return lines.length > 1 ? lines : [this.tickTrim(formatted)];
|
|
2570
|
+
}
|
|
2571
|
+
if (formatted.length > this.maxTickLength && this.scale.bandwidth) {
|
|
2271
2572
|
const maxLines = Math.floor(this.scale.bandwidth() / 15);
|
|
2272
2573
|
if (maxLines <= 1) {
|
|
2273
|
-
return [this.tickTrim(
|
|
2574
|
+
return [this.tickTrim(formatted)];
|
|
2274
2575
|
}
|
|
2275
|
-
return getTickLines(
|
|
2576
|
+
return getTickLines(formatted, this.maxTickLength, Math.min(maxLines, DEFAULT_CATEGORY_WRAP_MAX_LINES));
|
|
2276
2577
|
}
|
|
2277
|
-
return [
|
|
2578
|
+
return [formatted];
|
|
2278
2579
|
}
|
|
2279
2580
|
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 }); }
|
|
2280
2581
|
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: `
|
|
@@ -3894,6 +4195,12 @@ class TooltipArea {
|
|
|
3894
4195
|
this.showPercentage = false;
|
|
3895
4196
|
this.tooltipDisabled = false;
|
|
3896
4197
|
this.hover = new EventEmitter();
|
|
4198
|
+
this.isSSR = false;
|
|
4199
|
+
}
|
|
4200
|
+
ngOnInit() {
|
|
4201
|
+
if (isPlatformServer(this.platformId)) {
|
|
4202
|
+
this.isSSR = true;
|
|
4203
|
+
}
|
|
3897
4204
|
}
|
|
3898
4205
|
getValues(xVal) {
|
|
3899
4206
|
const results = [];
|
|
@@ -4026,7 +4333,7 @@ class TooltipArea {
|
|
|
4026
4333
|
return result;
|
|
4027
4334
|
}
|
|
4028
4335
|
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 }); }
|
|
4029
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
4336
|
+
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: `
|
|
4030
4337
|
<svg:g>
|
|
4031
4338
|
<svg:rect
|
|
4032
4339
|
class="tooltip-area"
|
|
@@ -4046,6 +4353,7 @@ class TooltipArea {
|
|
|
4046
4353
|
</xhtml:div>
|
|
4047
4354
|
</xhtml:div>
|
|
4048
4355
|
</ng-template>
|
|
4356
|
+
@if (!isSSR) {
|
|
4049
4357
|
<svg:rect
|
|
4050
4358
|
#tooltipAnchor
|
|
4051
4359
|
[@animationState]="anchorOpacity !== 0 ? 'active' : 'inactive'"
|
|
@@ -4065,6 +4373,26 @@ class TooltipArea {
|
|
|
4065
4373
|
[tooltipContext]="anchorValues"
|
|
4066
4374
|
[tooltipImmediateExit]="true"
|
|
4067
4375
|
/>
|
|
4376
|
+
} @else {
|
|
4377
|
+
<svg:rect
|
|
4378
|
+
#tooltipAnchor
|
|
4379
|
+
class="tooltip-anchor"
|
|
4380
|
+
[attr.x]="anchorPos"
|
|
4381
|
+
y="0"
|
|
4382
|
+
[attr.width]="1"
|
|
4383
|
+
[attr.height]="dims.height"
|
|
4384
|
+
[style.opacity]="anchorOpacity"
|
|
4385
|
+
[style.pointer-events]="'none'"
|
|
4386
|
+
ngx-tooltip
|
|
4387
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
4388
|
+
[tooltipPlacement]="placementTypes.Right"
|
|
4389
|
+
[tooltipType]="styleTypes.tooltip"
|
|
4390
|
+
[tooltipSpacing]="15"
|
|
4391
|
+
[tooltipTemplate]="tooltipTemplate ? tooltipTemplate : defaultTooltipTemplate"
|
|
4392
|
+
[tooltipContext]="anchorValues"
|
|
4393
|
+
[tooltipImmediateExit]="true"
|
|
4394
|
+
/>
|
|
4395
|
+
}
|
|
4068
4396
|
</svg:g>
|
|
4069
4397
|
`, 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: [
|
|
4070
4398
|
trigger('animationState', [
|
|
@@ -4107,6 +4435,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
4107
4435
|
</xhtml:div>
|
|
4108
4436
|
</xhtml:div>
|
|
4109
4437
|
</ng-template>
|
|
4438
|
+
@if (!isSSR) {
|
|
4110
4439
|
<svg:rect
|
|
4111
4440
|
#tooltipAnchor
|
|
4112
4441
|
[@animationState]="anchorOpacity !== 0 ? 'active' : 'inactive'"
|
|
@@ -4126,6 +4455,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
4126
4455
|
[tooltipContext]="anchorValues"
|
|
4127
4456
|
[tooltipImmediateExit]="true"
|
|
4128
4457
|
/>
|
|
4458
|
+
} @else {
|
|
4459
|
+
<svg:rect
|
|
4460
|
+
#tooltipAnchor
|
|
4461
|
+
class="tooltip-anchor"
|
|
4462
|
+
[attr.x]="anchorPos"
|
|
4463
|
+
y="0"
|
|
4464
|
+
[attr.width]="1"
|
|
4465
|
+
[attr.height]="dims.height"
|
|
4466
|
+
[style.opacity]="anchorOpacity"
|
|
4467
|
+
[style.pointer-events]="'none'"
|
|
4468
|
+
ngx-tooltip
|
|
4469
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
4470
|
+
[tooltipPlacement]="placementTypes.Right"
|
|
4471
|
+
[tooltipType]="styleTypes.tooltip"
|
|
4472
|
+
[tooltipSpacing]="15"
|
|
4473
|
+
[tooltipTemplate]="tooltipTemplate ? tooltipTemplate : defaultTooltipTemplate"
|
|
4474
|
+
[tooltipContext]="anchorValues"
|
|
4475
|
+
[tooltipImmediateExit]="true"
|
|
4476
|
+
/>
|
|
4477
|
+
}
|
|
4129
4478
|
</svg:g>
|
|
4130
4479
|
`,
|
|
4131
4480
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -5404,7 +5753,9 @@ class AreaChartComponent extends BaseChartComponent {
|
|
|
5404
5753
|
}
|
|
5405
5754
|
this.yDomain = this.getYDomain();
|
|
5406
5755
|
this.seriesDomain = this.getSeriesDomain();
|
|
5756
|
+
this.seedYAxisWidthForSsr();
|
|
5407
5757
|
this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
|
5758
|
+
this.seedXAxisHeightForSsr();
|
|
5408
5759
|
this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
|
5409
5760
|
this.updateTimeline();
|
|
5410
5761
|
this.setColors();
|
|
@@ -5573,6 +5924,43 @@ class AreaChartComponent extends BaseChartComponent {
|
|
|
5573
5924
|
this.yAxisWidth = width;
|
|
5574
5925
|
this.update();
|
|
5575
5926
|
}
|
|
5927
|
+
/** SSR serializes before the y-axis tick width emission lands, so reserve its width up front. */
|
|
5928
|
+
seedYAxisWidthForSsr() {
|
|
5929
|
+
if (!this.yAxis || !isPlatformServer(this.platformId)) {
|
|
5930
|
+
return;
|
|
5931
|
+
}
|
|
5932
|
+
const width = YAxisTicksComponent.approximateTicksWidth({
|
|
5933
|
+
scale: this.getYScale(this.yDomain, this.dims.height),
|
|
5934
|
+
height: this.dims.height,
|
|
5935
|
+
tickValues: this.yAxisTicks,
|
|
5936
|
+
tickFormatting: this.yAxisTickFormatting,
|
|
5937
|
+
trimTicks: this.trimYAxisTicks,
|
|
5938
|
+
maxTickLength: this.maxYAxisTickLength,
|
|
5939
|
+
wrapTicks: this.wrapTicks
|
|
5940
|
+
});
|
|
5941
|
+
const delta = width - this.yAxisWidth;
|
|
5942
|
+
this.dims.width = Math.max(0, this.dims.width - delta);
|
|
5943
|
+
this.dims.xOffset += delta;
|
|
5944
|
+
this.yAxisWidth = width;
|
|
5945
|
+
}
|
|
5946
|
+
/** SSR serializes before the deferred x-axis tick measurement lands, so reserve its height up front. */
|
|
5947
|
+
seedXAxisHeightForSsr() {
|
|
5948
|
+
if (!this.xAxis || !isPlatformServer(this.platformId)) {
|
|
5949
|
+
return;
|
|
5950
|
+
}
|
|
5951
|
+
const height = XAxisTicksComponent.approximateTicksHeight({
|
|
5952
|
+
scale: this.xScale,
|
|
5953
|
+
width: this.dims.width,
|
|
5954
|
+
tickValues: this.xAxisTicks,
|
|
5955
|
+
tickFormatting: this.xAxisTickFormatting,
|
|
5956
|
+
trimTicks: this.trimXAxisTicks,
|
|
5957
|
+
rotateTicks: this.rotateXAxisTicks,
|
|
5958
|
+
maxTickLength: this.maxXAxisTickLength,
|
|
5959
|
+
wrapTicks: this.wrapTicks
|
|
5960
|
+
});
|
|
5961
|
+
this.dims.height = Math.max(0, this.dims.height - (height - this.xAxisHeight));
|
|
5962
|
+
this.xAxisHeight = height;
|
|
5963
|
+
}
|
|
5576
5964
|
updateXAxisHeight({ height }) {
|
|
5577
5965
|
this.xAxisHeight = height;
|
|
5578
5966
|
this.update();
|
|
@@ -6021,7 +6409,9 @@ class AreaChartNormalizedComponent extends BaseChartComponent {
|
|
|
6021
6409
|
this.xDomain = this.filteredDomain;
|
|
6022
6410
|
}
|
|
6023
6411
|
this.seriesDomain = this.getSeriesDomain();
|
|
6412
|
+
this.seedYAxisWidthForSsr();
|
|
6024
6413
|
this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
|
6414
|
+
this.seedXAxisHeightForSsr();
|
|
6025
6415
|
this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
|
6026
6416
|
for (let i = 0; i < this.xSet.length; i++) {
|
|
6027
6417
|
const val = this.xSet[i];
|
|
@@ -6196,6 +6586,43 @@ class AreaChartNormalizedComponent extends BaseChartComponent {
|
|
|
6196
6586
|
this.yAxisWidth = width;
|
|
6197
6587
|
this.update();
|
|
6198
6588
|
}
|
|
6589
|
+
/** SSR serializes before the y-axis tick width emission lands, so reserve its width up front. */
|
|
6590
|
+
seedYAxisWidthForSsr() {
|
|
6591
|
+
if (!this.yAxis || !isPlatformServer(this.platformId)) {
|
|
6592
|
+
return;
|
|
6593
|
+
}
|
|
6594
|
+
const width = YAxisTicksComponent.approximateTicksWidth({
|
|
6595
|
+
scale: this.getYScale(this.yDomain, this.dims.height),
|
|
6596
|
+
height: this.dims.height,
|
|
6597
|
+
tickValues: this.yAxisTicks,
|
|
6598
|
+
tickFormatting: this.yAxisTickFormatting,
|
|
6599
|
+
trimTicks: this.trimYAxisTicks,
|
|
6600
|
+
maxTickLength: this.maxYAxisTickLength,
|
|
6601
|
+
wrapTicks: this.wrapTicks
|
|
6602
|
+
});
|
|
6603
|
+
const delta = width - this.yAxisWidth;
|
|
6604
|
+
this.dims.width = Math.max(0, this.dims.width - delta);
|
|
6605
|
+
this.dims.xOffset += delta;
|
|
6606
|
+
this.yAxisWidth = width;
|
|
6607
|
+
}
|
|
6608
|
+
/** SSR serializes before the deferred x-axis tick measurement lands, so reserve its height up front. */
|
|
6609
|
+
seedXAxisHeightForSsr() {
|
|
6610
|
+
if (!this.xAxis || !isPlatformServer(this.platformId)) {
|
|
6611
|
+
return;
|
|
6612
|
+
}
|
|
6613
|
+
const height = XAxisTicksComponent.approximateTicksHeight({
|
|
6614
|
+
scale: this.xScale,
|
|
6615
|
+
width: this.dims.width,
|
|
6616
|
+
tickValues: this.xAxisTicks,
|
|
6617
|
+
tickFormatting: this.xAxisTickFormatting,
|
|
6618
|
+
trimTicks: this.trimXAxisTicks,
|
|
6619
|
+
rotateTicks: this.rotateXAxisTicks,
|
|
6620
|
+
maxTickLength: this.maxXAxisTickLength,
|
|
6621
|
+
wrapTicks: this.wrapTicks
|
|
6622
|
+
});
|
|
6623
|
+
this.dims.height = Math.max(0, this.dims.height - (height - this.xAxisHeight));
|
|
6624
|
+
this.xAxisHeight = height;
|
|
6625
|
+
}
|
|
6199
6626
|
updateXAxisHeight({ height }) {
|
|
6200
6627
|
this.xAxisHeight = height;
|
|
6201
6628
|
this.update();
|
|
@@ -6622,7 +7049,9 @@ class AreaChartStackedComponent extends BaseChartComponent {
|
|
|
6622
7049
|
}
|
|
6623
7050
|
this.yDomain = this.getYDomain();
|
|
6624
7051
|
this.seriesDomain = this.getSeriesDomain();
|
|
7052
|
+
this.seedYAxisWidthForSsr();
|
|
6625
7053
|
this.xScale = this.getXScale(this.xDomain, this.dims.width);
|
|
7054
|
+
this.seedXAxisHeightForSsr();
|
|
6626
7055
|
this.yScale = this.getYScale(this.yDomain, this.dims.height);
|
|
6627
7056
|
for (let i = 0; i < this.xSet.length; i++) {
|
|
6628
7057
|
const val = this.xSet[i];
|
|
@@ -6806,6 +7235,43 @@ class AreaChartStackedComponent extends BaseChartComponent {
|
|
|
6806
7235
|
this.yAxisWidth = width;
|
|
6807
7236
|
this.update();
|
|
6808
7237
|
}
|
|
7238
|
+
/** SSR serializes before the y-axis tick width emission lands, so reserve its width up front. */
|
|
7239
|
+
seedYAxisWidthForSsr() {
|
|
7240
|
+
if (!this.yAxis || !isPlatformServer(this.platformId)) {
|
|
7241
|
+
return;
|
|
7242
|
+
}
|
|
7243
|
+
const width = YAxisTicksComponent.approximateTicksWidth({
|
|
7244
|
+
scale: this.getYScale(this.yDomain, this.dims.height),
|
|
7245
|
+
height: this.dims.height,
|
|
7246
|
+
tickValues: this.yAxisTicks,
|
|
7247
|
+
tickFormatting: this.yAxisTickFormatting,
|
|
7248
|
+
trimTicks: this.trimYAxisTicks,
|
|
7249
|
+
maxTickLength: this.maxYAxisTickLength,
|
|
7250
|
+
wrapTicks: this.wrapTicks
|
|
7251
|
+
});
|
|
7252
|
+
const delta = width - this.yAxisWidth;
|
|
7253
|
+
this.dims.width = Math.max(0, this.dims.width - delta);
|
|
7254
|
+
this.dims.xOffset += delta;
|
|
7255
|
+
this.yAxisWidth = width;
|
|
7256
|
+
}
|
|
7257
|
+
/** SSR serializes before the deferred x-axis tick measurement lands, so reserve its height up front. */
|
|
7258
|
+
seedXAxisHeightForSsr() {
|
|
7259
|
+
if (!this.xAxis || !isPlatformServer(this.platformId)) {
|
|
7260
|
+
return;
|
|
7261
|
+
}
|
|
7262
|
+
const height = XAxisTicksComponent.approximateTicksHeight({
|
|
7263
|
+
scale: this.xScale,
|
|
7264
|
+
width: this.dims.width,
|
|
7265
|
+
tickValues: this.xAxisTicks,
|
|
7266
|
+
tickFormatting: this.xAxisTickFormatting,
|
|
7267
|
+
trimTicks: this.trimXAxisTicks,
|
|
7268
|
+
rotateTicks: this.rotateXAxisTicks,
|
|
7269
|
+
maxTickLength: this.maxXAxisTickLength,
|
|
7270
|
+
wrapTicks: this.wrapTicks
|
|
7271
|
+
});
|
|
7272
|
+
this.dims.height = Math.max(0, this.dims.height - (height - this.xAxisHeight));
|
|
7273
|
+
this.xAxisHeight = height;
|
|
7274
|
+
}
|
|
6809
7275
|
updateXAxisHeight({ height }) {
|
|
6810
7276
|
this.xAxisHeight = height;
|
|
6811
7277
|
this.update();
|
|
@@ -7557,7 +8023,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
7557
8023
|
}] } });
|
|
7558
8024
|
|
|
7559
8025
|
class SeriesHorizontal {
|
|
7560
|
-
constructor() {
|
|
8026
|
+
constructor(platformId) {
|
|
8027
|
+
this.platformId = platformId;
|
|
7561
8028
|
this.type = BarChartType.Standard;
|
|
7562
8029
|
this.tooltipDisabled = false;
|
|
7563
8030
|
this.animations = true;
|
|
@@ -7569,6 +8036,12 @@ class SeriesHorizontal {
|
|
|
7569
8036
|
this.dataLabelWidthChanged = new EventEmitter();
|
|
7570
8037
|
this.barsForDataLabels = [];
|
|
7571
8038
|
this.barOrientation = BarOrientation;
|
|
8039
|
+
this.isSSR = false;
|
|
8040
|
+
}
|
|
8041
|
+
ngOnInit() {
|
|
8042
|
+
if (isPlatformServer(this.platformId)) {
|
|
8043
|
+
this.isSSR = true;
|
|
8044
|
+
}
|
|
7572
8045
|
}
|
|
7573
8046
|
ngOnChanges() {
|
|
7574
8047
|
this.update();
|
|
@@ -7729,38 +8202,73 @@ class SeriesHorizontal {
|
|
|
7729
8202
|
click(data) {
|
|
7730
8203
|
this.select.emit(data);
|
|
7731
8204
|
}
|
|
7732
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SeriesHorizontal, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
7733
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
8205
|
+
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 }); }
|
|
8206
|
+
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: `
|
|
8207
|
+
@if (!isSSR) {
|
|
8208
|
+
<svg:g>
|
|
8209
|
+
<svg:g
|
|
8210
|
+
ngx-charts-bar
|
|
8211
|
+
*ngFor="let bar of bars; trackBy: trackBy"
|
|
8212
|
+
[@animationState]="'active'"
|
|
8213
|
+
[width]="bar.width"
|
|
8214
|
+
[height]="bar.height"
|
|
8215
|
+
[x]="bar.x"
|
|
8216
|
+
[y]="bar.y"
|
|
8217
|
+
[fill]="bar.color"
|
|
8218
|
+
[stops]="bar.gradientStops"
|
|
8219
|
+
[data]="bar.data"
|
|
8220
|
+
[orientation]="barOrientation.Horizontal"
|
|
8221
|
+
[roundEdges]="bar.roundEdges"
|
|
8222
|
+
(select)="click($event)"
|
|
8223
|
+
[gradient]="gradient"
|
|
8224
|
+
[isActive]="isActive(bar.data)"
|
|
8225
|
+
[ariaLabel]="bar.ariaLabel"
|
|
8226
|
+
[animations]="animations"
|
|
8227
|
+
(activate)="activate.emit($event)"
|
|
8228
|
+
(deactivate)="deactivate.emit($event)"
|
|
8229
|
+
ngx-tooltip
|
|
8230
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
8231
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
8232
|
+
[tooltipType]="tooltipType"
|
|
8233
|
+
[tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
|
|
8234
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
8235
|
+
[tooltipContext]="bar.data"
|
|
8236
|
+
[noBarWhenZero]="noBarWhenZero"
|
|
8237
|
+
></svg:g>
|
|
8238
|
+
</svg:g>
|
|
8239
|
+
} @else {
|
|
8240
|
+
<svg:g>
|
|
8241
|
+
<svg:g
|
|
8242
|
+
ngx-charts-bar
|
|
8243
|
+
*ngFor="let bar of bars; trackBy: trackBy"
|
|
8244
|
+
[width]="bar.width"
|
|
8245
|
+
[height]="bar.height"
|
|
8246
|
+
[x]="bar.x"
|
|
8247
|
+
[y]="bar.y"
|
|
8248
|
+
[fill]="bar.color"
|
|
8249
|
+
[stops]="bar.gradientStops"
|
|
8250
|
+
[data]="bar.data"
|
|
8251
|
+
[orientation]="barOrientation.Horizontal"
|
|
8252
|
+
[roundEdges]="bar.roundEdges"
|
|
8253
|
+
(select)="click($event)"
|
|
8254
|
+
[gradient]="gradient"
|
|
8255
|
+
[isActive]="isActive(bar.data)"
|
|
8256
|
+
[ariaLabel]="bar.ariaLabel"
|
|
8257
|
+
[animations]="animations"
|
|
8258
|
+
(activate)="activate.emit($event)"
|
|
8259
|
+
(deactivate)="deactivate.emit($event)"
|
|
8260
|
+
ngx-tooltip
|
|
8261
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
8262
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
8263
|
+
[tooltipType]="tooltipType"
|
|
8264
|
+
[tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
|
|
8265
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
8266
|
+
[tooltipContext]="bar.data"
|
|
8267
|
+
[noBarWhenZero]="noBarWhenZero"
|
|
8268
|
+
></svg:g>
|
|
8269
|
+
</svg:g>
|
|
8270
|
+
} @if (showDataLabel) {
|
|
8271
|
+
<svg:g>
|
|
7764
8272
|
<svg:g
|
|
7765
8273
|
ngx-charts-bar-label
|
|
7766
8274
|
*ngFor="let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy"
|
|
@@ -7774,7 +8282,8 @@ class SeriesHorizontal {
|
|
|
7774
8282
|
(dimensionsChanged)="dataLabelWidthChanged.emit({ size: $event, index: i })"
|
|
7775
8283
|
/>
|
|
7776
8284
|
</svg:g>
|
|
7777
|
-
|
|
8285
|
+
}
|
|
8286
|
+
`, 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: [
|
|
7778
8287
|
trigger('animationState', [
|
|
7779
8288
|
transition(':leave', [
|
|
7780
8289
|
style({
|
|
@@ -7790,36 +8299,71 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
7790
8299
|
args: [{
|
|
7791
8300
|
selector: 'g[ngx-charts-series-horizontal]',
|
|
7792
8301
|
template: `
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
8302
|
+
@if (!isSSR) {
|
|
8303
|
+
<svg:g>
|
|
8304
|
+
<svg:g
|
|
8305
|
+
ngx-charts-bar
|
|
8306
|
+
*ngFor="let bar of bars; trackBy: trackBy"
|
|
8307
|
+
[@animationState]="'active'"
|
|
8308
|
+
[width]="bar.width"
|
|
8309
|
+
[height]="bar.height"
|
|
8310
|
+
[x]="bar.x"
|
|
8311
|
+
[y]="bar.y"
|
|
8312
|
+
[fill]="bar.color"
|
|
8313
|
+
[stops]="bar.gradientStops"
|
|
8314
|
+
[data]="bar.data"
|
|
8315
|
+
[orientation]="barOrientation.Horizontal"
|
|
8316
|
+
[roundEdges]="bar.roundEdges"
|
|
8317
|
+
(select)="click($event)"
|
|
8318
|
+
[gradient]="gradient"
|
|
8319
|
+
[isActive]="isActive(bar.data)"
|
|
8320
|
+
[ariaLabel]="bar.ariaLabel"
|
|
8321
|
+
[animations]="animations"
|
|
8322
|
+
(activate)="activate.emit($event)"
|
|
8323
|
+
(deactivate)="deactivate.emit($event)"
|
|
8324
|
+
ngx-tooltip
|
|
8325
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
8326
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
8327
|
+
[tooltipType]="tooltipType"
|
|
8328
|
+
[tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
|
|
8329
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
8330
|
+
[tooltipContext]="bar.data"
|
|
8331
|
+
[noBarWhenZero]="noBarWhenZero"
|
|
8332
|
+
></svg:g>
|
|
8333
|
+
</svg:g>
|
|
8334
|
+
} @else {
|
|
8335
|
+
<svg:g>
|
|
8336
|
+
<svg:g
|
|
8337
|
+
ngx-charts-bar
|
|
8338
|
+
*ngFor="let bar of bars; trackBy: trackBy"
|
|
8339
|
+
[width]="bar.width"
|
|
8340
|
+
[height]="bar.height"
|
|
8341
|
+
[x]="bar.x"
|
|
8342
|
+
[y]="bar.y"
|
|
8343
|
+
[fill]="bar.color"
|
|
8344
|
+
[stops]="bar.gradientStops"
|
|
8345
|
+
[data]="bar.data"
|
|
8346
|
+
[orientation]="barOrientation.Horizontal"
|
|
8347
|
+
[roundEdges]="bar.roundEdges"
|
|
8348
|
+
(select)="click($event)"
|
|
8349
|
+
[gradient]="gradient"
|
|
8350
|
+
[isActive]="isActive(bar.data)"
|
|
8351
|
+
[ariaLabel]="bar.ariaLabel"
|
|
8352
|
+
[animations]="animations"
|
|
8353
|
+
(activate)="activate.emit($event)"
|
|
8354
|
+
(deactivate)="deactivate.emit($event)"
|
|
8355
|
+
ngx-tooltip
|
|
8356
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
8357
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
8358
|
+
[tooltipType]="tooltipType"
|
|
8359
|
+
[tooltipTitle]="tooltipTemplate ? undefined : bar.tooltipText"
|
|
8360
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
8361
|
+
[tooltipContext]="bar.data"
|
|
8362
|
+
[noBarWhenZero]="noBarWhenZero"
|
|
8363
|
+
></svg:g>
|
|
8364
|
+
</svg:g>
|
|
8365
|
+
} @if (showDataLabel) {
|
|
8366
|
+
<svg:g>
|
|
7823
8367
|
<svg:g
|
|
7824
8368
|
ngx-charts-bar-label
|
|
7825
8369
|
*ngFor="let b of barsForDataLabels; let i = index; trackBy: trackDataLabelBy"
|
|
@@ -7833,6 +8377,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
7833
8377
|
(dimensionsChanged)="dataLabelWidthChanged.emit({ size: $event, index: i })"
|
|
7834
8378
|
/>
|
|
7835
8379
|
</svg:g>
|
|
8380
|
+
}
|
|
7836
8381
|
`,
|
|
7837
8382
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
7838
8383
|
animations: [
|
|
@@ -7847,7 +8392,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
7847
8392
|
],
|
|
7848
8393
|
standalone: false
|
|
7849
8394
|
}]
|
|
7850
|
-
}],
|
|
8395
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
8396
|
+
type: Inject,
|
|
8397
|
+
args: [PLATFORM_ID]
|
|
8398
|
+
}] }], propDecorators: { dims: [{
|
|
7851
8399
|
type: Input
|
|
7852
8400
|
}], type: [{
|
|
7853
8401
|
type: Input
|
|
@@ -7961,7 +8509,7 @@ class BarHorizontalComponent extends BaseChartComponent {
|
|
|
7961
8509
|
return;
|
|
7962
8510
|
}
|
|
7963
8511
|
const labels = this.results.map(d => formatLabel(d.name ?? d.label));
|
|
7964
|
-
this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16);
|
|
8512
|
+
this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
|
|
7965
8513
|
}
|
|
7966
8514
|
getXScale() {
|
|
7967
8515
|
this.xDomain = this.getXDomain();
|
|
@@ -8015,7 +8563,7 @@ class BarHorizontalComponent extends BaseChartComponent {
|
|
|
8015
8563
|
return opts;
|
|
8016
8564
|
}
|
|
8017
8565
|
updateYAxisWidth({ width }) {
|
|
8018
|
-
if (width
|
|
8566
|
+
if (Math.abs(width - this.yAxisWidth) <= 1) {
|
|
8019
8567
|
return;
|
|
8020
8568
|
}
|
|
8021
8569
|
this.yAxisWidth = width;
|
|
@@ -8343,6 +8891,8 @@ class BarHorizontal2DComponent extends BaseChartComponent {
|
|
|
8343
8891
|
this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
|
8344
8892
|
}
|
|
8345
8893
|
this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
|
|
8894
|
+
// Seed axis width before first measure so SSR/print HTML reserves label space.
|
|
8895
|
+
this.seedYAxisWidthFromResults();
|
|
8346
8896
|
this.dims = calculateViewDimensions({
|
|
8347
8897
|
width: this.width,
|
|
8348
8898
|
height: this.height,
|
|
@@ -8368,6 +8918,14 @@ class BarHorizontal2DComponent extends BaseChartComponent {
|
|
|
8368
8918
|
this.legendOptions = this.getLegendOptions();
|
|
8369
8919
|
this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
|
|
8370
8920
|
}
|
|
8921
|
+
/** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
|
|
8922
|
+
seedYAxisWidthFromResults() {
|
|
8923
|
+
if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
|
|
8924
|
+
return;
|
|
8925
|
+
}
|
|
8926
|
+
const labels = this.results.map(d => formatLabel(d.name ?? d.label));
|
|
8927
|
+
this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
|
|
8928
|
+
}
|
|
8371
8929
|
getGroupScale() {
|
|
8372
8930
|
const spacing = this.groupDomain.length / (this.dims.height / this.groupPadding + 1);
|
|
8373
8931
|
return scaleBand()
|
|
@@ -8457,10 +9015,16 @@ class BarHorizontal2DComponent extends BaseChartComponent {
|
|
|
8457
9015
|
return opts;
|
|
8458
9016
|
}
|
|
8459
9017
|
updateYAxisWidth({ width }) {
|
|
9018
|
+
if (Math.abs(width - this.yAxisWidth) <= 1) {
|
|
9019
|
+
return;
|
|
9020
|
+
}
|
|
8460
9021
|
this.yAxisWidth = width;
|
|
8461
9022
|
this.update();
|
|
8462
9023
|
}
|
|
8463
9024
|
updateXAxisHeight({ height }) {
|
|
9025
|
+
if (height === this.xAxisHeight) {
|
|
9026
|
+
return;
|
|
9027
|
+
}
|
|
8464
9028
|
this.xAxisHeight = height;
|
|
8465
9029
|
this.update();
|
|
8466
9030
|
}
|
|
@@ -8871,6 +9435,8 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
|
|
|
8871
9435
|
}
|
|
8872
9436
|
update() {
|
|
8873
9437
|
super.update();
|
|
9438
|
+
// Seed axis width before first measure so SSR/print HTML reserves label space.
|
|
9439
|
+
this.seedYAxisWidthFromResults();
|
|
8874
9440
|
this.dims = calculateViewDimensions({
|
|
8875
9441
|
width: this.width,
|
|
8876
9442
|
height: this.height,
|
|
@@ -8894,6 +9460,14 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
|
|
|
8894
9460
|
this.legendOptions = this.getLegendOptions();
|
|
8895
9461
|
this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
|
|
8896
9462
|
}
|
|
9463
|
+
/** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
|
|
9464
|
+
seedYAxisWidthFromResults() {
|
|
9465
|
+
if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
|
|
9466
|
+
return;
|
|
9467
|
+
}
|
|
9468
|
+
const labels = this.results.map(d => formatLabel(d.name ?? d.label));
|
|
9469
|
+
this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
|
|
9470
|
+
}
|
|
8897
9471
|
getGroupDomain() {
|
|
8898
9472
|
const domain = [];
|
|
8899
9473
|
for (const group of this.results) {
|
|
@@ -8961,10 +9535,16 @@ class BarHorizontalNormalizedComponent extends BaseChartComponent {
|
|
|
8961
9535
|
return opts;
|
|
8962
9536
|
}
|
|
8963
9537
|
updateYAxisWidth({ width }) {
|
|
9538
|
+
if (Math.abs(width - this.yAxisWidth) <= 1) {
|
|
9539
|
+
return;
|
|
9540
|
+
}
|
|
8964
9541
|
this.yAxisWidth = width;
|
|
8965
9542
|
this.update();
|
|
8966
9543
|
}
|
|
8967
9544
|
updateXAxisHeight({ height }) {
|
|
9545
|
+
if (height === this.xAxisHeight) {
|
|
9546
|
+
return;
|
|
9547
|
+
}
|
|
8968
9548
|
this.xAxisHeight = height;
|
|
8969
9549
|
this.update();
|
|
8970
9550
|
}
|
|
@@ -9321,6 +9901,8 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
|
|
|
9321
9901
|
this.dataLabelMaxWidth = { negative: 0, positive: 0 };
|
|
9322
9902
|
}
|
|
9323
9903
|
this.margin = [10, 20 + this.dataLabelMaxWidth.positive, 10, 20 + this.dataLabelMaxWidth.negative];
|
|
9904
|
+
// Seed axis width before first measure so SSR/print HTML reserves label space.
|
|
9905
|
+
this.seedYAxisWidthFromResults();
|
|
9324
9906
|
this.dims = calculateViewDimensions({
|
|
9325
9907
|
width: this.width,
|
|
9326
9908
|
height: this.height,
|
|
@@ -9345,6 +9927,14 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
|
|
|
9345
9927
|
this.legendOptions = this.getLegendOptions();
|
|
9346
9928
|
this.transform = `translate(${this.dims.xOffset} , ${this.margin[0]})`;
|
|
9347
9929
|
}
|
|
9930
|
+
/** Approx Y-axis width from category labels when not yet measured (SSR-safe). */
|
|
9931
|
+
seedYAxisWidthFromResults() {
|
|
9932
|
+
if (!this.yAxis || this.yAxisWidth > 0 || !this.results?.length) {
|
|
9933
|
+
return;
|
|
9934
|
+
}
|
|
9935
|
+
const labels = this.results.map(d => formatLabel(d.name ?? d.label));
|
|
9936
|
+
this.yAxisWidth = YAxisTicksComponent.approximateTickLabelsWidth(labels, this.trimYAxisTicks !== false, this.maxYAxisTickLength ?? 16, this.wrapTicks !== false);
|
|
9937
|
+
}
|
|
9348
9938
|
getGroupDomain() {
|
|
9349
9939
|
const domain = [];
|
|
9350
9940
|
for (const group of this.results) {
|
|
@@ -9438,10 +10028,16 @@ class BarHorizontalStackedComponent extends BaseChartComponent {
|
|
|
9438
10028
|
return opts;
|
|
9439
10029
|
}
|
|
9440
10030
|
updateYAxisWidth({ width }) {
|
|
10031
|
+
if (Math.abs(width - this.yAxisWidth) <= 1) {
|
|
10032
|
+
return;
|
|
10033
|
+
}
|
|
9441
10034
|
this.yAxisWidth = width;
|
|
9442
10035
|
this.update();
|
|
9443
10036
|
}
|
|
9444
10037
|
updateXAxisHeight({ height }) {
|
|
10038
|
+
if (height === this.xAxisHeight) {
|
|
10039
|
+
return;
|
|
10040
|
+
}
|
|
9445
10041
|
this.xAxisHeight = height;
|
|
9446
10042
|
this.update();
|
|
9447
10043
|
}
|
|
@@ -12551,13 +13147,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
12551
13147
|
}] } });
|
|
12552
13148
|
|
|
12553
13149
|
class BoxSeriesComponent {
|
|
12554
|
-
constructor() {
|
|
13150
|
+
constructor(platformId) {
|
|
13151
|
+
this.platformId = platformId;
|
|
12555
13152
|
this.animations = true;
|
|
12556
13153
|
this.tooltipDisabled = false;
|
|
12557
13154
|
this.gradient = false;
|
|
12558
13155
|
this.select = new EventEmitter();
|
|
12559
13156
|
this.activate = new EventEmitter();
|
|
12560
13157
|
this.deactivate = new EventEmitter();
|
|
13158
|
+
this.isSSR = false;
|
|
13159
|
+
}
|
|
13160
|
+
ngOnInit() {
|
|
13161
|
+
if (isPlatformServer(this.platformId)) {
|
|
13162
|
+
this.isSSR = true;
|
|
13163
|
+
}
|
|
12561
13164
|
}
|
|
12562
13165
|
ngOnChanges(changes) {
|
|
12563
13166
|
this.update();
|
|
@@ -12658,37 +13261,71 @@ class BoxSeriesComponent {
|
|
|
12658
13261
|
}
|
|
12659
13262
|
}
|
|
12660
13263
|
}
|
|
12661
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BoxSeriesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
12662
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
-
|
|
13264
|
+
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 }); }
|
|
13265
|
+
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: `
|
|
13266
|
+
@if (!isSSR) {
|
|
13267
|
+
<svg:g>
|
|
13268
|
+
<svg:g
|
|
13269
|
+
ngx-charts-box
|
|
13270
|
+
[@animationState]="'active'"
|
|
13271
|
+
[@.disabled]="!animations"
|
|
13272
|
+
[width]="box.width"
|
|
13273
|
+
[height]="box.height"
|
|
13274
|
+
[x]="box.x"
|
|
13275
|
+
[y]="box.y"
|
|
13276
|
+
[roundEdges]="box.roundEdges"
|
|
13277
|
+
[fill]="box.color"
|
|
13278
|
+
[gradientStops]="box.gradientStops"
|
|
13279
|
+
[strokeColor]="strokeColor"
|
|
13280
|
+
[strokeWidth]="strokeWidth"
|
|
13281
|
+
[data]="box.data"
|
|
13282
|
+
[lineCoordinates]="box.lineCoordinates"
|
|
13283
|
+
[gradient]="gradient"
|
|
13284
|
+
[ariaLabel]="box.ariaLabel"
|
|
13285
|
+
(select)="onClick($event)"
|
|
13286
|
+
(activate)="activate.emit($event)"
|
|
13287
|
+
(deactivate)="deactivate.emit($event)"
|
|
13288
|
+
ngx-tooltip
|
|
13289
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
13290
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
13291
|
+
[tooltipType]="tooltipType"
|
|
13292
|
+
[tooltipTitle]="tooltipTitle"
|
|
13293
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
13294
|
+
[tooltipContext]="box.data"
|
|
13295
|
+
[animations]="animations"
|
|
13296
|
+
></svg:g>
|
|
13297
|
+
</svg:g>
|
|
13298
|
+
} @else {
|
|
13299
|
+
<svg:g>
|
|
13300
|
+
<svg:g
|
|
13301
|
+
ngx-charts-box
|
|
13302
|
+
[width]="box.width"
|
|
13303
|
+
[height]="box.height"
|
|
13304
|
+
[x]="box.x"
|
|
13305
|
+
[y]="box.y"
|
|
13306
|
+
[roundEdges]="box.roundEdges"
|
|
13307
|
+
[fill]="box.color"
|
|
13308
|
+
[gradientStops]="box.gradientStops"
|
|
13309
|
+
[strokeColor]="strokeColor"
|
|
13310
|
+
[strokeWidth]="strokeWidth"
|
|
13311
|
+
[data]="box.data"
|
|
13312
|
+
[lineCoordinates]="box.lineCoordinates"
|
|
13313
|
+
[gradient]="gradient"
|
|
13314
|
+
[ariaLabel]="box.ariaLabel"
|
|
13315
|
+
(select)="onClick($event)"
|
|
13316
|
+
(activate)="activate.emit($event)"
|
|
13317
|
+
(deactivate)="deactivate.emit($event)"
|
|
13318
|
+
ngx-tooltip
|
|
13319
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
13320
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
13321
|
+
[tooltipType]="tooltipType"
|
|
13322
|
+
[tooltipTitle]="tooltipTitle"
|
|
13323
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
13324
|
+
[tooltipContext]="box.data"
|
|
13325
|
+
[animations]="animations"
|
|
13326
|
+
></svg:g>
|
|
13327
|
+
</svg:g>
|
|
13328
|
+
}
|
|
12692
13329
|
`, 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: [
|
|
12693
13330
|
trigger('animationState', [
|
|
12694
13331
|
transition(':leave', [
|
|
@@ -12705,35 +13342,69 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
12705
13342
|
args: [{
|
|
12706
13343
|
selector: 'g[ngx-charts-box-series]',
|
|
12707
13344
|
template: `
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
13345
|
+
@if (!isSSR) {
|
|
13346
|
+
<svg:g>
|
|
13347
|
+
<svg:g
|
|
13348
|
+
ngx-charts-box
|
|
13349
|
+
[@animationState]="'active'"
|
|
13350
|
+
[@.disabled]="!animations"
|
|
13351
|
+
[width]="box.width"
|
|
13352
|
+
[height]="box.height"
|
|
13353
|
+
[x]="box.x"
|
|
13354
|
+
[y]="box.y"
|
|
13355
|
+
[roundEdges]="box.roundEdges"
|
|
13356
|
+
[fill]="box.color"
|
|
13357
|
+
[gradientStops]="box.gradientStops"
|
|
13358
|
+
[strokeColor]="strokeColor"
|
|
13359
|
+
[strokeWidth]="strokeWidth"
|
|
13360
|
+
[data]="box.data"
|
|
13361
|
+
[lineCoordinates]="box.lineCoordinates"
|
|
13362
|
+
[gradient]="gradient"
|
|
13363
|
+
[ariaLabel]="box.ariaLabel"
|
|
13364
|
+
(select)="onClick($event)"
|
|
13365
|
+
(activate)="activate.emit($event)"
|
|
13366
|
+
(deactivate)="deactivate.emit($event)"
|
|
13367
|
+
ngx-tooltip
|
|
13368
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
13369
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
13370
|
+
[tooltipType]="tooltipType"
|
|
13371
|
+
[tooltipTitle]="tooltipTitle"
|
|
13372
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
13373
|
+
[tooltipContext]="box.data"
|
|
13374
|
+
[animations]="animations"
|
|
13375
|
+
></svg:g>
|
|
13376
|
+
</svg:g>
|
|
13377
|
+
} @else {
|
|
13378
|
+
<svg:g>
|
|
13379
|
+
<svg:g
|
|
13380
|
+
ngx-charts-box
|
|
13381
|
+
[width]="box.width"
|
|
13382
|
+
[height]="box.height"
|
|
13383
|
+
[x]="box.x"
|
|
13384
|
+
[y]="box.y"
|
|
13385
|
+
[roundEdges]="box.roundEdges"
|
|
13386
|
+
[fill]="box.color"
|
|
13387
|
+
[gradientStops]="box.gradientStops"
|
|
13388
|
+
[strokeColor]="strokeColor"
|
|
13389
|
+
[strokeWidth]="strokeWidth"
|
|
13390
|
+
[data]="box.data"
|
|
13391
|
+
[lineCoordinates]="box.lineCoordinates"
|
|
13392
|
+
[gradient]="gradient"
|
|
13393
|
+
[ariaLabel]="box.ariaLabel"
|
|
13394
|
+
(select)="onClick($event)"
|
|
13395
|
+
(activate)="activate.emit($event)"
|
|
13396
|
+
(deactivate)="deactivate.emit($event)"
|
|
13397
|
+
ngx-tooltip
|
|
13398
|
+
[tooltipDisabled]="tooltipDisabled"
|
|
13399
|
+
[tooltipPlacement]="tooltipPlacement"
|
|
13400
|
+
[tooltipType]="tooltipType"
|
|
13401
|
+
[tooltipTitle]="tooltipTitle"
|
|
13402
|
+
[tooltipTemplate]="tooltipTemplate"
|
|
13403
|
+
[tooltipContext]="box.data"
|
|
13404
|
+
[animations]="animations"
|
|
13405
|
+
></svg:g>
|
|
13406
|
+
</svg:g>
|
|
13407
|
+
}
|
|
12737
13408
|
`,
|
|
12738
13409
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12739
13410
|
animations: [
|
|
@@ -12748,7 +13419,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImpor
|
|
|
12748
13419
|
],
|
|
12749
13420
|
standalone: false
|
|
12750
13421
|
}]
|
|
12751
|
-
}],
|
|
13422
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
13423
|
+
type: Inject,
|
|
13424
|
+
args: [PLATFORM_ID]
|
|
13425
|
+
}] }], propDecorators: { dims: [{
|
|
12752
13426
|
type: Input
|
|
12753
13427
|
}], series: [{
|
|
12754
13428
|
type: Input
|
|
@@ -21064,5 +21738,5 @@ function tickFormat(fieldType, groupByType) {
|
|
|
21064
21738
|
* Generated bundle index. Do not edit.
|
|
21065
21739
|
*/
|
|
21066
21740
|
|
|
21067
|
-
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 };
|
|
21741
|
+
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 };
|
|
21068
21742
|
//# sourceMappingURL=swimlane-ngx-charts.mjs.map
|