@cardenelabs/cdl 0.40.2 → 0.40.4
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 +42 -1
- package/dist/index.cjs +33 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +33 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +33 -10
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/src/anim/core/timeline.ts +13 -3
- package/src/anim/core/types.ts +1 -1
- package/src/kinds/chart-gauge.tsx +56 -11
- package/src/render.tsx +4 -2
package/dist/react.cjs
CHANGED
|
@@ -42,7 +42,7 @@ function cubicBezier(x1, y1, x2, y2) {
|
|
|
42
42
|
return sampleCurveY(solveCurveX(t));
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
var
|
|
45
|
+
var easeOut = cubicBezier(0, 0, 0.58, 1);
|
|
46
46
|
function clamp01(value) {
|
|
47
47
|
if (value < 0) return 0;
|
|
48
48
|
if (value > 1) return 1;
|
|
@@ -87,7 +87,7 @@ var Timeline = class {
|
|
|
87
87
|
throw new Error("Timeline requires at least one phase");
|
|
88
88
|
}
|
|
89
89
|
this.phases = phases;
|
|
90
|
-
this.easing = options.easing ??
|
|
90
|
+
this.easing = options.easing ?? easeOut;
|
|
91
91
|
this.loop = options.loop ?? false;
|
|
92
92
|
this.autoAdvanceMsOverride = options.autoAdvanceMs;
|
|
93
93
|
this.phaseHoldMs = options.phaseHoldMs ?? 0;
|
|
@@ -12389,8 +12389,18 @@ function ChartGaugeNode({
|
|
|
12389
12389
|
const \u4F7F\u3048\u308B\u5E452 = node.w - PAD_SIDE * 2;
|
|
12390
12390
|
const \u540D\u524D\u306E\u7D1A = 14;
|
|
12391
12391
|
const \u6570\u5024\u306E\u7D1A = 13;
|
|
12392
|
-
const \
|
|
12392
|
+
const \u6BB5\u306E\u9AD8\u3055 = 56;
|
|
12393
12393
|
const \u5F27\u3068\u5185\u8A33\u306E\u9593 = 16;
|
|
12394
|
+
const \u5370\u306E\u5E452 = 30;
|
|
12395
|
+
const \u533A\u753B\u306E\u9593 = 12;
|
|
12396
|
+
const \u5185\u8A33\u306E\u6570\u5024 = data.map((d) => `${\u5B9F\u5024\u8868\u8A18(d.value)} ${\u5272\u5408\u8868\u8A18(d.value / total)}`);
|
|
12397
|
+
const \u4EF6\u306B\u8981\u308B\u5E45 = Math.max(\u5370\u306E\u5E452, ...\u5185\u8A33\u306E\u6570\u5024.map((t) => textWidth(t, \u6570\u5024\u306E\u7D1A))) + \u533A\u753B\u306E\u9593;
|
|
12398
|
+
const \u884C\u306E\u4EF6\u6570 = Math.min(
|
|
12399
|
+
Math.max(1, Math.floor(\u4F7F\u3048\u308B\u5E452 / Math.max(\u4EF6\u306B\u8981\u308B\u5E45, 1))),
|
|
12400
|
+
Math.max(data.length, 1)
|
|
12401
|
+
);
|
|
12402
|
+
const \u5185\u8A33\u306E\u6BB5\u6570 = Math.ceil(Math.max(data.length, 1) / \u884C\u306E\u4EF6\u6570);
|
|
12403
|
+
const \u5185\u8A33\u306E\u9AD8\u3055 = \u6BB5\u306E\u9AD8\u3055 * \u5185\u8A33\u306E\u6BB5\u6570;
|
|
12394
12404
|
const \u5F27\u306B\u4F7F\u3048\u308B\u9AD8\u3055 = \u4F7F\u3048\u308B\u9AD8\u3055 - \u5185\u8A33\u306E\u9AD8\u3055 - \u5F27\u3068\u5185\u8A33\u306E\u9593;
|
|
12395
12405
|
const radius = Math.max(24, Math.min(\u5F27\u306B\u4F7F\u3048\u308B\u9AD8\u3055, \u4F7F\u3048\u308B\u5E452 / 2));
|
|
12396
12406
|
const \u5185\u534A\u5F84 = radius * 0.62;
|
|
@@ -12419,7 +12429,7 @@ function ChartGaugeNode({
|
|
|
12419
12429
|
);
|
|
12420
12430
|
const \u5408\u8A08\u306E\u7D1A = Math.max(11, Math.round(\u7D1A\u306E\u5019\u88DC));
|
|
12421
12431
|
const \u898B\u51FA\u3057\u306E\u7D1A = Math.max(9, Math.round(\u5408\u8A08\u306E\u7D1A * 0.38));
|
|
12422
|
-
const \u5185\u8A33\u306E\u5E45 = \u4F7F\u3048\u308B\u5E452 /
|
|
12432
|
+
const \u5185\u8A33\u306E\u5E45 = \u4F7F\u3048\u308B\u5E452 / \u884C\u306E\u4EF6\u6570;
|
|
12423
12433
|
const \u5185\u8A33\u306Ey = cy + \u5F27\u3068\u5185\u8A33\u306E\u9593;
|
|
12424
12434
|
const \u4F38\u3073 = \u9032\u307F\u3092\u7573\u3080(drawing, progress);
|
|
12425
12435
|
const \u5207\u308A\u629C\u304Did = `cdl-gauge-draw-${react.useId().replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
@@ -12477,22 +12487,35 @@ function ChartGaugeNode({
|
|
|
12477
12487
|
}
|
|
12478
12488
|
),
|
|
12479
12489
|
data.map((d, idx) => {
|
|
12480
|
-
const
|
|
12481
|
-
const \
|
|
12490
|
+
const \u5217 = idx % \u884C\u306E\u4EF6\u6570;
|
|
12491
|
+
const \u6BB5 = Math.floor(idx / \u884C\u306E\u4EF6\u6570);
|
|
12492
|
+
const x = PAD_SIDE + \u5185\u8A33\u306E\u5E45 * \u5217;
|
|
12493
|
+
const y = \u5185\u8A33\u306Ey + \u6BB5\u306E\u9AD8\u3055 * \u6BB5;
|
|
12494
|
+
const \u53CE\u307E\u308B\u5E45 = \u5185\u8A33\u306E\u5E45 - \u533A\u753B\u306E\u9593;
|
|
12482
12495
|
return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-cdl-role": "chart-gauge-item", children: [
|
|
12483
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12496
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12497
|
+
"rect",
|
|
12498
|
+
{
|
|
12499
|
+
x,
|
|
12500
|
+
y,
|
|
12501
|
+
width: Math.max(4, Math.min(\u5370\u306E\u5E452, \u53CE\u307E\u308B\u5E45)),
|
|
12502
|
+
height: 4,
|
|
12503
|
+
rx: 2,
|
|
12504
|
+
fill: arcColor(d.tone, idx)
|
|
12505
|
+
}
|
|
12506
|
+
),
|
|
12484
12507
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12485
12508
|
"text",
|
|
12486
12509
|
{
|
|
12487
12510
|
x,
|
|
12488
|
-
y:
|
|
12511
|
+
y: y + 26,
|
|
12489
12512
|
fontSize: \u540D\u524D\u306E\u7D1A,
|
|
12490
12513
|
fontWeight: 700,
|
|
12491
12514
|
fill: "var(--cdl-text, #1a1f2a)",
|
|
12492
|
-
children: \u5207\u308A\u8A70\u3081\u308B(d.label ?? "", \
|
|
12515
|
+
children: \u5207\u308A\u8A70\u3081\u308B(d.label ?? "", \u53CE\u307E\u308B\u5E45, \u540D\u524D\u306E\u7D1A)
|
|
12493
12516
|
}
|
|
12494
12517
|
),
|
|
12495
|
-
/* @__PURE__ */ jsxRuntime.jsx("text", { x, y:
|
|
12518
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { x, y: y + 46, fontSize: \u6570\u5024\u306E\u7D1A, fill: "var(--cdl-text-dim, #5a6270)", children: \u5207\u308A\u8A70\u3081\u308B(\u5185\u8A33\u306E\u6570\u5024[idx] ?? "", \u53CE\u307E\u308B\u5E45, \u6570\u5024\u306E\u7D1A) })
|
|
12496
12519
|
] }, `legend-${idx}`);
|
|
12497
12520
|
})
|
|
12498
12521
|
] });
|