File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed
Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 110110 "vitest" : " ^3.1.1" ,
111111 "vue" : " ^3.5.14"
112112 }
113- }
113+ }
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
24782509const 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,
You can’t perform that action at this time.
0 commit comments