@cardenelabs/cdl 0.40.10 → 0.40.11

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
@@ -24959,18 +24959,35 @@ function ChartGaugeNode({
24959
24959
  const \u5185\u534A\u5F84 = radius * 0.62;
24960
24960
  const cx = node.w / 2;
24961
24961
  const cy = PAD_TOP2 + radius;
24962
+ const \u524D\u3042\u308A = \u51FA\u3059\u4EF6\u305F\u3061.some((d) => d.previous !== void 0);
24963
+ const \u524D\u306E\u5024 = \u51FA\u3059\u4EF6\u305F\u3061.map((d) => Math.max(0, d.previous ?? 0));
24964
+ const \u524D\u306E\u5408\u8A08 = \u524D\u306E\u5024.reduce((acc, v) => acc + v, 0);
24965
+ const \u5E2F = radius - \u5185\u534A\u5F84;
24966
+ const \u4ECA\u306E\u5185\u534A\u5F84 = \u524D\u3042\u308A ? \u5185\u534A\u5F84 + \u5E2F * 0.42 : \u5185\u534A\u5F84;
24967
+ const \u524D\u306E\u5185\u534A\u5F84 = \u5185\u534A\u5F84;
24968
+ const \u524D\u306E\u5916\u534A\u5F84 = \u5185\u534A\u5F84 + \u5E2F * 0.32;
24969
+ const \u6247\u306E\u9053 = (a0, a1, \u5185, \u5916) => {
24970
+ const \u59161 = \u6975(cx, cy, \u5916, a0);
24971
+ const \u59162 = \u6975(cx, cy, \u5916, a1);
24972
+ const \u51852 = \u6975(cx, cy, \u5185, a1);
24973
+ const \u51851 = \u6975(cx, cy, \u5185, a0);
24974
+ return `M ${\u59161.x} ${\u59161.y} A ${\u5916} ${\u5916} 0 0 1 ${\u59162.x} ${\u59162.y} L ${\u51852.x} ${\u51852.y} A ${\u5185} ${\u5185} 0 0 0 ${\u51851.x} ${\u51851.y} Z`;
24975
+ };
24962
24976
  let cumFrac = 0;
24963
24977
  const slices = \u51FA\u3059\u4EF6\u305F\u3061.map((d) => {
24964
24978
  const frac = d.value / total;
24965
24979
  const a0 = Math.PI + cumFrac * Math.PI;
24966
24980
  const a1 = a0 + frac * Math.PI;
24967
24981
  cumFrac += frac;
24968
- const \u59161 = \u6975(cx, cy, radius, a0);
24969
- const \u59162 = \u6975(cx, cy, radius, a1);
24970
- const \u51852 = \u6975(cx, cy, \u5185\u534A\u5F84, a1);
24971
- const \u51851 = \u6975(cx, cy, \u5185\u534A\u5F84, a0);
24972
- const path = `M ${\u59161.x} ${\u59161.y} A ${radius} ${radius} 0 0 1 ${\u59162.x} ${\u59162.y} L ${\u51852.x} ${\u51852.y} A ${\u5185\u534A\u5F84} ${\u5185\u534A\u5F84} 0 0 0 ${\u51851.x} ${\u51851.y} Z`;
24973
- return { d, frac, path };
24982
+ return { d, frac, path: \u6247\u306E\u9053(a0, a1, \u4ECA\u306E\u5185\u534A\u5F84, radius) };
24983
+ });
24984
+ let \u524D\u306Ecum = 0;
24985
+ const \u524D\u306E\u6247\u305F\u3061 = \u51FA\u3059\u4EF6\u305F\u3061.map((d, idx) => {
24986
+ const frac = \u524D\u306E\u5408\u8A08 > 0 ? (\u524D\u306E\u5024[idx] ?? 0) / \u524D\u306E\u5408\u8A08 : 0;
24987
+ const a0 = Math.PI + \u524D\u306Ecum * Math.PI;
24988
+ const a1 = a0 + frac * Math.PI;
24989
+ \u524D\u306Ecum += frac;
24990
+ return { d, frac, path: \u6247\u306E\u9053(a0, a1, \u524D\u306E\u5185\u534A\u5F84, \u524D\u306E\u5916\u534A\u5F84) };
24974
24991
  });
24975
24992
  const \u5408\u8A08\u306E\u6587\u5B57 = \u5B9F\u5024\u8868\u8A18(Math.round(total));
24976
24993
  const \u5358\u4F4D\u5E45 = Math.max(textWidth(\u5408\u8A08\u306E\u6587\u5B57, 100), 1) / 100;
@@ -24999,6 +25016,20 @@ function ChartGaugeNode({
24999
25016
  },
25000
25017
  `arc-${idx}`
25001
25018
  ));
25019
+ const \u524D\u306E\u5F27\u305F\u3061 = \u524D\u3042\u308A ? \u524D\u306E\u6247\u305F\u3061.map((s, idx) => /* @__PURE__ */ jsx(
25020
+ "path",
25021
+ {
25022
+ "data-cdl-role": "chart-gauge-previous",
25023
+ "data-cdl-unresolved": s.d.unresolved ? "true" : void 0,
25024
+ d: s.path,
25025
+ fill: arcColor(s.d.tone, idx),
25026
+ fillOpacity: 0.45,
25027
+ stroke: "var(--cdl-node-fill, #ffffff)",
25028
+ strokeWidth: 1.5,
25029
+ strokeLinejoin: "round"
25030
+ },
25031
+ `prev-arc-${idx}`
25032
+ )) : null;
25002
25033
  return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
25003
25034
  /* @__PURE__ */ jsx(
25004
25035
  "rect",
@@ -25015,7 +25046,13 @@ function ChartGaugeNode({
25015
25046
  }
25016
25047
  ),
25017
25048
  drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(cx, cy, radius + 2, \u4F38\u3073, Math.PI, Math.PI) }) }),
