@banyan_cloud/roots 2.0.14 → 2.0.15
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/esm/index.js +90 -71
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -16177,8 +16177,8 @@ var CapsulePolarChart = function CapsulePolarChart(_ref) {
|
|
|
16177
16177
|
});
|
|
16178
16178
|
};
|
|
16179
16179
|
|
|
16180
|
-
var css$12 = ".
|
|
16181
|
-
var modules_c20882aa = {"root":"
|
|
16180
|
+
var css$12 = ".BasePieChart_module_root__67603ea6 {\n width: 100%;\n contain-intrinsic-height: 90%;\n font-family: Poppins !important;\n}\n.BasePieChart_module_root__67603ea6 > canvas {\n width: -moz-fit-content !important;\n width: fit-content !important;\n}\n\n.BasePieChart_module_legend__67603ea6 {\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n gap: 0.625rem;\n}";
|
|
16181
|
+
var modules_c20882aa = {"root":"BasePieChart_module_root__67603ea6","legend":"BasePieChart_module_legend__67603ea6"};
|
|
16182
16182
|
n(css$12,{});
|
|
16183
16183
|
|
|
16184
16184
|
var css$11 = ".Skeleton_module_root__ecbd3e3d {\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n width: 100%;\n height: 100%;\n overflow: hidden;\n position: relative;\n}\n.Skeleton_module_root__ecbd3e3d > .Skeleton_module_outer__ecbd3e3d,\n.Skeleton_module_root__ecbd3e3d > .Skeleton_module_inner__ecbd3e3d {\n max-width: 100%;\n max-height: 100%;\n}\n.Skeleton_module_root__ecbd3e3d > .Skeleton_module_inner__ecbd3e3d {\n position: absolute;\n opacity: 1;\n}\n.Skeleton_module_root__ecbd3e3d span.Skeleton_module_line__ecbd3e3d {\n opacity: 1;\n height: 0.5rem;\n position: absolute;\n transform-origin: left;\n}\n.Skeleton_module_root__ecbd3e3d span.Skeleton_module_line__ecbd3e3d:nth-last-of-type(1) {\n transform: translateX(3.25rem) rotate(45deg);\n}\n.Skeleton_module_root__ecbd3e3d span.Skeleton_module_line__ecbd3e3d:nth-last-of-type(2) {\n transform: translateX(3.25rem) rotate(-75deg);\n}\n.Skeleton_module_root__ecbd3e3d span.Skeleton_module_line__ecbd3e3d:nth-last-of-type(3) {\n transform: translateX(3.25rem) rotate(-10deg);\n}\n.Skeleton_module_root__ecbd3e3d.Skeleton_module_lightTheme__ecbd3e3d > .Skeleton_module_inner__ecbd3e3d {\n background: var(--white);\n}\n.Skeleton_module_root__ecbd3e3d.Skeleton_module_lightTheme__ecbd3e3d span.Skeleton_module_line__ecbd3e3d {\n background: var(--white);\n}\n.Skeleton_module_root__ecbd3e3d.Skeleton_module_darkTheme__ecbd3e3d > .Skeleton_module_inner__ecbd3e3d {\n background: var(--menu-black);\n}\n.Skeleton_module_root__ecbd3e3d.Skeleton_module_darkTheme__ecbd3e3d span.Skeleton_module_line__ecbd3e3d {\n background: var(--menu-black);\n}";
|
|
@@ -16221,7 +16221,7 @@ var ChartSkeleton$1 = function ChartSkeleton(_ref) {
|
|
|
16221
16221
|
|
|
16222
16222
|
Chart.register(ArcElement, Tooltip$1, Legend, Title$1);
|
|
16223
16223
|
var BasePieChart = function BasePieChart(props) {
|
|
16224
|
-
var _seriesData$metaData, _seriesData$chartData, _seriesData$
|
|
16224
|
+
var _seriesData$metaData, _seriesData$chartData, _seriesData$metaData2, _seriesData$chartData2, _seriesData$chartData5, _doughnut$, _doughnut$2, _chartOptions$respons, _legend$display, _tooltip$borderWidth, _tooltip$callbacks, _tooltip$bodySpacing, _tooltip$displayColor, _tooltip$colorBoxWidt, _tooltip$colorBoxHeig, _tooltip$usePointStyl, _tooltip$bodyFont$tit, _tooltip$bodyFont, _tooltip$bodyFont$col, _tooltip$bodyFont2;
|
|
16225
16225
|
var loading = props.loading,
|
|
16226
16226
|
title = props.title,
|
|
16227
16227
|
tittleSize = props.tittleSize,
|
|
@@ -16254,7 +16254,7 @@ var BasePieChart = function BasePieChart(props) {
|
|
|
16254
16254
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
16255
16255
|
hoveredIndex = _useState4[0],
|
|
16256
16256
|
setHoveredIndex = _useState4[1]; // Track the hovered legend index
|
|
16257
|
-
|
|
16257
|
+
useRef(null); // Reference to hold the custom legend
|
|
16258
16258
|
|
|
16259
16259
|
if (loading || fallback) {
|
|
16260
16260
|
return /*#__PURE__*/jsx(ChartSkeleton$1, {
|
|
@@ -16276,33 +16276,48 @@ var BasePieChart = function BasePieChart(props) {
|
|
|
16276
16276
|
return newIndices;
|
|
16277
16277
|
});
|
|
16278
16278
|
}, []);
|
|
16279
|
+
var labels = seriesData !== null && seriesData !== void 0 && (_seriesData$metaData = seriesData.metaData) !== null && _seriesData$metaData !== void 0 && _seriesData$metaData.keyData ? Object.keys(seriesData.chartData).map(function (key) {
|
|
16280
|
+
return seriesData.metaData.keyData[key];
|
|
16281
|
+
}) : [];
|
|
16282
|
+
var values = Object.keys((_seriesData$chartData = seriesData === null || seriesData === void 0 ? void 0 : seriesData.chartData) !== null && _seriesData$chartData !== void 0 ? _seriesData$chartData : {}).map(function (key) {
|
|
16283
|
+
return seriesData.chartData[key];
|
|
16284
|
+
});
|
|
16285
|
+
var legendColors = seriesOption ? seriesOption.map(function (option) {
|
|
16286
|
+
var _option$itemStyle;
|
|
16287
|
+
var color = option === null || option === void 0 || (_option$itemStyle = option.itemStyle) === null || _option$itemStyle === void 0 ? void 0 : _option$itemStyle.color;
|
|
16288
|
+
if (typeof color !== 'string' || !color.startsWith('linear-gradient')) {
|
|
16289
|
+
return color;
|
|
16290
|
+
}
|
|
16291
|
+
var stops = color.match(/#(?:[0-9a-fA-F]{3}){1,2}/g);
|
|
16292
|
+
return (stops === null || stops === void 0 ? void 0 : stops[0]) || '#000';
|
|
16293
|
+
}) : [];
|
|
16279
16294
|
|
|
16280
16295
|
// Data for the Pie Chart
|
|
16281
16296
|
var data = {
|
|
16282
|
-
labels: seriesData !== null && seriesData !== void 0 && (_seriesData$
|
|
16297
|
+
labels: seriesData !== null && seriesData !== void 0 && (_seriesData$metaData2 = seriesData.metaData) !== null && _seriesData$metaData2 !== void 0 && _seriesData$metaData2.keyData ? Object.keys(seriesData.chartData).map(function (key) {
|
|
16283
16298
|
return seriesData.metaData.keyData[key];
|
|
16284
16299
|
}) : [],
|
|
16285
16300
|
datasets: [_objectSpread2({
|
|
16286
|
-
data: Object.keys((_seriesData$
|
|
16287
|
-
var _seriesData$
|
|
16288
|
-
return seriesData === null || seriesData === void 0 || (_seriesData$
|
|
16301
|
+
data: Object.keys((_seriesData$chartData2 = seriesData === null || seriesData === void 0 ? void 0 : seriesData.chartData) !== null && _seriesData$chartData2 !== void 0 ? _seriesData$chartData2 : {}).map(function (key) {
|
|
16302
|
+
var _seriesData$chartData3;
|
|
16303
|
+
return seriesData === null || seriesData === void 0 || (_seriesData$chartData3 = seriesData.chartData) === null || _seriesData$chartData3 === void 0 ? void 0 : _seriesData$chartData3[key];
|
|
16289
16304
|
}),
|
|
16290
16305
|
backgroundColor: function backgroundColor(ctx) {
|
|
16291
|
-
var _seriesData$
|
|
16306
|
+
var _seriesData$chartData4;
|
|
16292
16307
|
return seriesOption ? seriesOption.map(function (option, index) {
|
|
16293
|
-
var _option$
|
|
16308
|
+
var _option$itemStyle2;
|
|
16294
16309
|
if (hoveredIndex !== null && hoveredIndex !== index) {
|
|
16295
16310
|
return '#D3D3D3';
|
|
16296
16311
|
}
|
|
16297
16312
|
if (excludedIndices.includes(index)) {
|
|
16298
16313
|
return '#D3D3D3';
|
|
16299
16314
|
}
|
|
16300
|
-
var color = option === null || option === void 0 || (_option$
|
|
16315
|
+
var color = option === null || option === void 0 || (_option$itemStyle2 = option.itemStyle) === null || _option$itemStyle2 === void 0 ? void 0 : _option$itemStyle2.color;
|
|
16301
16316
|
if (typeof color === 'string' && color.startsWith('linear-gradient')) {
|
|
16302
16317
|
return getColorGradient(ctx, color);
|
|
16303
16318
|
}
|
|
16304
16319
|
return color || '#000'; // Fallback solid color
|
|
16305
|
-
}) : Object.keys((_seriesData$
|
|
16320
|
+
}) : Object.keys((_seriesData$chartData4 = seriesData === null || seriesData === void 0 ? void 0 : seriesData.chartData) !== null && _seriesData$chartData4 !== void 0 ? _seriesData$chartData4 : {}).map(function (_, index) {
|
|
16306
16321
|
var defaultColors = ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF', '#FF9F40'];
|
|
16307
16322
|
if (hoveredIndex !== null && hoveredIndex !== index) {
|
|
16308
16323
|
return '#D3D3D3';
|
|
@@ -16313,7 +16328,7 @@ var BasePieChart = function BasePieChart(props) {
|
|
|
16313
16328
|
borderColor: seriesOption ? seriesOption.map(function (option, index) {
|
|
16314
16329
|
return excludedIndices.includes(index) ? '#D3D3D3' // Grey for excluded items
|
|
16315
16330
|
: option.itemStyle.color; // Normal color for other borders
|
|
16316
|
-
}) : Object.keys((_seriesData$
|
|
16331
|
+
}) : Object.keys((_seriesData$chartData5 = seriesData === null || seriesData === void 0 ? void 0 : seriesData.chartData) !== null && _seriesData$chartData5 !== void 0 ? _seriesData$chartData5 : {}).map(function (_, index) {
|
|
16317
16332
|
var defaultColors = ['#FF6384', '#36A2EB', '#FFCE56', '#4BC0C0', '#9966FF', '#FF9F40'];
|
|
16318
16333
|
return excludedIndices.includes(index) ? '#D3D3D3' // Grey for excluded items
|
|
16319
16334
|
: defaultColors[index % defaultColors.length]; // Normal color for other borders
|
|
@@ -16531,62 +16546,6 @@ var BasePieChart = function BasePieChart(props) {
|
|
|
16531
16546
|
ctx.restore();
|
|
16532
16547
|
}
|
|
16533
16548
|
};
|
|
16534
|
-
var legendColors = seriesOption ? seriesOption.map(function (option) {
|
|
16535
|
-
var _option$itemStyle2;
|
|
16536
|
-
var color = option === null || option === void 0 || (_option$itemStyle2 = option.itemStyle) === null || _option$itemStyle2 === void 0 ? void 0 : _option$itemStyle2.color;
|
|
16537
|
-
if (typeof color !== 'string' || !color.startsWith('linear-gradient')) {
|
|
16538
|
-
return color; // return as-is if not a gradient
|
|
16539
|
-
}
|
|
16540
|
-
var colorStops = color.match(/#(?:[0-9a-fA-F]{3}){1,2}/g);
|
|
16541
|
-
|
|
16542
|
-
// Return the first color stop as fallback
|
|
16543
|
-
return (colorStops === null || colorStops === void 0 ? void 0 : colorStops[0]) || '#000'; // Fallback to black
|
|
16544
|
-
}) : [];
|
|
16545
|
-
var customLegendPlugin = {
|
|
16546
|
-
id: 'customLegend',
|
|
16547
|
-
afterUpdate: function afterUpdate(chart) {
|
|
16548
|
-
var ul = legendRef.current;
|
|
16549
|
-
while (ul !== null && ul !== void 0 && ul.firstChild) {
|
|
16550
|
-
ul.firstChild.remove();
|
|
16551
|
-
}
|
|
16552
|
-
chart.data.labels.forEach(function (label, index) {
|
|
16553
|
-
var li = document.createElement('li');
|
|
16554
|
-
li.style.display = 'flex';
|
|
16555
|
-
li.style.alignItems = 'center';
|
|
16556
|
-
li.style.cursor = 'pointer';
|
|
16557
|
-
|
|
16558
|
-
// Handle click for excluding/un-excluding slices
|
|
16559
|
-
li.onclick = function (event) {
|
|
16560
|
-
var legendItem = {
|
|
16561
|
-
index: index
|
|
16562
|
-
}; // Simulate legend item
|
|
16563
|
-
handleLegendClick(event, legendItem); // Handle click
|
|
16564
|
-
handleHover(index); // Set hover on legend click
|
|
16565
|
-
chart.update('none'); // Update the chart without animation
|
|
16566
|
-
};
|
|
16567
|
-
|
|
16568
|
-
// Handle hover on the legend item
|
|
16569
|
-
li.onmouseenter = function () {
|
|
16570
|
-
handleHover(index); // Set hover on legend hover
|
|
16571
|
-
chart.update('none'); // Update the chart without animation
|
|
16572
|
-
};
|
|
16573
|
-
|
|
16574
|
-
// Handle leave event to remove hover effect
|
|
16575
|
-
li.onmouseleave = function () {
|
|
16576
|
-
setHoveredIndex(null); // Reset hover index on leave
|
|
16577
|
-
hoveredIndexRef.current = null;
|
|
16578
|
-
chart.update('none'); // Update the chart without animation
|
|
16579
|
-
};
|
|
16580
|
-
|
|
16581
|
-
// Apply grey color dynamically based on the hovered state
|
|
16582
|
-
var isGreyedOut = hoveredIndexRef.current !== null && hoveredIndexRef.current !== index;
|
|
16583
|
-
var displayColor = isGreyedOut ? '#D3D3D3' : legendColors[index];
|
|
16584
|
-
var value = chart.data.datasets[0].data[index];
|
|
16585
|
-
li.innerHTML = "\n\t\t\t\t\t<svg width=\"15\" height=\"15\" viewBox=\"0 0 30 30\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n\t\t\t\t\t\t<circle cx=\"15\" cy=\"15\" r=\"12\" stroke=\"".concat(displayColor, "\" stroke-width=\"6\"/>\n\t\t\t\t\t</svg>\n\t\t\t\t\t\n\t\t\t\t\t<span style=\"margin-left: 10px;\">\n\t\t\t\t\t\t<span>").concat(label, "</span>\n\t\t\t\t\t\t<span style=\"margin-left: 14px;\">").concat(value, "</span>\n\t\t\t\t\t</span>\n\t\t\t\t");
|
|
16586
|
-
ul.appendChild(li);
|
|
16587
|
-
});
|
|
16588
|
-
}
|
|
16589
|
-
};
|
|
16590
16549
|
return /*#__PURE__*/jsxs("div", {
|
|
16591
16550
|
className: classes(modules_c20882aa.root, className),
|
|
16592
16551
|
onMouseLeave: function onMouseLeave() {
|
|
@@ -16604,10 +16563,70 @@ var BasePieChart = function BasePieChart(props) {
|
|
|
16604
16563
|
children: [/*#__PURE__*/jsx(Pie, _objectSpread2({
|
|
16605
16564
|
data: data,
|
|
16606
16565
|
options: _objectSpread2({}, options),
|
|
16607
|
-
plugins: [customLabel && centerTextPlugin
|
|
16566
|
+
plugins: [customLabel && centerTextPlugin].filter(Boolean)
|
|
16608
16567
|
}, extra)), (legend === null || legend === void 0 ? void 0 : legend.icon) && (legend === null || legend === void 0 ? void 0 : legend.display) && /*#__PURE__*/jsx("ul", {
|
|
16609
16568
|
style: _objectSpread2({}, legend === null || legend === void 0 ? void 0 : legend.legendStyles),
|
|
16610
|
-
|
|
16569
|
+
children: labels.map(function (label, index) {
|
|
16570
|
+
var _legendColors$index, _legend$circle;
|
|
16571
|
+
var value = values[index];
|
|
16572
|
+
var color = hoveredIndex !== null && hoveredIndex !== index ? '#D3D3D3' : excludedIndices.includes(index) ? '#D3D3D3' : (_legendColors$index = legendColors[index]) !== null && _legendColors$index !== void 0 ? _legendColors$index : '#000';
|
|
16573
|
+
return /*#__PURE__*/jsxs("li", {
|
|
16574
|
+
style: {
|
|
16575
|
+
display: 'flex',
|
|
16576
|
+
alignItems: 'center',
|
|
16577
|
+
cursor: 'pointer'
|
|
16578
|
+
},
|
|
16579
|
+
onClick: function onClick(e) {
|
|
16580
|
+
handleLegendClick(e, {
|
|
16581
|
+
index: index
|
|
16582
|
+
});
|
|
16583
|
+
handleHover(index);
|
|
16584
|
+
},
|
|
16585
|
+
onMouseEnter: function onMouseEnter() {
|
|
16586
|
+
handleHover(index);
|
|
16587
|
+
},
|
|
16588
|
+
onMouseLeave: function onMouseLeave() {
|
|
16589
|
+
setHoveredIndex(null);
|
|
16590
|
+
hoveredIndexRef.current = null;
|
|
16591
|
+
},
|
|
16592
|
+
children: [((_legend$circle = legend === null || legend === void 0 ? void 0 : legend.circle) !== null && _legend$circle !== void 0 ? _legend$circle : true) && /*#__PURE__*/jsx("svg", {
|
|
16593
|
+
width: "15",
|
|
16594
|
+
height: "15",
|
|
16595
|
+
viewBox: "0 0 30 30",
|
|
16596
|
+
fill: "none",
|
|
16597
|
+
children: /*#__PURE__*/jsx("circle", {
|
|
16598
|
+
cx: "15",
|
|
16599
|
+
cy: "15",
|
|
16600
|
+
r: "12",
|
|
16601
|
+
stroke: color,
|
|
16602
|
+
strokeWidth: "6"
|
|
16603
|
+
})
|
|
16604
|
+
}), /*#__PURE__*/jsx("div", {
|
|
16605
|
+
style: {
|
|
16606
|
+
marginLeft: 10
|
|
16607
|
+
},
|
|
16608
|
+
children: legend !== null && legend !== void 0 && legend.customLabels ? legend === null || legend === void 0 ? void 0 : legend.customLabels({
|
|
16609
|
+
label: label,
|
|
16610
|
+
value: value,
|
|
16611
|
+
index: index,
|
|
16612
|
+
color: color
|
|
16613
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
16614
|
+
className: modules_c20882aa.legend,
|
|
16615
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
16616
|
+
style: {
|
|
16617
|
+
color: '#333'
|
|
16618
|
+
},
|
|
16619
|
+
children: label
|
|
16620
|
+
}), /*#__PURE__*/jsx("span", {
|
|
16621
|
+
style: {
|
|
16622
|
+
marginLeft: 10
|
|
16623
|
+
},
|
|
16624
|
+
children: value
|
|
16625
|
+
})]
|
|
16626
|
+
})
|
|
16627
|
+
})]
|
|
16628
|
+
}, index);
|
|
16629
|
+
})
|
|
16611
16630
|
})]
|
|
16612
16631
|
});
|
|
16613
16632
|
};
|