@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/index.js CHANGED
@@ -22420,6 +22420,19 @@ function StateDiffCard({
22420
22420
  }
22421
22421
  );
22422
22422
  }
22423
+
22424
+ // src/kinds/axis-ticks.ts
22425
+ function \u76EE\u76DB\u308A\u306E\u523B\u307F(\u7BC4\u56F2, \u76EE\u5B89\u306E\u672C\u6570) {
22426
+ if (!(\u7BC4\u56F2 > 0) || false) return 0;
22427
+ const \u7C97\u3044 = \u7BC4\u56F2 / \u76EE\u5B89\u306E\u672C\u6570;
22428
+ const \u6841 = 10 ** Math.floor(Math.log10(\u7C97\u3044));
22429
+ const \u6B63\u898F = \u7C97\u3044 / \u6841;
22430
+ const \u5019\u88DC = \u6B63\u898F <= 1 ? 1 : \u6B63\u898F <= 2 ? 2 : \u6B63\u898F <= 2.5 ? 2.5 : \u6B63\u898F <= 5 ? 5 : 10;
22431
+ return \u5019\u88DC * \u6841;
22432
+ }
22433
+ var \u76EE\u76DB\u308A\u306E\u76EE\u5B89 = 4;
22434
+ var \u5024\u672D\u306E\u7D1A = 12;
22435
+ var \u8EF8\u306E\u540D\u524D\u306E\u7D1A = 11;
22423
22436
  var \u6570\u3092\u66F8\u304F = (value) => value.toLocaleString("en-US", { maximumFractionDigits: 12 });
22424
22437
  function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
22425
22438
  let rawMin = values.length > 0 ? Math.min(...values) : 0;
@@ -22429,11 +22442,7 @@ function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
22429
22442
  rawMin -= room;
22430
22443
  rawMax += room;
22431
22444
  }
22432
- const roughStep = (rawMax - rawMin) / 4;
22433
- const power = 10 ** Math.floor(Math.log10(roughStep));
22434
- const fraction = roughStep / power;
22435
- const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
22436
- const step = niceFraction * power;
22445
+ const step = \u76EE\u76DB\u308A\u306E\u523B\u307F(rawMax - rawMin, \u76EE\u76DB\u308A\u306E\u76EE\u5B89);
22437
22446
  const min = Math.floor(rawMin / step) * step;
22438
22447
  const max = Math.ceil(rawMax / step) * step;
22439
22448
  const tickCount = Math.round((max - min) / step);