25018
- drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u5F27\u305F\u3061 }) : \u5F27\u305F\u3061,
25049
+ drawing ? /* @__PURE__ */ jsxs("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: [
25050
+ \u524D\u306E\u5F27\u305F\u3061,
25051
+ \u5F27\u305F\u3061
25052
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
25053
+ \u524D\u306E\u5F27\u305F\u3061,
25054
+ \u5F27\u305F\u3061
25055
+ ] }),
25019
25056
  /* @__PURE__ */ jsx(
25020
25057
  "text",
25021
25058
  {
@@ -25124,9 +25161,11 @@ function ChartRadialNode({
25124
25161
  const rings = data.map((d, idx) => {
25125
25162
  const frac = d.value / total;
25126
25163
  const \u4E2D\u5FC3\u534A\u5F84 = \u5916\u534A\u5F84 - \u5E2F1\u672C * idx - \u5E2F1\u672C / 2;
25164
+ const \u524D\u306E\u5272\u5408 = d.previous === void 0 ? null : Math.max(0, d.previous) / total;
25127
25165
  return {
25128
25166
  d,
25129
25167
  frac,
25168
+ \u524D\u306E\u5272\u5408,
25130
25169
  \u4E2D\u5FC3\u534A\u5F84,
25131
25170
  // 軌道は全周。 1 周ちょうどは弧で表せないので、 わずかに欠かして描く
25132
25171
  \u8ECC\u9053: \u5F27\u306E\u90532(\u5F27\u306Ecx, cy, \u4E2D\u5FC3\u534A\u5F84, \u5E2F\u306E\u5E45, 0.9999),
@@ -25175,6 +25214,20 @@ function ChartRadialNode({
25175
25214
  )),
25176
25215
  drawing && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: \u5207\u308A\u629C\u304Did, children: \u6247\u5F62\u306E\u5207\u308A\u629C\u304D(\u5F27\u306Ecx, cy, \u5916\u534A\u5F84 + \u5E2F\u306E\u5E45, \u958B\u304D) }) }),
25177
25216
  drawing ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${\u5207\u308A\u629C\u304Did})`, children: \u53D6\u308A\u5206\u305F\u3061 }) : \u53D6\u308A\u5206\u305F\u3061,
25217
+ rings.map(
25218
+ (r, idx) => r.\u524D\u306E\u5272\u5408 === null ? null : /* @__PURE__ */ jsx(
25219
+ "line",
25220
+ {
25221
+ "data-cdl-role": "chart-radial-previous",
25222
+ "data-cdl-unresolved": r.d.unresolved ? "true" : void 0,
25223
+ ...\u5E2F\u3092\u6A2A\u5207\u308B\u5370(\u5F27\u306Ecx, cy, r.\u4E2D\u5FC3\u534A\u5F84, \u5E2F\u306E\u5E45, Math.min(r.\u524D\u306E\u5272\u5408, 0.9999)),
25224
+ stroke: "var(--cdl-text-mute, #8a8678)",
25225
+ strokeWidth: 2,
25226
+ strokeLinecap: "round"
25227
+ },
25228
+ `prev-${idx}`
25229
+ )
25230
+ ),
25178
25231
  data.map((d, idx) => {
25179
25232
  const y = \u4E00\u89A7\u306E\u59CB\u307E\u308A + \u884C\u306E\u9AD8\u3055 * idx;
25180
25233
  return /* @__PURE__ */ jsxs("g", { "data-cdl-role": "chart-radial-item", children: [
@@ -25214,6 +25267,18 @@ function \u5F27\u306E\u90532(cx, cy, \u4E2D\u5FC3\u534A\u5F84, \u5E45, \u5272\u5
25214
25267
  const p = (r, a) => `${cx + r * Math.cos(a)} ${cy + r * Math.sin(a)}`;
25215
25268
  return `M ${p(\u5916, a0)} A ${\u5916} ${\u5916} 0 ${large} 1 ${p(\u5916, a1)} L ${p(\u5185, a1)} A ${\u5185} ${\u5185} 0 ${large} 0 ${p(\u5185, a0)} Z`;
25216
25269
  }
25270
+ function \u5E2F\u3092\u6A2A\u5207\u308B\u5370(cx, cy, \u4E2D\u5FC3\u534A\u5F84, \u5E45, \u5272\u5408) {
25271
+ const \u306F\u307F\u51FA\u3057 = Math.min(\u5E45 * 0.3, 5);
25272
+ const \u5916 = \u4E2D\u5FC3\u534A\u5F84 + \u5E45 / 2 + \u306F\u307F\u51FA\u3057;
25273
+ const \u5185 = Math.max(0.5, \u4E2D\u5FC3\u534A\u5F84 - \u5E45 / 2 - \u306F\u307F\u51FA\u3057);
25274
+ const a = -Math.PI / 2 + \u5272\u5408 * Math.PI * 2;
25275
+ return {
25276
+ x1: cx + \u5185 * Math.cos(a),
25277
+ y1: cy + \u5185 * Math.sin(a),
25278
+ x2: cx + \u5916 * Math.cos(a),
25279
+ y2: cy + \u5916 * Math.sin(a)
25280
+ };
25281
+ }
25217
25282
  function arcColor2(tone, idx) {
25218
25283
  if (tone) return TONE[tone];
25219
25284
  return chartSeriesColor(idx);
@@ -25964,8 +26029,9 @@ function ChartBarNode({
25964
26029
  const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
25965
26030
  const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
25966
26031
  const vMax = data.length > 0 ? Math.max(...data.map((d) => d.value)) : 1;
26032
+ const \u8EF8\u306E\u3082\u3068 = data.length > 0 ? Math.max(vMax, ...data.map((d) => d.previous ?? 0)) : vMax;
25967
26033
  const \u76EE\u76DB\u308A\u306E\u76EE\u5B892 = 4;
25968
- const \u5929\u4E95\u306E\u3082\u3068 = vMax > 0 ? vMax : 1;
26034
+ const \u5929\u4E95\u306E\u3082\u3068 = \u8EF8\u306E\u3082\u3068 > 0 ? \u8EF8\u306E\u3082\u3068 : 1;
25969
26035
  const \u523B\u307F = \u76EE\u76DB\u308A\u306E\u523B\u307F(\u5929\u4E95\u306E\u3082\u3068, \u76EE\u76DB\u308A\u306E\u76EE\u5B892);
25970
26036
  const \u523B\u307F\u306E\u6841 = \u5C0F\u6570\u306E\u6841(\u523B\u307F);
25971
26037
  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);
@@ -26058,8 +26124,24 @@ function ChartBarNode({
26058
26124
  fillOpacity: \u6FC3\u3055(d.value)
26059
26125
  }
26060
26126
  );
26127
+ const \u5370\u306E\u306F\u307F\u51FA\u3057 = Math.min(barW * 0.18, 8);
26128
+ const \u524D\u306E\u5370 = d.previous === void 0 ? null : /* @__PURE__ */ jsx(
26129
+ "line",
26130
+ {
26131
+ "data-cdl-role": "chart-bar-previous",
26132
+ "data-cdl-unresolved": d.unresolved ? "true" : void 0,
26133
+ x1: bx - \u5370\u306E\u306F\u307F\u51FA\u3057,
26134
+ y1: yAt(Math.max(0, d.previous)),
26135
+ x2: bx + barW + \u5370\u306E\u306F\u307F\u51FA\u3057,
26136
+ y2: yAt(Math.max(0, d.previous)),
26137
+ stroke: "var(--cdl-text-mute, #8a8678)",
26138
+ strokeWidth: 1.5,
26139
+ strokeDasharray: "5 3"
26140
+ }
26141
+ );
26061
26142
  return /* @__PURE__ */ jsxs("g", { children: [
26062
26143
  drawing ? /* @__PURE__ */ jsx("g", { transform: `translate(0 ${\u6A2A\u8EF8\u306Ey}) scale(1 ${\u4F38\u3073}) translate(0 ${-\u6A2A\u8EF8\u306Ey})`, children: \u68D2 }) : \u68D2,
26144
+ \u524D\u306E\u5370,
26063
26145
  /* @__PURE__ */ jsx(
26064
26146
  "text",
26065
26147
  {