@cardenelabs/cdl 0.40.6 → 0.40.8

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/react.js CHANGED
@@ -9924,6 +9924,19 @@ function StateDiffCard({
9924
9924
  }
9925
9925
  );
9926
9926
  }
9927
+
9928
+ // src/kinds/axis-ticks.ts
9929
+ function \u76EE\u76DB\u308A\u306E\u523B\u307F(\u7BC4\u56F2, \u76EE\u5B89\u306E\u672C\u6570) {
9930
+ if (!(\u7BC4\u56F2 > 0) || false) return 0;
9931
+ const \u7C97\u3044 = \u7BC4\u56F2 / \u76EE\u5B89\u306E\u672C\u6570;
9932
+ const \u6841 = 10 ** Math.floor(Math.log10(\u7C97\u3044));
9933
+ const \u6B63\u898F = \u7C97\u3044 / \u6841;
9934
+ const \u5019\u88DC = \u6B63\u898F <= 1 ? 1 : \u6B63\u898F <= 2 ? 2 : \u6B63\u898F <= 2.5 ? 2.5 : \u6B63\u898F <= 5 ? 5 : 10;
9935
+ return \u5019\u88DC * \u6841;
9936
+ }
9937
+ var \u76EE\u76DB\u308A\u306E\u76EE\u5B89 = 4;
9938
+ var \u5024\u672D\u306E\u7D1A = 12;
9939
+ var \u8EF8\u306E\u540D\u524D\u306E\u7D1A = 11;
9927
9940
  var \u6570\u3092\u66F8\u304F = (value) => value.toLocaleString("en-US", { maximumFractionDigits: 12 });
9928
9941
  function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
9929
9942
  let rawMin = values.length > 0 ? Math.min(...values) : 0;
@@ -9933,11 +9946,7 @@ function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
9933
9946
  rawMin -= room;
9934
9947
  rawMax += room;
9935
9948
  }
9936
- const roughStep = (rawMax - rawMin) / 4;
9937
- const power = 10 ** Math.floor(Math.log10(roughStep));
9938
- const fraction = roughStep / power;
9939
- const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
9940
- const step = niceFraction * power;
9949
+ const step = \u76EE\u76DB\u308A\u306E\u523B\u307F(rawMax - rawMin, \u76EE\u76DB\u308A\u306E\u76EE\u5B89);
9941
9950
  const min = Math.floor(rawMin / step) * step;
9942
9951
  const max = Math.ceil(rawMax / step) * step;
9943
9952
  const tickCount = Math.round((max - min) / step);
