@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/index.js
CHANGED
|
@@ -4975,11 +4975,15 @@ var generateColors = function generateColors(_ref4) {
|
|
|
4975
4975
|
excludedColors = _ref4$excludedColors === void 0 ? [] : _ref4$excludedColors,
|
|
4976
4976
|
_ref4$exclusionThresh = _ref4.exclusionThreshold,
|
|
4977
4977
|
exclusionThreshold = _ref4$exclusionThresh === void 0 ? 30 : _ref4$exclusionThresh,
|
|
4978
|
-
_ref4$
|
|
4979
|
-
|
|
4978
|
+
_ref4$distinctionThre = _ref4.distinctionThreshold,
|
|
4979
|
+
distinctionThreshold = _ref4$distinctionThre === void 0 ? 40 : _ref4$distinctionThre,
|
|
4980
|
+
_ref4$excludedHueRang = _ref4.excludedHueRanges,
|
|
4981
|
+
excludedHueRanges = _ref4$excludedHueRang === void 0 ? [] : _ref4$excludedHueRang;
|
|
4980
4982
|
var colors = [];
|
|
4981
|
-
var minLightness =
|
|
4982
|
-
var maxLightness =
|
|
4983
|
+
var minLightness = 30;
|
|
4984
|
+
var maxLightness = 70;
|
|
4985
|
+
var minSaturation = 65;
|
|
4986
|
+
var maxSaturation = 100;
|
|
4983
4987
|
var normalizedExcludedColors = excludedColors.map(function (color) {
|
|
4984
4988
|
return color.startsWith('#') ? color : "#".concat(color);
|
|
4985
4989
|
});
|
|
@@ -4989,16 +4993,49 @@ var generateColors = function generateColors(_ref4) {
|
|
|
4989
4993
|
var b = parseInt(hex.slice(5, 7), 16);
|
|
4990
4994
|
return [r, g, b];
|
|
4991
4995
|
};
|
|
4996
|
+
var hexToHSL = function hexToHSL(hex) {
|
|
4997
|
+
var r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
4998
|
+
var g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
4999
|
+
var b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
5000
|
+
var cmin = Math.min(r, g, b);
|
|
5001
|
+
var cmax = Math.max(r, g, b);
|
|
5002
|
+
var delta = cmax - cmin;
|
|
5003
|
+
var h = 0;
|
|
5004
|
+
var s = 0;
|
|
5005
|
+
var l = 0;
|
|
5006
|
+
if (delta === 0) {
|
|
5007
|
+
h = 0;
|
|
5008
|
+
} else if (cmax === r) {
|
|
5009
|
+
h = (g - b) / delta % 6;
|
|
5010
|
+
} else if (cmax === g) {
|
|
5011
|
+
h = (b - r) / delta + 2;
|
|
5012
|
+
} else {
|
|
5013
|
+
h = (r - g) / delta + 4;
|
|
5014
|
+
}
|
|
5015
|
+
h = Math.round(h * 60);
|
|
5016
|
+
if (h < 0) h += 360;
|
|
5017
|
+
l = (cmax + cmin) / 2;
|
|
5018
|
+
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
5019
|
+
s = Math.round(s * 100);
|
|
5020
|
+
l = Math.round(l * 100);
|
|
5021
|
+
return [h, s, l];
|
|
5022
|
+
};
|
|
4992
5023
|
var colorDistance = function colorDistance(hex1, hex2) {
|
|
4993
5024
|
var rgb1 = hexToRGB(hex1);
|
|
4994
5025
|
var rgb2 = hexToRGB(hex2);
|
|
4995
|
-
var
|
|
4996
|
-
var
|
|
4997
|
-
var
|
|
4998
|
-
|
|
5026
|
+
var rMean = (rgb1[0] + rgb2[0]) / 2;
|
|
5027
|
+
var r = rgb1[0] - rgb2[0];
|
|
5028
|
+
var g = rgb1[1] - rgb2[1];
|
|
5029
|
+
var b = rgb1[2] - rgb2[2];
|
|
5030
|
+
var weightR = 2 + rMean / 256;
|
|
5031
|
+
var weightG = 4.0;
|
|
5032
|
+
var weightB = 2 + (255 - rMean) / 256;
|
|
5033
|
+
return Math.sqrt(weightR * r * r + weightG * g * g + weightB * b * b);
|
|
4999
5034
|
};
|
|
5000
5035
|
function hslToHex(h, s, l) {
|
|
5001
|
-
|
|
5036
|
+
h = (h % 360 + 360) % 360;
|
|
5037
|
+
s = Math.max(0, Math.min(100, s));
|
|
5038
|
+
l = Math.max(0, Math.min(100, l));
|
|
5002
5039
|
l /= 100;
|
|
5003
5040
|
var a = s * Math.min(l, 1 - l) / 100;
|
|
5004
5041
|
var f = function f(n) {
|
|
@@ -5008,7 +5045,21 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5008
5045
|
};
|
|
5009
5046
|
return "#".concat(f(0)).concat(f(8)).concat(f(4));
|
|
5010
5047
|
}
|
|
5048
|
+
var isHueExcluded = function isHueExcluded(hue) {
|
|
5049
|
+
return excludedHueRanges.some(function (range) {
|
|
5050
|
+
if (range.min > range.max) {
|
|
5051
|
+
return hue >= range.min || hue <= range.max;
|
|
5052
|
+
}
|
|
5053
|
+
return hue >= range.min && hue <= range.max;
|
|
5054
|
+
});
|
|
5055
|
+
};
|
|
5011
5056
|
var isTooSimilarToExcluded = function isTooSimilarToExcluded(hexColor) {
|
|
5057
|
+
var _hexToHSL = hexToHSL(hexColor),
|
|
5058
|
+
_hexToHSL2 = _slicedToArray(_hexToHSL, 1),
|
|
5059
|
+
hue = _hexToHSL2[0];
|
|
5060
|
+
if (isHueExcluded(hue)) {
|
|
5061
|
+
return true;
|
|
5062
|
+
}
|
|
5012
5063
|
var _iterator = _createForOfIteratorHelper(normalizedExcludedColors),
|
|
5013
5064
|
_step;
|
|
5014
5065
|
try {
|
|
@@ -5027,21 +5078,24 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5027
5078
|
};
|
|
5028
5079
|
var generateDistinctColor = function generateDistinctColor() {
|
|
5029
5080
|
var attempts = 0;
|
|
5030
|
-
var maxAttempts =
|
|
5081
|
+
var maxAttempts = 300;
|
|
5031
5082
|
while (attempts < maxAttempts) {
|
|
5032
|
-
var
|
|
5033
|
-
var
|
|
5034
|
-
var
|
|
5035
|
-
|
|
5083
|
+
var h = Math.floor(Math.random() * 360);
|
|
5084
|
+
var s = Math.floor(Math.random() * (maxSaturation - minSaturation)) + minSaturation;
|
|
5085
|
+
var l = Math.floor(Math.random() * (maxLightness - minLightness)) + minLightness;
|
|
5086
|
+
if (isHueExcluded(h)) {
|
|
5087
|
+
attempts++;
|
|
5088
|
+
continue;
|
|
5089
|
+
}
|
|
5090
|
+
var hexColor = hslToHex(h, s, l);
|
|
5036
5091
|
if (isTooSimilarToExcluded(hexColor)) {
|
|
5037
5092
|
attempts++;
|
|
5038
|
-
// eslint-disable-next-line no-continue
|
|
5039
5093
|
continue;
|
|
5040
5094
|
}
|
|
5041
5095
|
var isDistinct = true;
|
|
5042
5096
|
for (var _i2 = 0, _colors = colors; _i2 < _colors.length; _i2++) {
|
|
5043
5097
|
var existingColor = _colors[_i2];
|
|
5044
|
-
if (colorDistance(hexColor, existingColor) <
|
|
5098
|
+
if (colorDistance(hexColor, existingColor) < distinctionThreshold) {
|
|
5045
5099
|
isDistinct = false;
|
|
5046
5100
|
break;
|
|
5047
5101
|
}
|
|
@@ -5051,13 +5105,36 @@ var generateColors = function generateColors(_ref4) {
|
|
|
5051
5105
|
}
|
|
5052
5106
|
attempts++;
|
|
5053
5107
|
}
|
|
5054
|
-
var
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5108
|
+
for (var adjustedAttempts = 0; adjustedAttempts < 50; adjustedAttempts++) {
|
|
5109
|
+
var _h = Math.floor(Math.random() * 360);
|
|
5110
|
+
if (isHueExcluded(_h)) {
|
|
5111
|
+
continue;
|
|
5112
|
+
}
|
|
5113
|
+
var _s = 90;
|
|
5114
|
+
var _l = 50;
|
|
5115
|
+
var _hexColor = hslToHex(_h, _s, _l);
|
|
5116
|
+
if (!isTooSimilarToExcluded(_hexColor)) {
|
|
5117
|
+
var mostDistinct = true;
|
|
5118
|
+
for (var _i3 = 0, _colors2 = colors; _i3 < _colors2.length; _i3++) {
|
|
5119
|
+
var _existingColor = _colors2[_i3];
|
|
5120
|
+
var distance = colorDistance(_hexColor, _existingColor);
|
|
5121
|
+
if (distance < distinctionThreshold * 0.7) {
|
|
5122
|
+
mostDistinct = false;
|
|
5123
|
+
}
|
|
5124
|
+
}
|
|
5125
|
+
if (mostDistinct || adjustedAttempts >= 49) {
|
|
5126
|
+
return _hexColor;
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
return hslToHex(Math.floor(Math.random() * 360), 80, 50);
|
|
5058
5131
|
};
|
|
5059
|
-
|
|
5060
|
-
|
|
5132
|
+
var failsafeCounter = 0;
|
|
5133
|
+
var maxFailsafe = count * 3;
|
|
5134
|
+
while (colors.length < count && failsafeCounter < maxFailsafe) {
|
|
5135
|
+
var newColor = generateDistinctColor();
|
|
5136
|
+
colors.push(newColor);
|
|
5137
|
+
failsafeCounter++;
|
|
5061
5138
|
}
|
|
5062
5139
|
return colors;
|
|
5063
5140
|
};
|
|
@@ -25798,8 +25875,13 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25798
25875
|
barColor2 = _ref.barColor2,
|
|
25799
25876
|
xAxisTitle = _ref.xAxisTitle,
|
|
25800
25877
|
yAxisTitle = _ref.yAxisTitle,
|
|
25801
|
-
|
|
25802
|
-
|
|
25878
|
+
tooltip = _ref.tooltip,
|
|
25879
|
+
legends = _ref.legends,
|
|
25880
|
+
chartOptions = _ref.chartOptions,
|
|
25881
|
+
chartDatasets = _ref.chartDatasets,
|
|
25882
|
+
xAxis = _ref.xAxis,
|
|
25883
|
+
yAxis = _ref.yAxis,
|
|
25884
|
+
styles = _ref.styles;
|
|
25803
25885
|
if (loading) {
|
|
25804
25886
|
return /*#__PURE__*/jsx(ChartSkeleton$1, {});
|
|
25805
25887
|
}
|
|
@@ -25812,22 +25894,21 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25812
25894
|
return seriesData.chartData[label][key] !== undefined;
|
|
25813
25895
|
});
|
|
25814
25896
|
}).map(function (key) {
|
|
25815
|
-
return {
|
|
25897
|
+
return _objectSpread2({
|
|
25816
25898
|
label: seriesData.metaData.keyData[key],
|
|
25817
25899
|
backgroundColor: key === 'x1' ? barColor1 !== null && barColor1 !== void 0 ? barColor1 : COLORS.success : key === 'x2' ? barColor2 !== null && barColor2 !== void 0 ? barColor2 : COLORS.error : COLORS.warning,
|
|
25818
25900
|
data: labels.map(function (label) {
|
|
25819
|
-
// Only include data if it's defined
|
|
25820
25901
|
return seriesData.chartData[label][key] !== undefined ? seriesData.chartData[label][key] : null;
|
|
25821
25902
|
}),
|
|
25822
25903
|
borderRadius: borderRadius,
|
|
25823
25904
|
barThickness: barThickness
|
|
25824
|
-
};
|
|
25905
|
+
}, chartDatasets);
|
|
25825
25906
|
});
|
|
25826
25907
|
var options = {
|
|
25827
25908
|
responsive: true,
|
|
25828
25909
|
maintainAspectRatio: false,
|
|
25829
25910
|
// To allow custom height and width
|
|
25830
|
-
plugins: {
|
|
25911
|
+
plugins: _objectSpread2({
|
|
25831
25912
|
title: {
|
|
25832
25913
|
display: true,
|
|
25833
25914
|
font: {
|
|
@@ -25839,7 +25920,7 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25839
25920
|
left: (title === null || title === void 0 ? void 0 : title.left) || 0
|
|
25840
25921
|
}
|
|
25841
25922
|
},
|
|
25842
|
-
tooltip: _objectSpread2(
|
|
25923
|
+
tooltip: _objectSpread2({
|
|
25843
25924
|
borderWidth: (_tooltip$borderWidth = tooltip === null || tooltip === void 0 ? void 0 : tooltip.borderWidth) !== null && _tooltip$borderWidth !== void 0 ? _tooltip$borderWidth : 1,
|
|
25844
25925
|
borderColor: (_tooltip$borderColor = tooltip === null || tooltip === void 0 ? void 0 : tooltip.borderColor) !== null && _tooltip$borderColor !== void 0 ? _tooltip$borderColor : COLORS.success,
|
|
25845
25926
|
backgroundColor: 'rgba(255, 255, 255, 1)',
|
|
@@ -25858,7 +25939,7 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25858
25939
|
label: function label(tooltipItem) {
|
|
25859
25940
|
var _seriesData$metaData$;
|
|
25860
25941
|
var label = (_seriesData$metaData$ = seriesData.metaData.controlsApplied[tooltipItem.label]) === null || _seriesData$metaData$ === void 0 ? void 0 : _seriesData$metaData$.x1;
|
|
25861
|
-
return "".concat(tooltipItem.
|
|
25942
|
+
return "".concat(tooltipItem.label, ": ").concat(label);
|
|
25862
25943
|
},
|
|
25863
25944
|
title: tooltip.displayTitle ? function (tooltipItems) {
|
|
25864
25945
|
var _tooltipItems$;
|
|
@@ -25867,12 +25948,12 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25867
25948
|
return '';
|
|
25868
25949
|
}
|
|
25869
25950
|
}
|
|
25870
|
-
}),
|
|
25871
|
-
legend: {
|
|
25951
|
+
}, tooltip),
|
|
25952
|
+
legend: _objectSpread2({
|
|
25872
25953
|
display: false
|
|
25873
|
-
},
|
|
25954
|
+
}, legends),
|
|
25874
25955
|
// Enable the datalabels plugin
|
|
25875
|
-
datalabels:
|
|
25956
|
+
datalabels: {
|
|
25876
25957
|
anchor: 'end',
|
|
25877
25958
|
align: 'top',
|
|
25878
25959
|
// Align the labels above the bars
|
|
@@ -25887,10 +25968,10 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25887
25968
|
formatter: function formatter(value, context) {
|
|
25888
25969
|
return context.chart.data.labels[context.dataIndex];
|
|
25889
25970
|
}
|
|
25890
|
-
}
|
|
25891
|
-
},
|
|
25971
|
+
}
|
|
25972
|
+
}, chartOptions),
|
|
25892
25973
|
scales: {
|
|
25893
|
-
x: {
|
|
25974
|
+
x: _objectSpread2({
|
|
25894
25975
|
grid: {
|
|
25895
25976
|
display: (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.gridContainLabel) || true,
|
|
25896
25977
|
color: 'rgba(255, 255, 255, 0.2)'
|
|
@@ -25913,8 +25994,8 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25913
25994
|
family: 'Poppins'
|
|
25914
25995
|
}
|
|
25915
25996
|
}
|
|
25916
|
-
},
|
|
25917
|
-
y: {
|
|
25997
|
+
}, xAxis),
|
|
25998
|
+
y: _objectSpread2({
|
|
25918
25999
|
grid: {
|
|
25919
26000
|
display: true,
|
|
25920
26001
|
color: 'rgba(255, 255, 255, 0.2)'
|
|
@@ -25934,15 +26015,15 @@ var BaseVerticalBarChart = function BaseVerticalBarChart(_ref) {
|
|
|
25934
26015
|
family: 'Poppins'
|
|
25935
26016
|
}
|
|
25936
26017
|
}
|
|
25937
|
-
}
|
|
26018
|
+
}, yAxis)
|
|
25938
26019
|
}
|
|
25939
26020
|
};
|
|
25940
26021
|
return /*#__PURE__*/jsx("div", {
|
|
25941
|
-
style: {
|
|
26022
|
+
style: _objectSpread2({
|
|
25942
26023
|
width: width || '100%',
|
|
25943
26024
|
// Default to full width if not provided
|
|
25944
|
-
height: height || '100%'
|
|
25945
|
-
},
|
|
26025
|
+
height: height || '100%'
|
|
26026
|
+
}, styles),
|
|
25946
26027
|
children: /*#__PURE__*/jsx(Bar, {
|
|
25947
26028
|
data: {
|
|
25948
26029
|
labels: labels,
|