@cardenelabs/cdl 0.30.3 → 0.31.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/react.js CHANGED
@@ -9885,8 +9885,314 @@ function StateDiffCard({
9885
9885
  }
9886
9886
  );
9887
9887
  }
9888
+ var \u6570\u3092\u66F8\u304F = (value) => value.toLocaleString("en-US", { maximumFractionDigits: 12 });
9889
+ function \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values) {
9890
+ let rawMin = values.length > 0 ? Math.min(...values) : 0;
9891
+ let rawMax = values.length > 0 ? Math.max(...values) : 1;
9892
+ if (rawMin === rawMax) {
9893
+ const room = 10 ** Math.floor(Math.log10(Math.abs(rawMin) || 1) - 1);
9894
+ rawMin -= room;
9895
+ rawMax += room;
9896
+ }
9897
+ const roughStep = (rawMax - rawMin) / 4;
9898
+ const power = 10 ** Math.floor(Math.log10(roughStep));
9899
+ const fraction = roughStep / power;
9900
+ const niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 2.5 ? 2.5 : fraction <= 5 ? 5 : 10;
9901
+ const step = niceFraction * power;
9902
+ const min = Math.floor(rawMin / step) * step;
9903
+ const max = Math.ceil(rawMax / step) * step;
9904
+ const tickCount = Math.round((max - min) / step);
9905
+ const ticks = Array.from({ length: tickCount + 1 }, (_, i) => {
9906
+ const value = min + step * i;
9907
+ return Math.abs(value) < step * 1e-12 ? 0 : value;
9908
+ });
9909
+ return { min, max, ticks };
9910
+ }
9911
+ function ChartLineNode({
9912
+ node,
9913
+ active,
9914
+ stateValues = {},
9915
+ scale: fixedScale,
9916
+ drawing = false,
9917
+ progress = 1
9918
+ }) {
9919
+ const x0 = node.cx - node.w / 2;
9920
+ const y0 = node.cy - node.h / 2;
9921
+ const data = resolveChartData(node.chartData ?? [], stateValues);
9922
+ const PAD_TOP2 = 36;
9923
+ const PAD_RIGHT2 = 40;
9924
+ const PAD_BOTTOM2 = 56;
9925
+ const PAD_LEFT2 = 72;
9926
+ const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
9927
+ const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
9928
+ const scale = fixedScale ?? \u6298\u308C\u7DDA\u306E\u76EE\u76DB(data.map((d) => d.value));
9929
+ const vRange = scale.max - scale.min;
9930
+ const LABEL_ROOM = 20;
9931
+ const plotTop = PAD_TOP2 + LABEL_ROOM;
9932
+ const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
9933
+ const POINT_EDGE_ROOM = 24;
9934
+ const plotW = Math.max(canvasW - POINT_EDGE_ROOM * 2, 1);
9935
+ const xAt = (idx) => PAD_LEFT2 + POINT_EDGE_ROOM + (data.length <= 1 ? plotW / 2 : plotW * idx / (data.length - 1));
9936
+ const yAt = (v) => plotTop + plotH - (v - scale.min) / vRange * plotH;
9937
+ const plotBottom = PAD_TOP2 + canvasH;
9938
+ let \u7DDA\u306E\u5168\u9577 = 0;
9939
+ let \u524D\u306E\u70B9;
9940
+ const \u63CF\u753B\u70B9 = data.map((datum, idx) => {
9941
+ const \u4ECA\u306E\u70B9 = { datum, x: xAt(idx), y: yAt(datum.value), \u3053\u3053\u307E\u3067\u306E\u9577\u3055: 0 };
9942
+ if (\u524D\u306E\u70B9) {
9943
+ \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
9944
+ }
9945
+ \u4ECA\u306E\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 = \u7DDA\u306E\u5168\u9577;
9946
+ \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
9947
+ return \u4ECA\u306E\u70B9;
9948
+ });
9949
+ const points = \u63CF\u753B\u70B9.map((\u70B9) => `${\u70B9.x},${\u70B9.y}`).join(" ");
9950
+ const \u6BB5\u306E\u9032\u307F = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
9951
+ const \u7C92\u3092\u8D70\u3089\u305B\u308B = drawing && node.chartTrace === true;
9952
+ const \u4F38\u3073 = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, \u6BB5\u306E\u9032\u307F / 0.5) : \u6BB5\u306E\u9032\u307F;
9953
+ const \u7C92\u306E\u9032\u307F = \u7C92\u3092\u8D70\u3089\u305B\u308B ? Math.min(1, Math.max(0, (\u6BB5\u306E\u9032\u307F - 0.55) / 0.45)) : \u4F38\u3073;
9954
+ const \u7C92\u304C\u51FA\u308B = \u7C92\u3092\u8D70\u3089\u305B\u308B && \u6BB5\u306E\u9032\u307F >= 0.55 && \u6BB5\u306E\u9032\u307F < 1;
9955
+ const \u5230\u7740\u7A93 = 0.12;
9956
+ let \u7C92\u306E\u4F4D\u7F6E;
9957
+ const \u6700\u521D\u306E\u70B9 = \u63CF\u753B\u70B9[0];
9958
+ if (\u7C92\u304C\u51FA\u308B && \u6700\u521D\u306E\u70B9) {
9959
+ const \u7C92\u307E\u3067\u306E\u9577\u3055 = \u7C92\u306E\u9032\u307F * \u7DDA\u306E\u5168\u9577;
9960
+ let \u533A\u9593\u306E\u524D = \u6700\u521D\u306E\u70B9;
9961
+ let \u533A\u9593\u306E\u5F8C = \u6700\u521D\u306E\u70B9;
9962
+ for (const \u70B9 of \u63CF\u753B\u70B9.slice(1)) {
9963
+ \u533A\u9593\u306E\u5F8C = \u70B9;
9964
+ if (\u70B9.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 >= \u7C92\u307E\u3067\u306E\u9577\u3055) break;
9965
+ \u533A\u9593\u306E\u524D = \u70B9;
9966
+ }
9967
+ const \u533A\u9593\u306E\u59CB\u3081 = \u533A\u9593\u306E\u524D.\u3053\u3053\u307E\u3067\u306E\u9577\u3055;
9968
+ const \u533A\u9593\u306E\u9577\u3055 = \u533A\u9593\u306E\u5F8C.\u3053\u3053\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081;
9969
+ const \u533A\u9593\u306E\u9032\u307F = \u533A\u9593\u306E\u9577\u3055 === 0 ? 0 : (\u7C92\u307E\u3067\u306E\u9577\u3055 - \u533A\u9593\u306E\u59CB\u3081) / \u533A\u9593\u306E\u9577\u3055;
9970
+ \u7C92\u306E\u4F4D\u7F6E = {
9971
+ x: \u533A\u9593\u306E\u524D.x + (\u533A\u9593\u306E\u5F8C.x - \u533A\u9593\u306E\u524D.x) * \u533A\u9593\u306E\u9032\u307F,
9972
+ y: \u533A\u9593\u306E\u524D.y + (\u533A\u9593\u306E\u5F8C.y - \u533A\u9593\u306E\u524D.y) * \u533A\u9593\u306E\u9032\u307F
9973
+ };
9974
+ }
9975
+ const gridTicks = scale.ticks.map((value) => ({ y: yAt(value), value }));
9976
+ return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
9977
+ /* @__PURE__ */ jsx(
9978
+ "rect",
9979
+ {
9980
+ "data-cdl-role": "node-body",
9981
+ x: 0,
9982
+ y: 0,
9983
+ width: node.w,
9984
+ height: node.h,
9985
+ rx: 16,
9986
+ fill: "var(--cdl-node-fill, #ffffff)",
9987
+ stroke: "var(--cdl-divider, #d4d4d8)",
9988
+ strokeWidth: active ? 1.5 : 1
9989
+ }
9990
+ ),
9991
+ gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
9992
+ /* @__PURE__ */ jsx(
9993
+ "line",
9994
+ {
9995
+ x1: PAD_LEFT2,
9996
+ y1: t.y,
9997
+ x2: PAD_LEFT2 + canvasW,
9998
+ y2: t.y,
9999
+ stroke: "var(--cdl-divider, #d4d4d8)",
10000
+ strokeWidth: 0.75,
10001
+ strokeDasharray: "3 3",
10002
+ opacity: 0.65
10003
+ }
10004
+ ),
10005
+ /* @__PURE__ */ jsx(
10006
+ "text",
10007
+ {
10008
+ x: PAD_LEFT2 - 8,
10009
+ y: t.y + 4,
10010
+ fontSize: 11,
10011
+ textAnchor: "end",
10012
+ fill: "var(--cdl-text-dim, #5a6270)",
10013
+ children: \u6570\u3092\u66F8\u304F(t.value)
10014
+ }
10015
+ )
10016
+ ] }, `grid-${i}`)),
10017
+ node.chartFillUnder && data.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
10018
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
10019
+ "linearGradient",
10020
+ {
10021
+ id: `chart-line-fill-${node.id}`,
10022
+ gradientUnits: "userSpaceOnUse",
10023
+ x1: 0,
10024
+ y1: plotTop,
10025
+ x2: 0,
10026
+ y2: plotBottom,
10027
+ children: [
10028
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0.22 }),
10029
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "var(--cdl-tone-accent, #2d6a8f)", stopOpacity: 0 })
10030
+ ]
10031
+ }
10032
+ ) }),
10033
+ /* @__PURE__ */ jsx(
10034
+ "path",
10035
+ {
10036
+ "data-cdl-role": "chart-line-fill-under",
10037
+ d: `M ${xAt(0)} ${plotBottom} L ${points.replaceAll(",", " ")} L ${xAt(data.length - 1)} ${plotBottom} Z`,
10038
+ fill: `url(#chart-line-fill-${node.id})`,
10039
+ stroke: "none"
10040
+ }
10041
+ )
10042
+ ] }),
10043
+ data.length > 1 && /* @__PURE__ */ jsx(
10044
+ "polyline",
10045
+ {
10046
+ "data-cdl-role": "chart-line",
10047
+ points,
10048
+ fill: "none",
10049
+ stroke: "var(--cdl-tone-accent, #2d6a8f)",
10050
+ strokeWidth: active ? 3 : 2,
10051
+ strokeLinejoin: "round",
10052
+ strokeLinecap: "round",
10053
+ ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
10054
+ }
10055
+ ),
10056
+ \u7C92\u306E\u4F4D\u7F6E && /* @__PURE__ */ jsx(
10057
+ "circle",
10058
+ {
10059
+ "data-cdl-role": "chart-line-trace",
10060
+ cx: \u7C92\u306E\u4F4D\u7F6E.x,
10061
+ cy: \u7C92\u306E\u4F4D\u7F6E.y,
10062
+ r: 4.5,
10063
+ fill: "var(--cdl-now)"
10064
+ }
10065
+ ),
10066
+ \u63CF\u753B\u70B9.map(({ datum: d, x: cx, y: cy, \u3053\u3053\u307E\u3067\u306E\u9577\u3055 }, idx) => {
10067
+ const prev = data[idx - 1]?.value;
10068
+ const next = data[idx + 1]?.value;
10069
+ const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
10070
+ const labelAbove = !isValley;
10071
+ const labelY = labelAbove ? cy - 12 : cy + 18;
10072
+ const \u5230\u7740\u5F8C = \u7DDA\u306E\u5168\u9577 === 0 ? \u7C92\u306E\u9032\u307F : \u7C92\u306E\u9032\u307F - \u3053\u3053\u307E\u3067\u306E\u9577\u3055 / \u7DDA\u306E\u5168\u9577;
10073
+ const \u51FA\u3059 = !drawing || (!\u7C92\u3092\u8D70\u3089\u305B\u308B || \u6BB5\u306E\u9032\u307F >= 0.55) && \u5230\u7740\u5F8C >= 0;
10074
+ const \u5149\u308B = drawing && \u51FA\u3059 && \u5230\u7740\u5F8C < \u5230\u7740\u7A93;
10075
+ const \u5149\u306E\u9032\u307F = \u5149\u308B ? \u5230\u7740\u5F8C / \u5230\u7740\u7A93 : 1;
10076
+ let \u70B9\u3068\u5024;
10077
+ if (\u51FA\u3059) {
10078
+ const \u5149\u306E\u534A\u5F84 = 6 + 16 * \u5149\u306E\u9032\u307F;
10079
+ const \u5024 = /* @__PURE__ */ jsx(
10080
+ "text",
10081
+ {
10082
+ "data-cdl-role": "chart-line-value",
10083
+ x: cx,
10084
+ y: labelY,
10085
+ fontSize: 11,
10086
+ fontWeight: 600,
10087
+ textAnchor: "middle",
10088
+ fill: "var(--cdl-text, #1a1f2a)",
10089
+ children: \u6570\u3092\u66F8\u304F(d.value)
10090
+ }
10091
+ );
10092
+ \u70B9\u3068\u5024 = /* @__PURE__ */ jsxs(Fragment, { children: [
10093
+ \u5149\u308B && // marker の `circle` を数える利用側へ混ぜず、専用 role の等径 ellipse として輪を出す。
10094
+ /* @__PURE__ */ jsx(
10095
+ "ellipse",
10096
+ {
10097
+ "data-cdl-role": "chart-line-arrival-ring",
10098
+ cx,
10099
+ cy,
10100
+ rx: \u5149\u306E\u534A\u5F84,
10101
+ ry: \u5149\u306E\u534A\u5F84,
10102
+ fill: "none",
10103
+ stroke: "var(--cdl-now)",
10104
+ strokeWidth: 2,
10105
+ opacity: 0.85 * (1 - \u5149\u306E\u9032\u307F)
10106
+ }
10107
+ ),
10108
+ /* @__PURE__ */ jsx(
10109
+ "circle",
10110
+ {
10111
+ cx,
10112
+ cy,
10113
+ r: 5,
10114
+ fill: "var(--cdl-node-fill, #ffffff)",
10115
+ stroke: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)",
10116
+ strokeWidth: 2.5
10117
+ }
10118
+ ),
10119
+ /* @__PURE__ */ jsx(
10120
+ "circle",
10121
+ {
10122
+ cx,
10123
+ cy,
10124
+ r: 2.5,
10125
+ fill: \u5149\u308B ? "var(--cdl-now)" : "var(--cdl-tone-accent, #2d6a8f)"
10126
+ }
10127
+ ),
10128
+ node.chartValueRise && \u5149\u308B ? /* @__PURE__ */ jsx(
10129
+ "g",
10130
+ {
10131
+ "data-cdl-role": "chart-line-value-rise",
10132
+ transform: `translate(0 ${8 * (1 - \u5149\u306E\u9032\u307F)})`,
10133
+ children: \u5024
10134
+ }
10135
+ ) : \u5024
10136
+ ] });
10137
+ }
10138
+ return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
10139
+ \u70B9\u3068\u5024,
10140
+ /* @__PURE__ */ jsx(
10141
+ "text",
10142
+ {
10143
+ x: cx,
10144
+ y: PAD_TOP2 + canvasH + 20,
10145
+ fontSize: 12,
10146
+ textAnchor: "middle",
10147
+ fill: "var(--cdl-text-dim, #5a6270)",
10148
+ children: d.label
10149
+ }
10150
+ )
10151
+ ] }, `pt-${idx}`);
10152
+ })
10153
+ ] });
10154
+ }
10155
+
10156
+ // src/kinds/draw-ratio.ts
10157
+ var DRAW_RATIO_DEFAULT = 1;
10158
+ function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
10159
+ if (ratio === void 0) return DRAW_RATIO_DEFAULT;
10160
+ if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
10161
+ if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
10162
+ return ratio;
10163
+ }
10164
+ function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
10165
+ const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
10166
+ if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
10167
+ if (!Number.isFinite(progress)) return progress;
10168
+ return Math.min(1, progress / \u5272\u5408);
10169
+ }
10170
+
10171
+ // src/layout/lifeline.ts
10172
+ function lifelineStartYs(nodes) {
10173
+ const topmost = /* @__PURE__ */ new Map();
10174
+ for (const n of nodes) {
10175
+ const cur = topmost.get(n.lane);
10176
+ if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
10177
+ }
10178
+ const starts = /* @__PURE__ */ new Map();
10179
+ for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
10180
+ return starts;
10181
+ }
10182
+ function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
10183
+ const lifelineLanes = lanes.filter((l) => l.lifeline);
10184
+ let deepestStart = Number.NEGATIVE_INFINITY;
10185
+ for (const lane of lifelineLanes) {
10186
+ const start = starts.get(lane.id);
10187
+ if (start !== void 0) deepestStart = Math.max(deepestStart, start);
10188
+ }
10189
+ const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
10190
+ if (footerTops.length > 0) return Math.min(...footerTops);
10191
+ return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
10192
+ }
9888
10193
 
