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