@visns-studio/visns-components 5.3.4 → 5.3.6
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/package.json
CHANGED
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
79
79
|
},
|
|
80
80
|
"name": "@visns-studio/visns-components",
|
|
81
|
-
"version": "5.3.
|
|
81
|
+
"version": "5.3.6",
|
|
82
82
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
83
83
|
"main": "src/index.js",
|
|
84
84
|
"files": [
|
|
@@ -112,10 +112,14 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
if (widget.api?.url && widget.api?.method) {
|
|
115
|
+
const requestParams = {
|
|
116
|
+
...widgetFilters,
|
|
117
|
+
...(widget.api.params || {}),
|
|
118
|
+
};
|
|
115
119
|
return CustomFetch(
|
|
116
120
|
widget.api.url,
|
|
117
121
|
widget.api.method,
|
|
118
|
-
|
|
122
|
+
requestParams
|
|
119
123
|
);
|
|
120
124
|
}
|
|
121
125
|
return null;
|
|
@@ -515,9 +519,64 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
515
519
|
<ResponsivePie data={widgetData} {...widget.props} />
|
|
516
520
|
);
|
|
517
521
|
case 'bar': {
|
|
518
|
-
|
|
519
|
-
|
|
522
|
+
// Handle both data structures
|
|
523
|
+
let barData = [];
|
|
524
|
+
let colors = {};
|
|
525
|
+
let keys = [];
|
|
526
|
+
|
|
527
|
+
// Handle new data structure (from your first example)
|
|
528
|
+
if (
|
|
529
|
+
widgetData.data &&
|
|
530
|
+
Array.isArray(widgetData.data) &&
|
|
531
|
+
widgetData.colors
|
|
532
|
+
) {
|
|
533
|
+
barData = widgetData.data;
|
|
534
|
+
colors = widgetData.colors;
|
|
535
|
+
// Extract keys from the first data item, excluding 'month' or any other index field
|
|
536
|
+
keys = Object.keys(barData[0] || {}).filter(
|
|
537
|
+
(key) => key !== 'month'
|
|
538
|
+
);
|
|
520
539
|
}
|
|
540
|
+
// Handle newer data structure (from your second example)
|
|
541
|
+
else if (
|
|
542
|
+
widgetData.data &&
|
|
543
|
+
Array.isArray(widgetData.data) &&
|
|
544
|
+
widgetData.keys
|
|
545
|
+
) {
|
|
546
|
+
barData = widgetData.data;
|
|
547
|
+
keys = widgetData.keys;
|
|
548
|
+
// Extract colors from the first data item
|
|
549
|
+
if (barData[0]) {
|
|
550
|
+
keys.forEach((key) => {
|
|
551
|
+
const colorKey = `${key}Color`;
|
|
552
|
+
if (barData[0][colorKey]) {
|
|
553
|
+
colors[key] = barData[0][colorKey];
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// Handle legacy data structure
|
|
559
|
+
else {
|
|
560
|
+
barData =
|
|
561
|
+
widgetData.bar?.data ||
|
|
562
|
+
widgetData.data ||
|
|
563
|
+
widgetData;
|
|
564
|
+
if (widgetData.keys) {
|
|
565
|
+
keys = widgetData.keys;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Set up colors if they exist
|
|
570
|
+
if (Object.keys(colors).length > 0) {
|
|
571
|
+
widget.props.colors = ({ id }) => colors[id];
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// Set keys in props if they exist
|
|
575
|
+
if (keys.length > 0) {
|
|
576
|
+
widget.props.keys = keys;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Handle legend setup
|
|
521
580
|
let legendMapping = {};
|
|
522
581
|
if (widget.legend) {
|
|
523
582
|
legendMapping = widget.legend.reduce((acc, curr) => {
|
|
@@ -544,14 +603,14 @@ function GenericDashboard({ setting, userProfile, dynamicDashboard = false }) {
|
|
|
544
603
|
};
|
|
545
604
|
widget.props.tooltip = CustomTooltip;
|
|
546
605
|
}
|
|
547
|
-
|
|
548
|
-
widgetData.bar?.data || widgetData.data || widgetData;
|
|
606
|
+
|
|
549
607
|
if (barData?.length > 0) {
|
|
550
608
|
return (
|
|
551
609
|
<div style={{ height: widget.height || '600px' }}>
|
|
552
610
|
<ResponsiveBar
|
|
553
611
|
key={`${widget.id}-${widget.size}`}
|
|
554
612
|
data={barData}
|
|
613
|
+
indexBy="month"
|
|
555
614
|
{...widget.props}
|
|
556
615
|
/>
|
|
557
616
|
</div>
|