9889
10194
  // src/render/edge-head.ts
10195
+ var EDGE_HEAD_MUTED_MARKER_ID = "cdl-arrow-muted";
9890
10196
  var EDGE_HEAD_SHAPE = {
9891
10197
  // 何も描かない端。 marker 自体を出さないので `d` は読まれない
9892
10198
  none: { d: "", w: 10, h: 10, refX: 0, filled: false },
@@ -9917,6 +10223,11 @@ function edgeHeadMarkerId(tone, head, small, fill = EDGE_HEAD_FILL_DEFAULT) {
9917
10223
  const \u5857 = fill === EDGE_HEAD_FILL_DEFAULT || !EDGE_HEAD_SHAPE[head].filled ? "" : `-${fill}`;
9918
10224
  return head === EDGE_HEAD_DEFAULT && \u5857 === "" ? `cdl-arrow-${tone}${\u5C0F}` : `cdl-arrow-${tone}-${head}${\u5857}${\u5C0F}`;
9919
10225
  }
10226
+ function edgeHeadMarkerName(tone, head, small, fill) {
10227
+ const \u5B9F\u969B\u306E\u5F62 = head ?? EDGE_HEAD_DEFAULT;
10228
+ if (\u5B9F\u969B\u306E\u5F62 === "none") return void 0;
10229
+ return hasTone(tone) ? edgeHeadMarkerId(tone, \u5B9F\u969B\u306E\u5F62, small, fill ?? EDGE_HEAD_FILL_DEFAULT) : EDGE_HEAD_MUTED_MARKER_ID;
10230
+ }
9920
10231
  function edgeHeadPaint(head, fill, color) {
9921
10232
  const \u5F62 = EDGE_HEAD_SHAPE[head];
9922
10233
  if (!\u5F62.filled) return { fill: "none", stroke: color, strokeWidth: 1.6 };
@@ -9945,13 +10256,8 @@ function CdlEdgeView({
9945
10256
  stateValues
9946
10257
  }) {
9947
10258
  const color = edgeColor(edge);
9948
- const \u7AEF\u306E\u540D\u524D = (h, f) => {
9949
- const \u5F62 = h ?? EDGE_HEAD_DEFAULT;
9950
- if (\u5F62 === "none") return void 0;
9951
- return hasTone(edge.tone) ? edgeHeadMarkerId(edge.tone, \u5F62, !active, f ?? EDGE_HEAD_FILL_DEFAULT) : "cdl-arrow-muted";
9952
- };
9953
- const marker = \u7AEF\u306E\u540D\u524D(edge.head, edge.headFill);
9954
- const tailMarker = edge.tailHead === void 0 ? void 0 : \u7AEF\u306E\u540D\u524D(edge.tailHead, edge.tailHeadFill);
10259
+ const marker = edgeHeadMarkerName(edge.tone, edge.head, !active, edge.headFill);
10260
+ const tailMarker = edge.tailHead === void 0 ? void 0 : edgeHeadMarkerName(edge.tone, edge.tailHead, !active, edge.tailHeadFill);
9955
10261
  const style = edge.style ?? "solid";
9956
10262
  const isDotted = style === "dotted-flow";
9957
10263
  const isPassThrough = isDotted && Boolean(edge.dThrough);
@@ -11524,191 +11830,6 @@ function interpolateColor(template, stateValues, fallback) {
11524
11830
  if (!template) return fallback;
11525
11831
  return interpolate(template, stateValues);
11526
11832
  }
11527
- function ChartLineNode({
11528
- node,
11529
- active,
11530
- stateValues = {},
11531
- drawing = false,
11532
- progress = 1
11533
- }) {
11534
- const x0 = node.cx - node.w / 2;
11535
- const y0 = node.cy - node.h / 2;
11536
- const data = resolveChartData(node.chartData ?? [], stateValues);
11537
- const PAD_TOP2 = 36;
11538
- const PAD_RIGHT2 = 40;
11539
- const PAD_BOTTOM2 = 56;
11540
- const PAD_LEFT2 = 72;
11541
- const canvasW = node.w - PAD_LEFT2 - PAD_RIGHT2;
11542
- const canvasH = node.h - PAD_TOP2 - PAD_BOTTOM2;
11543
- const values = data.map((d) => d.value);
11544
- const vMin = values.length > 0 ? Math.min(...values) : 0;
11545
- const vMax = values.length > 0 ? Math.max(...values) : 1;
11546
- const vRange = vMax - vMin || 1;
11547
- const LABEL_ROOM = 20;
11548
- const plotTop = PAD_TOP2 + LABEL_ROOM;
11549
- const plotH = Math.max(canvasH - LABEL_ROOM * 2, 1);
11550
- const xAt = (idx) => PAD_LEFT2 + (data.length <= 1 ? canvasW / 2 : canvasW * idx / (data.length - 1));
11551
- const yAt = (v) => plotTop + plotH - (v - vMin) / vRange * plotH;
11552
- const points = data.map((d, idx) => `${xAt(idx)},${yAt(d.value)}`).join(" ");
11553
- const \u70B9\u307E\u3067\u306E\u9577\u3055 = [];
11554
- let \u7DDA\u306E\u5168\u9577 = 0;
11555
- let \u524D\u306E\u70B9;
11556
- for (const [idx, datum] of data.entries()) {
11557
- const \u4ECA\u306E\u70B9 = { x: xAt(idx), y: yAt(datum.value) };
11558
- if (\u524D\u306E\u70B9) {
11559
- \u7DDA\u306E\u5168\u9577 += Math.hypot(\u4ECA\u306E\u70B9.x - \u524D\u306E\u70B9.x, \u4ECA\u306E\u70B9.y - \u524D\u306E\u70B9.y);
11560
- }
11561
- \u70B9\u307E\u3067\u306E\u9577\u3055.push(\u7DDA\u306E\u5168\u9577);
11562
- \u524D\u306E\u70B9 = \u4ECA\u306E\u70B9;
11563
- }
11564
- const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
11565
- const \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F = (idx) => {
11566
- if (!drawing) return true;
11567
- if (data.length <= 1) return true;
11568
- if (\u7DDA\u306E\u5168\u9577 === 0) return true;
11569
- return \u4F38\u3073 >= (\u70B9\u307E\u3067\u306E\u9577\u3055[idx] ?? 0) / \u7DDA\u306E\u5168\u9577;
11570
- };
11571
- const gridCount = 4;
11572
- const gridTicks = Array.from({ length: gridCount + 1 }, (_, i) => {
11573
- const v = vMin + vRange * i / gridCount;
11574
- return { y: yAt(v), value: v };
11575
- });
11576
- return /* @__PURE__ */ jsxs("g", { transform: `translate(${x0} ${y0})`, children: [
11577
- /* @__PURE__ */ jsx(
11578
- "rect",
11579
- {
11580
- "data-cdl-role": "node-body",
11581
- x: 0,
11582
- y: 0,
11583
- width: node.w,
11584
- height: node.h,
11585
- rx: 16,
11586
- fill: "var(--cdl-node-fill, #ffffff)",
11587
- stroke: active ? "var(--cdl-tone-accent, #2d6a8f)" : "var(--cdl-divider, #d4d4d8)",
11588
- strokeWidth: active ? 3 : 1.25
11589
- }
11590
- ),
11591
- gridTicks.map((t, i) => /* @__PURE__ */ jsxs("g", { children: [
11592
- /* @__PURE__ */ jsx(
11593
- "line",
11594
- {
11595
- x1: PAD_LEFT2,
11596
- y1: t.y,
11597
- x2: PAD_LEFT2 + canvasW,
11598
- y2: t.y,
11599
- stroke: "var(--cdl-divider, #d4d4d8)",
11600
- strokeWidth: 0.75,
11601
- strokeDasharray: "3 3",
11602
- opacity: 0.65
11603
- }
11604
- ),
11605
- /* @__PURE__ */ jsx(
11606
- "text",
11607
- {
11608
- x: PAD_LEFT2 - 8,
11609
- y: t.y + 4,
11610
- fontSize: 11,
11611
- textAnchor: "end",
11612
- fill: "var(--cdl-text-dim, #5a6270)",
11613
- children: Math.round(t.value)
11614
- }
11615
- )
11616
- ] }, `grid-${i}`)),
11617
- /* @__PURE__ */ jsx(
11618
- "line",
11619
- {
11620
- x1: PAD_LEFT2,
11621
- y1: plotTop + plotH,
11622
- x2: PAD_LEFT2 + canvasW,
11623
- y2: plotTop + plotH,
11624
- stroke: "var(--cdl-text-mute, #8a8678)",
11625
- strokeWidth: 1.25
11626
- }
11627
- ),
11628
- /* @__PURE__ */ jsx(
11629
- "line",
11630
- {
11631
- x1: PAD_LEFT2,
11632
- y1: plotTop,
11633
- x2: PAD_LEFT2,
11634
- y2: plotTop + plotH,
11635
- stroke: "var(--cdl-text-mute, #8a8678)",
11636
- strokeWidth: 1.25
11637
- }
11638
- ),
11639
- data.length > 1 && /* @__PURE__ */ jsx(
11640
- "polyline",
11641
- {
11642
- "data-cdl-role": "chart-line",
11643
- points,
11644
- fill: "none",
11645
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11646
- strokeWidth: 2.5,
11647
- strokeLinejoin: "round",
11648
- strokeLinecap: "round",
11649
- ...\u4F38\u3070\u3059dash(drawing, \u4F38\u3073)
11650
- }
11651
- ),
11652
- data.map((d, idx) => {
11653
- const cx = xAt(idx);
11654
- const cy = yAt(d.value);
11655
- const prev = idx > 0 ? data[idx - 1].value : void 0;
11656
- const next = idx < data.length - 1 ? data[idx + 1].value : void 0;
11657
- const isValley = (prev === void 0 || d.value <= prev) && (next === void 0 || d.value <= next);
11658
- const labelAbove = !isValley;
11659
- const labelY = labelAbove ? cy - 12 : cy + 18;
11660
- const \u51FA\u3059 = \u7DDA\u306E\u5148\u304C\u5C4A\u3044\u305F(idx);
11661
- return /* @__PURE__ */ jsxs("g", { "data-cdl-unresolved": d.unresolved ? "true" : void 0, children: [
11662
- \u51FA\u3059 && /* @__PURE__ */ jsxs(Fragment, { children: [
11663
- /* @__PURE__ */ jsx(
11664
- "circle",
11665
- {
11666
- cx,
11667
- cy,
11668
- r: 5,
11669
- fill: "var(--cdl-node-fill, #ffffff)",
11670
- stroke: "var(--cdl-tone-accent, #2d6a8f)",
11671
- strokeWidth: 2.5
11672
- }
11673
- ),
11674
- /* @__PURE__ */ jsx(
11675
- "circle",
11676
- {
11677
- cx,
11678
- cy,
11679
- r: 2.5,
11680
- fill: "var(--cdl-tone-accent, #2d6a8f)"
11681
- }
11682
- ),
11683
- /* @__PURE__ */ jsx(
11684
- "text",
11685
- {
11686
- "data-cdl-role": "chart-line-value",
11687
- x: cx,
11688
- y: labelY,
11689
- fontSize: 11,
11690
- fontWeight: 600,
11691
- textAnchor: "middle",
11692
- fill: "var(--cdl-text, #1a1f2a)",
11693
- children: d.value.toLocaleString()
11694
- }
11695
- )
11696
- ] }),
11697
- /* @__PURE__ */ jsx(
11698
- "text",
11699
- {
11700
- x: cx,
11701
- y: PAD_TOP2 + canvasH + 20,
11702
- fontSize: 12,
11703
- textAnchor: "middle",
11704
- fill: "var(--cdl-text-dim, #5a6270)",
11705
- children: d.label
11706
- }
11707
- )
11708
- ] }, `pt-${idx}`);
11709
- })
11710
- ] });
11711
- }
11712
11833
  function ChartPieNode({
11713
11834
  node,
11714
11835
  active,
@@ -17219,7 +17340,8 @@ function CdlNodeView({
17219
17340
  drawing = false,
17220
17341
  progress,
17221
17342
  stateValues,
17222
- currentPhaseId
17343
+ currentPhaseId,
17344
+ chartLineScale
17223
17345
  }) {
17224
17346
  const value = node.value ? interpolate(node.value, stateValues) : void 0;
17225
17347
  const rows = (node.rows ?? []).map((r) => interpolate(r, stateValues));
@@ -17275,6 +17397,7 @@ function CdlNodeView({
17275
17397
  node: resolvedNode,
17276
17398
  active,
17277
17399
  stateValues,
17400
+ scale: chartLineScale,
17278
17401
  drawing,
17279
17402
  progress
17280
17403
  }
@@ -17516,44 +17639,6 @@ function CdlNodeView({
17516
17639
  }
17517
17640
  );
17518
17641
  }
17519
-
17520
- // src/layout/lifeline.ts
17521
- function lifelineStartYs(nodes) {
17522
- const topmost = /* @__PURE__ */ new Map();
17523
- for (const n of nodes) {
17524
- const cur = topmost.get(n.lane);
17525
- if (cur === void 0 || n.cy < cur.cy) topmost.set(n.lane, n);
17526
- }
17527
- const starts = /* @__PURE__ */ new Map();
17528
- for (const [laneId, n] of topmost) starts.set(laneId, n.cy + n.h / 2);
17529
- return starts;
17530
- }
17531
- function uniformLifelineEndY(lanes, nodes, starts = lifelineStartYs(nodes)) {
17532
- const lifelineLanes = lanes.filter((l) => l.lifeline);
17533
- let deepestStart = Number.NEGATIVE_INFINITY;
17534
- for (const lane of lifelineLanes) {
17535
- const start = starts.get(lane.id);
17536
- if (start !== void 0) deepestStart = Math.max(deepestStart, start);
17537
- }
17538
- const footerTops = lifelineFooterNodes(lanes, nodes).map((f) => footerShapeDrawTop(f)).filter((top) => top > deepestStart);
17539
- if (footerTops.length > 0) return Math.min(...footerTops);
17540
- return lifelineLanes[0] ? lifelineLanes[0].y + lifelineLanes[0].height : 0;
17541
- }
17542
-
17543
- // src/kinds/draw-ratio.ts
17544
- var DRAW_RATIO_DEFAULT = 1;
17545
- function \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio) {
17546
- if (ratio === void 0) return DRAW_RATIO_DEFAULT;
17547
- if (!Number.isFinite(ratio)) return DRAW_RATIO_DEFAULT;
17548
- if (ratio <= 0 || ratio > 1) return DRAW_RATIO_DEFAULT;
17549
- return ratio;
17550
- }
17551
- function \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, ratio) {
17552
- const \u5272\u5408 = \u63CF\u304F\u5272\u5408\u3092\u6B63\u3059(ratio);
17553
- if (\u5272\u5408 === DRAW_RATIO_DEFAULT) return progress;
17554
- if (!Number.isFinite(progress)) return progress;
17555
- return Math.min(1, progress / \u5272\u5408);
17556
- }
17557
17642
  function CdlStage({
17558
17643
  laid,
17559
17644
  currentPhase,
@@ -17595,6 +17680,26 @@ function CdlStage({
17595
17680
  };
17596
17681
  }, [laid.phases, currentPhase, laid.edgeReveal]);
17597
17682
  const drawSet = new Set(currentPhase?.draw ?? []);
17683
+ const chartLineScales = useMemo(() => {
17684
+ const nodes = laid.nodes.filter((node) => node.kind === "chart-line");
17685
+ if (nodes.length === 0) return /* @__PURE__ */ new Map();
17686
+ const frames = [
17687
+ // phase index -1 はどの段にも入る前の初期値。
17688
+ computeStateValues(laid, -1, 0),
17689
+ ...laid.phases.flatMap((_, phaseIndex) => [
17690
+ computeStateValues(laid, phaseIndex, 0),
17691
+ computeStateValues(laid, phaseIndex, 1)
17692
+ ])
17693
+ ];
17694
+ const scales = /* @__PURE__ */ new Map();
17695
+ for (const node of nodes) {
17696
+ const values = frames.flatMap(
17697
+ (stateValues2) => resolveChartData(node.chartData ?? [], stateValues2).map((datum) => datum.value)
17698
+ );
17699
+ scales.set(node.id, \u6298\u308C\u7DDA\u306E\u76EE\u76DB(values));
17700
+ }
17701
+ return scales;
17702
+ }, [laid]);
17598
17703
  const \u63CF\u304F\u9032\u307F = \u63CF\u304F\u9032\u307F\u306B\u76F4\u3059(progress, currentPhase?.drawRatio);
17599
17704
  const { lifelineStarts, uniformFooterTop } = useMemo(() => {
17600
17705
  const starts = lifelineStartYs(laid.nodes);
@@ -17603,6 +17708,63 @@ function CdlStage({
17603
17708
  uniformFooterTop: uniformLifelineEndY(laid.lanes, laid.nodes, starts)
17604
17709
  };
17605
17710
  }, [laid]);
17711
+ const edgeHeadMarkers = useMemo(() => {
17712
+ const referenced = /* @__PURE__ */ new Set();
17713
+ const add = (tone, head, fill) => {
17714
+ for (const small of [false, true]) {
17715
+ const id = edgeHeadMarkerName(tone, head, small, fill);
17716
+ if (id !== void 0) referenced.add(id);
17717
+ }
17718
+ };
17719
+ for (const edge of laid.edges) {
17720
+ add(edge.tone, edge.head, edge.headFill);
17721
+ if (edge.tailHead !== void 0) add(edge.tone, edge.tailHead, edge.tailHeadFill);
17722
+ }
17723
+ return Object.entries(TONE).flatMap(
17724
+ ([tone, color]) => [
17725
+ [false, 14],
17726
+ [true, 10]
17727
+ ].flatMap(
17728
+ ([small, size]) => EDGE_HEADS.flatMap(
17729
+ (head) => EDGE_HEAD_FILLS.map((fill) => {
17730
+ const \u5F62 = EDGE_HEAD_SHAPE[head];
17731
+ const id = edgeHeadMarkerId(tone, head, small, fill);
17732
+ if (!referenced.has(id) || \u5F62.d === "") return null;
17733
+ if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17734
+ const \u5857 = edgeHeadPaint(head, fill, color);
17735
+ return /* @__PURE__ */ jsx(
17736
+ "marker",
17737
+ {
17738
+ id,
17739
+ viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17740
+ refX: \u5F62.refX,
17741
+ refY: \u5F62.h / 2,
17742
+ markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17743
+ markerHeight: size * (\u5F62.scale ?? 1),
17744
+ markerUnits: "userSpaceOnUse",
17745
+ orient: "auto-start-reverse",
17746
+ children: /* @__PURE__ */ jsx(
17747
+ "path",
17748
+ {
17749
+ "data-cdl-role": "edge-arrowhead",
17750
+ "data-cdl-edge-head": head,
17751
+ "data-cdl-edge-head-fill": fill,
17752
+ d: \u5F62.d,
17753
+ fill: \u5857.fill,
17754
+ stroke: \u5857.stroke,
17755
+ strokeWidth: \u5857.strokeWidth,
17756
+ strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17757
+ strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17758
+ }
17759
+ )
17760
+ },
17761
+ id
17762
+ );
17763
+ })
17764
+ )
17765
+ )
17766
+ );
17767
+ }, [laid]);
17606
17768
  const diagramScale = laid.diagramScale ?? 1;
17607
17769
  return /* @__PURE__ */ jsxs("div", { className: compact ? "px-3 py-3" : "px-6 py-6", style: compact ? void 0 : { minHeight: 460 }, children: [
17608
17770
  /* @__PURE__ */ jsxs(
@@ -17621,55 +17783,11 @@ function CdlStage({
17621
17783
  "data-cdl-type": laid.type,
17622
17784
  children: [
17623
17785
  /* @__PURE__ */ jsxs("defs", { children: [
17624
- Object.entries(TONE).flatMap(
17625
- ([tone, color]) => [["", 14], ["-sm", 10]].flatMap(
17626
- ([suffix, size]) => EDGE_HEADS.flatMap(
17627
- (head) => (
17628
- // 塗り方は形と別の軸 (#578)。 塗らない形では 2 つが同じ名前に畳まれるので、
17629
- // `edgeHeadMarkerId` が返す名前で重複を外す
17630
- EDGE_HEAD_FILLS.map((fill) => {
17631
- const \u5F62 = EDGE_HEAD_SHAPE[head];
17632
- const id = edgeHeadMarkerId(tone, head, suffix === "-sm", fill);
17633
- if (\u5F62.d === "") return null;
17634
- if (fill !== EDGE_HEAD_FILL_DEFAULT && !\u5F62.filled) return null;
17635
- const \u5857 = edgeHeadPaint(head, fill, color);
17636
- return /* @__PURE__ */ jsx(
17637
- "marker",
17638
- {
17639
- id,
17640
- viewBox: `0 0 ${\u5F62.w} ${\u5F62.h}`,
17641
- refX: \u5F62.refX,
17642
- refY: \u5F62.h / 2,
17643
- markerWidth: size * (\u5F62.scale ?? 1) * \u5F62.w / \u5F62.h,
17644
- markerHeight: size * (\u5F62.scale ?? 1),
17645
- markerUnits: "userSpaceOnUse",
17646
- orient: "auto-start-reverse",
17647
- children: /* @__PURE__ */ jsx(
17648
- "path",
17649
- {
17650
- "data-cdl-role": "edge-arrowhead",
17651
- "data-cdl-edge-head": head,
17652
- "data-cdl-edge-head-fill": fill,
17653
- d: \u5F62.d,
17654
- fill: \u5857.fill,
17655
- stroke: \u5857.stroke,
17656
- strokeWidth: \u5857.strokeWidth,
17657
- strokeLinecap: \u5857.strokeWidth === void 0 ? void 0 : "round",
17658
- strokeLinejoin: \u5857.strokeWidth === void 0 ? void 0 : "round"
17659
- }
17660
- )
17661
- },
17662
- id
17663
- );
17664
- })
17665
- )
17666
- )
17667
- )
17668
- ),
17786
+ edgeHeadMarkers,
17669
17787
  /* @__PURE__ */ jsx(
17670
17788
  "marker",
17671
17789
  {
17672
- id: "cdl-arrow-muted",
17790
+ id: EDGE_HEAD_MUTED_MARKER_ID,
17673
17791
  viewBox: "0 0 10 10",
17674
17792
  refX: "9",
17675
17793
  refY: "5",
@@ -17776,7 +17894,8 @@ function CdlStage({
17776
17894
  drawing: \u63CF\u304F,
17777
17895
  progress: \u63CF\u304F ? \u63CF\u304F\u9032\u307F : progress,
17778
17896
  stateValues,
17779
- currentPhaseId: currentPhase?.id
17897
+ currentPhaseId: currentPhase?.id,
17898
+ chartLineScale: chartLineScales.get(node.id)
17780
17899
  }
17781
17900
  );
17782
17901
  return /* @__PURE__ */ jsx("g", { children: view }, node.id);