@constela/core 0.21.1 → 0.21.3
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 +21 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2955,7 +2955,7 @@ function scaleChartY(value, boundsMin, boundsMax, height, paddingTop, paddingBot
|
|
|
2955
2955
|
const normalized = (value - boundsMin) / (boundsMax - boundsMin);
|
|
2956
2956
|
return paddingTop + drawableHeight * (1 - normalized);
|
|
2957
2957
|
}
|
|
2958
|
-
function getBarDimensions(data, index, width, height, gap, orientation) {
|
|
2958
|
+
function getBarDimensions(data, index, width, height, gap, orientation, valueKey) {
|
|
2959
2959
|
if (!Array.isArray(data) || data.length === 0) {
|
|
2960
2960
|
return void 0;
|
|
2961
2961
|
}
|
|
@@ -2967,7 +2967,14 @@ function getBarDimensions(data, index, width, height, gap, orientation) {
|
|
|
2967
2967
|
}
|
|
2968
2968
|
const isVertical = orientation === "vertical";
|
|
2969
2969
|
const barCount = data.length;
|
|
2970
|
-
const
|
|
2970
|
+
const vk = typeof valueKey === "string" ? valueKey : void 0;
|
|
2971
|
+
const values = data.map((d) => {
|
|
2972
|
+
if (typeof d === "number") return d;
|
|
2973
|
+
if (d && typeof d === "object" && vk && typeof d[vk] === "number") {
|
|
2974
|
+
return d[vk];
|
|
2975
|
+
}
|
|
2976
|
+
return 0;
|
|
2977
|
+
});
|
|
2971
2978
|
const maxValue = Math.max(...values);
|
|
2972
2979
|
if (isVertical) {
|
|
2973
2980
|
const totalGap = gap * (barCount + 1);
|
|
@@ -3081,7 +3088,7 @@ function getArcPath(cx, cy, radius, startAngle, endAngle) {
|
|
|
3081
3088
|
const y2 = cy + radius * Math.sin(endAngle);
|
|
3082
3089
|
const angleDiff = endAngle - startAngle;
|
|
3083
3090
|
const largeArcFlag = Math.abs(angleDiff) > Math.PI ? 1 : 0;
|
|
3084
|
-
return `M${x1},${y1} A${radius},${radius} 0 ${largeArcFlag},1 ${x2},${y2}`;
|
|
3091
|
+
return `M${cx},${cy} L${x1},${y1} A${radius},${radius} 0 ${largeArcFlag},1 ${x2},${y2} Z`;
|
|
3085
3092
|
}
|
|
3086
3093
|
function getPieSlices(data, valueKey) {
|
|
3087
3094
|
if (!Array.isArray(data)) {
|
|
@@ -3627,7 +3634,7 @@ var GLOBAL_FUNCTIONS = {
|
|
|
3627
3634
|
// Chart helpers - Coordinate calculation
|
|
3628
3635
|
normalizeValue: (value, min, max) => normalizeValue(value, min, max),
|
|
3629
3636
|
scaleValue: (value, domainMin, domainMax, rangeMin, rangeMax) => scaleValue(value, domainMin, domainMax, rangeMin, rangeMax),
|
|
3630
|
-
getBarDimensions: (data, index, width, height, gap, orientation) => getBarDimensions(data, index, width, height, gap, orientation),
|
|
3637
|
+
getBarDimensions: (data, index, width, height, gap, orientation, valueKey) => getBarDimensions(data, index, width, height, gap, orientation, valueKey),
|
|
3631
3638
|
// Chart helpers - Path generation
|
|
3632
3639
|
getLinePath: (points, curved) => getLinePath(points, curved),
|
|
3633
3640
|
getAreaPath: (points, baseline, curved) => getAreaPath(points, baseline, curved),
|
|
@@ -3655,7 +3662,16 @@ var GLOBAL_FUNCTIONS = {
|
|
|
3655
3662
|
// Chart helpers - Activity Ring
|
|
3656
3663
|
getActivityRingArcPath: (cx, cy, radius, startAngle, endAngle) => getActivityRingArcPath(cx, cy, radius, startAngle, endAngle),
|
|
3657
3664
|
getActivityRingLayout: (data, valueKey, cx, cy, outerRadius, ringWidth, ringGap) => getActivityRingLayout(data, valueKey, cx, cy, outerRadius, ringWidth, ringGap),
|
|
3658
|
-
getChartDefaultColors: (palette) => getChartDefaultColors(palette)
|
|
3665
|
+
getChartDefaultColors: (palette) => getChartDefaultColors(palette),
|
|
3666
|
+
// Math utility functions
|
|
3667
|
+
min: (...args) => {
|
|
3668
|
+
const nums = args.filter((a) => typeof a === "number");
|
|
3669
|
+
return nums.length > 0 ? Math.min(...nums) : void 0;
|
|
3670
|
+
},
|
|
3671
|
+
max: (...args) => {
|
|
3672
|
+
const nums = args.filter((a) => typeof a === "number");
|
|
3673
|
+
return nums.length > 0 ? Math.max(...nums) : void 0;
|
|
3674
|
+
}
|
|
3659
3675
|
};
|
|
3660
3676
|
function callGlobalFunction(method, args) {
|
|
3661
3677
|
const fn = GLOBAL_FUNCTIONS[method];
|