@constela/core 0.19.0 → 0.20.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/dist/index.js +91 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3458,6 +3458,90 @@ function downsampleLTTB(data, targetCount) {
|
|
|
3458
3458
|
result.push(data[data.length - 1]);
|
|
3459
3459
|
return result;
|
|
3460
3460
|
}
|
|
3461
|
+
function getChartGridLines(min, max, height, padTop, padBottom, count) {
|
|
3462
|
+
if (typeof min !== "number" || typeof max !== "number" || typeof height !== "number" || typeof padTop !== "number" || typeof padBottom !== "number" || typeof count !== "number") {
|
|
3463
|
+
return [];
|
|
3464
|
+
}
|
|
3465
|
+
if (count <= 0) {
|
|
3466
|
+
return [];
|
|
3467
|
+
}
|
|
3468
|
+
const ticks = generateTicks(min, max, count);
|
|
3469
|
+
const result = [];
|
|
3470
|
+
for (const tick of ticks) {
|
|
3471
|
+
const y = scaleChartY(tick, min, max, height, padTop, padBottom);
|
|
3472
|
+
if (y === void 0) {
|
|
3473
|
+
continue;
|
|
3474
|
+
}
|
|
3475
|
+
result.push({
|
|
3476
|
+
y,
|
|
3477
|
+
value: tick,
|
|
3478
|
+
label: tick.toString()
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
return result;
|
|
3482
|
+
}
|
|
3483
|
+
function getRoundedBarPath(x, y, width, height, radius) {
|
|
3484
|
+
if (typeof x !== "number" || typeof y !== "number" || typeof width !== "number" || typeof height !== "number" || typeof radius !== "number") {
|
|
3485
|
+
return "";
|
|
3486
|
+
}
|
|
3487
|
+
if (width <= 0 || height <= 0) {
|
|
3488
|
+
return "";
|
|
3489
|
+
}
|
|
3490
|
+
const r = Math.min(radius, width / 2, height);
|
|
3491
|
+
if (r <= 0) {
|
|
3492
|
+
return `M${x},${y + height}L${x},${y}L${x + width},${y}L${x + width},${y + height}Z`;
|
|
3493
|
+
}
|
|
3494
|
+
return `M${x},${y + height}L${x},${y + r}Q${x},${y} ${x + r},${y}L${x + width - r},${y}Q${x + width},${y} ${x + width},${y + r}L${x + width},${y + height}Z`;
|
|
3495
|
+
}
|
|
3496
|
+
function getDonutArcPath(cx, cy, outerR, innerR, startAngle, endAngle) {
|
|
3497
|
+
if (typeof cx !== "number" || typeof cy !== "number" || typeof outerR !== "number" || typeof innerR !== "number" || typeof startAngle !== "number" || typeof endAngle !== "number") {
|
|
3498
|
+
return "";
|
|
3499
|
+
}
|
|
3500
|
+
if (innerR >= outerR || outerR <= 0 || innerR < 0) {
|
|
3501
|
+
return "";
|
|
3502
|
+
}
|
|
3503
|
+
const outerX1 = cx + outerR * Math.cos(startAngle - Math.PI / 2);
|
|
3504
|
+
const outerY1 = cy + outerR * Math.sin(startAngle - Math.PI / 2);
|
|
3505
|
+
const outerX2 = cx + outerR * Math.cos(endAngle - Math.PI / 2);
|
|
3506
|
+
const outerY2 = cy + outerR * Math.sin(endAngle - Math.PI / 2);
|
|
3507
|
+
const innerX1 = cx + innerR * Math.cos(startAngle - Math.PI / 2);
|
|
3508
|
+
const innerY1 = cy + innerR * Math.sin(startAngle - Math.PI / 2);
|
|
3509
|
+
const innerX2 = cx + innerR * Math.cos(endAngle - Math.PI / 2);
|
|
3510
|
+
const innerY2 = cy + innerR * Math.sin(endAngle - Math.PI / 2);
|
|
3511
|
+
const angleDiff = endAngle - startAngle;
|
|
3512
|
+
const largeArcFlag = Math.abs(angleDiff) > Math.PI ? 1 : 0;
|
|
3513
|
+
return `M${outerX1},${outerY1}A${outerR},${outerR} 0 ${largeArcFlag},1 ${outerX2},${outerY2}L${innerX2},${innerY2}A${innerR},${innerR} 0 ${largeArcFlag},0 ${innerX1},${innerY1}Z`;
|
|
3514
|
+
}
|
|
3515
|
+
function getSliceLabelPosition(cx, cy, radius, startAngle, endAngle) {
|
|
3516
|
+
if (typeof cx !== "number" || typeof cy !== "number" || typeof radius !== "number" || typeof startAngle !== "number" || typeof endAngle !== "number") {
|
|
3517
|
+
return void 0;
|
|
3518
|
+
}
|
|
3519
|
+
const midAngle = (startAngle + endAngle) / 2;
|
|
3520
|
+
const x = cx + radius * Math.cos(midAngle - Math.PI / 2);
|
|
3521
|
+
const y = cy + radius * Math.sin(midAngle - Math.PI / 2);
|
|
3522
|
+
return { x, y };
|
|
3523
|
+
}
|
|
3524
|
+
function getRadarGridPolygons(cx, cy, radius, sides, levels) {
|
|
3525
|
+
if (typeof cx !== "number" || typeof cy !== "number" || typeof radius !== "number" || typeof sides !== "number" || typeof levels !== "number") {
|
|
3526
|
+
return [];
|
|
3527
|
+
}
|
|
3528
|
+
if (sides < 3 || levels < 1) {
|
|
3529
|
+
return [];
|
|
3530
|
+
}
|
|
3531
|
+
const result = [];
|
|
3532
|
+
for (let i = 1; i <= levels; i++) {
|
|
3533
|
+
const levelRadius = radius * (i / levels);
|
|
3534
|
+
const points = [];
|
|
3535
|
+
for (let j = 0; j < sides; j++) {
|
|
3536
|
+
const angle = 2 * Math.PI * j / sides - Math.PI / 2;
|
|
3537
|
+
const x = cx + levelRadius * Math.cos(angle);
|
|
3538
|
+
const y = cy + levelRadius * Math.sin(angle);
|
|
3539
|
+
points.push(`${x},${y}`);
|
|
3540
|
+
}
|
|
3541
|
+
result.push(points.join(" "));
|
|
3542
|
+
}
|
|
3543
|
+
return result;
|
|
3544
|
+
}
|
|
3461
3545
|
var GLOBAL_FUNCTIONS = {
|
|
3462
3546
|
// Date helpers
|
|
3463
3547
|
getCalendarDays: (year, month) => getCalendarDays(year, month),
|
|
@@ -3494,7 +3578,13 @@ var GLOBAL_FUNCTIONS = {
|
|
|
3494
3578
|
// Chart helpers - Data aggregation
|
|
3495
3579
|
binData: (data, valueKey, binCount) => binData(data, valueKey, binCount),
|
|
3496
3580
|
aggregateData: (data, groupKey, valueKey, aggregation) => aggregateData(data, groupKey, valueKey, aggregation),
|
|
3497
|
-
downsample: (data, targetCount, method) => downsample(data, targetCount, method)
|
|
3581
|
+
downsample: (data, targetCount, method) => downsample(data, targetCount, method),
|
|
3582
|
+
// Chart helpers - Grid & redesign
|
|
3583
|
+
getChartGridLines: (min, max, height, padTop, padBottom, count) => getChartGridLines(min, max, height, padTop, padBottom, count),
|
|
3584
|
+
getRoundedBarPath: (x, y, width, height, radius) => getRoundedBarPath(x, y, width, height, radius),
|
|
3585
|
+
getDonutArcPath: (cx, cy, outerR, innerR, startAngle, endAngle) => getDonutArcPath(cx, cy, outerR, innerR, startAngle, endAngle),
|
|
3586
|
+
getSliceLabelPosition: (cx, cy, radius, startAngle, endAngle) => getSliceLabelPosition(cx, cy, radius, startAngle, endAngle),
|
|
3587
|
+
getRadarGridPolygons: (cx, cy, radius, sides, levels) => getRadarGridPolygons(cx, cy, radius, sides, levels)
|
|
3498
3588
|
};
|
|
3499
3589
|
function callGlobalFunction(method, args) {
|
|
3500
3590
|
const fn = GLOBAL_FUNCTIONS[method];
|