@constela/runtime 2.0.4 → 2.0.5
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 +19 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -974,6 +974,7 @@ var GLOBAL_FUNCTIONS = {
|
|
|
974
974
|
getRadarAxes: (labels, cx, cy, radius) => getRadarAxes(labels, cx, cy, radius),
|
|
975
975
|
// Chart helpers - Utilities
|
|
976
976
|
getChartBounds: (data, valueKey) => getChartBounds(data, valueKey),
|
|
977
|
+
getLinePoints: (data, valueKey, width, height, padding) => getLinePoints(data, valueKey, width, height, padding),
|
|
977
978
|
generateTicks: (min, max, count) => generateTicks(min, max, count),
|
|
978
979
|
// Chart helpers - Data aggregation
|
|
979
980
|
binData: (data, valueKey, binCount) => binData(data, valueKey, binCount),
|
|
@@ -1591,6 +1592,24 @@ function getChartBounds(data, valueKey) {
|
|
|
1591
1592
|
max: Math.max(...values)
|
|
1592
1593
|
};
|
|
1593
1594
|
}
|
|
1595
|
+
function getLinePoints(data, valueKey, width, height, padding) {
|
|
1596
|
+
if (!Array.isArray(data) || data.length === 0) return void 0;
|
|
1597
|
+
if (typeof valueKey !== "string") return void 0;
|
|
1598
|
+
if (typeof width !== "number" || typeof height !== "number") return void 0;
|
|
1599
|
+
const pad = typeof padding === "number" ? padding : 40;
|
|
1600
|
+
const bounds = getChartBounds(data, valueKey);
|
|
1601
|
+
if (!bounds) return void 0;
|
|
1602
|
+
const { min, max } = bounds;
|
|
1603
|
+
const chartWidth = width - pad * 2;
|
|
1604
|
+
const chartHeight = height - pad * 2;
|
|
1605
|
+
return data.map((item, idx) => {
|
|
1606
|
+
const value = item[valueKey];
|
|
1607
|
+
if (typeof value !== "number") return { x: 0, y: 0 };
|
|
1608
|
+
const x2 = pad + (data.length > 1 ? idx / (data.length - 1) * chartWidth : chartWidth / 2);
|
|
1609
|
+
const y2 = min === max ? pad + chartHeight / 2 : pad + chartHeight - scaleValue(value, min, max, 0, chartHeight);
|
|
1610
|
+
return { x: x2, y: y2 };
|
|
1611
|
+
});
|
|
1612
|
+
}
|
|
1594
1613
|
function generateTicks(min, max, count) {
|
|
1595
1614
|
if (typeof min !== "number" || typeof max !== "number" || typeof count !== "number") {
|
|
1596
1615
|
return [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/runtime",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Runtime DOM renderer for Constela UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dompurify": "^3.3.1",
|
|
19
19
|
"marked": "^17.0.1",
|
|
20
20
|
"shiki": "^3.20.0",
|
|
21
|
-
"@constela/
|
|
22
|
-
"@constela/
|
|
21
|
+
"@constela/core": "0.18.2",
|
|
22
|
+
"@constela/compiler": "0.15.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/dompurify": "^3.2.0",
|