@redvars/peacock 3.15.0 → 3.17.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.
Files changed (157) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/theme.js +19 -19
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/card-content.js +8 -7
  7. package/dist/card-content.js.map +1 -1
  8. package/dist/card.js +142 -98
  9. package/dist/card.js.map +1 -1
  10. package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
  11. package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
  12. package/dist/chart-area.js +78 -0
  13. package/dist/chart-area.js.map +1 -0
  14. package/dist/chart-bar.js +283 -213
  15. package/dist/chart-bar.js.map +1 -1
  16. package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
  17. package/dist/chart-base-C2qRMF48.js.map +1 -0
  18. package/dist/chart-doughnut.js +55 -287
  19. package/dist/chart-doughnut.js.map +1 -1
  20. package/dist/chart-line.js +626 -0
  21. package/dist/chart-line.js.map +1 -0
  22. package/dist/chart-pie.js +637 -195
  23. package/dist/chart-pie.js.map +1 -1
  24. package/dist/code-editor.js +704 -131
  25. package/dist/code-editor.js.map +1 -1
  26. package/dist/code-group.js +188 -0
  27. package/dist/code-group.js.map +1 -0
  28. package/dist/code-highlighter.js +895 -257
  29. package/dist/code-highlighter.js.map +1 -1
  30. package/dist/custom-elements-jsdocs.json +2278 -677
  31. package/dist/custom-elements.json +13962 -3690
  32. package/dist/image.js +5 -1
  33. package/dist/image.js.map +1 -1
  34. package/dist/index.js +8 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/loader-full.js +1 -1
  37. package/dist/loader.js +9 -3
  38. package/dist/loader.js.map +1 -1
  39. package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
  40. package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
  41. package/dist/pagination.js +408 -110
  42. package/dist/pagination.js.map +1 -1
  43. package/dist/path-CJ0Arqcy.js +166 -0
  44. package/dist/path-CJ0Arqcy.js.map +1 -0
  45. package/dist/snackbar.js +89 -34
  46. package/dist/snackbar.js.map +1 -1
  47. package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
  48. package/dist/src/__internal/chart/chart-base.d.ts +113 -0
  49. package/dist/src/__internal/chart/paths.d.ts +5 -0
  50. package/dist/src/__internal/chart/types.d.ts +42 -0
  51. package/dist/src/card/card-content.d.ts +2 -3
  52. package/dist/src/card/card.d.ts +31 -17
  53. package/dist/src/chart-area/chart-area.d.ts +54 -0
  54. package/dist/src/chart-area/index.d.ts +1 -0
  55. package/dist/src/chart-bar/chart-bar.d.ts +44 -33
  56. package/dist/src/chart-bar/index.d.ts +0 -1
  57. package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
  58. package/dist/src/chart-line/chart-line.d.ts +69 -0
  59. package/dist/src/chart-line/index.d.ts +1 -0
  60. package/dist/src/chart-pie/chart-pie.d.ts +63 -28
  61. package/dist/src/code-editor/code-editor.d.ts +52 -13
  62. package/dist/src/code-editor/editor-theme.d.ts +60 -0
  63. package/dist/src/code-highlighter/code-group.d.ts +52 -0
  64. package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
  65. package/dist/src/code-highlighter/index.d.ts +1 -0
  66. package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
  67. package/dist/src/code-highlighter/local.d.ts +4 -1
  68. package/dist/src/code-highlighter/token-colors.d.ts +8 -0
  69. package/dist/src/index.d.ts +4 -2
  70. package/dist/src/pagination/page-items.d.ts +14 -0
  71. package/dist/src/pagination/pagination.d.ts +46 -7
  72. package/dist/src/snackbar/snackbar.d.ts +13 -1
  73. package/dist/src/table/table.d.ts +125 -27
  74. package/dist/src/toolbar/toolbar.d.ts +56 -51
  75. package/dist/table.js +1007 -338
  76. package/dist/table.js.map +1 -1
  77. package/dist/test/chart.test.d.ts +1 -0
  78. package/dist/test/code-highlighter.test.d.ts +1 -0
  79. package/dist/test/pagination.test.d.ts +1 -0
  80. package/dist/test/table.test.d.ts +1 -0
  81. package/dist/token-colors-0TFHWbcq.js +81 -0
  82. package/dist/token-colors-0TFHWbcq.js.map +1 -0
  83. package/dist/toolbar.js +195 -184
  84. package/dist/toolbar.js.map +1 -1
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +1 -2
  87. package/readme.md +7 -6
  88. package/scss/_code-block.scss +139 -0
  89. package/scss/tokens.css +24 -0
  90. package/src/__internal/chart/cartesian-chart.ts +404 -0
  91. package/src/__internal/chart/chart-base.scss +252 -0
  92. package/src/__internal/chart/chart-base.ts +474 -0
  93. package/src/__internal/chart/paths.ts +28 -0
  94. package/src/__internal/chart/types.ts +49 -0
  95. package/src/card/card-content.ts +12 -9
  96. package/src/card/card.scss +66 -54
  97. package/src/card/card.ts +109 -73
  98. package/src/chart-area/chart-area.ts +82 -0
  99. package/src/chart-area/index.ts +1 -0
  100. package/src/chart-bar/chart-bar.ts +336 -250
  101. package/src/chart-bar/index.ts +0 -1
  102. package/src/chart-doughnut/chart-doughnut.ts +62 -262
  103. package/src/chart-doughnut/demo/index.html +14 -22
  104. package/src/chart-line/chart-line.scss +25 -0
  105. package/src/chart-line/chart-line.ts +346 -0
  106. package/src/chart-line/index.ts +1 -0
  107. package/src/chart-pie/chart-pie.scss +35 -16
  108. package/src/chart-pie/chart-pie.ts +282 -188
  109. package/src/chart-pie/demo/index.html +13 -21
  110. package/src/code-editor/code-editor.scss +132 -36
  111. package/src/code-editor/code-editor.ts +308 -88
  112. package/src/code-editor/demo/index.html +39 -12
  113. package/src/code-editor/editor-theme.ts +213 -0
  114. package/src/code-highlighter/code-group.scss +34 -0
  115. package/src/code-highlighter/code-group.ts +173 -0
  116. package/src/code-highlighter/code-highlighter.scss +226 -111
  117. package/src/code-highlighter/code-highlighter.ts +554 -199
  118. package/src/code-highlighter/demo/index.html +68 -4
  119. package/src/code-highlighter/index.ts +1 -0
  120. package/src/code-highlighter/line-ranges.ts +81 -0
  121. package/src/code-highlighter/local.ts +9 -3
  122. package/src/code-highlighter/token-colors.ts +42 -0
  123. package/src/index.ts +4 -2
  124. package/src/loader.ts +8 -2
  125. package/src/pagination/page-items.ts +50 -0
  126. package/src/pagination/pagination.scss +159 -44
  127. package/src/pagination/pagination.ts +275 -74
  128. package/src/snackbar/demo/index.html +39 -4
  129. package/src/snackbar/snackbar.scss +27 -10
  130. package/src/snackbar/snackbar.ts +80 -37
  131. package/src/table/table.scss +337 -109
  132. package/src/table/table.ts +812 -272
  133. package/src/toolbar/toolbar-colors.scss +6 -7
  134. package/src/toolbar/toolbar.scss +35 -106
  135. package/src/toolbar/toolbar.ts +180 -80
  136. package/dist/array-D5vjT2Xm.js +0 -14
  137. package/dist/array-D5vjT2Xm.js.map +0 -1
  138. package/dist/chart-bar-D5dGFJfK.js.map +0 -1
  139. package/dist/chart-stacked-bar.js +0 -403
  140. package/dist/chart-stacked-bar.js.map +0 -1
  141. package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
  142. package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
  143. package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
  144. package/dist/pie-Dz0IDiPt.js +0 -537
  145. package/dist/pie-Dz0IDiPt.js.map +0 -1
  146. package/dist/pierre-dark-DFWl0m-C.js +0 -4
  147. package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
  148. package/dist/pierre-light-BEkAPImt.js +0 -4
  149. package/dist/pierre-light-BEkAPImt.js.map +0 -1
  150. package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
  151. package/dist/src/code-highlighter/constants.d.ts +0 -1
  152. package/dist/transform-DSwFSqzD.js.map +0 -1
  153. package/src/chart-bar/chart-bar.scss +0 -58
  154. package/src/chart-bar/chart-stacked-bar.ts +0 -398
  155. package/src/chart-doughnut/chart-donut.scss +0 -37
  156. package/src/code-highlighter/constants.ts +0 -117
  157. /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
