oolib 2.192.2 → 2.193.0
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/v2/components/dataviz/BarGraphCollection/index.d.ts +1 -1
- package/dist/v2/components/dataviz/BarGraphCollection/index.js +4 -1
- package/dist/v2/components/dataviz/BarGraphCollection/styled.d.ts +2 -0
- package/dist/v2/components/dataviz/BarGraphCollection/styled.js +51 -7
- package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.d.ts +1 -0
- package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.js +15 -20
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ export function BarGraphCollection({ data: originalData, valuePath, labelPath, t
|
|
|
13
13
|
totalDataCount: any;
|
|
14
14
|
debug: any;
|
|
15
15
|
}): React.JSX.Element;
|
|
16
|
-
export function BarGraph({ tagCategory, index1, showCount, showPercent, onClick, debug }: {
|
|
16
|
+
export function BarGraph({ tagCategory, index1, showCount, showPercent, onClick, debug, }: {
|
|
17
17
|
tagCategory: any;
|
|
18
18
|
index1: any;
|
|
19
19
|
showCount?: boolean;
|
|
@@ -75,7 +75,10 @@ var BarGraphCollection = function (_a) {
|
|
|
75
75
|
if ((data === null || data === void 0 ? void 0 : data.length) === 0) {
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
|
+
var barDivisions = (0, useGetDimensions_1.divideBarIntoEqualParts)(highestCount);
|
|
78
79
|
return (react_1.default.createElement(styled_1.StyledBarGraphContainer, { style: { width: "auto" }, ref: containerRef },
|
|
80
|
+
react_1.default.createElement("div", { style: { position: "absolute", left: 50, height: "".concat(exports.BAR_GRAPH_HEIGHT, "px"), width: "20px" } },
|
|
81
|
+
react_1.default.createElement(styled_1.YAxisLabels, null, (0, styled_1.generateYAxisValues)(barDivisions).map(function (value, index) { return (react_1.default.createElement(__2.UI_BODY_SM, { key: index }, String(value))); }))),
|
|
79
82
|
react_1.default.createElement(styled_1.StyledBarGraphCollectionWrapper, { style: {
|
|
80
83
|
width: "auto",
|
|
81
84
|
gap: "".concat(exports.BAR_GAP, "rem"),
|
|
@@ -90,7 +93,7 @@ var BarGraphCollection = function (_a) {
|
|
|
90
93
|
height: "".concat(exports.BAR_GRAPH_HEIGHT + 50, "px"),
|
|
91
94
|
marginBottom: "0.6rem"
|
|
92
95
|
} },
|
|
93
|
-
react_1.default.createElement(exports.BarGraph, { tagCategory: tagCategory, index1: index1, showCount: showCount, showPercent: showPercent, onClick: onClick, debug: debug }),
|
|
96
|
+
react_1.default.createElement(exports.BarGraph, { tagCategory: tagCategory, index1: index1, showCount: showCount, showPercent: showPercent, onClick: onClick, debug: debug, highestCount: highestCount }),
|
|
94
97
|
categoryTitle && react_1.default.createElement("div", { title: categoryTitle, style: {
|
|
95
98
|
width: "".concat(tagCategory === null || tagCategory === void 0 ? void 0 : tagCategory.width, "px"),
|
|
96
99
|
background: grey5,
|
|
@@ -5,3 +5,5 @@ export const StyledBarGraphWrapper: import("styled-components").StyledComponent<
|
|
|
5
5
|
export const StyledSingleBarWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
6
|
export const StyledBar: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
7
|
export const StyledLabelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export const YAxisLabels: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export function generateYAxisValues(barDivisions: any): any[];
|
|
@@ -3,19 +3,49 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
4
|
return cooked;
|
|
5
5
|
};
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
9
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.StyledLabelWrapper = exports.StyledBar = exports.StyledSingleBarWrapper = exports.StyledBarGraphWrapper = exports.StyledBarGraphCollectionWrapper = exports.StyledBarGraphContainer = exports.CONTAINER_PADDING = void 0;
|
|
11
|
-
var styled_components_1 =
|
|
40
|
+
exports.generateYAxisValues = exports.YAxisLabels = exports.StyledLabelWrapper = exports.StyledBar = exports.StyledSingleBarWrapper = exports.StyledBarGraphWrapper = exports.StyledBarGraphCollectionWrapper = exports.StyledBarGraphContainer = exports.CONTAINER_PADDING = void 0;
|
|
41
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
12
42
|
var __1 = require("../../../..");
|
|
13
43
|
exports.CONTAINER_PADDING = 10;
|
|
14
44
|
var barColor = __1.colors2.secondaryContainer; // temp color
|
|
15
45
|
var grey5 = __1.colors2.grey5;
|
|
16
46
|
exports.StyledBarGraphContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", "px;\n padding-bottom: 0.4rem; // UI scroll bar bottom space \n overflow-x: auto;\n background-color: white;\n border-radius: 8px;\n"], ["\n padding: ", "px;\n padding-bottom: 0.4rem; // UI scroll bar bottom space \n overflow-x: auto;\n background-color: white;\n border-radius: 8px;\n"])), exports.CONTAINER_PADDING);
|
|
17
47
|
exports.StyledBarGraphCollectionWrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
|
18
|
-
exports.StyledBarGraphWrapper = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n position: relative;\n "], ["\n display: flex;\n position: relative;\n "])));
|
|
48
|
+
exports.StyledBarGraphWrapper = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n position: relative;\n\n "], ["\n display: flex;\n position: relative;\n\n "])));
|
|
19
49
|
var generateDebugLines = function (barSections, debug) {
|
|
20
50
|
if (!debug)
|
|
21
51
|
return '';
|
|
@@ -36,4 +66,18 @@ exports.StyledSingleBarWrapper = styled_components_1.default.div(templateObject_
|
|
|
36
66
|
});
|
|
37
67
|
exports.StyledBar = styled_components_1.default.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n border-radius: 2px;\n background-color: ", ";\n color: ", ";\n position: relative;\n ", ";\n"], ["\n border-radius: 2px;\n background-color: ", ";\n color: ", ";\n position: relative;\n ", ";\n"])), barColor, __1.colors2.onSecondary, (0, __1.transition)("width"));
|
|
38
68
|
exports.StyledLabelWrapper = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: absolute;\n transform: rotate(-90deg);\n transform-origin: left top;\n bottom: 0;\n left: calc(50% - 8px); // 10px for font\n text-wrap: nowrap;\n display: flex;\n"], ["\n position: absolute;\n transform: rotate(-90deg);\n transform-origin: left top;\n bottom: 0;\n left: calc(50% - 8px); // 10px for font\n text-wrap: nowrap;\n display: flex;\n"])));
|
|
39
|
-
|
|
69
|
+
exports.YAxisLabels = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n height: inherit;\n display: flex;\n\n flex-direction: column-reverse;\n justify-content: space-between;\n\n color: ", ";\n z-index: 100;\n"], ["\n height: inherit;\n display: flex;\n\n flex-direction: column-reverse;\n justify-content: space-between;\n\n color: ", ";\n z-index: 100;\n"])), __1.colors2.grey50);
|
|
70
|
+
var generateYAxisValues = function (barDivisions) {
|
|
71
|
+
// For 5 labels, we want to divide the range into 4 equal parts
|
|
72
|
+
var numLabels = 5;
|
|
73
|
+
var step = barDivisions / (numLabels - 1);
|
|
74
|
+
var values = [];
|
|
75
|
+
for (var i = 0; i < numLabels; i++) {
|
|
76
|
+
values.push(Math.round(step * i));
|
|
77
|
+
}
|
|
78
|
+
// Ensure the last value is exactly barDivisions to avoid rounding errors
|
|
79
|
+
values[values.length - 1] = barDivisions;
|
|
80
|
+
return values;
|
|
81
|
+
};
|
|
82
|
+
exports.generateYAxisValues = generateYAxisValues;
|
|
83
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -11,9 +11,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useGetDimensions = void 0;
|
|
14
|
+
exports.useGetDimensions = exports.divideBarIntoEqualParts = void 0;
|
|
15
15
|
var __1 = require("..");
|
|
16
16
|
var styled_1 = require("../styled");
|
|
17
|
+
var divideBarIntoEqualParts = function (num) {
|
|
18
|
+
if (num <= 100)
|
|
19
|
+
return num;
|
|
20
|
+
if (num <= 200)
|
|
21
|
+
return 200;
|
|
22
|
+
if (num <= 500)
|
|
23
|
+
return 500;
|
|
24
|
+
if (num <= 1000)
|
|
25
|
+
return 1000;
|
|
26
|
+
var magnitude = Math.pow(10, Math.floor(Math.log10(num)));
|
|
27
|
+
return Math.ceil(num / magnitude) * magnitude;
|
|
28
|
+
};
|
|
29
|
+
exports.divideBarIntoEqualParts = divideBarIntoEqualParts;
|
|
17
30
|
var useGetDimensions = function (data, maxHeight, containerWidth, totalDataCount, highestCount) {
|
|
18
31
|
var singleBarWidth;
|
|
19
32
|
var totalBars = data === null || data === void 0 ? void 0 : data.reduce(function (total, tagCategory) {
|
|
@@ -26,25 +39,7 @@ var useGetDimensions = function (data, maxHeight, containerWidth, totalDataCount
|
|
|
26
39
|
var dynamicBarWidth = availableWidthForBars / totalBars;
|
|
27
40
|
singleBarWidth = Math.max(dynamicBarWidth, __1.DEFAULT_SINGLE_BAR_WIDTH);
|
|
28
41
|
// Calculate the ceiling value for the highest count
|
|
29
|
-
var
|
|
30
|
-
if (num <= 10)
|
|
31
|
-
return num;
|
|
32
|
-
if (num <= 20)
|
|
33
|
-
return 20;
|
|
34
|
-
if (num <= 50)
|
|
35
|
-
return 50;
|
|
36
|
-
if (num <= 100)
|
|
37
|
-
return 100;
|
|
38
|
-
if (num <= 200)
|
|
39
|
-
return 200;
|
|
40
|
-
if (num <= 500)
|
|
41
|
-
return 500;
|
|
42
|
-
if (num <= 1000)
|
|
43
|
-
return 1000;
|
|
44
|
-
var magnitude = Math.pow(10, Math.floor(Math.log10(num)));
|
|
45
|
-
return Math.ceil(num / magnitude) * magnitude;
|
|
46
|
-
};
|
|
47
|
-
var barSections = divideBarIntoEqualParts(highestCount);
|
|
42
|
+
var barSections = (0, exports.divideBarIntoEqualParts)(highestCount);
|
|
48
43
|
return data === null || data === void 0 ? void 0 : data.map(function (category) {
|
|
49
44
|
// total count for this category
|
|
50
45
|
var total = category.tagSpecificCount.reduce(function (sum, tag) { return sum + tag.count; }, 0);
|