@@ -22540,6 +22549,7 @@ function ChartLineNode({
22540
22549
  /* @__PURE__ */ jsx(
22541
22550
  "text",
22542
22551
  {
22552
+ "data-cdl-role": "chart-line-tick",
22543
22553
  x: PAD_LEFT2 - 8,
22544
22554
  y: t.y + 4,
22545
22555
  fontSize: 11,
@@ -22617,7 +22627,7 @@ function ChartLineNode({
22617
22627
  "data-cdl-role": "chart-line-value",
22618
22628
  x: cx,
22619
22629
  y: labelY,
22620
- fontSize: 11,
22630
+ fontSize: \u5024\u672D\u306E\u7D1A,
22621
22631
  fontWeight: 600,
22622
22632
  textAnchor: "middle",
22623
22633
  fill: "var(--cdl-text, #1a1f2a)",
@@ -22675,9 +22685,10 @@ function ChartLineNode({
22675
22685
  /* @__PURE__ */ jsx(
22676
22686
  "text",
22677
22687
  {
22688
+ "data-cdl-role": "chart-line-label",
22678
22689
  x: cx,
22679
22690
  y: PAD_TOP2 + canvasH + 20,
22680
- fontSize: 12,
22691
+ fontSize: \u8EF8\u306E\u540D\u524D\u306E\u7D1A,
22681
22692
  textAnchor: "middle",
22682
22693
  fill: "var(--cdl-text-dim, #5a6270)",
22683
22694
  children: d.label
@@ -25895,6 +25906,14 @@ function \u53CE\u3081\u308B\u7D1A2(\u540D\u524D\u305F\u3061, \u5E45, \u4E0A\u965
25895
25906
  while (\u7D1A > \u4E0B\u9650 && Math.max(...\u540D\u524D\u305F\u3061.map((n) => textWidth(n, \u7D1A))) > \u5E45) \u7D1A -= 1;
25896
25907
  return \u7D1A;
25897
25908
  }
25909
+ function \u5C0F\u6570\u306E\u6841(n) {
25910
+ const [\u4EEE\u6570, \u6307\u6570] = n.toExponential().split("e");
25911
+ const \u5C0F\u6570\u90E8 = (\u4EEE\u6570 ?? "").split(".")[1]?.length ?? 0;
25912
+ return Math.min(20, Math.max(0, \u5C0F\u6570\u90E8 - Number(\u6307\u6570)));
25913
+ }
25914
+ var \u5024\u672D\u306E\u7D1A2 = 12;
25915
+ var \u8EF8\u306E\u540D\u524D\u306E\u7D1A2 = 11;
25916
+ var \u6841\u3067\u4E38\u3081\u308B = (v, \u6841) => Number(v.toFixed(\u6841));
25898
25917
  function ChartBarNode({
25899
25918
  node,
25900
25919
  active,
@@ -25905,24 +25924,33 @@ function ChartBarNode({
25905
25924
  const x0 = node.cx - node.w / 2;
25906
25925
  const y0 = node.cy - node.h / 2;
25907
25926
  const data = resolveChartData(node.chartData ?? [], stateValues);
25908
- const PAD_TOP2 = 20;
25927
+ const PAD_TOP2 = 34;
25909
25928
  const PAD_RIGHT2 = 24;
25910
25929
  const PAD_BOTTOM2 = 44;
25911
25930
  const PAD_LEFT2 = 60;
25912
25931
  const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
25913
25932
  const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
25914
25933
  const vMax = data.length > 0 ? Math.max(...data.map((d) => d.value)) : 1;
25915
- const vRange = vMax || 1;
25916
- const barGap = 10;
25934
+ const \u76EE\u76DB\u308A\u306E\u76EE\u5B892 = 4;
25935
+ const \u5929\u4E95\u306E\u3082\u3068 = vMax > 0 ? vMax : 1;
25936
+ const \u523B\u307F = \u76EE\u76DB\u308A\u306E\u523B\u307F(\u5929\u4E95\u306E\u3082\u3068, \u76EE\u76DB\u308A\u306E\u76EE\u5B892);
25937
+ const \u523B\u307F\u306E\u6841 = \u5C0F\u6570\u306E\u6841(\u523B\u307F);
25938
+ 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);
25939
+ const \u68D2\u3068\u9699\u9593\u306E\u6BD4 = 2.2;
25940
+ const \u68D2\u306E\u4E0A\u9650 = 96;
25917
25941
  const barCount = data.length || 1;
25918
- const barW = (canvasW - barGap * (barCount + 1)) / barCount;
25919
- const yAt = (v) => PAD_TOP2 + canvasH - v / vRange * canvasH;
25942
+ const \u5358\u4F4D = canvasW / (barCount * \u68D2\u3068\u9699\u9593\u306E\u6BD4 + (barCount + 1));
25943
+ const barW = Math.max(0, Math.min(\u5358\u4F4D * \u68D2\u3068\u9699\u9593\u306E\u6BD4, \u68D2\u306E\u4E0A\u9650));
25944
+ const barGap = (canvasW - barW * barCount) / (barCount + 1);
25945
+ const yAt = (v) => PAD_TOP2 + canvasH - v / \u5929\u4E95 * canvasH;
25920
25946
  const xAt = (idx) => PAD_LEFT2 + barGap + idx * (barW + barGap);
25921
- const gridCount = 4;
25922
- const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
25923
- const v = vMax * i / gridCount;
25947
+ const \u76EE\u76DB\u308A\u306E\u672C\u6570 = Math.round(\u5929\u4E95 / \u523B\u307F);
25948
+ const gridTicks = Array.from({ length: \u76EE\u76DB\u308A\u306E\u672C\u6570 + 1 }, (_, i) => {
25949
+ const v = \u6841\u3067\u4E38\u3081\u308B(\u523B\u307F * i, \u523B\u307F\u306E\u6841);
25924
25950
  return { y: yAt(v), value: v };
25925
25951
  });
25952
+ const \u6FC3\u3055 = (v) => vMax > 0 ? v >= vMax ? 1 : 0.45 : 0.9;
25953
+ const \u89D2\u4E38 = Math.min(barW * 0.06, 8);
25926
25954
  const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
25927
25955
  const \u6A2A\u8EF8\u306Ey = PAD_TOP2 + canvasH;
25928
25956
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
@@ -25957,12 +25985,13 @@ function ChartBarNode({
25957
25985
  /* @__PURE__ */ jsx(
25958
25986
  "text",
25959
25987
  {
25988
+ "data-cdl-role": "chart-bar-tick",
25960
25989
  x: PAD_LEFT2 - 8,
25961
25990
  y: t.y + 4,
25962
25991
  fontSize: 11,
25963
25992
  textAnchor: "end",
25964
25993
  fill: "var(--cdl-text-dim, #5a6270)",
25965
- children: Math.round(t.value)
25994
+ children: t.value
25966
25995
  }
25967
25996
  )
25968
25997
  ] }, `grid-${i}`)),
@@ -25980,7 +26009,7 @@ function ChartBarNode({
25980
26009
  data.map((d, idx) => {
25981
26010
  const bx = xAt(idx);
25982
26011
  const by = yAt(d.value);
25983
- const bh = PAD_TOP2 + canvasH - by;
26012
+ const bh = Math.max(0, PAD_TOP2 + canvasH - by);
25984
26013
  const \u898B\u3048\u3066\u3044\u308B\u982D = \u6A2A\u8EF8\u306Ey - (\u6A2A\u8EF8\u306Ey - by) * \u4F38\u3073;
25985
26014
  const \u68D2 = /* @__PURE__ */ jsx(
25986
26015
  "rect",
@@ -25991,9 +26020,9 @@ function ChartBarNode({
25991
26020
  y: by,
25992
26021
  width: barW,
25993
26022
  height: bh,
25994
- rx: 2,
26023
+ rx: \u89D2\u4E38,
25995
26024
  fill: "var(--cdl-tone-accent, #2d6a8f)",
25996
- fillOpacity: 0.9
26025
+ fillOpacity: \u6FC3\u3055(d.value)
25997
26026
  }
25998
26027
  );
25999
26028
  return /* @__PURE__ */ jsxs("g", { children: [
@@ -26001,9 +26030,11 @@ function ChartBarNode({
26001
26030
  /* @__PURE__ */ jsx(
26002
26031
  "text",
26003
26032
  {
26033
+ "data-cdl-role": "chart-bar-value",
26004
26034
  x: bx + barW / 2,
26005
- y: \u898B\u3048\u3066\u3044\u308B\u982D - 6,
26006
- fontSize: 11,
26035
+ y: \u898B\u3048\u3066\u3044\u308B\u982D - 8,
26036
+ fontSize: \u5024\u672D\u306E\u7D1A2,
26037
+ fontWeight: 600,
26007
26038
  textAnchor: "middle",
26008
26039
  fill: "var(--cdl-text, #1a1f2a)",
26009
26040
  children: d.value.toLocaleString()
@@ -26012,9 +26043,10 @@ function ChartBarNode({
26012
26043
  /* @__PURE__ */ jsx(
26013
26044
  "text",
26014
26045
  {
26046
+ "data-cdl-role": "chart-bar-label",
26015
26047
  x: bx + barW / 2,
26016
26048
  y: PAD_TOP2 + canvasH + 18,
26017
- fontSize: 12,
26049
+ fontSize: \u8EF8\u306E\u540D\u524D\u306E\u7D1A2,
26018
26050
  textAnchor: "middle",
26019
26051
  fill: "var(--cdl-text-dim, #5a6270)",
26020
26052
  children: d.label