@@ -1,5 +1,6 @@
1
- import { a as constant, i as interpolateNumber, b as color, d as interpolateRgb, e as interpolateString, o as ordinal, f as initRange } from './transform-DSwFSqzD.js';
2
- import { i } from './IndividualComponent-Bdwyrvd6.js';
1
+ import { f as interpolateNumber, i as interpolate, a as constant, b as array, C as ChartBase, d as chartColor, s as select } from './chart-base-C2qRMF48.js';
2
+ import { _ as __decorate, w, b } from './IndividualComponent-Bdwyrvd6.js';
3
+ import { n } from './property-B49QQ8pS.js';
3
4
 
4
5
  function ascending(a, b) {
5
6
  return a == null || b == null ? NaN : a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
@@ -67,13 +68,58 @@ function zero() {
67
68
  return 0;
68
69
  }
69
70
 
70
- function number$2(x) {
71
+ function number$1(x) {
71
72
  return x === null ? NaN : +x;
72
73
  }
73
74
 
74
75
  const ascendingBisect = bisector(ascending);
75
76
  const bisectRight = ascendingBisect.right;
76
- bisector(number$2).center;
77
+ bisector(number$1).center;
78
+
79
+ class InternMap extends Map {
80
+ constructor(entries, key = keyof) {
81
+ super();
82
+ Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}});
83
+ if (entries != null) for (const [key, value] of entries) this.set(key, value);
84
+ }
85
+ get(key) {
86
+ return super.get(intern_get(this, key));
87
+ }
88
+ has(key) {
89
+ return super.has(intern_get(this, key));
90
+ }
91
+ set(key, value) {
92
+ return super.set(intern_set(this, key), value);
93
+ }
94
+ delete(key) {
95
+ return super.delete(intern_delete(this, key));
96
+ }
97
+ }
98
+
99
+ function intern_get({_intern, _key}, value) {
100
+ const key = _key(value);
101
+ return _intern.has(key) ? _intern.get(key) : value;
102
+ }
103
+
104
+ function intern_set({_intern, _key}, value) {
105
+ const key = _key(value);
106
+ if (_intern.has(key)) return _intern.get(key);
107
+ _intern.set(key, value);
108
+ return value;
109
+ }
110
+
111
+ function intern_delete({_intern, _key}, value) {
112
+ const key = _key(value);
113
+ if (_intern.has(key)) {
114
+ value = _intern.get(key);
115
+ _intern.delete(key);
116
+ }
117
+ return value;
118
+ }
119
+
120
+ function keyof(value) {
121
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
122
+ }
77
123
 
