@cardenelabs/cdl 0.14.0 → 0.16.0
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/CHANGELOG.md +249 -1
- package/README.md +20 -1
- package/dist/index.cjs +1243 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +1242 -93
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1208 -88
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1208 -88
- package/dist/react.js.map +1 -1
- package/dist/{render-B5JHcUrb.d.cts → render-BS1E6Mlo.d.cts} +55 -2
- package/dist/{render-B5JHcUrb.d.ts → render-BS1E6Mlo.d.ts} +55 -2
- package/package.json +1 -1
- package/src/builder.ts +24 -0
- package/src/index.ts +2 -1
- package/src/kinds/chart-gauge.tsx +241 -0
- package/src/kinds/chart-pie.tsx +214 -53
- package/src/kinds/chart-radial.tsx +210 -0
- package/src/kinds/chart-stacked-bar.tsx +272 -0
- package/src/kinds/chart-stat.tsx +231 -0
- package/src/kinds/chart-waffle.tsx +197 -0
- package/src/kinds/draw-ratio.ts +44 -0
- package/src/kinds/dyn-shape.tsx +3 -6
- package/src/kinds/generic.tsx +18 -6
- package/src/kinds/terminal-mark.tsx +96 -0
- package/src/layout/edges.ts +30 -1
- package/src/layout/self-loop.ts +217 -0
- package/src/layout/spec.ts +81 -4
- package/src/layout/tokens.ts +15 -0
- package/src/presets.ts +68 -4
- package/src/render/edge-head.ts +45 -0
- package/src/render/edges.tsx +4 -2
- package/src/render/interactive-panel.tsx +2 -2
- package/src/render/nodes.tsx +25 -0
- package/src/render/payload-binding.ts +14 -3
- package/src/render/stage.tsx +41 -18
- package/src/render/tone.ts +52 -0
- package/src/types.ts +66 -2
- package/src/validate.ts +13 -5
- package/src/visual-validate.ts +48 -1
package/src/visual-validate.ts
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
* test が無いと、 次に種別を足した時に同じ状態へ戻る。
|
|
78
78
|
* ───────────────────────────────────────────────────────────
|
|
79
79
|
*/
|
|
80
|
-
import type
|
|
80
|
+
import { EDGE_HEADS, type CdlDiagram, type LaidDiagram, type LaidNode, type NodeKind } from "./types";
|
|
81
81
|
import { CLEARANCE_LANE_LABEL, DIST_LABEL_PATH_MAX } from "./layout/clearance-constants";
|
|
82
82
|
import { layout } from "./layout";
|
|
83
83
|
import {
|
|
@@ -134,7 +134,9 @@ import {
|
|
|
134
134
|
computeLabelBBoxWorld,
|
|
135
135
|
hasRenderedLabel,
|
|
136
136
|
isRenderedNode,
|
|
137
|
+
genericTitleBaselineY,
|
|
137
138
|
rendersRows,
|
|
139
|
+
TITLE_ROW_MIN_GAP,
|
|
138
140
|
rendersTitleText,
|
|
139
141
|
fitsOwnTitleWidth,
|
|
140
142
|
rowBaselineY,
|
|
@@ -238,6 +240,11 @@ export const GRID_ALIGNED_KINDS: ReadonlySet<NodeKind> = new Set([
|
|
|
238
240
|
"chart-pie",
|
|
239
241
|
"chart-line",
|
|
240
242
|
"chart-bar",
|
|
243
|
+
"chart-gauge",
|
|
244
|
+
"chart-radial",
|
|
245
|
+
"chart-stat",
|
|
246
|
+
"chart-waffle",
|
|
247
|
+
"chart-stacked-bar",
|
|
241
248
|
"funnel-stages",
|
|
242
249
|
"quadrant-matrix",
|
|
243
250
|
]);
|
|
@@ -374,6 +381,7 @@ export type VisualAxis =
|
|
|
374
381
|
| "column-gap-uniform"
|
|
375
382
|
// Axis 68 (#387) = 行を描かない種別に rows が書かれている (書いた内容が画面に出ない)。
|
|
376
383
|
| "rows-not-rendered"
|
|
384
|
+
| "title-row-overlap"
|
|
377
385
|
// #393 = 検査に渡された図の形自体が壊れている (検査できなかったことを結果として出す)。
|
|
378
386
|
| "malformed-input"
|
|
379
387
|
// #393 = 検査が例外で中断したが、 原因が入力の破綻か検査側の欠陥か **決められない**。
|
|
@@ -498,6 +506,7 @@ function emptyCounts(): Record<VisualAxis, number> {
|
|
|
498
506
|
"row-gap-uniform": 0,
|
|
499
507
|
"column-gap-uniform": 0,
|
|
500
508
|
"rows-not-rendered": 0,
|
|
509
|
+
"title-row-overlap": 0,
|
|
501
510
|
"malformed-input": 0,
|
|
502
511
|
"validation-interrupted": 0,
|
|
503
512
|
};
|
|
@@ -2736,6 +2745,36 @@ function runAxes(
|
|
|
2736
2745
|
);
|
|
2737
2746
|
}
|
|
2738
2747
|
|
|
2748
|
+
// ───────────────────────────────────────────────────────────
|
|
2749
|
+
// Axis 69: title-row-overlap (題の字と 1 行目の字が重なる)
|
|
2750
|
+
//
|
|
2751
|
+
// 判定 = 題の baseline から下へ伸びる字形と、 1 行目の baseline から上へ伸びる字形が
|
|
2752
|
+
// 触れるか。 位置は `spec.ts` の 2 関数 (`genericTitleBaselineY` / `rowBaselineY`) から
|
|
2753
|
+
// 取るので、 描画側を変えれば本軸も一緒に動く。
|
|
2754
|
+
//
|
|
2755
|
+
// 題と行の縦位置は形ごとに別々の式で決まっていた時期があり、 円柱と中央寄せの 3 種で
|
|
2756
|
+
// 字が重なっていた (#558)。 軸 4 (`row-format`) と軸 16 (`row-vertical-spacing`) は
|
|
2757
|
+
// 行どうしと枠との関係しか見ないため、 題との関係は誰も見ていなかった。
|
|
2758
|
+
//
|
|
2759
|
+
// `storage` は専用の表組みで題と列の間に区切り線を引いており、 位置の出所が別なので対象外。
|
|
2760
|
+
// ───────────────────────────────────────────────────────────
|
|
2761
|
+
for (const n of diag.nodes) {
|
|
2762
|
+
if (!n.rows || n.rows.length === 0) continue;
|
|
2763
|
+
if (!rendersRows(n.kind)) continue;
|
|
2764
|
+
if (n.kind === "storage") continue;
|
|
2765
|
+
// 高さを取れない node は測らない。 0 に潰すと中央寄せの題が上端に来て誤って重なる判定になる
|
|
2766
|
+
if (typeof n.h !== "number") continue;
|
|
2767
|
+
const 題 = genericTitleBaselineY(n.kind, n.h, true);
|
|
2768
|
+
const 行 = rowBaselineY(n.kind, 0);
|
|
2769
|
+
if (行 === null) continue;
|
|
2770
|
+
const 間 = 行 - 題;
|
|
2771
|
+
if (間 >= TITLE_ROW_MIN_GAP) continue;
|
|
2772
|
+
push(
|
|
2773
|
+
"title-row-overlap",
|
|
2774
|
+
`node "${n.id}" (kind=${n.kind ?? "未指定"}) の題 baseline y=${題.toFixed(0)} と 1 行目 baseline y=${行.toFixed(0)} の間が ${間.toFixed(0)} world で、 見込む字形の高さ ${TITLE_ROW_MIN_GAP.toFixed(0)} に届かない (字が重なる)`,
|
|
2775
|
+
);
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2739
2778
|
// ───────────────────────────────────────────────────────────
|
|
2740
2779
|
// Axis 17: group-boundary-clearance (topology group の boundary padding + 外部 clearance)
|
|
2741
2780
|
//
|
|
@@ -3307,6 +3346,14 @@ function runAxes(
|
|
|
3307
3346
|
`edge "${e.id}" tone "${e.tone}" が TONE_COLORS 定義に存在しない、 marker "cdl-arrow-${e.tone}" dead ref`,
|
|
3308
3347
|
);
|
|
3309
3348
|
}
|
|
3349
|
+
// 端の形も同じ理由で dead ref になる (#560)。 marker は EDGE_HEADS の分しか定義しないので、
|
|
3350
|
+
// 定義外の値が来ると "cdl-arrow-<tone>-<未定義>" を引いて矢頭が消える。
|
|
3351
|
+
if (e.head !== undefined && !EDGE_HEADS.includes(e.head)) {
|
|
3352
|
+
push(
|
|
3353
|
+
"marker-gradient-def-integrity",
|
|
3354
|
+
`edge "${e.id}" head "${e.head}" が EDGE_HEADS 定義に存在しない、 marker "cdl-arrow-${e.tone}-${e.head}" dead ref`,
|
|
3355
|
+
);
|
|
3356
|
+
}
|
|
3310
3357
|
}
|
|
3311
3358
|
|
|
3312
3359
|
// ───────────────────────────────────────────────────────────
|