@banyan_cloud/roots 1.0.345 → 1.0.347
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/cjs/index.js +124 -43
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +124 -43
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +124 -43
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4996,11 +4996,15 @@ var generateColors = function generateColors(_ref4) {
|
|
|
4996
4996
|
excludedColors = _ref4$excludedColors === void 0 ? [] : _ref4$excludedColors,
|
|
4997
4997
|
_ref4$exclusionThresh = _ref4.exclusionThreshold,
|
|
4998
4998
|
exclusionThreshold = _ref4$exclusionThresh === void 0 ? 30 : _ref4$exclusionThresh,
|
|
4999
|
-
_ref4$
|
|
5000
|
-
|
|
4999
|
+
_ref4$distinctionThre = _ref4.distinctionThreshold,
|
|
5000
|
+
distinctionThreshold = _ref4$distinctionThre === void 0 ? 40 : _ref4$distinctionThre,
|
|
5001
|
+
_ref4$excludedHueRang = _ref4.excludedHueRanges,
|
|
5002
|
+
excludedHueRanges = _ref4$excludedHueRang === void 0 ? [] : _ref4$excludedHueRang;
|
|
5001
5003
|
var colors = [];
|
|
5002
|
-
var minLightness =
|
|
5003
|
-
var maxLightness =
|
|
5004
|
+
var minLightness = 30;
|
|
5005
|
+
var maxLightness = 70;
|
|
5006
|
+
var minSaturation = 65;
|
|
5007
|
+
var maxSaturation = 100;
|
|
5004
5008
|
var normalizedExcludedColors = excludedColors.map(function (color) {
|
|
5005
5009
|
return color.startsWith('#') ? color : "#".concat(color);
|
|
5006
5010
|
});
|
|
@@ -5010,16 +5014,49 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5010
5014
|
var b = parseInt(hex.slice(5, 7), 16);
|
|
5011
5015
|
return [r, g, b];
|
|
5012
5016
|
};
|
|
5017
|
+
var hexToHSL = function hexToHSL(hex) {
|
|
5018
|
+
var r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
5019
|
+
var g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
5020
|
+
var b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
5021
|
+
var cmin = Math.min(r, g, b);
|
|
5022
|
+
var cmax = Math.max(r, g, b);
|
|
5023
|
+
var delta = cmax - cmin;
|
|
5024
|
+
var h = 0;
|
|
5025
|
+
var s = 0;
|
|
5026
|
+
var l = 0;
|
|
5027
|
+
if (delta === 0) {
|
|
5028
|
+
h = 0;
|
|
5029
|
+
} else if (cmax === r) {
|
|
5030
|
+
h = (g - b) / delta % 6;
|
|
5031
|
+
} else if (cmax === g) {
|
|
5032
|
+
h = (b - r) / delta + 2;
|
|
5033
|
+
} else {
|
|
5034
|
+
h = (r - g) / delta + 4;
|
|
5035
|
+
}
|
|
5036
|
+
h = Math.round(h * 60);
|
|
5037
|
+
if (h < 0) h += 360;
|
|
5038
|
+
l = (cmax + cmin) / 2;
|
|
5039
|
+
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
5040
|
+
s = Math.round(s * 100);
|
|
5041
|
+
l = Math.round(l * 100);
|
|
5042
|
+
return [h, s, l];
|
|
5043
|
+
};
|
|
5013
5044
|
var colorDistance = function colorDistance(hex1, hex2) {
|
|
5014
5045
|
var rgb1 = hexToRGB(hex1);
|
|
5015
5046
|
var rgb2 = hexToRGB(hex2);
|
|
5016
|
-
var
|
|
5017
|
-
var
|
|
5018
|
-
var
|
|
5019
|
-
|
|
5047
|
+
var rMean = (rgb1[0] + rgb2[0]) / 2;
|
|
5048
|
+
var r = rgb1[0] - rgb2[0];
|
|
5049
|
+
var g = rgb1[1] - rgb2[1];
|
|
5050
|
+
var b = rgb1[2] - rgb2[2];
|
|
5051
|
+
var weightR = 2 + rMean / 256;
|
|
5052
|
+
var weightG = 4.0;
|
|
5053
|
+
var weightB = 2 + (255 - rMean) / 256;
|
|
5054
|
+
return Math.sqrt(weightR * r * r + weightG * g * g + weightB * b * b);
|
|
5020
5055
|
};
|
|
5021
5056
|
function hslToHex(h, s, l) {
|
|
5022
|
-
|
|
5057
|
+
h = (h % 360 + 360) % 360;
|
|
5058
|
+
s = Math.max(0, Math.min(100, s));
|
|
5059
|
+
l = Math.max(0, Math.min(100, l));
|
|
5023
5060
|
l /= 100;
|
|
5024
5061
|
var a = s * Math.min(l, 1 - l) / 100;
|
|
5025
5062
|
var f = function f(n) {
|
|
@@ -5029,7 +5066,21 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5029
5066
|
};
|
|
5030
5067
|
return "#".concat(f(0)).concat(f(8)).concat(f(4));
|
|
5031
5068
|
}
|
|
5069
|
+
var isHueExcluded = function isHueExcluded(hue) {
|
|
5070
|
+
return excludedHueRanges.some(function (range) {
|
|
5071
|
+
if (range.min > range.max) {
|
|
5072
|
+
return hue >= range.min || hue <= range.max;
|
|
5073
|
+
}
|
|
5074
|
+
return hue >= range.min && hue <= range.max;
|
|
5075
|
+
});
|
|
5076
|
+
};
|
|
5032
5077
|
var isTooSimilarToExcluded = function isTooSimilarToExcluded(hexColor) {
|
|
5078
|
+
var _hexToHSL = hexToHSL(hexColor),
|
|
5079
|
+
_hexToHSL2 = _slicedToArray(_hexToHSL, 1),
|
|
5080
|
+
hue = _hexToHSL2[0];
|
|
5081
|
+
if (isHueExcluded(hue)) {
|
|
5082
|
+
return true;
|
|
5083
|
+
}
|
|
5033
5084
|
var _iterator = _createForOfIteratorHelper(normalizedExcludedColors),
|
|
5034
5085
|
_step;
|
|
5035
5086
|
try {
|
|
@@ -5048,21 +5099,24 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5048
5099
|
};
|
|
5049
5100
|
var generateDistinctColor = function generateDistinctColor() {
|
|
5050
5101
|
var attempts = 0;
|
|
5051
|
-
var maxAttempts =
|
|
5102
|
+
var maxAttempts = 300;
|
|
5052
5103
|
while (attempts < maxAttempts) {
|
|
5053
|
-
var
|
|
5054
|
-
var
|
|
5055
|
-
var
|
|
5056
|
-
|
|
5104
|
+
var h = Math.floor(Math.random() * 360);
|
|
5105
|
+
var s = Math.floor(Math.random() * (maxSaturation - minSaturation)) + minSaturation;
|
|
5106
|
+
var l = Math.floor(Math.random() * (maxLightness - minLightness)) + minLightness;
|
|
5107
|
+
if (isHueExcluded(h)) {
|
|
5108
|
+
attempts++;
|
|
5109
|
+
continue;
|
|
5110
|
+
}
|
|
5111
|
+
var hexColor = hslToHex(h, s, l);
|
|
5057
5112
|
if (isTooSimilarToExcluded(hexColor)) {
|
|
5058
5113
|
attempts++;
|
|
5059
|
-
// eslint-disable-next-line no-continue
|
|
5060
5114
|
continue;
|
|
5061
5115
|
}
|
|
5062
5116
|
var isDistinct = true;
|
|
5063
5117
|
for (var _i2 = 0, _colors = colors; _i2 < _colors.length; _i2++) {
|
|
5064
5118
|
var existingColor = _colors[_i2];
|
|
5065
|
-
if (colorDistance(hexColor, existingColor) <
|
|
5119
|
+
if (colorDistance(hexColor, existingColor) < distinctionThreshold) {
|
|
5066
5120
|
isDistinct = false;
|
|
5067
5121
|
break;
|
|
5068
5122
|
}
|
|
@@ -5072,13 +5126,36 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5072
5126
|
}
|
|
5073
5127
|
attempts++;
|
|
5074
5128
|
}
|
|
5075
|
-
var
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5129
|
+
for (var adjustedAttempts = 0; adjustedAttempts < 50; adjustedAttempts++) {
|
|
5130
|
+
var _h = Math.floor(Math.random() * 360);
|
|
5131
|
+
if (isHueExcluded(_h)) {
|
|
5132
|
+
continue;
|
|
5133
|
+
}
|
|
5134
|
+
var _s = 90;
|
|
5135
|
+
var _l = 50;
|
|
5136
|
+
var _hexColor = hslToHex(_h, _s, _l);
|
|
5137
|
+
if (!isTooSimilarToExcluded(_hexColor)) {
|
|
5138
|
+
var mostDistinct = true;
|
|
5139
|
+
for (var _i3 = 0, _colors2 = colors; _i3 < _colors2.length; _i3++) {
|
|
5140
|
+
var _existingColor = _colors2[_i3];
|
|
5141
|
+
var distance = colorDistance(_hexColor, _existingColor);
|
|
5142
|
+
if (distance < distinctionThreshold * 0.7) {
|
|
5143
|
+
mostDistinct = false;
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
if (mostDistinct || adjustedAttempts >= 49) {
|
|
5147
|
+
return _hexColor;
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
return hslToHex(Math.floor(Math.random() * 360), 80, 50);
|
|
5079
5152
|
};
|
|
5080
|
-
|
|
5081
|
-
|
|
5153
|
+
var failsafeCounter = 0;
|
|
5154
|
+
var maxFailsafe = count * 3;
|
|
5155
|
+
while (colors.length < count && failsafeCounter < maxFailsafe) {
|
|
5156
|
+
var newColor = generateDistinctColor();
|
|
5157
|
+
colors.push(newColor);
|
|
5158
|
+
failsafeCounter++;
|
|
5082
5159
|
}
|
|
5083
5160
|
return colors;
|
|
5084
5161
|
};
|
|
@@ -25819,8 +25896,13 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25819
25896
|
barColor2 = _ref.barColor2,
|
|
25820
25897
|
xAxisTitle = _ref.xAxisTitle,
|
|
25821
25898
|
yAxisTitle = _ref.yAxisTitle,
|
|
25822
|
-
|
|
25823
|
-
|
|
25899
|
+
tooltip = _ref.tooltip,
|
|
25900
|
+
legends = _ref.legends,
|
|
25901
|
+
chartOptions = _ref.chartOptions,
|
|
25902
|
+
chartDatasets = _ref.chartDatasets,
|
|
25903
|
+
xAxis = _ref.xAxis,
|
|
25904
|
+
yAxis = _ref.yAxis,
|
|
25905
|
+
styles = _ref.styles;
|
|
25824
25906
|
if (loading) {
|
|
25825
25907
|
return /*#__PURE__*/jsxRuntime.jsx(ChartSkeleton$1, {});
|
|
25826
25908
|
}
|
|
@@ -25833,22 +25915,21 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25833
25915
|
return seriesData.chartData[label][key] !== undefined;
|
|
25834
25916
|
});
|
|
25835
25917
|
}).map(function (key) {
|
|
25836
|
-
return {
|
|
25918
|
+
return _objectSpread2({
|
|
25837
25919
|
label: seriesData.metaData.keyData[key],
|
|
25838
25920
|
backgroundColor: key === 'x1' ? barColor1 !== null && barColor1 !== void 0 ? barColor1 : COLORS.success : key === 'x2' ? barColor2 !== null && barColor2 !== void 0 ? barColor2 : COLORS.error : COLORS.warning,
|
|
25839
25921
|
data: labels.map(function (label) {
|
|
25840
|
-
// Only include data if it's defined
|
|
25841
25922
|
return seriesData.chartData[label][key] !== undefined ? seriesData.chartData[label][key] : null;
|
|
25842
25923
|
}),
|
|
25843
25924
|
borderRadius: borderRadius,
|
|
25844
25925
|
barThickness: barThickness
|
|
25845
|
-
};
|
|
25926
|
+
}, chartDatasets);
|
|
25846
25927
|
});
|
|
25847
25928
|
var options = {
|
|
25848
25929
|
responsive: true,
|
|
25849
25930
|
maintainAspectRatio: false,
|
|
25850
25931
|
// To allow custom height and width
|
|
25851
|
-
plugins: {
|
|
25932
|
+
plugins: _objectSpread2({
|
|
25852
25933
|
title: {
|
|
25853
25934
|
display: true,
|
|
25854
25935
|
font: {
|
|
@@ -25860,7 +25941,7 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25860
25941
|
left: (title === null || title === void 0 ? void 0 : title.left) || 0
|
|
25861
25942
|
}
|
|
25862
25943
|
},
|
|
25863
|
-
tooltip: _objectSpread2(
|
|
25944
|
+
tooltip: _objectSpread2({
|
|
25864
25945
|
borderWidth: (_tooltip$borderWidth = tooltip === null || tooltip === void 0 ? void 0 : tooltip.borderWidth) !== null && _tooltip$borderWidth !== void 0 ? _tooltip$borderWidth : 1,
|
|
25865
25946
|
borderColor: (_tooltip$borderColor = tooltip === null || tooltip === void 0 ? void 0 : tooltip.borderColor) !== null && _tooltip$borderColor !== void 0 ? _tooltip$borderColor : COLORS.success,
|
|
25866
25947
|
backgroundColor: 'rgba(255, 255, 255, 1)',
|
|
@@ -25879,7 +25960,7 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25879
25960
|
label: function label(tooltipItem) {
|
|
25880
25961
|
var _seriesData$metaData$;
|
|
25881
25962
|
var label = (_seriesData$metaData$ = seriesData.metaData.controlsApplied[tooltipItem.label]) === null || _seriesData$metaData$ === void 0 ? void 0 : _seriesData$metaData$.x1;
|
|
25882
|
-
return "".concat(tooltipItem.
|
|
25963
|
+
return "".concat(tooltipItem.label, ": ").concat(label);
|
|
25883
25964
|
},
|
|
25884
25965
|
title: tooltip.displayTitle ? function (tooltipItems) {
|
|
25885
25966
|
var _tooltipItems$;
|
|
@@ -25888,12 +25969,12 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25888
25969
|
return '';
|
|
25889
25970
|
}
|
|
25890
25971
|
}
|
|
25891
|
-
}),
|
|
25892
|
-
legend: {
|
|
25972
|
+
}, tooltip),
|
|
25973
|
+
legend: _objectSpread2({
|
|
25893
25974
|
display: false
|
|
25894
|
-
},
|
|
25975
|
+
}, legends),
|
|
25895
25976
|
// Enable the datalabels plugin
|
|
25896
|
-
datalabels:
|
|
25977
|
+
datalabels: {
|
|
25897
25978
|
anchor: 'end',
|
|
25898
25979
|
align: 'top',
|
|
25899
25980
|
// Align the labels above the bars
|
|
@@ -25908,10 +25989,10 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25908
25989
|
formatter: function formatter(value, context) {
|
|
25909
25990
|
return context.chart.data.labels[context.dataIndex];
|
|
25910
25991
|
}
|
|
25911
|
-
}
|
|
25912
|
-
},
|
|
25992
|
+
}
|
|
25993
|
+
}, chartOptions),
|
|
25913
25994
|
scales: {
|
|
25914
|
-
x: {
|
|
25995
|
+
x: _objectSpread2({
|
|
25915
25996
|
grid: {
|
|
25916
25997
|
display: (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.gridContainLabel) || true,
|
|
25917
25998
|
color: 'rgba(255, 255, 255, 0.2)'
|
|
@@ -25934,8 +26015,8 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25934
26015
|
family: 'Poppins'
|
|
25935
26016
|
}
|
|
25936
26017
|
}
|
|
25937
|
-
},
|
|
25938
|
-
y: {
|
|
26018
|
+
}, xAxis),
|
|
26019
|
+
y: _objectSpread2({
|
|
25939
26020
|
grid: {
|
|
25940
26021
|
display: true,
|
|
25941
26022
|
color: 'rgba(255, 255, 255, 0.2)'
|
|
@@ -25955,15 +26036,15 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25955
26036
|
family: 'Poppins'
|
|
25956
26037
|
}
|
|
25957
26038
|
}
|
|
25958
|
-
}
|
|
26039
|
+
}, yAxis)
|
|
25959
26040
|
}
|
|
25960
26041
|
};
|
|
25961
26042
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
25962
|
-
style: {
|
|
26043
|
+
style: _objectSpread2({
|
|
25963
26044
|
width: width || '100%',
|
|
25964
26045
|
// Default to full width if not provided
|
|
25965
|
-
height: height || '100%'
|
|
25966
|
-
},
|
|
26046
|
+
height: height || '100%'
|
|
26047
|
+
}, styles),
|
|
25967
26048
|
children: /*#__PURE__*/jsxRuntime.jsx(reactChartjs2.Bar, {
|
|
25968
26049
|
data: {
|
|
25969
26050
|
labels: labels,
|