78
124
  const e10 = Math.sqrt(50),
79
125
  e5 = Math.sqrt(10),
@@ -152,6 +198,19 @@ function max(values, valueof) {
152
198
  return max;
153
199
  }
154
200
 
201
+ function min(values, valueof) {
202
+ let min;
203
+ {
204
+ for (const value of values) {
205
+ if (value != null
206
+ && (min > value || (min === undefined && value >= value))) {
207
+ min = value;
208
+ }
209
+ }
210
+ }
211
+ return min;
212
+ }
213
+
155
214
  function range(start, stop, step) {
156
215
  start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;
157
216
 
@@ -166,248 +225,6 @@ function range(start, stop, step) {
166
225
  return range;
167
226
  }
168
227
 
169
- function identity$2(x) {
170
- return x;
171
- }
172
-
173
- var top = 1,
174
- right = 2,
175
- bottom = 3,
176
- left = 4,
177
- epsilon = 1e-6;
178
-
179
- function translateX(x) {
180
- return "translate(" + x + ",0)";
181
- }
182
-
183
- function translateY(y) {
184
- return "translate(0," + y + ")";
185
- }
186
-
187
- function number$1(scale) {
188
- return d => +scale(d);
189
- }
190
-
191
- function center(scale, offset) {
192
- offset = Math.max(0, scale.bandwidth() - offset * 2) / 2;
193
- if (scale.round()) offset = Math.round(offset);
194
- return d => +scale(d) + offset;
195
- }
196
-
197
- function entering() {
198
- return !this.__axis;
199
- }
200
-
201
- function axis(orient, scale) {
202
- var tickArguments = [],
203
- tickValues = null,
204
- tickFormat = null,
205
- tickSizeInner = 6,
206
- tickSizeOuter = 6,
207
- tickPadding = 3,
208
- offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5,
209
- k = orient === top || orient === left ? -1 : 1,
210
- x = orient === left || orient === right ? "x" : "y",
211
- transform = orient === top || orient === bottom ? translateX : translateY;
212
-
213
- function axis(context) {
214
- var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues,
215
- format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$2) : tickFormat,
216
- spacing = Math.max(tickSizeInner, 0) + tickPadding,
217
- range = scale.range(),
218
- range0 = +range[0] + offset,
219
- range1 = +range[range.length - 1] + offset,
220
- position = (scale.bandwidth ? center : number$1)(scale.copy(), offset),
221
- selection = context.selection ? context.selection() : context,
222
- path = selection.selectAll(".domain").data([null]),
223
- tick = selection.selectAll(".tick").data(values, scale).order(),
224
- tickExit = tick.exit(),
225
- tickEnter = tick.enter().append("g").attr("class", "tick"),
226
- line = tick.select("line"),
227
- text = tick.select("text");
228
-
229
- path = path.merge(path.enter().insert("path", ".tick")
230
- .attr("class", "domain")
231
- .attr("stroke", "currentColor"));
232
-
233
- tick = tick.merge(tickEnter);
234
-
235
- line = line.merge(tickEnter.append("line")
236
- .attr("stroke", "currentColor")
237
- .attr(x + "2", k * tickSizeInner));
238
-
239
- text = text.merge(tickEnter.append("text")
240
- .attr("fill", "currentColor")
241
- .attr(x, k * spacing)
242
- .attr("dy", orient === top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
243
-
244
- if (context !== selection) {
245
- path = path.transition(context);
246
- tick = tick.transition(context);
247
- line = line.transition(context);
248
- text = text.transition(context);
249
-
250
- tickExit = tickExit.transition(context)
251
- .attr("opacity", epsilon)
252
- .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform"); });
253
-
254
- tickEnter
255
- .attr("opacity", epsilon)
256
- .attr("transform", function(d) { var p = this.parentNode.__axis; return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset); });
257
- }
258
-
259
- tickExit.remove();
260
-
261
- path
262
- .attr("d", orient === left || orient === right
263
- ? (tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1)
264
- : (tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1));
265
-
266
- tick
267
- .attr("opacity", 1)
268
- .attr("transform", function(d) { return transform(position(d) + offset); });
269
-
270
- line
271
- .attr(x + "2", k * tickSizeInner);
272
-
273
- text
274
- .attr(x, k * spacing)
275
- .text(format);
276
-
277
- selection.filter(entering)
278
- .attr("fill", "none")
279
- .attr("font-size", 10)
280
- .attr("font-family", "sans-serif")
281
- .attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle");
282
-
283
- selection
284
- .each(function() { this.__axis = position; });
285
- }
286
-
287
- axis.scale = function(_) {
288
- return arguments.length ? (scale = _, axis) : scale;
289
- };
290
-
291
- axis.ticks = function() {
292
- return tickArguments = Array.from(arguments), axis;
293
- };
294
-
295
- axis.tickArguments = function(_) {
296
- return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice();
297
- };
298
-
299
- axis.tickValues = function(_) {
300
- return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice();
301
- };
302
-
303
- axis.tickFormat = function(_) {
304
- return arguments.length ? (tickFormat = _, axis) : tickFormat;
305
- };
306
-
307
- axis.tickSize = function(_) {
308
- return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis) : tickSizeInner;
309
- };
310
-
311
- axis.tickSizeInner = function(_) {
312
- return arguments.length ? (tickSizeInner = +_, axis) : tickSizeInner;
313
- };
314
-
315
- axis.tickSizeOuter = function(_) {
316
- return arguments.length ? (tickSizeOuter = +_, axis) : tickSizeOuter;
317
- };
318
-
319
- axis.tickPadding = function(_) {
320
- return arguments.length ? (tickPadding = +_, axis) : tickPadding;
321
- };
322
-
323
- axis.offset = function(_) {
324
- return arguments.length ? (offset = +_, axis) : offset;
325
- };
326
-
327
- return axis;
328
- }
329
-
330
- function axisBottom(scale) {
331
- return axis(bottom, scale);
332
- }
333
-
334
- function axisLeft(scale) {
335
- return axis(left, scale);
336
- }
337
-
338
- function numberArray(a, b) {
339
- if (!b) b = [];
340
- var n = a ? Math.min(b.length, a.length) : 0,
341
- c = b.slice(),
342
- i;
343
- return function(t) {
344
- for (i = 0; i < n; ++i) c[i] = a[i] * (1 - t) + b[i] * t;
345
- return c;
346
- };
347
- }
348
-
349
- function isNumberArray(x) {
350
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
351
- }
352
-
353
- function genericArray(a, b) {
354
- var nb = b ? b.length : 0,
355
- na = a ? Math.min(nb, a.length) : 0,
356
- x = new Array(na),
357
- c = new Array(nb),
358
- i;
359
-
360
- for (i = 0; i < na; ++i) x[i] = interpolate(a[i], b[i]);
361
- for (; i < nb; ++i) c[i] = b[i];
362
-
363
- return function(t) {
364
- for (i = 0; i < na; ++i) c[i] = x[i](t);
365
- return c;
366
- };
367
- }
368
-
369
- function date(a, b) {
370
- var d = new Date;
371
- return a = +a, b = +b, function(t) {
372
- return d.setTime(a * (1 - t) + b * t), d;
373
- };
374
- }
375
-
376
- function object(a, b) {
377
- var i = {},
378
- c = {},
379
- k;
380
-
381
- if (a === null || typeof a !== "object") a = {};
382
- if (b === null || typeof b !== "object") b = {};
383
-
384
- for (k in b) {
385
- if (k in a) {
386
- i[k] = interpolate(a[k], b[k]);
387
- } else {
388
- c[k] = b[k];
389
- }
390
- }
391
-
392
- return function(t) {
393
- for (k in i) c[k] = i[k](t);
394
- return c;
395
- };
396
- }
397
-
398
- function interpolate(a, b) {
399
- var t = typeof b, c;
400
- return b == null || t === "boolean" ? constant(b)
401
- : (t === "number" ? interpolateNumber
402
- : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
403
- : b instanceof color ? interpolateRgb
404
- : b instanceof Date ? date
405
- : isNumberArray(b) ? numberArray
406
- : Array.isArray(b) ? genericArray
407
- : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
408
- : interpolateNumber)(a, b);
409
- }
410
-
411
228
  function interpolateRound(a, b) {
412
229
  return a = +a, b = +b, function(t) {
413
230
  return Math.round(a * (1 - t) + b * t);
@@ -740,6 +557,59 @@ function precisionRound(step, max) {
740
557
  return Math.max(0, exponent(max) - exponent(step)) + 1;
741
558
  }
742
559
 
560
+ function initRange(domain, range) {
561
+ switch (arguments.length) {
562
+ case 0: break;
563
+ case 1: this.range(domain); break;
564
+ default: this.range(range).domain(domain); break;
565
+ }
566
+ return this;
567
+ }
568
+
569
+ const implicit = Symbol("implicit");
570
+
571
+ function ordinal() {
572
+ var index = new InternMap(),
573
+ domain = [],
574
+ range = [],
575
+ unknown = implicit;
576
+
577
+ function scale(d) {
578
+ let i = index.get(d);
579
+ if (i === undefined) {
580
+ if (unknown !== implicit) return unknown;
581
+ index.set(d, i = domain.push(d) - 1);
582
+ }
583
+ return range[i % range.length];
584
+ }
585
+
586
+ scale.domain = function(_) {
587
+ if (!arguments.length) return domain.slice();
588
+ domain = [], index = new InternMap();
589
+ for (const value of _) {
590
+ if (index.has(value)) continue;
591
+ index.set(value, domain.push(value) - 1);
592
+ }
593
+ return scale;
594
+ };
595
+
596
+ scale.range = function(_) {
597
+ return arguments.length ? (range = Array.from(_), scale) : range.slice();
598
+ };
599
+
600
+ scale.unknown = function(_) {
601
+ return arguments.length ? (unknown = _, scale) : unknown;
602
+ };
603
+
604
+ scale.copy = function() {
605
+ return ordinal(domain, range).unknown(unknown);
606
+ };
607
+
608
+ initRange.apply(scale, arguments);
609
+
610
+ return scale;
611
+ }
612
+
743
613
  function band() {
744
614
  var scale = ordinal().unknown(undefined),
745
615
  domain = scale.domain,
@@ -820,6 +690,24 @@ function band() {
820
690
  return initRange.apply(rescale(), arguments);
821
691
  }
822
692
 
693
+ function pointish(scale) {
694
+ var copy = scale.copy;
695
+
696
+ scale.padding = scale.paddingOuter;
697
+ delete scale.paddingInner;
698
+ delete scale.paddingOuter;
699
+
700
+ scale.copy = function() {
701
+ return pointish(copy());
702
+ };
703
+
704
+ return scale;
705
+ }
706
+
707
+ function point() {
708
+ return pointish(band.apply(null, arguments).paddingInner(1));
709
+ }
710
+
823
711
  function constants(x) {
824
712
  return function() {
825
713
  return x;
@@ -1044,83 +932,412 @@ function linear() {
1044
932
  return linearish(scale);
1045
933
  }
1046
934
 
1047
- var css_248z = i`* {
1048
- box-sizing: border-box;
1049
- -webkit-tap-highlight-color: transparent;
935
+ function stackOffsetNone(series, order) {
936
+ if (!((n = series.length) > 1)) return;
937
+ for (var i = 1, j, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) {
938
+ s0 = s1, s1 = series[order[i]];
939
+ for (j = 0; j < m; ++j) {
940
+ s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1];
941
+ }
942
+ }
1050
943
  }
1051
944
 
1052
- .screen-reader-only {
1053
- display: none !important;
945
+ function none(series) {
946
+ var n = series.length, o = new Array(n);
947
+ while (--n >= 0) o[n] = n;
948
+ return o;
1054
949
  }
1055
950
 
1056
- [hidden] {
1057
- display: none !important;
951
+ function stackValue(d, key) {
952
+ return d[key];
1058
953
  }
1059
954
 
1060
- :host {
1061
- display: block;
1062
- color: var(--color-on-surface);
955
+ function stackSeries(key) {
956
+ const series = [];
957
+ series.key = key;
958
+ return series;
1063
959
  }
1064
960
 
1065
- .chart-frame {
1066
- background: var(--color-surface-container-low);
1067
- border: 1px solid var(--color-outline-variant);
1068
- border-radius: var(--shape-corner-medium);
1069
- padding: var(--spacing-300);
1070
- box-shadow: var(--elevation-level1);
1071
- }
961
+ function stack() {
962
+ var keys = constant([]),
963
+ order = none,
964
+ offset = stackOffsetNone,
965
+ value = stackValue;
1072
966
 
1073
- svg {
1074
- width: 100%;
1075
- height: 100%;
1076
- }
967
+ function stack(data) {
968
+ var sz = Array.from(keys.apply(this, arguments), stackSeries),
969
+ i, n = sz.length, j = -1,
970
+ oz;
1077
971
 
1078
- .axis-label {
1079
- font-family: var(--typography-label-medium-font-family) !important;
1080
- font-size: var(--typography-label-medium-font-size) !important;
1081
- font-weight: var(--typography-label-medium-font-weight) !important;
1082
- line-height: var(--typography-label-medium-line-height) !important;
1083
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
1084
- fill: var(--color-on-surface-variant);
1085
- }
972
+ for (const d of data) {
973
+ for (i = 0, ++j; i < n; ++i) {
974
+ (sz[i][j] = [0, +value(d, sz[i].key, j, data)]).data = d;
975
+ }
976
+ }
1086
977
 
1087
- .value-label {
1088
- font-family: var(--typography-label-small-font-family) !important;
1089
- font-size: var(--typography-label-small-font-size) !important;
1090
- font-weight: var(--typography-label-small-font-weight) !important;
1091
- line-height: var(--typography-label-small-line-height) !important;
1092
- letter-spacing: var(--typography-label-small-letter-spacing) !important;
1093
- fill: var(--color-on-surface);
1094
- }
978
+ for (i = 0, oz = array(order(sz)); i < n; ++i) {
979
+ sz[oz[i]].index = i;
980
+ }
1095
981
 
1096
- .gridline {
1097
- stroke: var(--color-outline-variant);
1098
- opacity: 0.6;
1099
- }
982
+ offset(sz, oz);
983
+ return sz;
984
+ }
1100
985
 
1101
- .legend {
1102
- display: flex;
1103
- flex-wrap: wrap;
1104
- gap: var(--spacing-200);
1105
- margin-top: var(--spacing-200);
1106
- color: var(--color-on-surface);
1107
- font-family: var(--typography-label-medium-font-family) !important;
1108
- font-size: var(--typography-label-medium-font-size) !important;
1109
- font-weight: var(--typography-label-medium-font-weight) !important;
1110
- line-height: var(--typography-label-medium-line-height) !important;
1111
- letter-spacing: var(--typography-label-medium-letter-spacing) !important;
1112
- }
1113
- .legend .legend-item {
1114
- display: inline-flex;
1115
- align-items: center;
1116
- gap: var(--spacing-150);
986
+ stack.keys = function(_) {
987
+ return arguments.length ? (keys = typeof _ === "function" ? _ : constant(Array.from(_)), stack) : keys;
988
+ };
989
+
990
+ stack.value = function(_) {
991
+ return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
992
+ };
993
+
994
+ stack.order = function(_) {
995
+ return arguments.length ? (order = _ == null ? none : typeof _ === "function" ? _ : constant(Array.from(_)), stack) : order;
996
+ };
997
+
998
+ stack.offset = function(_) {
999
+ return arguments.length ? (offset = _ == null ? stackOffsetNone : _, stack) : offset;
1000
+ };
1001
+
1002
+ return stack;
1003
+ }
1004
+
1005
+ /** Rough width of a `label-medium` character, used to size axes before text is measured. */
1006
+ const CHAR_WIDTH = 7;
1007
+ const AXIS_GAP = 8;
1008
+ const X_AXIS_HEIGHT = 24;
1009
+ const MAX_CATEGORY_AXIS_WIDTH = 120;
1010
+ /**
1011
+ * Base for charts with a category axis and a value axis (bar, line, area). Data is an array of
1012
+ * rows; `index` names the category field and `config` names the series fields.
1013
+ */
1014
+ class CartesianChart extends ChartBase {
1015
+ constructor() {
1016
+ // ── Properties
1017
+ super(...arguments);
1018
+ /** Rows to plot. Each row holds the category field (`index`) and a number per series. */
1019
+ this.data = [];
1020
+ /** Series to plot, keyed by data field, with optional label and color. Defaults to every numeric field. */
1021
+ this.config = {};
1022
+ /** Data field that holds the category label, for example `month`. */
1023
+ this.index = '';
1024
+ /** Hides the gridlines. */
1025
+ this.hideGrid = false;
1026
+ /** Hides the category axis labels. */
1027
+ this.hideCategoryAxis = false;
1028
+ /** Hides the value axis labels. */
1029
+ this.hideValueAxis = false;
1030
+ // ── Private fields
1031
+ /** Current plot layout, set by `computeLayout()`. */
1032
+ this.layout = {
1033
+ left: 0,
1034
+ top: 0,
1035
+ right: 0,
1036
+ bottom: 0,
1037
+ innerWidth: 0,
1038
+ innerHeight: 0,
1039
+ };
1040
+ /** Which axis carries the categories. */
1041
+ this.orientation = 'vertical';
1042
+ /** Category centers along the category axis, in inner plot coordinates. */
1043
+ this.centers = [];
1044
+ /** Width of one category slot along the category axis. */
1045
+ this.step = 0;
1046
+ /** Tooltip anchor per category, in plot element coordinates. */
1047
+ this.anchors = [];
1048
+ /** Whether the cursor is a band (bars) or a line (line, area). */
1049
+ this.cursorKind = 'band';
1050
+ }
1051
+ // ── Overrides
1052
+ drawProperties() {
1053
+ return [
1054
+ ...super.drawProperties(),
1055
+ 'data',
1056
+ 'config',
1057
+ 'index',
1058
+ 'hideGrid',
1059
+ 'hideCategoryAxis',
1060
+ 'hideValueAxis',
1061
+ ];
1062
+ }
1063
+ hasData() {
1064
+ return this.data.length > 0 && this.seriesKeys().length > 0;
1065
+ }
1066
+ getSeries() {
1067
+ return this.seriesKeys().map((key, i) => ({
1068
+ key,
1069
+ label: this.config[key]?.label ?? key,
1070
+ color: this.config[key]?.color ?? chartColor(i),
1071
+ }));
1072
+ }
1073
+ getItemCount() {
1074
+ return this.data.length;
1075
+ }
1076
+ itemAtPoint(x, y) {
1077
+ const { left, top, innerWidth, innerHeight } = this.layout;
1078
+ const px = x - left;
1079
+ const py = y - top;
1080
+ if (px < 0 || py < 0 || px > innerWidth || py > innerHeight)
1081
+ return -1;
1082
+ const along = this.orientation === 'vertical' ? px : py;
1083
+ let best = -1;
1084
+ let bestDistance = Infinity;
1085
+ this.centers.forEach((center, i) => {
1086
+ const distance = Math.abs(center - along);
1087
+ if (distance < bestDistance) {
1088
+ bestDistance = distance;
1089
+ best = i;
1090
+ }
1091
+ });
1092
+ return best;
1093
+ }
1094
+ getTooltip(index) {
1095
+ const datum = this.data[index];
1096
+ if (!datum)
1097
+ return undefined;
1098
+ const anchor = this.anchors[index] ?? { x: 0, y: 0 };
1099
+ return {
1100
+ title: this.categoryLabel(index),
1101
+ rows: this.visibleSeries().map(series => ({
1102
+ key: series.key,
1103
+ label: series.label,
1104
+ color: series.color,
1105
+ value: this.formatValue(this.seriesValue(datum, series.key)),
1106
+ })),
1107
+ x: anchor.x,
1108
+ y: anchor.y,
1109
+ };
1110
+ }
1111
+ getSelectDetail(index) {
1112
+ return { index, datum: this.data[index] };
1113
+ }
1114
+ drawHighlight() {
1115
+ const root = this.plotArea();
1116
+ if (!root)
1117
+ return;
1118
+ const cursor = root.select('.cursor');
1119
+ const index = this.activeIndex;
1120
+ if (index < 0 || this.centers[index] === undefined) {
1121
+ cursor.classed('is-visible', false);
1122
+ return;
1123
+ }
1124
+ const { innerWidth, innerHeight } = this.layout;
1125
+ const center = this.centers[index];
1126
+ const size = this.cursorKind === 'band' ? this.step : 1;
1127
+ cursor
1128
+ .classed('cursor-line', this.cursorKind === 'line')
1129
+ .classed('is-visible', true);
1130
+ if (this.orientation === 'vertical') {
1131
+ cursor
1132
+ .attr('x', center - size / 2)
1133
+ .attr('y', 0)
1134
+ .attr('width', size)
1135
+ .attr('height', innerHeight);
1136
+ }
1137
+ else {
1138
+ cursor
1139
+ .attr('x', 0)
1140
+ .attr('y', center - size / 2)
1141
+ .attr('width', innerWidth)
1142
+ .attr('height', size);
1143
+ }
1144
+ }
1145
+ renderSvgContent() {
1146
+ return w `<defs></defs>
1147
+ <g class="plot-area">
1148
+ <g class="grid"></g>
1149
+ <rect class="cursor"></rect>
1150
+ <g class="marks"></g>
1151
+ <g class="value-labels"></g>
1152
+ <g class="category-axis"></g>
1153
+ <g class="value-axis"></g>
1154
+ <g class="active-layer"></g>
1155
+ </g>`;
1156
+ }
1157
+ renderTable() {
1158
+ const series = this.getSeries();
1159
+ return b `<thead>
1160
+ <tr>
1161
+ <th scope="col">${this.index || 'Category'}</th>
1162
+ ${series.map(s => b `<th scope="col">${s.label}</th>`)}
1163
+ </tr>
1164
+ </thead>
1165
+ <tbody>
1166
+ ${this.data.map((datum, i) => b `<tr>
1167
+ <th scope="row">${this.categoryLabel(i)}</th>
1168
+ ${series.map(s => b `<td>
1169
+ ${this.formatValue(this.seriesValue(datum, s.key))}
1170
+ </td>`)}
1171
+ </tr>`)}
1172
+ </tbody>`;
1173
+ }
1174
+ // ── Helpers for subclasses
1175
+ /** Series keys from `config`, or every numeric field of the first row except `index`. */
1176
+ seriesKeys() {
1177
+ const configured = Object.keys(this.config ?? {});
1178
+ if (configured.length)
1179
+ return configured;
1180
+ const first = this.data[0];
1181
+ if (!first)
1182
+ return [];
1183
+ return Object.keys(first).filter(key => key !== this.index && typeof first[key] === 'number');
1184
+ }
1185
+ /** Series not switched off in the legend. */
1186
+ visibleSeries() {
1187
+ return this.getSeries().filter(series => !this.isHidden(series.key));
1188
+ }
1189
+ /** A row's value for a series, 0 when missing. */
1190
+ seriesValue(datum, key) {
1191
+ const value = Number(datum[key]);
1192
+ return Number.isFinite(value) ? value : 0;
1193
+ }
1194
+ /** Category label of a row. */
1195
+ categoryLabel(index) {
1196
+ const datum = this.data[index];
1197
+ if (!datum)
1198
+ return '';
1199
+ return this.index ? String(datum[this.index] ?? '') : String(index + 1);
1200
+ }
1201
+ /** Category domain: row positions, so repeated labels stay distinct. */
1202
+ categoryDomain() {
1203
+ return this.data.map((_, i) => String(i));
1204
+ }
1205
+ /** The `.plot-area` group, or undefined before the SVG renders. */
1206
+ plotArea() {
1207
+ if (!this.svgElement)
1208
+ return undefined;
1209
+ return select(this.svgElement).select('.plot-area');
1210
+ }
1211
+ /**
1212
+ * Sets `layout` from the value scale's ticks and the category labels. Call before setting the
1213
+ * scales' ranges. `valueLabelSpace` reserves room for value labels at the end of the marks.
1214
+ */
1215
+ computeLayout(valueScale, valueLabelSpace = 0) {
1216
+ const { width, height } = this.svgSize();
1217
+ const tickWidth = Math.max(...valueScale.ticks(5).map(t => this.formatTick(t).length), 1) *
1218
+ CHAR_WIDTH +
1219
+ AXIS_GAP;
1220
+ const categoryWidth = Math.min(Math.max(...this.data.map((_, i) => this.categoryLabel(i).length), 1) *
1221
+ CHAR_WIDTH +
1222
+ AXIS_GAP, MAX_CATEGORY_AXIS_WIDTH);
1223
+ let left;
1224
+ let bottom;
1225
+ let top = 8;
1226
+ let right = 8;
1227
+ if (this.orientation === 'vertical') {
1228
+ left = this.hideValueAxis ? 4 : tickWidth;
1229
+ bottom = this.hideCategoryAxis ? 4 : X_AXIS_HEIGHT;
1230
+ top += valueLabelSpace ? 12 : 0;
1231
+ // Room for half of the last category label.
1232
+ right += this.hideCategoryAxis ? 0 : 4;
1233
+ }
1234
+ else {
1235
+ left = this.hideCategoryAxis ? 4 : categoryWidth;
1236
+ bottom = this.hideValueAxis ? 4 : X_AXIS_HEIGHT;
1237
+ right += valueLabelSpace;
1238
+ }
1239
+ this.layout = {
1240
+ left,
1241
+ top,
1242
+ right,
1243
+ bottom,
1244
+ innerWidth: Math.max(width - left - right, 0),
1245
+ innerHeight: Math.max(height - top - bottom, 0),
1246
+ };
1247
+ }
1248
+ /**
1249
+ * Draws gridlines, the zero baseline and both axes' labels, and records category centers.
1250
+ * The scales must already have their ranges set from `layout`.
1251
+ */
1252
+ drawFrame(categoryScale, valueScale) {
1253
+ const root = this.plotArea();
1254
+ if (!root)
1255
+ return;
1256
+ const { left, top, innerWidth, innerHeight } = this.layout;
1257
+ const vertical = this.orientation === 'vertical';
1258
+ root.attr('transform', `translate(${left},${top})`);
1259
+ const domain = categoryScale.domain();
1260
+ const bandwidth = categoryScale.bandwidth();
1261
+ this.step = categoryScale.step();
1262
+ this.centers = domain.map(key => (categoryScale(key) ?? 0) + bandwidth / 2);
1263
+ // Gridlines at each value tick; the zero line is solid.
1264
+ const ticks = valueScale.ticks(5);
1265
+ const gridTicks = this.hideGrid ? [] : ticks.filter(t => t !== 0);
1266
+ root
1267
+ .select('.grid')
1268
+ .selectAll('line.gridline')
1269
+ .data(gridTicks, d => String(d))
1270
+ .join('line')
1271
+ .attr('class', 'gridline')
1272
+ .attr('x1', d => (vertical ? 0 : valueScale(d)))
1273
+ .attr('x2', d => (vertical ? innerWidth : valueScale(d)))
1274
+ .attr('y1', d => (vertical ? valueScale(d) : 0))
1275
+ .attr('y2', d => (vertical ? valueScale(d) : innerHeight));
1276
+ const zero = valueScale(0);
1277
+ root
1278
+ .select('.grid')
1279
+ .selectAll('line.baseline')
1280
+ .data([zero])
1281
+ .join('line')
1282
+ .attr('class', 'baseline')
1283
+ .attr('x1', vertical ? 0 : zero)
1284
+ .attr('x2', vertical ? innerWidth : zero)
1285
+ .attr('y1', vertical ? zero : 0)
1286
+ .attr('y2', vertical ? zero : innerHeight);
1287
+ // Value axis labels.
1288
+ const showValueAxis = !this.hideValueAxis;
1289
+ root
1290
+ .select('.value-axis')
1291
+ .selectAll('text')
1292
+ .data(showValueAxis ? ticks : [], d => String(d))
1293
+ .join('text')
1294
+ .attr('class', 'axis-label')
1295
+ .attr('text-anchor', vertical ? 'end' : 'middle')
1296
+ .attr('dominant-baseline', vertical ? 'middle' : 'hanging')
1297
+ .attr('x', d => (vertical ? -AXIS_GAP : valueScale(d)))
1298
+ .attr('y', d => (vertical ? valueScale(d) : innerHeight + AXIS_GAP))
1299
+ .text(d => this.formatTick(d));
1300
+ // Category axis labels, thinned out when they would overlap.
1301
+ const showCategoryAxis = !this.hideCategoryAxis;
1302
+ const longest = Math.max(...domain.map((_, i) => this.categoryLabel(i).length), 1);
1303
+ const labelSize = vertical ? longest * CHAR_WIDTH + AXIS_GAP : 18;
1304
+ const every = Math.max(1, Math.ceil(labelSize / Math.max(this.step, 1)));
1305
+ const shown = showCategoryAxis
1306
+ ? domain.filter((_, i) => i % every === 0)
1307
+ : [];
1308
+ root
1309
+ .select('.category-axis')
1310
+ .selectAll('text')
1311
+ .data(shown, d => d)
1312
+ .join('text')
1313
+ .attr('class', 'axis-label')
1314
+ .attr('text-anchor', vertical ? 'middle' : 'end')
1315
+ .attr('dominant-baseline', vertical ? 'hanging' : 'middle')
1316
+ .attr('x', d => vertical ? (categoryScale(d) ?? 0) + bandwidth / 2 : -AXIS_GAP)
1317
+ .attr('y', d => vertical
1318
+ ? innerHeight + AXIS_GAP
1319
+ : (categoryScale(d) ?? 0) + bandwidth / 2)
1320
+ .text(d => this.categoryLabel(Number(d)));
1321
+ }
1117
1322
  }
1118
- .legend .legend-item .swatch {
1119
- width: 12px;
1120
- height: 12px;
1121
- border-radius: var(--shape-corner-full);
1122
- border: 1px solid var(--color-outline-variant);
1123
- }`;
1124
-
1125
- export { axisLeft as a, band as b, css_248z as c, axisBottom as d, linear as l, max as m };
1126
- //# sourceMappingURL=chart-bar-D5dGFJfK.js.map
1323
+ __decorate([
1324
+ n({ type: Array })
1325
+ ], CartesianChart.prototype, "data", void 0);
1326
+ __decorate([
1327
+ n({ type: Object })
1328
+ ], CartesianChart.prototype, "config", void 0);
1329
+ __decorate([
1330
+ n({ type: String })
1331
+ ], CartesianChart.prototype, "index", void 0);
1332
+ __decorate([
1333
+ n({ type: Boolean, attribute: 'hide-grid' })
1334
+ ], CartesianChart.prototype, "hideGrid", void 0);
1335
+ __decorate([
1336
+ n({ type: Boolean, attribute: 'hide-category-axis' })
1337
+ ], CartesianChart.prototype, "hideCategoryAxis", void 0);
1338
+ __decorate([
1339
+ n({ type: Boolean, attribute: 'hide-value-axis' })
1340
+ ], CartesianChart.prototype, "hideValueAxis", void 0);
1341
+
1342
+ export { CartesianChart as C, max as a, band as b, stackOffsetNone as c, linear as l, min as m, point as p, stack as s };
1343
+ //# sourceMappingURL=cartesian-chart-DgE4USyC.js.map