@adecore/charts 0.39.0 → 0.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Root.js CHANGED
@@ -9,7 +9,7 @@ import { LABEL_GAP as X_AXIS_GAP } from "./axes.js";
9
9
  import { bandLayout, GROUP_GAP } from './band.js';
10
10
  import { seriesColor } from './color.js';
11
11
  import { ChartContext, GroupContext } from './context.js';
12
- import { containingIndex, moveIndex, nearestIndex, snapIndex } from './cursor.js';
12
+ import { containingIndex, keyIndexOf, moveIndex, nearestIndex, snapIndex } from './cursor.js';
13
13
  import { useAlignedAxes } from './group-axes.js';
14
14
  import { movePoint, nearestPoint } from './points.js';
15
15
  import { bucketStepOf, continuousXScale, extentOf, pointXScale, stackSeries, tickCount, yScaleOf } from './scale.js';
@@ -167,17 +167,22 @@ export function ChartRoot(t0) {
167
167
  const members = new Map();
168
168
  for (const [seriesId_1, entry_2] of series) {
169
169
  if (entry_2.kind === "bar") {
170
- members.set(entry_2.bars ?? "", [...(members.get(entry_2.bars ?? "") ?? []), seriesId_1]);
170
+ const ids = members.get(entry_2.bars ?? "");
171
+ if (ids === undefined) {
172
+ members.set(entry_2.bars ?? "", [seriesId_1]);
173
+ } else {
174
+ ids.push(seriesId_1);
175
+ }
171
176
  }
172
177
  }
173
- for (const ids of members.values()) {
174
- const stackedBars = ids.some(seriesId_2 => series.get(seriesId_2).stack !== null);
175
- ids.forEach((seriesId_3, index_4) => slots.set(seriesId_3, stackedBars ? {
178
+ for (const ids_0 of members.values()) {
179
+ const stackedBars = ids_0.some(seriesId_2 => series.get(seriesId_2).stack !== null);
180
+ ids_0.forEach((seriesId_3, index_4) => slots.set(seriesId_3, stackedBars ? {
176
181
  slot: 0,
177
182
  count: 1
178
183
  } : {
179
184
  slot: index_4,
180
- count: ids.length
185
+ count: ids_0.length
181
186
  }));
182
187
  }
183
188
  const placing = points ? [...series.values()].find(_temp5) : undefined;
@@ -248,7 +253,7 @@ export function ChartRoot(t0) {
248
253
  };
249
254
  const pixelOfX = value_2 => {
250
255
  if (layout !== null) {
251
- const index_12 = xs.findIndex(key_0 => String(key_0) === String(value_2));
256
+ const index_12 = keyIndexOf(xs, value_2);
252
257
  return index_12 < 0 ? null : centerOf(index_12);
253
258
  }
254
259
  return typeof value_2 === "number" ? continuous.at(value_2) : null;
@@ -289,8 +294,8 @@ export function ChartRoot(t0) {
289
294
  for (const range of bands.values()) {
290
295
  let inside_0;
291
296
  if (band) {
292
- const from = xs.findIndex(key_1 => String(key_1) === String(range.from));
293
- const to = xs.findIndex(key_2 => String(key_2) === String(range.to));
297
+ const from = keyIndexOf(xs, range.from);
298
+ const to = keyIndexOf(xs, range.to);
294
299
  inside_0 = from >= 0 && to >= 0 && index_14 >= Math.min(from, to) && index_14 <= Math.max(from, to);
295
300
  } else {
296
301
  if (bucketStep > 0) {
@@ -312,23 +317,28 @@ export function ChartRoot(t0) {
312
317
  };
313
318
  const controlled = activeX !== undefined;
314
319
  const cursorX = controlled ? activeX : sharedCursor !== null ? sharedCursor.x : ownX;
315
- const pointIndex = keys === null || cursorX === null ? -1 : keys.indexOf(String(cursorX));
316
- const activeIndex = points ? positions[pointIndex] == null ? -1 : pointIndex : snapIndex(xs, xScale, cursorX, bucketStep);
317
- const keyPoint = keys === null || keyX === null ? -1 : keys.indexOf(String(keyX));
318
- const keyIndex = points ? positions[keyPoint] == null ? -1 : keyPoint : snapIndex(xs, xScale, keyX, bucketStep);
320
+ const indexAt = value_4 => {
321
+ if (keys === null) {
322
+ return snapIndex(xs, xScale, value_4, bucketStep);
323
+ }
324
+ const index_15 = value_4 === null ? -1 : keys.indexOf(String(value_4));
325
+ return positions[index_15] == null ? -1 : index_15;
326
+ };
327
+ const activeIndex = indexAt(cursorX);
328
+ const keyIndex = indexAt(keyX);
319
329
  const from_0 = keyIndex >= 0 ? keyIndex : activeIndex;
320
330
  const ownsCursor = controlled || sharedCursor === null || sharedCursor.owner === id;
321
331
  let t16;
322
332
  if ($[2] !== controlled || $[3] !== id || $[4] !== onActiveXChange || $[5] !== sharedCursor) {
323
- t16 = value_4 => {
333
+ t16 = value_5 => {
324
334
  if (!controlled) {
325
335
  if (sharedCursor !== null) {
326
- sharedCursor.setX(value_4, id);
336
+ sharedCursor.setX(value_5, id);
327
337
  } else {
328
- setOwnX(value_4);
338
+ setOwnX(value_5);
329
339
  }
330
340
  }
331
- onActiveXChange?.(value_4);
341
+ onActiveXChange?.(value_5);
332
342
  };
333
343
  $[2] = controlled;
334
344
  $[3] = id;
@@ -350,7 +360,7 @@ export function ChartRoot(t0) {
350
360
  const picked = t17;
351
361
  let t18;
352
362
  if ($[9] !== picked) {
353
- t18 = key_3 => picked.has(String(key_3));
363
+ t18 = key_0 => picked.has(String(key_0));
354
364
  $[9] = picked;
355
365
  $[10] = t18;
356
366
  } else {
@@ -359,31 +369,31 @@ export function ChartRoot(t0) {
359
369
  const selectedRows = (keys ?? xs).map(t18);
360
370
  let t19;
361
371
  if ($[11] !== dimmed) {
362
- t19 = (row_6, index_15) => dimmed?.(row_6, index_15) ?? false;
372
+ t19 = (row_6, index_16) => dimmed?.(row_6, index_16) ?? false;
363
373
  $[11] = dimmed;
364
374
  $[12] = t19;
365
375
  } else {
366
376
  t19 = $[12];
367
377
  }
368
378
  const dimmedRows = data.map(t19);
369
- const dimmedGroups = new Set(pointGroups.filter(run => run.indexes.every(index_16 => dimmedRows[index_16])).map(_temp7));
379
+ const dimmedGroups = new Set(pointGroups.filter(run => run.indexes.every(index_17 => dimmedRows[index_17])).map(_temp7));
370
380
  const anyPicked = selectedRows.some(Boolean);
371
381
  const columnDim = [...series.values()].find(_temp8)?.dimOpacity ?? null;
372
- const labelFocus = xs.map((__1, index_17) => {
373
- if (index_17 === activeIndex || selectedRows[index_17]) {
382
+ const labelFocus = xs.map((__1, index_18) => {
383
+ if (index_18 === activeIndex || selectedRows[index_18]) {
374
384
  return "strong";
375
385
  }
376
- return dimmedRows[index_17] || anyPicked ? "dim" : null;
386
+ return dimmedRows[index_18] || anyPicked ? "dim" : null;
377
387
  });
378
- const describe = index_18 => {
379
- const parts = (points ? [groupLabels?.[index_18], rowLabels?.[index_18], xValueOf(index_18)] : [groupLabels?.[index_18], rowLabels?.[index_18] ?? xValueOf(index_18)]).filter(_temp9);
388
+ const describe = index_19 => {
389
+ const parts = (points ? [groupLabels?.[index_19], rowLabels?.[index_19], xValueOf(index_19)] : [groupLabels?.[index_19], rowLabels?.[index_19] ?? xValueOf(index_19)]).filter(_temp9);
380
390
  for (const [, entry_6] of readable) {
381
- const value_5 = entry_6.values[index_18];
382
- if (value_5 !== null && value_5 !== undefined) {
383
- parts.push(`${entry_6.label} ${formatY(value_5)}`);
391
+ const value_6 = entry_6.values[index_19];
392
+ if (value_6 !== null && value_6 !== undefined) {
393
+ parts.push(`${entry_6.label} ${formatY(value_6)}`);
384
394
  }
385
395
  }
386
- return [...parts, ...notesAt(index_18).map(_temp0)].join(", ");
396
+ return [...parts, ...notesAt(index_19).map(_temp0)].join(", ");
387
397
  };
388
398
  let t20;
389
399
  let t21;
@@ -407,7 +417,7 @@ export function ChartRoot(t0) {
407
417
  if (points) {
408
418
  return nearestPoint(placed, pixel_1, e.clientY - box.top, POINT_REACH);
409
419
  }
410
- return nearestIndex(xs.map((__2, index_19) => centerOf(index_19)), pixel_1);
420
+ return nearestIndex(xs.map((__2, index_20) => centerOf(index_20)), pixel_1);
411
421
  };
412
422
  const onPointerMove = e_0 => {
413
423
  setAnnounce(false);
@@ -415,32 +425,32 @@ export function ChartRoot(t0) {
415
425
  return;
416
426
  }
417
427
  if (keys !== null) {
418
- const index_20 = indexAtPointer(e_0);
419
- if (index_20 !== activeIndex) {
420
- setActiveX(index_20 < 0 ? null : keys[index_20]);
428
+ const index_21 = indexAtPointer(e_0);
429
+ if (index_21 !== activeIndex) {
430
+ setActiveX(index_21 < 0 ? null : keys[index_21]);
421
431
  }
422
432
  return;
423
433
  }
424
434
  if (continuous !== null) {
425
435
  const pixel_2 = e_0.clientX - e_0.currentTarget.getBoundingClientRect().left;
426
- const index_21 = snapIndex(xs, xScale, continuous.invert(Math.min(plot.right - 1, Math.max(plot.left, pixel_2))), bucketStep);
427
- const value_6 = index_21 < 0 ? null : xs[index_21];
428
- if (value_6 !== cursorX) {
429
- setActiveX(value_6);
436
+ const index_22 = snapIndex(xs, xScale, continuous.invert(Math.min(plot.right - 1, Math.max(plot.left, pixel_2))), bucketStep);
437
+ const value_7 = index_22 < 0 ? null : xs[index_22];
438
+ if (value_7 !== cursorX) {
439
+ setActiveX(value_7);
430
440
  }
431
441
  return;
432
442
  }
433
- const index_22 = indexAtPointer(e_0);
434
- if (index_22 >= 0 && String(xs[index_22]) !== String(cursorX)) {
435
- setActiveX(xs[index_22]);
443
+ const index_23 = indexAtPointer(e_0);
444
+ if (index_23 >= 0 && String(xs[index_23]) !== String(cursorX)) {
445
+ setActiveX(xs[index_23]);
436
446
  }
437
447
  };
438
448
  const pressable = interactive && onActivate !== undefined && (layout !== null || points);
439
449
  let t22;
440
450
  if ($[17] !== data || $[18] !== onActivate || $[19] !== pressable) {
441
- t22 = index_23 => {
442
- if (pressable && index_23 >= 0) {
443
- onActivate(data[index_23], index_23);
451
+ t22 = index_24 => {
452
+ if (pressable && index_24 >= 0) {
453
+ onActivate(data[index_24], index_24);
444
454
  }
445
455
  };
446
456
  $[17] = data;
@@ -458,7 +468,7 @@ export function ChartRoot(t0) {
458
468
  return;
459
469
  }
460
470
  const groupStarts = layout?.groups.map(_temp1) ?? [];
461
- const target = keys === null ? moveIndex(e_1.key, from_0, xs.length, groupStarts) : movePoint(pointGroups.map(run_2 => run_2.indexes.filter(index_24 => positions[index_24] !== null)), from_0, e_1.key);
471
+ const target = keys === null ? moveIndex(e_1.key, from_0, xs.length, groupStarts) : movePoint(pointGroups.map(run_2 => run_2.indexes.filter(index_25 => positions[index_25] !== null)), from_0, e_1.key);
462
472
  if (target === undefined) {
463
473
  return;
464
474
  }
@@ -470,8 +480,9 @@ export function ChartRoot(t0) {
470
480
  return;
471
481
  }
472
482
  setAnnounce(true);
473
- setKeyX(keys === null ? xs[target] : keys[target]);
474
- setActiveX(keys === null ? xs[target] : keys[target]);
483
+ const value_8 = keys === null ? xs[target] : keys[target];
484
+ setKeyX(value_8);
485
+ setActiveX(value_8);
475
486
  const box_0 = scroller.current;
476
487
  if (box_0 !== null && box_0.scrollWidth > box_0.clientWidth) {
477
488
  const center = centerOf(target);
@@ -577,7 +588,7 @@ export function ChartRoot(t0) {
577
588
  t26 = $[31];
578
589
  }
579
590
  const hint = t26.join(" ");
580
- const highlighted = layout === null ? [] : xs.flatMap((__3, index_25) => cursor === "full" && index_25 === activeIndex || selectedRows[index_25] ? [index_25] : []);
591
+ const highlighted = layout === null ? [] : xs.flatMap((__3, index_26) => cursor === "full" && index_26 === activeIndex || selectedRows[index_26] ? [index_26] : []);
581
592
  const t27 = grow && "h-full min-h-0";
582
593
  let t28;
583
594
  if ($[32] !== className || $[33] !== t27) {
@@ -821,37 +832,37 @@ export function ChartRoot(t0) {
821
832
  setActiveX(null);
822
833
  }
823
834
  },
824
- children: [layout !== null && highlighted.map(index_26 => /*#__PURE__*/_jsx("rect", {
825
- x: Math.round(plot.left + layout.lefts[index_26]),
835
+ children: [layout !== null && highlighted.map(index_27 => /*#__PURE__*/_jsx("rect", {
836
+ x: Math.round(plot.left + layout.lefts[index_27]),
826
837
  y: plot.top,
827
838
  width: Math.max(1, Math.round(layout.bucket)),
828
839
  height: plot.height,
829
840
  className: "fill-surface-hover"
830
- }, index_26)), children, t43, continuous !== null && !points && activeIndex >= 0 && cursor !== "none" && /*#__PURE__*/_jsx(Crosshair, {
841
+ }, index_27)), children, t43, continuous !== null && !points && activeIndex >= 0 && cursor !== "none" && /*#__PURE__*/_jsx(Crosshair, {
831
842
  context: context,
832
843
  dots: cursor === "full"
833
844
  }), points && /*#__PURE__*/_jsx(Guides, {
834
845
  context: context
835
- }), pressable && points && positions.map((position, index_27) => position === null ? null : /*#__PURE__*/_jsx("circle", {
836
- id: `${id}-${index_27}`,
846
+ }), pressable && points && positions.map((position, index_28) => position === null ? null : /*#__PURE__*/_jsx("circle", {
847
+ id: `${id}-${index_28}`,
837
848
  role: "button",
838
- "aria-pressed": selectedRows[index_27],
839
- "aria-label": describe(index_27),
849
+ "aria-pressed": selectedRows[index_28],
850
+ "aria-label": describe(index_28),
840
851
  cx: position[0],
841
852
  cy: position[1],
842
853
  r: 10,
843
854
  fill: "transparent"
844
- }, keys[index_27])), pressable && layout !== null && xs.map((key_4, index_28) => /*#__PURE__*/_jsx("rect", {
845
- id: `${id}-${index_28}`,
855
+ }, keys[index_28])), pressable && layout !== null && xs.map((key_1, index_29) => /*#__PURE__*/_jsx("rect", {
856
+ id: `${id}-${index_29}`,
846
857
  role: "button",
847
- "aria-pressed": selectedRows[index_28],
848
- "aria-label": describe(index_28),
849
- x: Math.round(plot.left + layout.lefts[index_28]),
858
+ "aria-pressed": selectedRows[index_29],
859
+ "aria-label": describe(index_29),
860
+ x: Math.round(plot.left + layout.lefts[index_29]),
850
861
  y: plot.top,
851
862
  width: Math.max(1, Math.round(layout.bucket)),
852
863
  height: height - plot.top,
853
864
  fill: "transparent"
854
- }, String(key_4))), xs.length === 0 && /*#__PURE__*/_jsx("text", {
865
+ }, String(key_1))), xs.length === 0 && /*#__PURE__*/_jsx("text", {
855
866
  x: Math.round((plot.left + plot.right) / 2),
856
867
  y: Math.round((plot.top + plot.bottom) / 2),
857
868
  dy: "0.32em",
@@ -5,6 +5,7 @@ import clsx from 'clsx';
5
5
  import { xOf } from './access.js';
6
6
  import { colorOf } from './color.js';
7
7
  import { useChartContext } from './context.js';
8
+ import { keyIndexOf } from './cursor.js';
8
9
  import { useRegistration } from './register.js';
9
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
11
  const MIN_BAND = 4;
@@ -323,7 +324,7 @@ export function ChartMarker(t0) {
323
324
  }
324
325
  /* A hatched range, such as a stretch without data. */
325
326
  export function ChartBand(t0) {
326
- const $ = _c(48);
327
+ const $ = _c(28);
327
328
  const {
328
329
  from,
329
330
  to,
@@ -336,69 +337,32 @@ export function ChartBand(t0) {
336
337
  const tone = t1 === undefined ? "muted" : t1;
337
338
  const chart = useChartContext("Chart.Band");
338
339
  const id = useId();
340
+ const color = colorOf(tone);
341
+ const start = xOf(from);
342
+ const end = xOf(to);
339
343
  let t2;
340
- if ($[0] !== tone) {
341
- t2 = colorOf(tone);
342
- $[0] = tone;
343
- $[1] = t2;
344
- } else {
345
- t2 = $[1];
346
- }
347
- const color = t2;
348
- let t3;
349
- if ($[2] !== from) {
350
- t3 = xOf(from);
351
- $[2] = from;
352
- $[3] = t3;
353
- } else {
354
- t3 = $[3];
355
- }
356
- const start = t3;
357
- let t4;
358
- if ($[4] !== to) {
359
- t4 = xOf(to);
360
- $[4] = to;
361
- $[5] = t4;
362
- } else {
363
- t4 = $[5];
364
- }
365
- const end = t4;
366
- let t5;
367
- if ($[6] !== id) {
368
- let t6;
369
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
370
- t6 = /[^\w-]/g;
371
- $[8] = t6;
344
+ if ($[0] !== id) {
345
+ let t3;
346
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
347
+ t3 = /[^\w-]/g;
348
+ $[2] = t3;
372
349
  } else {
373
- t6 = $[8];
350
+ t3 = $[2];
374
351
  }
375
- t5 = id.replace(t6, "");
376
- $[6] = id;
377
- $[7] = t5;
378
- } else {
379
- t5 = $[7];
380
- }
381
- const pattern = `chart-band-${t5}`;
382
- const t6 = detail ?? null;
383
- let t7;
384
- if ($[9] !== color || $[10] !== end || $[11] !== label || $[12] !== start || $[13] !== t6) {
385
- t7 = {
386
- from: start,
387
- to: end,
388
- label,
389
- detail: t6,
390
- color
391
- };
392
- $[9] = color;
393
- $[10] = end;
394
- $[11] = label;
395
- $[12] = start;
396
- $[13] = t6;
397
- $[14] = t7;
352
+ t2 = id.replace(t3, "");
353
+ $[0] = id;
354
+ $[1] = t2;
398
355
  } else {
399
- t7 = $[14];
356
+ t2 = $[1];
400
357
  }
401
- useRegistration(chart.store, "band", id, t7);
358
+ const pattern = `chart-band-${t2}`;
359
+ useRegistration(chart.store, "band", id, {
360
+ from: start,
361
+ to: end,
362
+ label,
363
+ detail: detail ?? null,
364
+ color
365
+ });
402
366
  const {
403
367
  plot,
404
368
  band,
@@ -407,34 +371,12 @@ export function ChartBand(t0) {
407
371
  let left = null;
408
372
  let right = null;
409
373
  if (continuous !== null && typeof start === "number" && typeof end === "number") {
410
- const t8 = plot.left;
411
- let t9;
412
- if ($[15] !== continuous || $[16] !== end || $[17] !== start) {
413
- t9 = continuous.at(Math.min(start, end));
414
- $[15] = continuous;
415
- $[16] = end;
416
- $[17] = start;
417
- $[18] = t9;
418
- } else {
419
- t9 = $[18];
420
- }
421
- left = Math.max(t8, t9);
422
- const t10 = plot.right;
423
- let t11;
424
- if ($[19] !== continuous || $[20] !== end || $[21] !== start) {
425
- t11 = continuous.at(Math.max(start, end));
426
- $[19] = continuous;
427
- $[20] = end;
428
- $[21] = start;
429
- $[22] = t11;
430
- } else {
431
- t11 = $[22];
432
- }
433
- right = Math.min(t10, t11);
374
+ left = Math.max(plot.left, continuous.at(Math.min(start, end)));
375
+ right = Math.min(plot.right, continuous.at(Math.max(start, end)));
434
376
  } else {
435
377
  if (band !== null) {
436
- const first = chart.xs.findIndex(key => String(key) === String(start));
437
- const last = chart.xs.findIndex(key_0 => String(key_0) === String(end));
378
+ const first = keyIndexOf(chart.xs, start);
379
+ const last = keyIndexOf(chart.xs, end);
438
380
  if (first >= 0 && last >= 0) {
439
381
  left = plot.left + band.lefts[Math.min(first, last)];
440
382
  right = plot.left + band.lefts[Math.max(first, last)] + band.bucket;
@@ -446,27 +388,27 @@ export function ChartBand(t0) {
446
388
  }
447
389
  const x = Math.round(left);
448
390
  const width = Math.max(MIN_BAND, Math.round(right) - x);
449
- let t8;
450
- if ($[23] !== className) {
451
- t8 = clsx("pointer-events-none", className);
452
- $[23] = className;
453
- $[24] = t8;
391
+ let t3;
392
+ if ($[3] !== className) {
393
+ t3 = clsx("pointer-events-none", className);
394
+ $[3] = className;
395
+ $[4] = t3;
454
396
  } else {
455
- t8 = $[24];
397
+ t3 = $[4];
456
398
  }
457
- let t9;
458
- if ($[25] !== color) {
459
- t9 = {
399
+ let t4;
400
+ if ($[5] !== color) {
401
+ t4 = {
460
402
  color
461
403
  };
462
- $[25] = color;
463
- $[26] = t9;
404
+ $[5] = color;
405
+ $[6] = t4;
464
406
  } else {
465
- t9 = $[26];
407
+ t4 = $[6];
466
408
  }
467
- let t10;
468
- if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
469
- t10 = /*#__PURE__*/_jsx("line", {
409
+ let t5;
410
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
411
+ t5 = /*#__PURE__*/_jsx("line", {
470
412
  x1: 0,
471
413
  x2: 0,
472
414
  y1: 0,
@@ -475,30 +417,30 @@ export function ChartBand(t0) {
475
417
  strokeWidth: 2,
476
418
  strokeOpacity: 0.3
477
419
  });
478
- $[27] = t10;
420
+ $[7] = t5;
479
421
  } else {
480
- t10 = $[27];
422
+ t5 = $[7];
481
423
  }
482
- let t11;
483
- if ($[28] !== pattern) {
484
- t11 = /*#__PURE__*/_jsx("defs", {
424
+ let t6;
425
+ if ($[8] !== pattern) {
426
+ t6 = /*#__PURE__*/_jsx("defs", {
485
427
  children: /*#__PURE__*/_jsx("pattern", {
486
428
  id: pattern,
487
429
  width: 6,
488
430
  height: 6,
489
431
  patternUnits: "userSpaceOnUse",
490
432
  patternTransform: "rotate(45)",
491
- children: t10
433
+ children: t5
492
434
  })
493
435
  });
494
- $[28] = pattern;
495
- $[29] = t11;
436
+ $[8] = pattern;
437
+ $[9] = t6;
496
438
  } else {
497
- t11 = $[29];
439
+ t6 = $[9];
498
440
  }
499
- let t12;
500
- if ($[30] !== plot.height || $[31] !== plot.top || $[32] !== width || $[33] !== x) {
501
- t12 = /*#__PURE__*/_jsx("rect", {
441
+ let t7;
442
+ if ($[10] !== plot.height || $[11] !== plot.top || $[12] !== width || $[13] !== x) {
443
+ t7 = /*#__PURE__*/_jsx("rect", {
502
444
  x: x,
503
445
  y: plot.top,
504
446
  width: width,
@@ -506,51 +448,51 @@ export function ChartBand(t0) {
506
448
  fill: "currentColor",
507
449
  fillOpacity: 0.08
508
450
  });
509
- $[30] = plot.height;
510
- $[31] = plot.top;
511
- $[32] = width;
512
- $[33] = x;
513
- $[34] = t12;
451
+ $[10] = plot.height;
452
+ $[11] = plot.top;
453
+ $[12] = width;
454
+ $[13] = x;
455
+ $[14] = t7;
514
456
  } else {
515
- t12 = $[34];
457
+ t7 = $[14];
516
458
  }
517
- const t13 = `url(#${pattern})`;
518
- let t14;
519
- if ($[35] !== plot.height || $[36] !== plot.top || $[37] !== t13 || $[38] !== width || $[39] !== x) {
520
- t14 = /*#__PURE__*/_jsx("rect", {
459
+ const t8 = `url(#${pattern})`;
460
+ let t9;
461
+ if ($[15] !== plot.height || $[16] !== plot.top || $[17] !== t8 || $[18] !== width || $[19] !== x) {
462
+ t9 = /*#__PURE__*/_jsx("rect", {
521
463
  x: x,
522
464
  y: plot.top,
523
465
  width: width,
524
466
  height: plot.height,
525
- fill: t13
467
+ fill: t8
526
468
  });
527
- $[35] = plot.height;
528
- $[36] = plot.top;
529
- $[37] = t13;
530
- $[38] = width;
531
- $[39] = x;
532
- $[40] = t14;
469
+ $[15] = plot.height;
470
+ $[16] = plot.top;
471
+ $[17] = t8;
472
+ $[18] = width;
473
+ $[19] = x;
474
+ $[20] = t9;
533
475
  } else {
534
- t14 = $[40];
476
+ t9 = $[20];
535
477
  }
536
- let t15;
537
- if ($[41] !== ref || $[42] !== t11 || $[43] !== t12 || $[44] !== t14 || $[45] !== t8 || $[46] !== t9) {
538
- t15 = /*#__PURE__*/_jsxs("g", {
478
+ let t10;
479
+ if ($[21] !== ref || $[22] !== t3 || $[23] !== t4 || $[24] !== t6 || $[25] !== t7 || $[26] !== t9) {
480
+ t10 = /*#__PURE__*/_jsxs("g", {
539
481
  ref: ref,
540
- className: t8,
541
- style: t9,
482
+ className: t3,
483
+ style: t4,
542
484
  "aria-hidden": true,
543
- children: [t11, t12, t14]
485
+ children: [t6, t7, t9]
544
486
  });
545
- $[41] = ref;
546
- $[42] = t11;
547
- $[43] = t12;
548
- $[44] = t14;
549
- $[45] = t8;
550
- $[46] = t9;
551
- $[47] = t15;
487
+ $[21] = ref;
488
+ $[22] = t3;
489
+ $[23] = t4;
490
+ $[24] = t6;
491
+ $[25] = t7;
492
+ $[26] = t9;
493
+ $[27] = t10;
552
494
  } else {
553
- t15 = $[47];
495
+ t10 = $[27];
554
496
  }
555
- return t15;
497
+ return t10;
556
498
  }
package/dist/cursor.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ChartX, ChartXScale } from './types.ts';
2
2
  export declare function nearestIndex(xs: readonly number[], x: number): number;
3
3
  export declare function containingIndex(xs: readonly number[], at: number, step?: number): number;
4
+ export declare function keyIndexOf(xs: readonly ChartX[], x: ChartX): number;
4
5
  export declare function snapIndex(xs: readonly ChartX[], scale: ChartXScale, x: ChartX | null, step?: number): number;
5
6
  export declare function moveIndex(key: string, current: number, count: number, groupStarts?: readonly number[]): number | null | undefined;
package/dist/cursor.js CHANGED
@@ -41,6 +41,10 @@ export function containingIndex(xs, at, step) {
41
41
  }
42
42
  return at < xs[index] + length ? index : -1;
43
43
  }
44
+ /* The bucket of a band scale whose key reads as `x`; -1 for none. */
45
+ export function keyIndexOf(xs, x) {
46
+ return xs.findIndex(key => String(key) === String(x));
47
+ }
44
48
  /*
45
49
  * The bucket the cursor is on: the equal key on a band scale, the bucket the moment falls in on a time scale with
46
50
  * buckets of `step`, and the nearest otherwise.
@@ -50,7 +54,7 @@ export function snapIndex(xs, scale, x, step = 0) {
50
54
  return -1;
51
55
  }
52
56
  if (scale === 'band') {
53
- return xs.findIndex(key => String(key) === String(x));
57
+ return keyIndexOf(xs, x);
54
58
  }
55
59
  if (typeof x !== 'number') {
56
60
  return -1;
package/dist/heat.js CHANGED
@@ -7,14 +7,14 @@ export function heatStep(value, max, steps) {
7
7
  }
8
8
  return Math.min(steps, Math.max(1, Math.ceil(value / max * steps)));
9
9
  }
10
- /* The percentage of the color in a step: from 15% for the first up to 100% for the last, 0 for an empty cell. */
10
+ /* The percentage of the color in a step, up to 100 for the last; 0 for an empty cell. */
11
11
  export function heatShare(step, steps) {
12
12
  if (step <= 0) {
13
13
  return 0;
14
14
  }
15
15
  return steps <= 1 ? 100 : Math.round(FLOOR + (step - 1) / (steps - 1) * (100 - FLOOR));
16
16
  }
17
- /* The percentage of the color in a cell: in `steps` shades when given, else from 15% up with the value, 0 for an empty cell. */
17
+ /* The percentage of the color in a cell: in `steps` shades when given, else following the value; 0 for an empty cell. */
18
18
  export function heatMix(value, max, steps) {
19
19
  if (steps !== undefined) {
20
20
  return heatShare(heatStep(value, max, steps), steps);