@lifecorner/angular-ui-kit 3.20.0 → 3.21.0

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.
@@ -21,6 +21,7 @@ var BarChartComponent = class BarChartComponent {
21
21
  orientation = input("vertical", ...ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []);
22
22
  showValues = input(true, ...ngDevMode ? [{ debugName: "showValues" }] : /* istanbul ignore next */ []);
23
23
  showLabels = input(true, ...ngDevMode ? [{ debugName: "showLabels" }] : /* istanbul ignore next */ []);
24
+ labelLayout = input("axis", ...ngDevMode ? [{ debugName: "labelLayout" }] : /* istanbul ignore next */ []);
24
25
  showGrid = input(true, ...ngDevMode ? [{ debugName: "showGrid" }] : /* istanbul ignore next */ []);
25
26
  barGap = input(.3, ...ngDevMode ? [{ debugName: "barGap" }] : /* istanbul ignore next */ []);
26
27
  color = input("", ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
@@ -33,6 +34,13 @@ var BarChartComponent = class BarChartComponent {
33
34
  effectiveWidth = computed(() => this._containerWidth() || this.width() || DEFAULT_WIDTH, ...ngDevMode ? [{ debugName: "effectiveWidth" }] : /* istanbul ignore next */ []);
34
35
  viewBox = computed(() => `0 0 ${this.effectiveWidth()} ${this.height()}`, ...ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []);
35
36
  isVertical = computed(() => this.orientation() === "vertical", ...ngDevMode ? [{ debugName: "isVertical" }] : /* istanbul ignore next */ []);
37
+ wrapRows = computed(() => this.labelLayout() === "wrap" && !this.isVertical(), ...ngDevMode ? [{ debugName: "wrapRows" }] : /* istanbul ignore next */ []);
38
+ wrapColumns = computed(() => this.labelLayout() === "wrap" && this.isVertical(), ...ngDevMode ? [{ debugName: "wrapColumns" }] : /* istanbul ignore next */ []);
39
+ paddingBottom = computed(() => {
40
+ if (!this.wrapColumns()) return this.PADDING_BOTTOM;
41
+ const negative = (this.data() ?? []).some((i) => toFinite(i.value) < 0);
42
+ return this.showValues() && negative ? 18 : 2;
43
+ }, ...ngDevMode ? [{ debugName: "paddingBottom" }] : /* istanbul ignore next */ []);
36
44
  plot = computed(() => {
37
45
  const w = this.effectiveWidth();
38
46
  const h = this.height();
@@ -40,9 +48,12 @@ var BarChartComponent = class BarChartComponent {
40
48
  x: this.PADDING_LEFT,
41
49
  y: this.PADDING_TOP,
42
50
  w: w - this.PADDING_LEFT - this.PADDING_RIGHT,
43
- h: h - this.PADDING_TOP - this.PADDING_BOTTOM
51
+ h: h - this.PADDING_TOP - this.paddingBottom()
44
52
  };
45
53
  }, ...ngDevMode ? [{ debugName: "plot" }] : /* istanbul ignore next */ []);
54
+ textOf(item, value, fmt) {
55
+ return item.valueText ?? fmt(value, item);
56
+ }
46
57
  scale = computed(() => {
47
58
  const values = (this.data() ?? []).map((i) => toFinite(i.value));
48
59
  return niceScale(Math.min(0, ...values), Math.max(0, ...values), 4);
@@ -88,7 +99,7 @@ var BarChartComponent = class BarChartComponent {
88
99
  color: singleColor || item.color || chartColor(i),
89
100
  label: item.label || "",
90
101
  value,
91
- valueText: fmt(value),
102
+ valueText: this.textOf(item, value, fmt),
92
103
  labelX: p.x + i * totalBarWidth + totalBarWidth / 2,
93
104
  labelY: h - this.PADDING_BOTTOM + 16,
94
105
  valueX: p.x + i * totalBarWidth + totalBarWidth / 2,
@@ -113,7 +124,7 @@ var BarChartComponent = class BarChartComponent {
113
124
  color: singleColor || item.color || chartColor(i),
114
125
  label: item.label || "",
115
126
  value,
116
- valueText: fmt(value),
127
+ valueText: this.textOf(item, value, fmt),
117
128
  labelX: p.x - 6,
118
129
  labelY: p.y + i * totalBarHeight + totalBarHeight / 2,
119
130
  valueX: value >= 0 ? x + barW + 6 : x - 6,
@@ -139,13 +150,46 @@ var BarChartComponent = class BarChartComponent {
139
150
  };
140
151
  }, ...ngDevMode ? [{ debugName: "axisLine" }] : /* istanbul ignore next */ []);
141
152
  plotBottom = computed(() => this.plot().y + this.plot().h, ...ngDevMode ? [{ debugName: "plotBottom" }] : /* istanbul ignore next */ []);
153
+ rowBounds = computed(() => {
154
+ const values = (this.data() ?? []).map((i) => toFinite(i.value));
155
+ const lo = Math.min(0, ...values);
156
+ return {
157
+ values,
158
+ lo,
159
+ range: Math.max(0, ...values) - lo || 1
160
+ };
161
+ }, ...ngDevMode ? [{ debugName: "rowBounds" }] : /* istanbul ignore next */ []);
162
+ rows = computed(() => {
163
+ const d = this.data() ?? [];
164
+ const { values, lo, range } = this.rowBounds();
165
+ const singleColor = this.color();
166
+ const fmt = this.formatValue();
167
+ return d.map((item, i) => {
168
+ const value = values[i];
169
+ return {
170
+ label: item.label || "",
171
+ valueText: this.textOf(item, value, fmt),
172
+ color: singleColor || item.color || chartColor(i),
173
+ x: `${(Math.min(value, 0) - lo) / range * 100}%`,
174
+ width: `${Math.abs(value) / range * 100}%`
175
+ };
176
+ });
177
+ }, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
178
+ rowZero = computed(() => {
179
+ const { lo, range } = this.rowBounds();
180
+ return lo < 0 ? `${-lo / range * 100}%` : null;
181
+ }, ...ngDevMode ? [{ debugName: "rowZero" }] : /* istanbul ignore next */ []);
142
182
  effectiveAriaLabel = computed(() => {
143
183
  const explicit = this.ariaLabel();
144
184
  if (explicit) return explicit;
145
185
  const d = this.data() ?? [];
146
186
  if (!d.length) return "Bar chart: no data";
147
187
  const fmt = this.formatValue();
148
- return `Bar chart: ${d.map((item, i) => `${item.label || `Bar ${i + 1}`} ${fmt(toFinite(item.value))}`).join(", ")}`;
188
+ return `Bar chart: ${d.map((item, i) => {
189
+ const label = item.label || `Bar ${i + 1}`;
190
+ const text = this.textOf(item, toFinite(item.value), fmt);
191
+ return text === "" ? label : `${label} ${text}`;
192
+ }).join(", ")}`;
149
193
  }, ...ngDevMode ? [{ debugName: "effectiveAriaLabel" }] : /* istanbul ignore next */ []);
150
194
  static ɵfac = i0.ɵɵngDeclareFactory({
151
195
  minVersion: "12.0.0",
@@ -204,6 +248,13 @@ var BarChartComponent = class BarChartComponent {
204
248
  isRequired: false,
205
249
  transformFunction: null
206
250
  },
251
+ labelLayout: {
252
+ classPropertyName: "labelLayout",
253
+ publicName: "labelLayout",
254
+ isSignal: true,
255
+ isRequired: false,
256
+ transformFunction: null
257
+ },
207
258
  showGrid: {
208
259
  classPropertyName: "showGrid",
209
260
  publicName: "showGrid",
@@ -242,8 +293,8 @@ var BarChartComponent = class BarChartComponent {
242
293
  },
243
294
  host: { properties: { "style.max-width.px": "width()" } },
244
295
  ngImport: i0,
245
- template: "<svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n>\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n @if (showLabels()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n</svg>\n",
246
- styles: [":host{display:block;width:100%}.lc-bar-chart{overflow:visible}.lc-bar-chart__axis{stroke:var(--color-border);stroke-width:1}.lc-bar-chart__grid-line{stroke:var(--color-border);stroke-width:1;stroke-dasharray:3 3}.lc-bar-chart__grid-label{font-size:.625rem;fill:var(--color-text-tertiary)}.lc-bar-chart__bar{transition:opacity .15s ease}.lc-bar-chart__bar:hover{opacity:.8}.lc-bar-chart__value{font-size:.625rem;font-weight:600;fill:var(--color-text-secondary)}.lc-bar-chart__label{font-size:.6875rem;fill:var(--color-text-secondary)}\n"],
296
+ template: "@if (wrapRows()) {\n <!--\n Horizontal 'wrap' (3.21, request 028): HTML rows, so labels wrap and follow\n the text size. Bar x/width are percentages: final in the server HTML.\n No inline style (CSP). The children of role=\"img\" are presentational.\n -->\n <div\n class=\"lc-bar-chart lc-bar-chart--rows\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n >\n @for (row of rows(); track $index) {\n <div class=\"lc-bar-chart__row\">\n @if ((showLabels() && row.label) || (showValues() && row.valueText)) {\n <div class=\"lc-bar-chart__row-head\">\n @if (showLabels() && row.label) {\n <span class=\"lc-bar-chart__row-label\">{{ row.label }}</span>\n }\n @if (showValues() && row.valueText) {\n <span class=\"lc-bar-chart__row-value\">{{ row.valueText }}</span>\n }\n </div>\n }\n <svg\n width=\"100%\"\n aria-hidden=\"true\"\n focusable=\"false\"\n class=\"lc-bar-chart__row-track\"\n >\n @if (rowZero(); as zero) {\n <line\n [attr.x1]=\"zero\"\n y1=\"-25%\"\n [attr.x2]=\"zero\"\n y2=\"125%\"\n class=\"lc-bar-chart__zero-line\"\n />\n }\n <rect\n [attr.x]=\"row.x\"\n y=\"0\"\n [attr.width]=\"row.width\"\n height=\"100%\"\n [attr.fill]=\"row.color\"\n rx=\"2\"\n class=\"lc-bar-chart__row-bar\"\n />\n </svg>\n </div>\n }\n </div>\n} @else {\n <svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n >\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n <!-- One block (not nested), so the SVG's comment anchors stay as before 3.21. -->\n @if (showLabels() && !wrapColumns()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n </svg>\n\n <!--\n Vertical 'wrap' (3.21, request 028): the category labels as HTML under the\n plot, one cell per column, wrapping within it. Hidden from assistive\n technology: the names are in the SVG's accessible name.\n -->\n @if (wrapColumns() && showLabels()) {\n <div class=\"lc-bar-chart__category-labels\" aria-hidden=\"true\">\n @for (bar of bars(); track $index) {\n <span class=\"lc-bar-chart__category-label\">{{ bar.label }}</span>\n }\n </div>\n }\n}\n",
297
+ styles: [":host{display:block;width:100%}.lc-bar-chart{overflow:visible}.lc-bar-chart__axis{stroke:var(--color-border);stroke-width:1}.lc-bar-chart__grid-line{stroke:var(--color-border);stroke-width:1;stroke-dasharray:3 3}.lc-bar-chart__grid-label{font-size:.625rem;fill:var(--color-text-tertiary)}.lc-bar-chart__bar{transition:opacity .15s ease}.lc-bar-chart__bar:hover{opacity:.8}.lc-bar-chart__value{font-size:.625rem;font-weight:600;fill:var(--color-text-secondary)}.lc-bar-chart__label{font-size:.6875rem;fill:var(--color-text-secondary)}.lc-bar-chart--rows{display:flex;flex-direction:column;gap:var(--lc-bar-chart-row-gap, var(--spacing-4))}.lc-bar-chart__row{display:flex;flex-direction:column;gap:var(--spacing-1)}.lc-bar-chart__row-head{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:var(--spacing-2);font-size:var(--typography-font-size-sm);line-height:var(--typography-line-height-normal)}.lc-bar-chart__row-label{flex:1 1 auto;min-width:0;color:var(--color-text-primary);font-weight:var(--typography-font-weight-normal);overflow-wrap:break-word;hyphens:auto;hyphenate-limit-chars:12 4 3}.lc-bar-chart__row-value{margin-inline-start:auto;min-width:0;text-align:end;color:var(--color-text-primary);font-weight:var(--typography-font-weight-semibold);font-variant-numeric:tabular-nums;overflow-wrap:break-word}.lc-bar-chart__row-track{display:block;width:100%;height:var(--lc-bar-chart-bar-size, .75rem);overflow:visible}.lc-bar-chart__zero-line{stroke:var(--color-text-tertiary);stroke-width:1}.lc-bar-chart__category-labels{display:flex;padding:var(--spacing-1) 10px 0 40px}.lc-bar-chart__category-label{flex:1 1 0%;min-width:0;padding-inline:2px;text-align:center;font-size:.6875rem;line-height:var(--typography-line-height-tight);color:var(--color-text-secondary);overflow-wrap:break-word;hyphens:auto;hyphenate-limit-chars:12 4 3}@media(forced-colors:active){.lc-bar-chart__row-track{forced-color-adjust:none}.lc-bar-chart__row-bar{fill:Highlight}.lc-bar-chart__zero-line{stroke:CanvasText}}\n"],
247
298
  changeDetection: i0.ChangeDetectionStrategy.OnPush
248
299
  });
249
300
  };
@@ -259,8 +310,8 @@ i0.ɵɵngDeclareClassMetadata({
259
310
  standalone: true,
260
311
  changeDetection: ChangeDetectionStrategy.OnPush,
261
312
  host: { "[style.max-width.px]": "width()" },
262
- template: "<svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n>\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n @if (showLabels()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n</svg>\n",
263
- styles: [":host{display:block;width:100%}.lc-bar-chart{overflow:visible}.lc-bar-chart__axis{stroke:var(--color-border);stroke-width:1}.lc-bar-chart__grid-line{stroke:var(--color-border);stroke-width:1;stroke-dasharray:3 3}.lc-bar-chart__grid-label{font-size:.625rem;fill:var(--color-text-tertiary)}.lc-bar-chart__bar{transition:opacity .15s ease}.lc-bar-chart__bar:hover{opacity:.8}.lc-bar-chart__value{font-size:.625rem;font-weight:600;fill:var(--color-text-secondary)}.lc-bar-chart__label{font-size:.6875rem;fill:var(--color-text-secondary)}\n"]
313
+ template: "@if (wrapRows()) {\n <!--\n Horizontal 'wrap' (3.21, request 028): HTML rows, so labels wrap and follow\n the text size. Bar x/width are percentages: final in the server HTML.\n No inline style (CSP). The children of role=\"img\" are presentational.\n -->\n <div\n class=\"lc-bar-chart lc-bar-chart--rows\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n >\n @for (row of rows(); track $index) {\n <div class=\"lc-bar-chart__row\">\n @if ((showLabels() && row.label) || (showValues() && row.valueText)) {\n <div class=\"lc-bar-chart__row-head\">\n @if (showLabels() && row.label) {\n <span class=\"lc-bar-chart__row-label\">{{ row.label }}</span>\n }\n @if (showValues() && row.valueText) {\n <span class=\"lc-bar-chart__row-value\">{{ row.valueText }}</span>\n }\n </div>\n }\n <svg\n width=\"100%\"\n aria-hidden=\"true\"\n focusable=\"false\"\n class=\"lc-bar-chart__row-track\"\n >\n @if (rowZero(); as zero) {\n <line\n [attr.x1]=\"zero\"\n y1=\"-25%\"\n [attr.x2]=\"zero\"\n y2=\"125%\"\n class=\"lc-bar-chart__zero-line\"\n />\n }\n <rect\n [attr.x]=\"row.x\"\n y=\"0\"\n [attr.width]=\"row.width\"\n height=\"100%\"\n [attr.fill]=\"row.color\"\n rx=\"2\"\n class=\"lc-bar-chart__row-bar\"\n />\n </svg>\n </div>\n }\n </div>\n} @else {\n <svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n >\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n <!-- One block (not nested), so the SVG's comment anchors stay as before 3.21. -->\n @if (showLabels() && !wrapColumns()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n </svg>\n\n <!--\n Vertical 'wrap' (3.21, request 028): the category labels as HTML under the\n plot, one cell per column, wrapping within it. Hidden from assistive\n technology: the names are in the SVG's accessible name.\n -->\n @if (wrapColumns() && showLabels()) {\n <div class=\"lc-bar-chart__category-labels\" aria-hidden=\"true\">\n @for (bar of bars(); track $index) {\n <span class=\"lc-bar-chart__category-label\">{{ bar.label }}</span>\n }\n </div>\n }\n}\n",
314
+ styles: [":host{display:block;width:100%}.lc-bar-chart{overflow:visible}.lc-bar-chart__axis{stroke:var(--color-border);stroke-width:1}.lc-bar-chart__grid-line{stroke:var(--color-border);stroke-width:1;stroke-dasharray:3 3}.lc-bar-chart__grid-label{font-size:.625rem;fill:var(--color-text-tertiary)}.lc-bar-chart__bar{transition:opacity .15s ease}.lc-bar-chart__bar:hover{opacity:.8}.lc-bar-chart__value{font-size:.625rem;font-weight:600;fill:var(--color-text-secondary)}.lc-bar-chart__label{font-size:.6875rem;fill:var(--color-text-secondary)}.lc-bar-chart--rows{display:flex;flex-direction:column;gap:var(--lc-bar-chart-row-gap, var(--spacing-4))}.lc-bar-chart__row{display:flex;flex-direction:column;gap:var(--spacing-1)}.lc-bar-chart__row-head{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:var(--spacing-2);font-size:var(--typography-font-size-sm);line-height:var(--typography-line-height-normal)}.lc-bar-chart__row-label{flex:1 1 auto;min-width:0;color:var(--color-text-primary);font-weight:var(--typography-font-weight-normal);overflow-wrap:break-word;hyphens:auto;hyphenate-limit-chars:12 4 3}.lc-bar-chart__row-value{margin-inline-start:auto;min-width:0;text-align:end;color:var(--color-text-primary);font-weight:var(--typography-font-weight-semibold);font-variant-numeric:tabular-nums;overflow-wrap:break-word}.lc-bar-chart__row-track{display:block;width:100%;height:var(--lc-bar-chart-bar-size, .75rem);overflow:visible}.lc-bar-chart__zero-line{stroke:var(--color-text-tertiary);stroke-width:1}.lc-bar-chart__category-labels{display:flex;padding:var(--spacing-1) 10px 0 40px}.lc-bar-chart__category-label{flex:1 1 0%;min-width:0;padding-inline:2px;text-align:center;font-size:.6875rem;line-height:var(--typography-line-height-tight);color:var(--color-text-secondary);overflow-wrap:break-word;hyphens:auto;hyphenate-limit-chars:12 4 3}@media(forced-colors:active){.lc-bar-chart__row-track{forced-color-adjust:none}.lc-bar-chart__row-bar{fill:Highlight}.lc-bar-chart__zero-line{stroke:CanvasText}}\n"]
264
315
  }]
265
316
  }],
266
317
  ctorParameters: () => [],
@@ -313,6 +364,14 @@ i0.ɵɵngDeclareClassMetadata({
313
364
  required: false
314
365
  }]
315
366
  }],
367
+ labelLayout: [{
368
+ type: i0.Input,
369
+ args: [{
370
+ isSignal: true,
371
+ alias: "labelLayout",
372
+ required: false
373
+ }]
374
+ }],
316
375
  showGrid: [{
317
376
  type: i0.Input,
318
377
  args: [{
@@ -1 +1 @@
1
- {"version":3,"file":"lifecorner-angular-ui-kit-bar-chart.mjs","names":[],"sources":["../../../../libs/angular-ui-kit/src/lib/bar-chart/bar-chart.component.ts","../../../../libs/angular-ui-kit/src/lib/bar-chart/bar-chart.component.html"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n afterNextRender,\n inject,\n input,\n computed,\n signal,\n} from '@angular/core';\nimport { chartColor } from '@lifecorner/angular-ui-kit/internal/chart';\nimport {\n ChartValueFormatter,\n formatChartValue,\n niceScale,\n toFinite,\n} from '@lifecorner/angular-ui-kit/internal/chart';\n\nexport interface BarChartItem {\n /** Bar value. Negative values draw downward (left) from the zero baseline. */\n value: number;\n label?: string;\n color?: string;\n}\n\nexport type BarChartOrientation = 'vertical' | 'horizontal';\n\n/** viewBox width used until the container has been measured. */\nconst DEFAULT_WIDTH = 400;\n\n@Component({\n selector: 'lc-bar-chart',\n standalone: true,\n templateUrl: './bar-chart.component.html',\n styleUrls: ['./bar-chart.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[style.max-width.px]': 'width()',\n },\n})\n/**\n * Bar chart component for comparing categorical data.\n *\n * Features:\n * - Vertical and horizontal orientation\n * - Per-bar or uniform color support\n * - Negative values drawn from a zero baseline\n * - Optional value labels on bars\n * - Configurable grid and axis labels on a nice tick scale\n * - Adjustable bar gap spacing\n * - Responsive SVG rendering\n *\n * @example\n * ```html\n * <lc-bar-chart [data]=\"items\" orientation=\"vertical\" [showValues]=\"true\" />\n * ```\n */\nexport class BarChartComponent {\n private readonly _el = inject(ElementRef);\n private readonly _destroyRef = inject(DestroyRef);\n private readonly _containerWidth = signal<number>(0);\n\n constructor() {\n afterNextRender(() => {\n const obs = new ResizeObserver(([entry]) => {\n this._containerWidth.set(entry.contentRect.width);\n });\n obs.observe(this._el.nativeElement);\n this._destroyRef.onDestroy(() => obs.disconnect());\n });\n }\n\n /** Data items. */\n data = input.required<BarChartItem[]>();\n\n /**\n * Intrinsic chart width in pixels. The chart fills its container (the SVG is\n * `width=\"100%\"` and its viewBox follows the measured container width);\n * `width` is the viewBox width until the container has been measured and,\n * when set, the host's `max-width`, so the chart never grows past it. Leave\n * unset for a fully fluid chart.\n */\n width = input<number | undefined>(undefined);\n\n /** Chart height in pixels. */\n height = input<number>(200);\n\n /** Bar orientation. */\n orientation = input<BarChartOrientation>('vertical');\n\n /** Show value labels on bars. */\n showValues = input<boolean>(true);\n\n /** Show axis labels. */\n showLabels = input<boolean>(true);\n\n /** Show grid lines. */\n showGrid = input<boolean>(true);\n\n /** Gap between bars as ratio (0-1). */\n barGap = input<number>(0.3);\n\n /** Use a single color for all bars. */\n color = input<string>('');\n\n /** Formats value labels and axis ticks. Defaults to a float-safe `String(value)`. */\n formatValue = input<ChartValueFormatter>(formatChartValue);\n\n /**\n * Accessible name of the chart. Defaults to a generated summary that lists\n * every bar's label and value, so assistive technology hears the data and\n * not just \"Bar chart\".\n */\n ariaLabel = input<string>('');\n\n // Layout constants\n private readonly PADDING_LEFT = 40;\n private readonly PADDING_RIGHT = 10;\n private readonly PADDING_TOP = 10;\n private readonly PADDING_BOTTOM = 30;\n\n protected readonly effectiveWidth = computed(\n () => this._containerWidth() || this.width() || DEFAULT_WIDTH\n );\n\n protected readonly viewBox = computed(\n () => `0 0 ${this.effectiveWidth()} ${this.height()}`\n );\n\n protected readonly isVertical = computed(() => this.orientation() === 'vertical');\n\n private readonly plot = computed(() => {\n const w = this.effectiveWidth();\n const h = this.height();\n return {\n x: this.PADDING_LEFT,\n y: this.PADDING_TOP,\n w: w - this.PADDING_LEFT - this.PADDING_RIGHT,\n h: h - this.PADDING_TOP - this.PADDING_BOTTOM,\n };\n });\n\n /**\n * One scale for grid *and* bars: bounds are nice multiples of the tick step,\n * always include zero, and extend below zero when the data does — so the top\n * tick is the value at the plot edge and negative bars hang off the baseline.\n */\n protected readonly scale = computed(() => {\n const values = (this.data() ?? []).map((i) => toFinite(i.value));\n return niceScale(Math.min(0, ...values), Math.max(0, ...values), 4);\n });\n\n /** Maps a data value to a pixel position along the value axis. */\n private valueToPos(value: number): number {\n const { min, max } = this.scale();\n const p = this.plot();\n const frac = (value - min) / (max - min || 1);\n return this.isVertical() ? p.y + p.h - frac * p.h : p.x + frac * p.w;\n }\n\n protected readonly gridLines = computed(() => {\n if (!this.showGrid() || !this.data()?.length) return [];\n const fmt = this.formatValue();\n return this.scale().ticks.map((tick) => ({\n pos: this.valueToPos(tick),\n label: fmt(tick),\n }));\n });\n\n protected readonly bars = computed(() => {\n const d = this.data();\n if (!d || d.length === 0) return [];\n\n const isVertical = this.isVertical();\n const p = this.plot();\n const gap = this.barGap();\n const singleColor = this.color();\n const fmt = this.formatValue();\n const zero = this.valueToPos(0);\n const h = this.height();\n\n if (isVertical) {\n const totalBarWidth = p.w / d.length;\n const barWidth = totalBarWidth * (1 - gap);\n const barOffset = (totalBarWidth - barWidth) / 2;\n\n return d.map((item, i) => {\n const value = toFinite(item.value);\n const end = this.valueToPos(value);\n const y = Math.min(zero, end);\n const barH = Math.abs(end - zero);\n return {\n x: p.x + i * totalBarWidth + barOffset,\n y,\n width: barWidth,\n height: barH,\n color: singleColor || item.color || chartColor(i),\n label: item.label || '',\n value,\n valueText: fmt(value),\n labelX: p.x + i * totalBarWidth + totalBarWidth / 2,\n labelY: h - this.PADDING_BOTTOM + 16,\n valueX: p.x + i * totalBarWidth + totalBarWidth / 2,\n // Above a positive bar, below a negative one.\n valueY: value >= 0 ? y - 6 : y + barH + 12,\n valueAnchor: 'middle',\n };\n });\n } else {\n const totalBarHeight = p.h / d.length;\n const barHeight = totalBarHeight * (1 - gap);\n const barOffset = (totalBarHeight - barHeight) / 2;\n\n return d.map((item, i) => {\n const value = toFinite(item.value);\n const end = this.valueToPos(value);\n const x = Math.min(zero, end);\n const barW = Math.abs(end - zero);\n return {\n x,\n y: p.y + i * totalBarHeight + barOffset,\n width: barW,\n height: barHeight,\n color: singleColor || item.color || chartColor(i),\n label: item.label || '',\n value,\n valueText: fmt(value),\n labelX: p.x - 6,\n labelY: p.y + i * totalBarHeight + totalBarHeight / 2,\n // Right of a positive bar, left of a negative one.\n valueX: value >= 0 ? x + barW + 6 : x - 6,\n valueY: p.y + i * totalBarHeight + totalBarHeight / 2,\n valueAnchor: value >= 0 ? 'start' : 'end',\n };\n });\n }\n });\n\n /**\n * Value axis along the plot edge plus the zero baseline, which sits inside\n * the plot when the data goes negative.\n */\n protected readonly axisLine = computed(() => {\n const p = this.plot();\n const isVertical = this.isVertical();\n const zero = this.data()?.length ? this.valueToPos(0) : (isVertical ? p.y + p.h : p.x);\n return {\n x1: isVertical ? p.x : zero,\n y1: p.y,\n x2: isVertical ? p.x : zero,\n y2: p.y + p.h,\n bx1: p.x,\n by1: isVertical ? zero : p.y + p.h,\n bx2: p.x + p.w,\n by2: isVertical ? zero : p.y + p.h,\n };\n });\n\n /** Bottom edge of the plot — where horizontal-orientation tick labels sit. */\n protected readonly plotBottom = computed(() => this.plot().y + this.plot().h);\n\n protected readonly effectiveAriaLabel = computed(() => {\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const d = this.data() ?? [];\n if (!d.length) return 'Bar chart: no data';\n const fmt = this.formatValue();\n return `Bar chart: ${d\n .map((item, i) => `${item.label || `Bar ${i + 1}`} ${fmt(toFinite(item.value))}`)\n .join(', ')}`;\n });\n}\n","<svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n>\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n @if (showLabels()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n</svg>\n"],"mappings":";;;AA6BA,MAAM,gBAAgB;AA6BtB,IAAa,oBAAb,MAAa,kBAAiB;CACX,MAAM,OAAO,UAAU;CACvB,cAAc,OAAO,UAAU;CAC/B,kBAAkB,OAAe,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,kBAAA,CAAA,+BAAA,CAAA,CAAA;CAEpD,cAAA;EACE,sBAAqB;GACnB,MAAM,MAAM,IAAI,gBAAgB,CAAC,WAAU;IACzC,KAAK,gBAAgB,IAAI,MAAM,YAAY,KAAK;GAClD,CAAC;GACD,IAAI,QAAQ,KAAK,IAAI,aAAa;GAClC,KAAK,YAAY,gBAAgB,IAAI,WAAU,CAAE;EACnD,CAAC;CACH;CAGA,OAAO,MAAM,SAA0B,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CASvC,QAAQ,MAA0B,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAG5C,SAAS,MAAc,KAAI,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAG3B,cAAc,MAA2B,YAAW,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAGpD,aAAa,MAAe,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAA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AA,yhBAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AD7Ca,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiB,YAAA,CAAA;EA3B7B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAc,YACZ;GAAI,iBAGC,wBAAwB;GAAM,MACzC,EACJ,wBAAwB,UACzB;GAAA,UAAA;GAAA,QAAA,CAAA,yhBAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"lifecorner-angular-ui-kit-bar-chart.mjs","names":[],"sources":["../../../../libs/angular-ui-kit/src/lib/bar-chart/bar-chart.component.ts","../../../../libs/angular-ui-kit/src/lib/bar-chart/bar-chart.component.html"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n afterNextRender,\n inject,\n input,\n computed,\n signal,\n} from '@angular/core';\nimport { chartColor } from '@lifecorner/angular-ui-kit/internal/chart';\nimport {\n formatChartValue,\n niceScale,\n toFinite,\n} from '@lifecorner/angular-ui-kit/internal/chart';\n\nexport interface BarChartItem {\n /** Bar value. Negative values draw downward (left) from the zero baseline. */\n value: number;\n label?: string;\n color?: string;\n /**\n * The text shown as this bar's value and read in the generated aria label,\n * instead of `formatValue(value, item)`, for example \"313.000,00 · 54,8 %\".\n * The kit shows it as given and never formats or computes it. An empty\n * string shows no value for this bar.\n */\n valueText?: string;\n}\n\nexport type BarChartOrientation = 'vertical' | 'horizontal';\n\n/**\n * How the category labels are set: `'axis'` (one line of SVG text on the\n * category axis) or `'wrap'` (HTML text that wraps and follows the text size).\n */\nexport type BarChartLabelLayout = 'axis' | 'wrap';\n\n/**\n * Signature of `lc-bar-chart`'s `formatValue`. A bar's value label passes the\n * bar's item; an axis tick passes the tick only (`item` is `undefined`).\n * One-argument formatters keep working.\n */\nexport type BarChartValueFormatter = (value: number, item?: BarChartItem) => string;\n\n/** viewBox width used until the container has been measured. */\nconst DEFAULT_WIDTH = 400;\n\n@Component({\n selector: 'lc-bar-chart',\n standalone: true,\n templateUrl: './bar-chart.component.html',\n styleUrls: ['./bar-chart.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[style.max-width.px]': 'width()',\n },\n})\n/**\n * Bar chart component for comparing categorical data.\n *\n * Features:\n * - Vertical and horizontal orientation\n * - Per-bar or uniform color support\n * - Negative values drawn from a zero baseline\n * - Optional value labels on bars\n * - Configurable grid and axis labels on a nice tick scale\n * - Adjustable bar gap spacing\n * - Responsive SVG rendering\n *\n * @example\n * ```html\n * <lc-bar-chart [data]=\"items\" orientation=\"vertical\" [showValues]=\"true\" />\n * ```\n */\nexport class BarChartComponent {\n private readonly _el = inject(ElementRef);\n private readonly _destroyRef = inject(DestroyRef);\n private readonly _containerWidth = signal<number>(0);\n\n constructor() {\n afterNextRender(() => {\n const obs = new ResizeObserver(([entry]) => {\n this._containerWidth.set(entry.contentRect.width);\n });\n obs.observe(this._el.nativeElement);\n this._destroyRef.onDestroy(() => obs.disconnect());\n });\n }\n\n /** Data items. */\n data = input.required<BarChartItem[]>();\n\n /**\n * Intrinsic chart width in pixels. The chart fills its container (the SVG is\n * `width=\"100%\"` and its viewBox follows the measured container width);\n * `width` is the viewBox width until the container has been measured and,\n * when set, the host's `max-width`, so the chart never grows past it. Leave\n * unset for a fully fluid chart.\n * @default undefined\n */\n width = input<number | undefined>(undefined);\n\n /**\n * Chart height in pixels. A horizontal `'wrap'` chart takes the height of\n * its rows; a vertical `'wrap'` chart adds its label row below this height.\n * @default 200\n */\n height = input<number>(200);\n\n /**\n * Bar orientation.\n * @default 'vertical'\n */\n orientation = input<BarChartOrientation>('vertical');\n\n /**\n * Show value labels on bars. In horizontal `'wrap'` rows the value sits at\n * the end of the label line.\n * @default true\n */\n showValues = input<boolean>(true);\n\n /**\n * Show axis labels.\n * @default true\n */\n showLabels = input<boolean>(true);\n\n /**\n * How the category labels are set. `'axis'`: one line of SVG text on the\n * category axis, in a fixed 40 px band left of a horizontal bar or centred\n * under a vertical column. Long labels can run out of the chart. `'wrap'`:\n * HTML text that wraps to the room it needs and follows the text size. A\n * horizontal chart becomes a list of rows: the label and the value on one\n * line (the value moves under the label when both don't fit), and below\n * them the bar across the full width. The longest bar fills the width, and\n * `height`, `barGap` and `showGrid` don't apply. A vertical chart keeps its\n * plot and wraps each label within its column, under the chart.\n * @default 'axis'\n */\n labelLayout = input<BarChartLabelLayout>('axis');\n\n /**\n * Show grid lines. Not used by horizontal `'wrap'` rows.\n * @default true\n */\n showGrid = input<boolean>(true);\n\n /**\n * Gap between bars as ratio (0-1). Not used by horizontal `'wrap'` rows.\n * @default 0.3\n */\n barGap = input<number>(0.3);\n\n /**\n * Use a single color for all bars.\n * @default ''\n */\n color = input<string>('');\n\n /**\n * Formats the value labels and the axis ticks. For a bar it gets the bar's\n * item as the second argument; for an axis tick it gets the tick only\n * (`item` is `undefined`). An item's `valueText` takes precedence.\n * @default float-safe `String(value)`\n */\n formatValue = input<BarChartValueFormatter>(formatChartValue);\n\n /**\n * Accessible name of the chart. Defaults to a generated summary that lists\n * every bar's label and value, so assistive technology hears the data and\n * not just \"Bar chart\".\n * @default ''\n */\n ariaLabel = input<string>('');\n\n // Layout constants\n private readonly PADDING_LEFT = 40;\n private readonly PADDING_RIGHT = 10;\n private readonly PADDING_TOP = 10;\n private readonly PADDING_BOTTOM = 30;\n\n protected readonly effectiveWidth = computed(\n () => this._containerWidth() || this.width() || DEFAULT_WIDTH\n );\n\n protected readonly viewBox = computed(\n () => `0 0 ${this.effectiveWidth()} ${this.height()}`\n );\n\n protected readonly isVertical = computed(() => this.orientation() === 'vertical');\n\n /** Horizontal `'wrap'`: HTML rows instead of the SVG plot. */\n protected readonly wrapRows = computed(\n () => this.labelLayout() === 'wrap' && !this.isVertical()\n );\n\n /** Vertical `'wrap'`: the SVG plot, with the category labels as an HTML row under it. */\n protected readonly wrapColumns = computed(\n () => this.labelLayout() === 'wrap' && this.isVertical()\n );\n\n /**\n * Room under the plot. `'axis'` keeps 30 for the SVG labels; vertical\n * `'wrap'` labels sit under the SVG, so only 2 are left, or 18 when a\n * negative bar's value label hangs below it.\n */\n private readonly paddingBottom = computed(() => {\n if (!this.wrapColumns()) return this.PADDING_BOTTOM;\n const negative = (this.data() ?? []).some((i) => toFinite(i.value) < 0);\n return this.showValues() && negative ? 18 : 2;\n });\n\n private readonly plot = computed(() => {\n const w = this.effectiveWidth();\n const h = this.height();\n return {\n x: this.PADDING_LEFT,\n y: this.PADDING_TOP,\n w: w - this.PADDING_LEFT - this.PADDING_RIGHT,\n h: h - this.PADDING_TOP - this.paddingBottom(),\n };\n });\n\n /** A bar's text: `valueText`, else `formatValue(value, item)`. */\n private textOf(item: BarChartItem, value: number, fmt: BarChartValueFormatter): string {\n return item.valueText ?? fmt(value, item);\n }\n\n /**\n * One scale for grid *and* bars: bounds are nice multiples of the tick step,\n * always include zero, and extend below zero when the data does — so the top\n * tick is the value at the plot edge and negative bars hang off the baseline.\n */\n protected readonly scale = computed(() => {\n const values = (this.data() ?? []).map((i) => toFinite(i.value));\n return niceScale(Math.min(0, ...values), Math.max(0, ...values), 4);\n });\n\n /** Maps a data value to a pixel position along the value axis. */\n private valueToPos(value: number): number {\n const { min, max } = this.scale();\n const p = this.plot();\n const frac = (value - min) / (max - min || 1);\n return this.isVertical() ? p.y + p.h - frac * p.h : p.x + frac * p.w;\n }\n\n protected readonly gridLines = computed(() => {\n if (!this.showGrid() || !this.data()?.length) return [];\n const fmt = this.formatValue();\n return this.scale().ticks.map((tick) => ({\n pos: this.valueToPos(tick),\n label: fmt(tick),\n }));\n });\n\n protected readonly bars = computed(() => {\n const d = this.data();\n if (!d || d.length === 0) return [];\n\n const isVertical = this.isVertical();\n const p = this.plot();\n const gap = this.barGap();\n const singleColor = this.color();\n const fmt = this.formatValue();\n const zero = this.valueToPos(0);\n const h = this.height();\n\n if (isVertical) {\n const totalBarWidth = p.w / d.length;\n const barWidth = totalBarWidth * (1 - gap);\n const barOffset = (totalBarWidth - barWidth) / 2;\n\n return d.map((item, i) => {\n const value = toFinite(item.value);\n const end = this.valueToPos(value);\n const y = Math.min(zero, end);\n const barH = Math.abs(end - zero);\n return {\n x: p.x + i * totalBarWidth + barOffset,\n y,\n width: barWidth,\n height: barH,\n color: singleColor || item.color || chartColor(i),\n label: item.label || '',\n value,\n valueText: this.textOf(item, value, fmt),\n labelX: p.x + i * totalBarWidth + totalBarWidth / 2,\n labelY: h - this.PADDING_BOTTOM + 16,\n valueX: p.x + i * totalBarWidth + totalBarWidth / 2,\n // Above a positive bar, below a negative one.\n valueY: value >= 0 ? y - 6 : y + barH + 12,\n valueAnchor: 'middle',\n };\n });\n } else {\n const totalBarHeight = p.h / d.length;\n const barHeight = totalBarHeight * (1 - gap);\n const barOffset = (totalBarHeight - barHeight) / 2;\n\n return d.map((item, i) => {\n const value = toFinite(item.value);\n const end = this.valueToPos(value);\n const x = Math.min(zero, end);\n const barW = Math.abs(end - zero);\n return {\n x,\n y: p.y + i * totalBarHeight + barOffset,\n width: barW,\n height: barHeight,\n color: singleColor || item.color || chartColor(i),\n label: item.label || '',\n value,\n valueText: this.textOf(item, value, fmt),\n labelX: p.x - 6,\n labelY: p.y + i * totalBarHeight + totalBarHeight / 2,\n // Right of a positive bar, left of a negative one.\n valueX: value >= 0 ? x + barW + 6 : x - 6,\n valueY: p.y + i * totalBarHeight + totalBarHeight / 2,\n valueAnchor: value >= 0 ? 'start' : 'end',\n };\n });\n }\n });\n\n /**\n * Value axis along the plot edge plus the zero baseline, which sits inside\n * the plot when the data goes negative.\n */\n protected readonly axisLine = computed(() => {\n const p = this.plot();\n const isVertical = this.isVertical();\n const zero = this.data()?.length ? this.valueToPos(0) : (isVertical ? p.y + p.h : p.x);\n return {\n x1: isVertical ? p.x : zero,\n y1: p.y,\n x2: isVertical ? p.x : zero,\n y2: p.y + p.h,\n bx1: p.x,\n by1: isVertical ? zero : p.y + p.h,\n bx2: p.x + p.w,\n by2: isVertical ? zero : p.y + p.h,\n };\n });\n\n /** Bottom edge of the plot — where horizontal-orientation tick labels sit. */\n protected readonly plotBottom = computed(() => this.plot().y + this.plot().h);\n\n /**\n * Bounds of the horizontal `'wrap'` rows: zero is always inside, and the\n * longest bar fills the track.\n */\n private readonly rowBounds = computed(() => {\n const values = (this.data() ?? []).map((i) => toFinite(i.value));\n const lo = Math.min(0, ...values);\n const hi = Math.max(0, ...values);\n return { values, lo, range: hi - lo || 1 };\n });\n\n /**\n * Horizontal `'wrap'` rows. Bar `x` and `width` are percentages of the\n * track, so the server HTML is final before the container is measured.\n */\n protected readonly rows = computed(() => {\n const d = this.data() ?? [];\n const { values, lo, range } = this.rowBounds();\n const singleColor = this.color();\n const fmt = this.formatValue();\n return d.map((item, i) => {\n const value = values[i];\n return {\n label: item.label || '',\n valueText: this.textOf(item, value, fmt),\n color: singleColor || item.color || chartColor(i),\n x: `${((Math.min(value, 0) - lo) / range) * 100}%`,\n width: `${(Math.abs(value) / range) * 100}%`,\n };\n });\n });\n\n /** Position of the zero line in the `'wrap'` rows; `null` without negative values. */\n protected readonly rowZero = computed(() => {\n const { lo, range } = this.rowBounds();\n return lo < 0 ? `${(-lo / range) * 100}%` : null;\n });\n\n protected readonly effectiveAriaLabel = computed(() => {\n const explicit = this.ariaLabel();\n if (explicit) return explicit;\n const d = this.data() ?? [];\n if (!d.length) return 'Bar chart: no data';\n const fmt = this.formatValue();\n return `Bar chart: ${d\n .map((item, i) => {\n const label = item.label || `Bar ${i + 1}`;\n const text = this.textOf(item, toFinite(item.value), fmt);\n return text === '' ? label : `${label} ${text}`;\n })\n .join(', ')}`;\n });\n}\n","@if (wrapRows()) {\n <!--\n Horizontal 'wrap' (3.21, request 028): HTML rows, so labels wrap and follow\n the text size. Bar x/width are percentages: final in the server HTML.\n No inline style (CSP). The children of role=\"img\" are presentational.\n -->\n <div\n class=\"lc-bar-chart lc-bar-chart--rows\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n >\n @for (row of rows(); track $index) {\n <div class=\"lc-bar-chart__row\">\n @if ((showLabels() && row.label) || (showValues() && row.valueText)) {\n <div class=\"lc-bar-chart__row-head\">\n @if (showLabels() && row.label) {\n <span class=\"lc-bar-chart__row-label\">{{ row.label }}</span>\n }\n @if (showValues() && row.valueText) {\n <span class=\"lc-bar-chart__row-value\">{{ row.valueText }}</span>\n }\n </div>\n }\n <svg\n width=\"100%\"\n aria-hidden=\"true\"\n focusable=\"false\"\n class=\"lc-bar-chart__row-track\"\n >\n @if (rowZero(); as zero) {\n <line\n [attr.x1]=\"zero\"\n y1=\"-25%\"\n [attr.x2]=\"zero\"\n y2=\"125%\"\n class=\"lc-bar-chart__zero-line\"\n />\n }\n <rect\n [attr.x]=\"row.x\"\n y=\"0\"\n [attr.width]=\"row.width\"\n height=\"100%\"\n [attr.fill]=\"row.color\"\n rx=\"2\"\n class=\"lc-bar-chart__row-bar\"\n />\n </svg>\n </div>\n }\n </div>\n} @else {\n <svg\n width=\"100%\"\n [attr.height]=\"height()\"\n [attr.viewBox]=\"viewBox()\"\n role=\"img\"\n [attr.aria-label]=\"effectiveAriaLabel()\"\n class=\"lc-bar-chart\"\n >\n <title>{{ effectiveAriaLabel() }}</title>\n\n <!-- Grid lines -->\n @if (showGrid()) {\n @for (line of gridLines(); track line.pos) {\n @if (isVertical()) {\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"line.pos\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"line.pos\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"axisLine().x1 - 6\"\n [attr.y]=\"line.pos\"\n text-anchor=\"end\"\n dominant-baseline=\"central\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n } @else {\n <line\n [attr.x1]=\"line.pos\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"line.pos\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__grid-line\"\n />\n <text\n [attr.x]=\"line.pos\"\n [attr.y]=\"plotBottom() + 12\"\n text-anchor=\"middle\"\n class=\"lc-bar-chart__grid-label\"\n >\n {{ line.label }}\n </text>\n }\n }\n }\n\n <!-- Axes -->\n <line\n [attr.x1]=\"axisLine().x1\"\n [attr.y1]=\"axisLine().y1\"\n [attr.x2]=\"axisLine().x2\"\n [attr.y2]=\"axisLine().y2\"\n class=\"lc-bar-chart__axis\"\n />\n <line\n [attr.x1]=\"axisLine().bx1\"\n [attr.y1]=\"axisLine().by1\"\n [attr.x2]=\"axisLine().bx2\"\n [attr.y2]=\"axisLine().by2\"\n class=\"lc-bar-chart__axis\"\n />\n\n <!-- Bars -->\n @for (bar of bars(); track $index) {\n <rect\n [attr.x]=\"bar.x\"\n [attr.y]=\"bar.y\"\n [attr.width]=\"bar.width\"\n [attr.height]=\"bar.height\"\n [attr.fill]=\"bar.color\"\n rx=\"2\"\n class=\"lc-bar-chart__bar\"\n />\n\n @if (showValues()) {\n <text\n [attr.x]=\"bar.valueX\"\n [attr.y]=\"bar.valueY\"\n [attr.text-anchor]=\"bar.valueAnchor\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__value\"\n >\n {{ bar.valueText }}\n </text>\n }\n\n <!-- One block (not nested), so the SVG's comment anchors stay as before 3.21. -->\n @if (showLabels() && !wrapColumns()) {\n <text\n [attr.x]=\"bar.labelX\"\n [attr.y]=\"bar.labelY\"\n [attr.text-anchor]=\"isVertical() ? 'middle' : 'end'\"\n [attr.dominant-baseline]=\"isVertical() ? 'auto' : 'central'\"\n class=\"lc-bar-chart__label\"\n >\n {{ bar.label }}\n </text>\n }\n }\n </svg>\n\n <!--\n Vertical 'wrap' (3.21, request 028): the category labels as HTML under the\n plot, one cell per column, wrapping within it. Hidden from assistive\n technology: the names are in the SVG's accessible name.\n -->\n @if (wrapColumns() && showLabels()) {\n <div class=\"lc-bar-chart__category-labels\" aria-hidden=\"true\">\n @for (bar of bars(); track $index) {\n <span class=\"lc-bar-chart__category-label\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;IAAA,mBAAA;GAAA;GAAA,QAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,WAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,sBAAA,UAAA,EAAA;EAAA,UAAA;EAAA,UC7E9B;EA0KA,QAAA,CAAA,49DAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AD7Fa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiB,YAAA,CAAA;EA3B7B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAc,YACZ;GAAI,iBAGC,wBAAwB;GAAM,MACzC,EACJ,wBAAwB,UACzB;GAAA,UAAA;GAAA,QAAA,CAAA,49DAAA;EAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifecorner/angular-ui-kit",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "LifeCorner Design System – Angular UI component library",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,12 +1,29 @@
1
- import { ChartValueFormatter } from "@lifecorner/angular-ui-kit/internal/chart";
2
1
  import * as i0 from "@angular/core";
3
2
  export interface BarChartItem {
4
3
  /** Bar value. Negative values draw downward (left) from the zero baseline. */
5
4
  value: number;
6
5
  label?: string;
7
6
  color?: string;
7
+ /**
8
+ * The text shown as this bar's value and read in the generated aria label,
9
+ * instead of `formatValue(value, item)`, for example "313.000,00 · 54,8 %".
10
+ * The kit shows it as given and never formats or computes it. An empty
11
+ * string shows no value for this bar.
12
+ */
13
+ valueText?: string;
8
14
  }
9
15
  export type BarChartOrientation = 'vertical' | 'horizontal';
16
+ /**
17
+ * How the category labels are set: `'axis'` (one line of SVG text on the
18
+ * category axis) or `'wrap'` (HTML text that wraps and follows the text size).
19
+ */
20
+ export type BarChartLabelLayout = 'axis' | 'wrap';
21
+ /**
22
+ * Signature of `lc-bar-chart`'s `formatValue`. A bar's value label passes the
23
+ * bar's item; an axis tick passes the tick only (`item` is `undefined`).
24
+ * One-argument formatters keep working.
25
+ */
26
+ export type BarChartValueFormatter = (value: number, item?: BarChartItem) => string;
10
27
  export declare class BarChartComponent {
11
28
  private readonly _el;
12
29
  private readonly _destroyRef;
@@ -20,28 +37,71 @@ export declare class BarChartComponent {
20
37
  * `width` is the viewBox width until the container has been measured and,
21
38
  * when set, the host's `max-width`, so the chart never grows past it. Leave
22
39
  * unset for a fully fluid chart.
40
+ * @default undefined
23
41
  */
24
42
  width: import("@angular/core").InputSignal<number | undefined>;
25
- /** Chart height in pixels. */
43
+ /**
44
+ * Chart height in pixels. A horizontal `'wrap'` chart takes the height of
45
+ * its rows; a vertical `'wrap'` chart adds its label row below this height.
46
+ * @default 200
47
+ */
26
48
  height: import("@angular/core").InputSignal<number>;
27
- /** Bar orientation. */
49
+ /**
50
+ * Bar orientation.
51
+ * @default 'vertical'
52
+ */
28
53
  orientation: import("@angular/core").InputSignal<BarChartOrientation>;
29
- /** Show value labels on bars. */
54
+ /**
55
+ * Show value labels on bars. In horizontal `'wrap'` rows the value sits at
56
+ * the end of the label line.
57
+ * @default true
58
+ */
30
59
  showValues: import("@angular/core").InputSignal<boolean>;
31
- /** Show axis labels. */
60
+ /**
61
+ * Show axis labels.
62
+ * @default true
63
+ */
32
64
  showLabels: import("@angular/core").InputSignal<boolean>;
33
- /** Show grid lines. */
65
+ /**
66
+ * How the category labels are set. `'axis'`: one line of SVG text on the
67
+ * category axis, in a fixed 40 px band left of a horizontal bar or centred
68
+ * under a vertical column. Long labels can run out of the chart. `'wrap'`:
69
+ * HTML text that wraps to the room it needs and follows the text size. A
70
+ * horizontal chart becomes a list of rows: the label and the value on one
71
+ * line (the value moves under the label when both don't fit), and below
72
+ * them the bar across the full width. The longest bar fills the width, and
73
+ * `height`, `barGap` and `showGrid` don't apply. A vertical chart keeps its
74
+ * plot and wraps each label within its column, under the chart.
75
+ * @default 'axis'
76
+ */
77
+ labelLayout: import("@angular/core").InputSignal<BarChartLabelLayout>;
78
+ /**
79
+ * Show grid lines. Not used by horizontal `'wrap'` rows.
80
+ * @default true
81
+ */
34
82
  showGrid: import("@angular/core").InputSignal<boolean>;
35
- /** Gap between bars as ratio (0-1). */
83
+ /**
84
+ * Gap between bars as ratio (0-1). Not used by horizontal `'wrap'` rows.
85
+ * @default 0.3
86
+ */
36
87
  barGap: import("@angular/core").InputSignal<number>;
37
- /** Use a single color for all bars. */
88
+ /**
89
+ * Use a single color for all bars.
90
+ * @default ''
91
+ */
38
92
  color: import("@angular/core").InputSignal<string>;
39
- /** Formats value labels and axis ticks. Defaults to a float-safe `String(value)`. */
40
- formatValue: import("@angular/core").InputSignal<ChartValueFormatter>;
93
+ /**
94
+ * Formats the value labels and the axis ticks. For a bar it gets the bar's
95
+ * item as the second argument; for an axis tick it gets the tick only
96
+ * (`item` is `undefined`). An item's `valueText` takes precedence.
97
+ * @default float-safe `String(value)`
98
+ */
99
+ formatValue: import("@angular/core").InputSignal<BarChartValueFormatter>;
41
100
  /**
42
101
  * Accessible name of the chart. Defaults to a generated summary that lists
43
102
  * every bar's label and value, so assistive technology hears the data and
44
103
  * not just "Bar chart".
104
+ * @default ''
45
105
  */
46
106
  ariaLabel: import("@angular/core").InputSignal<string>;
47
107
  private readonly PADDING_LEFT;
@@ -51,7 +111,19 @@ export declare class BarChartComponent {
51
111
  protected readonly effectiveWidth: import("@angular/core").Signal<number>;
52
112
  protected readonly viewBox: import("@angular/core").Signal<string>;
53
113
  protected readonly isVertical: import("@angular/core").Signal<boolean>;
114
+ /** Horizontal `'wrap'`: HTML rows instead of the SVG plot. */
115
+ protected readonly wrapRows: import("@angular/core").Signal<boolean>;
116
+ /** Vertical `'wrap'`: the SVG plot, with the category labels as an HTML row under it. */
117
+ protected readonly wrapColumns: import("@angular/core").Signal<boolean>;
118
+ /**
119
+ * Room under the plot. `'axis'` keeps 30 for the SVG labels; vertical
120
+ * `'wrap'` labels sit under the SVG, so only 2 are left, or 18 when a
121
+ * negative bar's value label hangs below it.
122
+ */
123
+ private readonly paddingBottom;
54
124
  private readonly plot;
125
+ /** A bar's text: `valueText`, else `formatValue(value, item)`. */
126
+ private textOf;
55
127
  /**
56
128
  * One scale for grid *and* bars: bounds are nice multiples of the tick step,
57
129
  * always include zero, and extend below zero when the data does — so the top
@@ -95,6 +167,24 @@ export declare class BarChartComponent {
95
167
  }>;
96
168
  /** Bottom edge of the plot — where horizontal-orientation tick labels sit. */
97
169
  protected readonly plotBottom: import("@angular/core").Signal<number>;
170
+ /**
171
+ * Bounds of the horizontal `'wrap'` rows: zero is always inside, and the
172
+ * longest bar fills the track.
173
+ */
174
+ private readonly rowBounds;
175
+ /**
176
+ * Horizontal `'wrap'` rows. Bar `x` and `width` are percentages of the
177
+ * track, so the server HTML is final before the container is measured.
178
+ */
179
+ protected readonly rows: import("@angular/core").Signal<{
180
+ label: string;
181
+ valueText: string;
182
+ color: string;
183
+ x: string;
184
+ width: string;
185
+ }[]>;
186
+ /** Position of the zero line in the `'wrap'` rows; `null` without negative values. */
187
+ protected readonly rowZero: import("@angular/core").Signal<string | null>;
98
188
  protected readonly effectiveAriaLabel: import("@angular/core").Signal<string>;
99
189
  static ɵfac: i0.ɵɵFactoryDeclaration<BarChartComponent, never>;
100
190
  static ɵcmp: i0.ɵɵComponentDeclaration<BarChartComponent, "lc-bar-chart", never, {
@@ -128,6 +218,11 @@ export declare class BarChartComponent {
128
218
  "required": false;
129
219
  "isSignal": true;
130
220
  };
221
+ "labelLayout": {
222
+ "alias": "labelLayout";
223
+ "required": false;
224
+ "isSignal": true;
225
+ };
131
226
  "showGrid": {
132
227
  "alias": "showGrid";
133
228
  "required": false;