Skip to content

Commit f409797

Browse files
committed
Fix - VueUiRidgeline - Fix issue with null values in nested VueUiXy config
1 parent 8681394 commit f409797

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
"vitest": "^3.1.1",
111111
"vue": "^3.5.14"
112112
}
113-
}
113+
}

src/components/vue-ui-ridgeline.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
createStraightPath,
1111
createUid,
1212
dataLabel,
13+
deepEmptyObjectToNull,
1314
downloadCsv,
1415
error,
1516
getMissingDatasetAttributes,
@@ -254,7 +255,6 @@ const formattedDataset = computed(() => {
254255
uid: createUid(),
255256
datapoints: ds.datapoints.map((dp, j) => {
256257
const color = dp.color ? convertColorToHex(dp.color) : customPalette.value[j] || palette[j] || palette[j % palette.length];
257-
console.log(color);
258258
const id = slugify(dp.name);
259259
return {
260260
...dp,
@@ -469,7 +469,7 @@ function createXyDatasetForDialog(ds) {
469469
470470
selectedDatapoint.value = ds;
471471
472-
xyConfig.value = {
472+
xyConfig.value = deepEmptyObjectToNull({
473473
...FINAL_CONFIG.value.style.chart.dialog.xyChart,
474474
responsive: true, // Overriding
475475
chart: {
@@ -489,7 +489,7 @@ function createXyDatasetForDialog(ds) {
489489
showTimeLabel: FINAL_CONFIG.value.style.chart.xAxis.labels.values.length > 0 // Overriding
490490
}
491491
}
492-
};
492+
})
493493
494494
dialog.value && dialog.value.open();
495495
}

src/lib.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,37 @@ export function slugify(str) {
24742474
.replace(/-+$/, ''); // Trim end
24752475
}
24762476

2477+
export function emptyObjectToNull(obj) {
2478+
if (
2479+
obj &&
2480+
typeof obj === 'object' &&
2481+
!Array.isArray(obj) &&
2482+
Object.keys(obj).length === 0
2483+
) {
2484+
return null;
2485+
}
2486+
return obj;
2487+
}
2488+
2489+
export function deepEmptyObjectToNull(value) {
2490+
if (Array.isArray(value)) {
2491+
return value.map(deepEmptyObjectToNull);
2492+
} else if (
2493+
value &&
2494+
typeof value === 'object' &&
2495+
!Array.isArray(value)
2496+
) {
2497+
const result = {};
2498+
for (const key in value) {
2499+
if (Object.hasOwn(value, key)) {
2500+
result[key] = deepEmptyObjectToNull(value[key]);
2501+
}
2502+
}
2503+
return emptyObjectToNull(result);
2504+
}
2505+
return value;
2506+
}
2507+
24772508

24782509
const lib = {
24792510
XMLNS,
@@ -2515,8 +2546,10 @@ const lib = {
25152546
darkenHexColor,
25162547
dataLabel,
25172548
deepClone,
2549+
deepEmptyObjectToNull,
25182550
degreesToRadians,
25192551
downloadCsv,
2552+
emptyObjectToNull,
25202553
error,
25212554
forceValidValue,
25222555
functionReturnsString,

0 commit comments

Comments
 (0)