@@ -10044,6 +10053,7 @@ function ChartLineNode({
10044
10053
  /* @__PURE__ */ jsx(
10045
10054
  "text",
10046
10055
  {
10056
+ "data-cdl-role": "chart-line-tick",
10047
10057
  x: PAD_LEFT2 - 8,
10048
10058
  y: t.y + 4,
10049
10059
  fontSize: 11,
@@ -10121,7 +10131,7 @@ function ChartLineNode({
10121
10131
  "data-cdl-role": "chart-line-value",
10122
10132
  x: cx,
10123
10133
  y: labelY,
10124
- fontSize: 11,
10134
+ fontSize: \u5024\u672D\u306E\u7D1A,
10125
10135
  fontWeight: 600,
10126
10136
  textAnchor: "middle",
10127
10137
  fill: "var(--cdl-text, #1a1f2a)",
@@ -10179,9 +10189,10 @@ function ChartLineNode({
10179
10189
  /* @__PURE__ */ jsx(
10180
10190
  "text",
10181
10191
  {
10192
+ "data-cdl-role": "chart-line-label",
10182
10193
  x: cx,
10183
10194
  y: PAD_TOP2 + canvasH + 20,
10184
- fontSize: 12,
10195
+ fontSize: \u8EF8\u306E\u540D\u524D\u306E\u7D1A,
10185
10196
  textAnchor: "middle",
10186
10197
  fill: "var(--cdl-text-dim, #5a6270)",
10187
10198
  children: d.label
@@ -13396,6 +13407,14 @@ function \u53CE\u3081\u308B\u7D1A2(\u540D\u524D\u305F\u3061, \u5E45, \u4E0A\u965
13396
13407
  while (\u7D1A > \u4E0B\u9650 && Math.max(...\u540D\u524D\u305F\u3061.map((n) => textWidth(n, \u7D1A))) > \u5E45) \u7D1A -= 1;
13397
13408
  return \u7D1A;
13398
13409
  }
13410
+ function \u5C0F\u6570\u306E\u6841(n) {
13411
+ const [\u4EEE\u6570, \u6307\u6570] = n.toExponential().split("e");
13412
+ const \u5C0F\u6570\u90E8 = (\u4EEE\u6570 ?? "").split(".")[1]?.length ?? 0;
13413
+ return Math.min(20, Math.max(0, \u5C0F\u6570\u90E8 - Number(\u6307\u6570)));
13414
+ }
13415
+ var \u5024\u672D\u306E\u7D1A2 = 12;
13416
+ var \u8EF8\u306E\u540D\u524D\u306E\u7D1A2 = 11;
13417
+ var \u6841\u3067\u4E38\u3081\u308B = (v, \u6841) => Number(v.toFixed(\u6841));
13399
13418
  function ChartBarNode({
13400
13419
  node,
13401
13420
  active,
@@ -13406,24 +13425,33 @@ function ChartBarNode({
13406
13425
  const x0 = node.cx - node.w / 2;
13407
13426
  const y0 = node.cy - node.h / 2;
13408
13427
  const data = resolveChartData(node.chartData ?? [], stateValues);
13409
- const PAD_TOP2 = 20;
13428
+ const PAD_TOP2 = 34;
13410
13429
  const PAD_RIGHT2 = 24;
13411
13430
  const PAD_BOTTOM2 = 44;
13412
13431
  const PAD_LEFT2 = 60;
13413
13432
  const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
13414
13433
  const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
13415
13434
  const vMax = data.length > 0 ? Math.max(...data.map((d) => d.value)) : 1;
13416
- const vRange = vMax || 1;
13417
- const barGap = 10;
13435
+ const \u76EE\u76DB\u308A\u306E\u76EE\u5B892 = 4;
13436
+ const \u5929\u4E95\u306E\u3082\u3068 = vMax > 0 ? vMax : 1;
13437
+ const \u523B\u307F = \u76EE\u76DB\u308A\u306E\u523B\u307F(\u5929\u4E95\u306E\u3082\u3068, \u76EE\u76DB\u308A\u306E\u76EE\u5B892);
13438
+ const \u523B\u307F\u306E\u6841 = \u5C0F\u6570\u306E\u6841(\u523B\u307F);
13439
+ const \u5929\u4E95 = \u6841\u3067\u4E38\u3081\u308B(Math.ceil(\u5929\u4E95\u306E\u3082\u3068 / \u523B\u307F - 1e-9) * \u523B\u307F, \u523B\u307F\u306E\u6841);
13440
+ const \u68D2\u3068\u9699\u9593\u306E\u6BD4 = 2.2;
13441
+ const \u68D2\u306E\u4E0A\u9650 = 96;
13418
13442
  const barCount = data.length || 1;
13419
- const barW = (canvasW - barGap * (barCount + 1)) / barCount;
13420
- const yAt = (v) => PAD_TOP2 + canvasH - v / vRange * canvasH;
13443
+ const \u5358\u4F4D = canvasW / (barCount * \u68D2\u3068\u9699\u9593\u306E\u6BD4 + (barCount + 1));
13444
+ const barW = Math.max(0, Math.min(\u5358\u4F4D * \u68D2\u3068\u9699\u9593\u306E\u6BD4, \u68D2\u306E\u4E0A\u9650));
13445
+ const barGap = (canvasW - barW * barCount) / (barCount + 1);
13446
+ const yAt = (v) => PAD_TOP2 + canvasH - v / \u5929\u4E95 * canvasH;
13421
13447
  const xAt = (idx) => PAD_LEFT2 + barGap + idx * (barW + barGap);
13422
- const gridCount = 4;
13423
- const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
13424
- const v = vMax * i / gridCount;
13448
+ const \u76EE\u76DB\u308A\u306E\u672C\u6570 = Math.round(\u5929\u4E95 / \u523B\u307F);
13449
+ const gridTicks = Array.from({ length: \u76EE\u76DB\u308A\u306E\u672C\u6570 + 1 }, (_, i) => {
13450
+ const v = \u6841\u3067\u4E38\u3081\u308B(\u523B\u307F * i, \u523B\u307F\u306E\u6841);
13425
13451
  return { y: yAt(v), value: v };
13426
13452
  });
13453
+ const \u6FC3\u3055 = (v) => vMax > 0 ? v >= vMax ? 1 : 0.45 : 0.9;
13454
+ const \u89D2\u4E38 = Math.min(barW * 0.06, 8);
13427
13455
  const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
13428
13456
  const \u6A2A\u8EF8\u306Ey = PAD_TOP2 + canvasH;
13429
13457
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
@@ -13458,12 +13486,13 @@ function ChartBarNode({
13458
13486
  /* @__PURE__ */ jsx(
13459
13487
  "text",
13460
13488
  {
13489
+ "data-cdl-role": "chart-bar-tick",
13461
13490
  x: PAD_LEFT2 - 8,
13462
13491
  y: t.y + 4,
13463
13492
  fontSize: 11,
13464
13493
  textAnchor: "end",
13465
13494
  fill: "var(--cdl-text-dim, #5a6270)",
13466
- children: Math.round(t.value)
13495
+ children: t.value
13467
13496
  }
13468
13497
  )
13469
13498
  ] }, `grid-${i}`)),
@@ -13481,7 +13510,7 @@ function ChartBarNode({
13481
13510
  data.map((d, idx) => {
13482
13511
  const bx = xAt(idx);
13483
13512
  const by = yAt(d.value);
13484
- const bh = PAD_TOP2 + canvasH - by;
13513
+ const bh = Math.max(0, PAD_TOP2 + canvasH - by);
13485
13514
  const \u898B\u3048\u3066\u3044\u308B\u982D = \u6A2A\u8EF8\u306Ey - (\u6A2A\u8EF8\u306Ey - by) * \u4F38\u3073;
13486
13515
  const \u68D2 = /* @__PURE__ */ jsx(
13487
13516
  "rect",
@@ -13492,9 +13521,9 @@ function ChartBarNode({
13492
13521
  y: by,
13493
13522
  width: barW,
13494
13523
  height: bh,
13495
- rx: 2,
13524
+ rx: \u89D2\u4E38,
13496
13525
  fill: "var(--cdl-tone-accent, #2d6a8f)",
13497
- fillOpacity: 0.9
13526
+ fillOpacity: \u6FC3\u3055(d.value)
13498
13527
  }
13499
13528
  );
13500
13529
  return /* @__PURE__ */ jsxs("g", { children: [
@@ -13502,9 +13531,11 @@ function ChartBarNode({
13502
13531
  /* @__PURE__ */ jsx(
13503
13532
  "text",
13504
13533
  {
13534
+ "data-cdl-role": "chart-bar-value",
13505
13535
  x: bx + barW / 2,
13506
- y: \u898B\u3048\u3066\u3044\u308B\u982D - 6,
13507
- fontSize: 11,
13536
+ y: \u898B\u3048\u3066\u3044\u308B\u982D - 8,
13537
+ fontSize: \u5024\u672D\u306E\u7D1A2,
13538
+ fontWeight: 600,
13508
13539
  textAnchor: "middle",
13509
13540
  fill: "var(--cdl-text, #1a1f2a)",
13510
13541
  children: d.value.toLocaleString()
@@ -13513,9 +13544,10 @@ function ChartBarNode({
13513
13544
  /* @__PURE__ */ jsx(
13514
13545
  "text",
13515
13546
  {
13547
+ "data-cdl-role": "chart-bar-label",
13516
13548
  x: bx + barW / 2,
13517
13549
  y: PAD_TOP2 + canvasH + 18,
13518
- fontSize: 12,
13550
+ fontSize: \u8EF8\u306E\u540D\u524D\u306E\u7D1A2,
13519
13551
  textAnchor: "middle",
13520
13552
  fill: "var(--cdl-text-dim, #5a6270)",
13521
13553
  children: d.label