dp-widgets-framework 1.3.2 → 1.3.4
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.esm.js +13 -3
- package/dist/index.js +13 -3
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -15291,6 +15291,8 @@ const PieChart = (props) => {
|
|
|
15291
15291
|
}
|
|
15292
15292
|
return value;
|
|
15293
15293
|
};
|
|
15294
|
+
// Sanitize data to prevent null/undefined values
|
|
15295
|
+
const sanitizedData = Object.assign(Object.assign({}, data), { datasets: data.datasets.map(dataset => (Object.assign(Object.assign({}, dataset), { data: dataset.data.map(d => d === null || d === undefined || isNaN(Number(d)) ? 0 : d) }))) });
|
|
15294
15296
|
const defaultOptions = {
|
|
15295
15297
|
responsive: true,
|
|
15296
15298
|
maintainAspectRatio: false,
|
|
@@ -15303,10 +15305,18 @@ const PieChart = (props) => {
|
|
|
15303
15305
|
position: "bottom",
|
|
15304
15306
|
},
|
|
15305
15307
|
datalabels: {
|
|
15306
|
-
display: (context) => {
|
|
15308
|
+
display: (context) => {
|
|
15309
|
+
var _a;
|
|
15310
|
+
const value = context.dataset.data[context.dataIndex];
|
|
15311
|
+
return value !== null && value !== undefined && !isNaN(Number(value)) && value !== 0 && ((_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false);
|
|
15312
|
+
},
|
|
15307
15313
|
color: "white",
|
|
15308
15314
|
font: { size: 12 },
|
|
15309
|
-
formatter: (value) =>
|
|
15315
|
+
formatter: (value) => {
|
|
15316
|
+
if (value === null || value === undefined || isNaN(Number(value)))
|
|
15317
|
+
return '';
|
|
15318
|
+
return formatValue(value);
|
|
15319
|
+
},
|
|
15310
15320
|
},
|
|
15311
15321
|
title: {
|
|
15312
15322
|
display: true,
|
|
@@ -15335,7 +15345,7 @@ const PieChart = (props) => {
|
|
|
15335
15345
|
},
|
|
15336
15346
|
},
|
|
15337
15347
|
};
|
|
15338
|
-
return jsxRuntimeExports.jsx(Pie, { data:
|
|
15348
|
+
return jsxRuntimeExports.jsx(Pie, { data: sanitizedData, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15339
15349
|
};
|
|
15340
15350
|
|
|
15341
15351
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend, ChartDataLabels);
|
package/dist/index.js
CHANGED
|
@@ -15318,6 +15318,8 @@ const PieChart = (props) => {
|
|
|
15318
15318
|
}
|
|
15319
15319
|
return value;
|
|
15320
15320
|
};
|
|
15321
|
+
// Sanitize data to prevent null/undefined values
|
|
15322
|
+
const sanitizedData = Object.assign(Object.assign({}, data), { datasets: data.datasets.map(dataset => (Object.assign(Object.assign({}, dataset), { data: dataset.data.map(d => d === null || d === undefined || isNaN(Number(d)) ? 0 : d) }))) });
|
|
15321
15323
|
const defaultOptions = {
|
|
15322
15324
|
responsive: true,
|
|
15323
15325
|
maintainAspectRatio: false,
|
|
@@ -15330,10 +15332,18 @@ const PieChart = (props) => {
|
|
|
15330
15332
|
position: "bottom",
|
|
15331
15333
|
},
|
|
15332
15334
|
datalabels: {
|
|
15333
|
-
display: (context) => {
|
|
15335
|
+
display: (context) => {
|
|
15336
|
+
var _a;
|
|
15337
|
+
const value = context.dataset.data[context.dataIndex];
|
|
15338
|
+
return value !== null && value !== undefined && !isNaN(Number(value)) && value !== 0 && ((_a = content === null || content === void 0 ? void 0 : content.showLabels) !== null && _a !== void 0 ? _a : false);
|
|
15339
|
+
},
|
|
15334
15340
|
color: "white",
|
|
15335
15341
|
font: { size: 12 },
|
|
15336
|
-
formatter: (value) =>
|
|
15342
|
+
formatter: (value) => {
|
|
15343
|
+
if (value === null || value === undefined || isNaN(Number(value)))
|
|
15344
|
+
return '';
|
|
15345
|
+
return formatValue(value);
|
|
15346
|
+
},
|
|
15337
15347
|
},
|
|
15338
15348
|
title: {
|
|
15339
15349
|
display: true,
|
|
@@ -15362,7 +15372,7 @@ const PieChart = (props) => {
|
|
|
15362
15372
|
},
|
|
15363
15373
|
},
|
|
15364
15374
|
};
|
|
15365
|
-
return jsxRuntimeExports.jsx(Pie, { data:
|
|
15375
|
+
return jsxRuntimeExports.jsx(Pie, { data: sanitizedData, options: options !== null && options !== void 0 ? options : defaultOptions });
|
|
15366
15376
|
};
|
|
15367
15377
|
|
|
15368
15378
|
Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend, ChartDataLabels);
|