oolib 2.188.8 → 2.189.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/components/Dropdowns/DropdownMulti/index.js +2 -0
- package/dist/components/Dropdowns/DropdownSingle/index.js +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/stories/v2/components/Accordion.stories.js +1 -1
- package/dist/stories/v2/components/BarChart.stories.js +70 -43
- package/dist/stories/v2/components/HeatMapGrid.stories.d.ts +17 -0
- package/dist/stories/v2/components/HeatMapGrid.stories.js +107 -0
- package/dist/v2/components/DataVizAccordion/index.d.ts +1 -1
- package/dist/v2/components/DataVizAccordion/index.js +1 -1
- package/dist/v2/components/Dropdowns/DropdownMulti/index.js +2 -0
- package/dist/v2/components/Dropdowns/DropdownSingle/index.js +6 -1
- package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.d.ts +18 -0
- package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.js +24 -0
- package/dist/v2/components/{BarChart → dataviz/BarChart}/comps/CustomTooltip/index.d.ts +4 -4
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.js +161 -0
- package/dist/v2/components/{BarChart → dataviz/BarChart}/comps/CustomizedLabel/index.d.ts +7 -12
- package/dist/v2/components/{BarChart → dataviz/BarChart}/comps/CustomizedLabel/index.js +22 -12
- package/dist/v2/components/{BarChart → dataviz/BarChart}/index.d.ts +12 -14
- package/dist/v2/components/dataviz/BarChart/index.js +276 -0
- package/dist/v2/components/dataviz/HeatMapGrid/index.d.ts +21 -0
- package/dist/v2/components/dataviz/HeatMapGrid/index.js +230 -0
- package/dist/v2/components/dataviz/types.d.ts +12 -0
- package/dist/v2/components/dataviz/types.js +2 -0
- package/dist/v2/components/dataviz/utils/usePrepareData.d.ts +20 -0
- package/dist/v2/components/dataviz/utils/usePrepareData.js +116 -0
- package/package.json +1 -1
- package/dist/v2/components/BarChart/comps/CustomTooltip/index.js +0 -50
- package/dist/v2/components/BarChart/index.js +0 -294
- /package/dist/v2/components/{BarChart → dataviz/BarChart}/comps/TruncatedSVGText/index.d.ts +0 -0
- /package/dist/v2/components/{BarChart → dataviz/BarChart}/comps/TruncatedSVGText/index.js +0 -0
|
@@ -35,22 +35,32 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CustomizedLabel = void 0;
|
|
37
37
|
var react_1 = __importStar(require("react"));
|
|
38
|
-
var themes_1 = require("
|
|
38
|
+
var themes_1 = require("../../../../../themes");
|
|
39
39
|
var TruncatedSVGText_1 = require("../TruncatedSVGText");
|
|
40
40
|
var CustomizedLabel = function (_a) {
|
|
41
|
-
var y = _a.y, width = _a.width, height = _a.height, value = _a.value, showPercent = _a.showPercent, showCount = _a.showCount, opacity = _a.opacity,
|
|
41
|
+
var y = _a.y, width = _a.width, height = _a.height, value = _a.value, showPercent = _a.showPercent, showCount = _a.showCount, opacity = _a.opacity, _base_barchart_ui_configs = _a._base_barchart_ui_configs, _debug_controls = _a._debug_controls, onMouseOver = _a.onMouseOver, onMouseOut = _a.onMouseOut, onMouseDown = _a.onMouseDown, activeBar = _a.activeBar, TOT_HEIGHT_SINGLE_BAR_SECTION = _a.TOT_HEIGHT_SINGLE_BAR_SECTION, TOT_HEIGHT_GROUPED_BAR_SECTION = _a.TOT_HEIGHT_GROUPED_BAR_SECTION, CALC_SINGLE_BAR_SECTION_Y_POS = _a.CALC_SINGLE_BAR_SECTION_Y_POS, breakdownDisplayType = _a.breakdownDisplayType, _b = _a.showSumOfBreakdownValues, showSumOfBreakdownValues = _b === void 0 ? false : _b;
|
|
42
42
|
if (!value)
|
|
43
43
|
return null;
|
|
44
|
-
var yOffset = -(
|
|
44
|
+
var yOffset = -(_base_barchart_ui_configs.labelToBarGap + (_base_barchart_ui_configs.barHeight / 2));
|
|
45
45
|
var xOffsetRelative = 10;
|
|
46
46
|
var isBreakdown = Array.isArray(value);
|
|
47
47
|
var name = isBreakdown ? value[0].name : value.name;
|
|
48
48
|
var formatValue = function () {
|
|
49
49
|
if (isBreakdown) {
|
|
50
50
|
var values_1 = value;
|
|
51
|
-
|
|
52
|
-
showPercent ?
|
|
53
|
-
|
|
51
|
+
if (showSumOfBreakdownValues) {
|
|
52
|
+
var valueKey_1 = showPercent ? 'percentage' : 'count';
|
|
53
|
+
var suffixFunction = function (value) {
|
|
54
|
+
return showPercent ? value.toFixed(1) + '%' : value;
|
|
55
|
+
};
|
|
56
|
+
var totValue = suffixFunction(values_1.reduce(function (acc, b) { return acc + b[valueKey_1]; }, 0));
|
|
57
|
+
return totValue;
|
|
58
|
+
}
|
|
59
|
+
else { //only used while showing the summarized data as a stacked bar
|
|
60
|
+
return values_1.map(function (v, index) { return (react_1.default.createElement("tspan", { key: index, fill: v.color, className: "UI_BODY_BOLD_SM" },
|
|
61
|
+
showPercent ? v.percentage.toFixed(1) + '%' : v.count,
|
|
62
|
+
index < values_1.length - 1 && (react_1.default.createElement("tspan", { fill: themes_1.colors.grey80 }, " + ")))); });
|
|
63
|
+
}
|
|
54
64
|
}
|
|
55
65
|
else {
|
|
56
66
|
var singleValue = value;
|
|
@@ -70,14 +80,14 @@ var CustomizedLabel = function (_a) {
|
|
|
70
80
|
var widthRef = (0, react_1.useRef)(null);
|
|
71
81
|
var textContainerRef = (0, react_1.useRef)(null);
|
|
72
82
|
return (react_1.default.createElement("g", null,
|
|
73
|
-
react_1.default.createElement("text", { ref: textContainerRef, opacity: opacity, x:
|
|
83
|
+
react_1.default.createElement("text", { ref: textContainerRef, opacity: opacity, x: _base_barchart_ui_configs.marginLeft, dy: y - (_base_barchart_ui_configs.labelToBarGap), fill: themes_1.colors.grey80, textAnchor: "start", className: "UI_BODY_BOLD_SM" },
|
|
74
84
|
formatValue(),
|
|
75
85
|
showPercent && !isBreakdown && (react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, getCount())),
|
|
76
86
|
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 },
|
|
77
|
-
react_1.default.createElement(TruncatedSVGText_1.TruncatedSVGText, { text: name, textContainerRef: textContainerRef, widthRef: widthRef, widthOffset: -(
|
|
78
|
-
react_1.default.createElement("rect", { ref: widthRef, style: onMouseDown ? { cursor: 'pointer' } : {}, onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x:
|
|
79
|
-
?
|
|
80
|
-
:
|
|
81
|
-
(activeBar === name ? 1 : 0), stroke: themes_1.colors.grey30, rx: 5, ry: 5, strokeWidth: "".concat(
|
|
87
|
+
react_1.default.createElement(TruncatedSVGText_1.TruncatedSVGText, { text: name, textContainerRef: textContainerRef, widthRef: widthRef, widthOffset: -(_base_barchart_ui_configs.marginLeft + _base_barchart_ui_configs.marginRight) }))),
|
|
88
|
+
react_1.default.createElement("rect", { ref: widthRef, style: onMouseDown ? { cursor: 'pointer' } : {}, onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) { return onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value); }, onMouseOut: function (e) { return onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value); }, x: _base_barchart_ui_configs.hoverRectStrokeWidth, y: (!isBreakdown || breakdownDisplayType === 'stacked')
|
|
89
|
+
? _base_barchart_ui_configs.hoverRectStrokeWidth + CALC_SINGLE_BAR_SECTION_Y_POS(value.dataIndex)
|
|
90
|
+
: _base_barchart_ui_configs.hoverRectStrokeWidth + (TOT_HEIGHT_GROUPED_BAR_SECTION + _base_barchart_ui_configs.gapBetweenBarSections) * value[0].dataIndex, width: "calc(100% - ".concat(_base_barchart_ui_configs.hoverRectStrokeWidth * 2, "px)"), height: (!isBreakdown || breakdownDisplayType === 'stacked') ? TOT_HEIGHT_SINGLE_BAR_SECTION : TOT_HEIGHT_GROUPED_BAR_SECTION, opacity: _debug_controls.mouseEventDetectorOpacity ||
|
|
91
|
+
(activeBar === name ? 1 : 0), stroke: themes_1.colors.grey30, rx: 5, ry: 5, strokeWidth: "".concat(_base_barchart_ui_configs.hoverRectStrokeWidth, "px"), fillOpacity: _debug_controls.mouseEventDetectorOpacity })));
|
|
82
92
|
};
|
|
83
93
|
exports.CustomizedLabel = CustomizedLabel;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
barHeight: number;
|
|
4
|
-
labelToBarGap: number;
|
|
5
|
-
labelHeight: number;
|
|
6
|
-
labelToNextBarGap: number;
|
|
7
|
-
barRadius: number;
|
|
8
|
-
gapBetweenBarSections: number;
|
|
9
|
-
hoverRectStrokeWidth: number;
|
|
10
|
-
marginLeft: number;
|
|
11
|
-
marginRight: number;
|
|
12
|
-
gapBetweenBarsInGroup: number;
|
|
13
|
-
}
|
|
2
|
+
import { CountVizData } from "../types";
|
|
14
3
|
export interface DebugControls {
|
|
15
4
|
mouseEventDetectorOpacity: number;
|
|
16
5
|
chartWrapperBgColor: string;
|
|
17
6
|
}
|
|
7
|
+
export declare const useTrackMousePosition: () => {
|
|
8
|
+
mousePosition: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type BreakdownDisplayType = "grouped" | "stacked";
|
|
18
14
|
export interface BarChartProps {
|
|
19
|
-
data:
|
|
15
|
+
data: CountVizData;
|
|
20
16
|
valuePath: string | string[];
|
|
21
17
|
tooltipLabelsMapping: {
|
|
22
18
|
[key: string]: string;
|
|
@@ -27,7 +23,9 @@ export interface BarChartProps {
|
|
|
27
23
|
valueSuffix?: string;
|
|
28
24
|
showCount?: boolean;
|
|
29
25
|
showPercent?: boolean;
|
|
30
|
-
breakdownDisplayType?:
|
|
26
|
+
breakdownDisplayType?: BreakdownDisplayType;
|
|
31
27
|
colorIdx?: number;
|
|
28
|
+
summarizeAfterIdx?: number;
|
|
32
29
|
}
|
|
33
30
|
export declare const BarChart: React.FC<BarChartProps>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.BarChart = exports.useTrackMousePosition = void 0;
|
|
51
|
+
var react_1 = __importStar(require("react"));
|
|
52
|
+
var recharts_1 = require("recharts");
|
|
53
|
+
var CustomizedLabel_1 = require("./comps/CustomizedLabel");
|
|
54
|
+
var colors_1 = require("../../../themes/colors");
|
|
55
|
+
var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
|
|
56
|
+
var usePrepareData_1 = require("../utils/usePrepareData");
|
|
57
|
+
var _base_barchart_ui_configs_1 = require("./_base_barchart_ui_configs");
|
|
58
|
+
var useTrackMousePosition = function () {
|
|
59
|
+
var _a = (0, react_1.useState)({
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
}), mousePosition = _a[0], setMousePosition = _a[1];
|
|
63
|
+
(0, react_1.useEffect)(function () {
|
|
64
|
+
var handleMouseMove = function (e) {
|
|
65
|
+
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
66
|
+
};
|
|
67
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
68
|
+
// Clean up
|
|
69
|
+
return function () {
|
|
70
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
71
|
+
};
|
|
72
|
+
}, []);
|
|
73
|
+
return ({ mousePosition: mousePosition });
|
|
74
|
+
};
|
|
75
|
+
exports.useTrackMousePosition = useTrackMousePosition;
|
|
76
|
+
// CHART_OFFSET_TOP is the y shift on top of the entire chart, because otherwise the chart starts with bar 1 at 0,0 coordinates
|
|
77
|
+
var CHART_OFFSET_TOP = _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
78
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
79
|
+
(_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap / 2 - 2); //this minus 2 is just to correct the extra white space that the labelHeight takes on top of the text
|
|
80
|
+
var TOT_HEIGHT_SINGLE_BAR_SECTION = _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
|
|
81
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
82
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
83
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap;
|
|
84
|
+
var CALC_SINGLE_BAR_SECTION_Y_POS = function (index) {
|
|
85
|
+
return (TOT_HEIGHT_SINGLE_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) * index;
|
|
86
|
+
};
|
|
87
|
+
var CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION = function (noOfBarsInGroup) {
|
|
88
|
+
var totalHeightOfAllBars = noOfBarsInGroup * _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
|
|
89
|
+
(noOfBarsInGroup - 1) * _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup;
|
|
90
|
+
return (totalHeightOfAllBars +
|
|
91
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
92
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
93
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap);
|
|
94
|
+
};
|
|
95
|
+
var CALC_GROUPED_BAR_SECTION_Y_POS = function (index, barIndex, noOfBarsInGroup) {
|
|
96
|
+
var TOTAL_HEIGHT_GROUPED_BAR_SECTION = CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(noOfBarsInGroup);
|
|
97
|
+
var startYPosOfGroup = (TOTAL_HEIGHT_GROUPED_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) *
|
|
98
|
+
index;
|
|
99
|
+
return (startYPosOfGroup +
|
|
100
|
+
barIndex * (_base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup));
|
|
101
|
+
};
|
|
102
|
+
var CALC_TOTAL_HEIGHT_OF_CHART = function (_a) {
|
|
103
|
+
var isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, data = _a.data;
|
|
104
|
+
return isBreakdown && breakdownDisplayType === "grouped"
|
|
105
|
+
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length) *
|
|
106
|
+
data.length +
|
|
107
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
|
|
108
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2
|
|
109
|
+
: TOT_HEIGHT_SINGLE_BAR_SECTION * data.length +
|
|
110
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
|
|
111
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2;
|
|
112
|
+
};
|
|
113
|
+
var _debug_controls = {
|
|
114
|
+
mouseEventDetectorOpacity: 0, //only increase this for debugging. nothing else.
|
|
115
|
+
chartWrapperBgColor: "", //set this to some color value for debugging
|
|
116
|
+
};
|
|
117
|
+
var barConfigs = {
|
|
118
|
+
isBreakdown: {
|
|
119
|
+
getBarRadius: function (stackIndex, breakdownDisplayType, //replaced breakdownDisplayType
|
|
120
|
+
totalStacks) {
|
|
121
|
+
return breakdownDisplayType === "grouped" //replaced breakdownDisplayType
|
|
122
|
+
? _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius
|
|
123
|
+
: stackIndex === totalStacks - 1
|
|
124
|
+
? [0, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, 0]
|
|
125
|
+
: stackIndex === 0
|
|
126
|
+
? [_base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, 0, 0, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius]
|
|
127
|
+
: 0;
|
|
128
|
+
},
|
|
129
|
+
getDataKey: function (stackIndex) { return "".concat(stackIndex, ".labels.count"); },
|
|
130
|
+
getStackId: function (stackIndex, breakdownDisplayType //replaced breakdownDisplayType
|
|
131
|
+
) { return (breakdownDisplayType === "stacked" ? "stack" : "stack-".concat(stackIndex)); },
|
|
132
|
+
getCellFill: function (colorIdx, stackIndex, dataVizColors) { return dataVizColors[(colorIdx + stackIndex) % dataVizColors.length]; },
|
|
133
|
+
},
|
|
134
|
+
isNotBreakdown: {
|
|
135
|
+
getBarRadius: function () { return _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius; },
|
|
136
|
+
getDataKey: function () { return "labels.count"; },
|
|
137
|
+
getStackId: function () { return undefined; },
|
|
138
|
+
getCellFill: function (colorIdx, _stackIndex, dataVizColors) { return dataVizColors[colorIdx]; },
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
var renderBar = function (_a) {
|
|
142
|
+
var _b = _a.stackIndex, stackIndex = _b === void 0 ? 0 : _b, dataToRender = _a.data, isBreakdownToRender = _a.isBreakdown, breakdownDisplayTypeToRender = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues,
|
|
143
|
+
//
|
|
144
|
+
colorIdx = _a.colorIdx, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick;
|
|
145
|
+
var activeConfig = isBreakdownToRender
|
|
146
|
+
? barConfigs.isBreakdown
|
|
147
|
+
: barConfigs.isNotBreakdown;
|
|
148
|
+
var totalStacks = isBreakdownToRender
|
|
149
|
+
? dataToRender[0].length
|
|
150
|
+
: 1;
|
|
151
|
+
var currentStackId = activeConfig.getStackId(stackIndex, breakdownDisplayTypeToRender);
|
|
152
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
153
|
+
react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex, breakdownDisplayTypeToRender, totalStacks), dataKey: activeConfig.getDataKey(stackIndex), stackId: currentStackId },
|
|
154
|
+
(!isBreakdownToRender || stackIndex === 0) && (react_1.default.createElement(recharts_1.LabelList, { dataKey: isBreakdownToRender ? function (dataPoint) { return dataPoint; } : "labels", offset: 0, position: "bottom", content: function (props) { return (react_1.default.createElement(CustomizedLabel_1.CustomizedLabel, __assign({ CALC_SINGLE_BAR_SECTION_Y_POS: CALC_SINGLE_BAR_SECTION_Y_POS, TOT_HEIGHT_SINGLE_BAR_SECTION: TOT_HEIGHT_SINGLE_BAR_SECTION, TOT_HEIGHT_GROUPED_BAR_SECTION: isBreakdownToRender &&
|
|
155
|
+
breakdownDisplayTypeToRender === "grouped"
|
|
156
|
+
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(dataToRender[0].length)
|
|
157
|
+
: undefined,
|
|
158
|
+
breakdownDisplayType: breakdownDisplayTypeToRender,
|
|
159
|
+
y: props.y,
|
|
160
|
+
width: props.width,
|
|
161
|
+
height: props.height,
|
|
162
|
+
value: isBreakdownToRender
|
|
163
|
+
? dataToRender[props.index].map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColorsText[(colorIdx + idx) % colors_1.dataVizColorsText.length] })); })
|
|
164
|
+
: props.value, showPercent: showPercent, showCount: showCount, showSumOfBreakdownValues: showSumOfBreakdownValues, opacity: 1, activeBar: activeBar, _base_barchart_ui_configs: _base_barchart_ui_configs_1._base_barchart_ui_configs, _debug_controls: _debug_controls }, (onClick
|
|
165
|
+
? {
|
|
166
|
+
onMouseOver: function (e, value) {
|
|
167
|
+
setActiveBar(isBreakdownToRender
|
|
168
|
+
? dataToRender[props.index][0].labels.name
|
|
169
|
+
: value.name);
|
|
170
|
+
},
|
|
171
|
+
onMouseOut: function () { return setActiveBar(undefined); },
|
|
172
|
+
onMouseDown: function (e, value) {
|
|
173
|
+
var name = isBreakdownToRender
|
|
174
|
+
? dataToRender[props.index][0].labels.name
|
|
175
|
+
: value.name;
|
|
176
|
+
setActiveBar(name);
|
|
177
|
+
onClick(name);
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
: {})))); } })),
|
|
181
|
+
dataToRender.map(function (d, index) { return (react_1.default.createElement(recharts_1.Cell, { y: !isBreakdownToRender || breakdownDisplayTypeToRender === "stacked"
|
|
182
|
+
? CALC_SINGLE_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP
|
|
183
|
+
: CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, dataToRender[0].length) + CHART_OFFSET_TOP, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight, fill: activeConfig.getCellFill(colorIdx, stackIndex, colors_1.dataVizColors) })); }))));
|
|
184
|
+
};
|
|
185
|
+
var BarChartRenderer = function (_a) {
|
|
186
|
+
var data = _a.data, isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues, colorIdx = _a.colorIdx, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick,
|
|
187
|
+
//
|
|
188
|
+
mousePosition = _a.mousePosition, dataMaxValue = _a.dataMaxValue;
|
|
189
|
+
return (react_1.default.createElement(recharts_1.BarChart, { width: 500, height: CALC_TOTAL_HEIGHT_OF_CHART({
|
|
190
|
+
isBreakdown: isBreakdown,
|
|
191
|
+
breakdownDisplayType: breakdownDisplayType,
|
|
192
|
+
data: data
|
|
193
|
+
}), data: data, layout: "vertical", margin: {
|
|
194
|
+
top: 0,
|
|
195
|
+
right: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginRight,
|
|
196
|
+
left: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginLeft,
|
|
197
|
+
bottom: 0,
|
|
198
|
+
} },
|
|
199
|
+
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number", domain: [0, dataMaxValue] }),
|
|
200
|
+
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
201
|
+
isBreakdown && (react_1.default.createElement(recharts_1.Tooltip, { content: function (props) {
|
|
202
|
+
var _a;
|
|
203
|
+
return (react_1.default.createElement(CustomTooltip_1.default, __assign({}, props, { mousePosition: mousePosition, showPercent: showPercent,
|
|
204
|
+
// god knows why the dataindex gets stored against props.label.
|
|
205
|
+
// this is some internal recharts thing for tooltips specifically.
|
|
206
|
+
// we dont do this.
|
|
207
|
+
value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColors[(colorIdx + idx) % colors_1.dataVizColors.length] })); }) })));
|
|
208
|
+
}, cursor: false, allowEscapeViewBox: { x: true, y: true } })),
|
|
209
|
+
isBreakdown
|
|
210
|
+
? data[0].map(function (_, stackIndex) {
|
|
211
|
+
return renderBar({
|
|
212
|
+
stackIndex: stackIndex,
|
|
213
|
+
data: data,
|
|
214
|
+
isBreakdown: isBreakdown,
|
|
215
|
+
breakdownDisplayType: breakdownDisplayType,
|
|
216
|
+
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
217
|
+
colorIdx: colorIdx,
|
|
218
|
+
showPercent: showPercent,
|
|
219
|
+
showCount: showCount,
|
|
220
|
+
activeBar: activeBar,
|
|
221
|
+
setActiveBar: setActiveBar,
|
|
222
|
+
onClick: onClick,
|
|
223
|
+
});
|
|
224
|
+
})
|
|
225
|
+
: renderBar({
|
|
226
|
+
stackIndex: undefined,
|
|
227
|
+
data: data,
|
|
228
|
+
isBreakdown: isBreakdown,
|
|
229
|
+
breakdownDisplayType: breakdownDisplayType,
|
|
230
|
+
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
231
|
+
colorIdx: colorIdx,
|
|
232
|
+
showPercent: showPercent,
|
|
233
|
+
showCount: showCount,
|
|
234
|
+
activeBar: activeBar,
|
|
235
|
+
setActiveBar: setActiveBar,
|
|
236
|
+
onClick: onClick,
|
|
237
|
+
})));
|
|
238
|
+
};
|
|
239
|
+
var BarChart = function (_a) {
|
|
240
|
+
var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.breakdownDisplayType, breakdownDisplayType = _c === void 0 ? "grouped" : _c, _d = _a.showCount, showCount = _d === void 0 ? true : _d, _e = _a.showPercent, showPercent = _e === void 0 ? true : _e, _f = _a.colorIdx, colorIdx = _f === void 0 ? 0 : _f, _g = _a.summarizeAfterIdx, summarizeAfterIdx = _g === void 0 ? 5 : _g;
|
|
241
|
+
var isBreakdown = Array.isArray(valuePath);
|
|
242
|
+
var _h = (0, usePrepareData_1.usePrepareData)({
|
|
243
|
+
_data: _data,
|
|
244
|
+
labelPath: labelPath,
|
|
245
|
+
valuePath: valuePath,
|
|
246
|
+
tooltipLabelsMapping: tooltipLabelsMapping,
|
|
247
|
+
tooltipLabelsPath: tooltipLabelsPath,
|
|
248
|
+
isBreakdown: isBreakdown,
|
|
249
|
+
showPercent: showPercent,
|
|
250
|
+
summarizeAfterIdx: summarizeAfterIdx,
|
|
251
|
+
}), data = _h.data, dataMaxValue = _h.dataMaxValue, dataToSummarize = _h.dataToSummarize;
|
|
252
|
+
var _j = (0, react_1.useState)(undefined), activeBar = _j[0], setActiveBar = _j[1];
|
|
253
|
+
var mousePosition = (0, exports.useTrackMousePosition)().mousePosition;
|
|
254
|
+
// menu options for grouped and stacked
|
|
255
|
+
return (react_1.default.createElement("div", { style: {
|
|
256
|
+
height: "".concat(CALC_TOTAL_HEIGHT_OF_CHART({
|
|
257
|
+
isBreakdown: isBreakdown,
|
|
258
|
+
breakdownDisplayType: breakdownDisplayType,
|
|
259
|
+
data: data
|
|
260
|
+
}) + (isBreakdown ? 0 : CALC_TOTAL_HEIGHT_OF_CHART({
|
|
261
|
+
isBreakdown: true,
|
|
262
|
+
breakdownDisplayType: 'stacked',
|
|
263
|
+
data: dataToSummarize
|
|
264
|
+
})), "px"),
|
|
265
|
+
width: "100%",
|
|
266
|
+
background: _debug_controls.chartWrapperBgColor,
|
|
267
|
+
} },
|
|
268
|
+
react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
|
|
269
|
+
react_1.default.createElement("div", null,
|
|
270
|
+
react_1.default.createElement(BarChartRenderer, { data: data, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, colorIdx: colorIdx, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue }),
|
|
271
|
+
dataToSummarize && (react_1.default.createElement(BarChartRenderer, { data: dataToSummarize,
|
|
272
|
+
isBreakdown: true,
|
|
273
|
+
breakdownDisplayType: "stacked",
|
|
274
|
+
showSumOfBreakdownValues: true, colorIdx: colorIdx, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue }))))));
|
|
275
|
+
};
|
|
276
|
+
exports.BarChart = BarChart;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface HeatMapGridProps {
|
|
3
|
+
data: any;
|
|
4
|
+
valuePath: string | string[];
|
|
5
|
+
tooltipLabelsMapping: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
tooltipLabelsPath: string | string[];
|
|
9
|
+
labelPath: string;
|
|
10
|
+
onClick?: (name: string) => void;
|
|
11
|
+
valueSuffix?: string;
|
|
12
|
+
showCount?: boolean;
|
|
13
|
+
showPercent?: boolean;
|
|
14
|
+
breakdownDisplayType?: "grouped" | "stacked";
|
|
15
|
+
colorIdx?: number;
|
|
16
|
+
summarizeAfterIdx?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* expects exactly the same data structure as barcharts - breakdown version
|
|
20
|
+
*/
|
|
21
|
+
export declare const HeatMapGrid: React.FC<HeatMapGridProps>;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.HeatMapGrid = void 0;
|
|
51
|
+
var react_1 = __importStar(require("react"));
|
|
52
|
+
var BarChart_1 = require("../BarChart");
|
|
53
|
+
var Typo2_1 = require("../../Typo2");
|
|
54
|
+
var CustomTooltip_1 = __importDefault(require("../BarChart/comps/CustomTooltip"));
|
|
55
|
+
var usePrepareData_1 = require("../utils/usePrepareData");
|
|
56
|
+
var __1 = require("../../../..");
|
|
57
|
+
/**
|
|
58
|
+
* Maps a value from an input range to a color
|
|
59
|
+
* with the base color at the center point of the range
|
|
60
|
+
* @param {number} value - The value to map
|
|
61
|
+
* @param {number} minValue - The minimum value in the input range
|
|
62
|
+
* @param {number} maxValue - The maximum value in the input range
|
|
63
|
+
* @param {Object} hslColor - The base HSL color object
|
|
64
|
+
* @param {number} hslColor.h - Hue component (0-360)
|
|
65
|
+
* @param {number} hslColor.s - Saturation component (0-100)
|
|
66
|
+
* @param {number} hslColor.l - Lightness component (0-100)
|
|
67
|
+
* @param {number} minLightness - The minimum lightness (0-100) for darkest shade
|
|
68
|
+
* @param {number} maxLightness - The maximum lightness (0-100) for lightest shade
|
|
69
|
+
* @return {string} - A hex color code
|
|
70
|
+
*/
|
|
71
|
+
function mapValueToColor(value, minValue, maxValue, hslColor, // Default to #be185d
|
|
72
|
+
minLightness, maxLightness) {
|
|
73
|
+
if (hslColor === void 0) { hslColor = { h: 336, s: 74, l: 42 }; }
|
|
74
|
+
if (minLightness === void 0) { minLightness = 20; }
|
|
75
|
+
if (maxLightness === void 0) { maxLightness = 80; }
|
|
76
|
+
// Ensure value is within range
|
|
77
|
+
value = Math.max(minValue, Math.min(maxValue, value));
|
|
78
|
+
// Calculate the center point of the range
|
|
79
|
+
var centerPoint = (minValue + maxValue) / 2;
|
|
80
|
+
// Extract the hsl components
|
|
81
|
+
var h = hslColor.h, s = hslColor.s, baseLightness = hslColor.l;
|
|
82
|
+
// Determine lightness based on position relative to center point
|
|
83
|
+
var lightness;
|
|
84
|
+
if (value < centerPoint) {
|
|
85
|
+
// Value is below center (smaller) - scale from maxLightness to baseLightness
|
|
86
|
+
var normalizedValue = (value - minValue) / (centerPoint - minValue);
|
|
87
|
+
lightness = maxLightness - normalizedValue * (maxLightness - baseLightness);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// Value is above center (larger) - scale from baseLightness to minLightness
|
|
91
|
+
var normalizedValue = (value - centerPoint) / (maxValue - centerPoint);
|
|
92
|
+
lightness = baseLightness - normalizedValue * (baseLightness - minLightness);
|
|
93
|
+
}
|
|
94
|
+
// Convert HSL back to hex
|
|
95
|
+
return "hsl(".concat(h, ", ").concat(s, "%, ").concat(lightness, "%)"); //hslToHex(h, s, lightness);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Convert HSL values to hex color code
|
|
99
|
+
* @param {number} h - Hue (0-360)
|
|
100
|
+
* @param {number} s - Saturation (0-100)
|
|
101
|
+
* @param {number} l - Lightness (0-100)
|
|
102
|
+
* @return {string} - Hex color code
|
|
103
|
+
*/
|
|
104
|
+
function hslToHex(h, s, l) {
|
|
105
|
+
l /= 100;
|
|
106
|
+
var a = (s * Math.min(l, 1 - l)) / 100;
|
|
107
|
+
var f = function (n) {
|
|
108
|
+
var k = (n + h / 30) % 12;
|
|
109
|
+
var color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
110
|
+
return Math.round(255 * color)
|
|
111
|
+
.toString(16)
|
|
112
|
+
.padStart(2, "0");
|
|
113
|
+
};
|
|
114
|
+
return "#".concat(f(0)).concat(f(8)).concat(f(4));
|
|
115
|
+
}
|
|
116
|
+
var _configs = {
|
|
117
|
+
gridGap: 2,
|
|
118
|
+
cellRoundness: 4,
|
|
119
|
+
cellSize: 36,
|
|
120
|
+
axisLabelWidth: 62,
|
|
121
|
+
};
|
|
122
|
+
var HeatMapCell = function (_a) {
|
|
123
|
+
var value = _a.value, dataMaxValue = _a.dataMaxValue, _b = _a.dataMinValue, dataMinValue = _b === void 0 ? 0 : _b, showPercent = _a.showPercent;
|
|
124
|
+
var mousePosition = (0, BarChart_1.useTrackMousePosition)().mousePosition;
|
|
125
|
+
var _c = (0, react_1.useState)(false), showTooltip = _c[0], setShowTooltip = _c[1];
|
|
126
|
+
var cellColor = mapValueToColor(value.labels.count, dataMinValue, dataMaxValue);
|
|
127
|
+
var getCellColorLightness = function () {
|
|
128
|
+
var splitUp = cellColor.trim().replace('hsl(', '');
|
|
129
|
+
splitUp = splitUp.replace(')', '');
|
|
130
|
+
var splitUpAry = splitUp.split(',').map(function (d) { return d.trim(); });
|
|
131
|
+
var toReturn = parseInt(splitUpAry[2].replace('%', ''));
|
|
132
|
+
return toReturn;
|
|
133
|
+
};
|
|
134
|
+
var textColor = getCellColorLightness() > 60 ? __1.colors2.black : __1.colors2.white;
|
|
135
|
+
return (react_1.default.createElement("div", { onMouseOver: function () { return setShowTooltip(true); }, onMouseOut: function () { return setShowTooltip(false); } },
|
|
136
|
+
showTooltip && (react_1.default.createElement(CustomTooltip_1.default, { active: true, value: [__assign(__assign({}, value.labels), { tooltipLabel: value.labels.name + ' | ' + value.labels.tooltipLabel //bit of a hack but will sort later
|
|
137
|
+
})], showPercent: showPercent, mousePosition: mousePosition })),
|
|
138
|
+
react_1.default.createElement("div", { style: {
|
|
139
|
+
height: _configs.cellSize + "px",
|
|
140
|
+
width: _configs.cellSize + "px",
|
|
141
|
+
background: cellColor,
|
|
142
|
+
borderRadius: _configs.cellRoundness + "px",
|
|
143
|
+
display: 'flex',
|
|
144
|
+
justifyContent: 'center',
|
|
145
|
+
alignItems: 'center'
|
|
146
|
+
} },
|
|
147
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: { color: textColor } }, value.labels.count))));
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* expects exactly the same data structure as barcharts - breakdown version
|
|
151
|
+
*/
|
|
152
|
+
var HeatMapGrid = function (_a) {
|
|
153
|
+
var _data = _a.data, valuePath = _a.valuePath, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, _b = _a.labelPath, labelPath = _b === void 0 ? "name" : _b, onClick = _a.onClick, _c = _a.showCount, showCount = _c === void 0 ? true : _c, _d = _a.showPercent, showPercent = _d === void 0 ? true : _d, _e = _a.colorIdx, colorIdx = _e === void 0 ? 0 : _e, _f = _a.summarizeAfterIdx, summarizeAfterIdx = _f === void 0 ? 5 : _f;
|
|
154
|
+
var _g = (0, usePrepareData_1.usePrepareData)({
|
|
155
|
+
_data: _data,
|
|
156
|
+
labelPath: labelPath,
|
|
157
|
+
valuePath: valuePath,
|
|
158
|
+
tooltipLabelsMapping: tooltipLabelsMapping,
|
|
159
|
+
tooltipLabelsPath: tooltipLabelsPath,
|
|
160
|
+
isBreakdown: true,
|
|
161
|
+
showPercent: showPercent,
|
|
162
|
+
summarizeAfterIdx: summarizeAfterIdx,
|
|
163
|
+
}), data = _g.data, dataMaxValue = _g.dataMaxValue, dataToSummarize = _g.dataToSummarize;
|
|
164
|
+
return (react_1.default.createElement("div", null,
|
|
165
|
+
react_1.default.createElement("div", { style: {
|
|
166
|
+
display: "grid",
|
|
167
|
+
gridTemplateColumns: "auto 1fr",
|
|
168
|
+
gap: _configs.gridGap + 'px',
|
|
169
|
+
} },
|
|
170
|
+
react_1.default.createElement("div", { style: {
|
|
171
|
+
display: "flex",
|
|
172
|
+
flexDirection: "column",
|
|
173
|
+
gap: _configs.gridGap + "px",
|
|
174
|
+
} },
|
|
175
|
+
react_1.default.createElement("div", { style: { height: _configs.axisLabelWidth + "px" } }),
|
|
176
|
+
data.map(function (d) { return (react_1.default.createElement("div", { style: {
|
|
177
|
+
height: _configs.cellSize + "px",
|
|
178
|
+
textAlign: "right",
|
|
179
|
+
display: "flex",
|
|
180
|
+
alignItems: "center",
|
|
181
|
+
justifyContent: "flex-end",
|
|
182
|
+
} },
|
|
183
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
|
|
184
|
+
width: _configs.axisLabelWidth + "px",
|
|
185
|
+
textOverflow: "ellipsis",
|
|
186
|
+
overflow: "hidden",
|
|
187
|
+
whiteSpace: "nowrap",
|
|
188
|
+
} }, d[0].labels.name))); })),
|
|
189
|
+
react_1.default.createElement("div", { style: {
|
|
190
|
+
display: "flex",
|
|
191
|
+
flexDirection: "column",
|
|
192
|
+
gap: _configs.gridGap + "px",
|
|
193
|
+
} },
|
|
194
|
+
react_1.default.createElement("div", { style: {
|
|
195
|
+
display: "flex",
|
|
196
|
+
alignItems: "center",
|
|
197
|
+
gap: _configs.gridGap + "px",
|
|
198
|
+
} }, data[0].map(function (dd) { return (react_1.default.createElement("div", { style: {
|
|
199
|
+
width: _configs.cellSize + "px",
|
|
200
|
+
height: _configs.axisLabelWidth + "px",
|
|
201
|
+
display: "flex",
|
|
202
|
+
alignItems: "flex-end",
|
|
203
|
+
textWrap: "nowrap",
|
|
204
|
+
justifyContent: 'center',
|
|
205
|
+
position: "relative", // Add this
|
|
206
|
+
overflow: "visible" // Add this to allow content to overflow
|
|
207
|
+
} },
|
|
208
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD_DF, { style: {
|
|
209
|
+
width: _configs.axisLabelWidth + "px",
|
|
210
|
+
textOverflow: "ellipsis",
|
|
211
|
+
overflow: "hidden",
|
|
212
|
+
whiteSpace: "nowrap",
|
|
213
|
+
position: "absolute", // Add this
|
|
214
|
+
bottom: '-8px', // which is half of the line height of the current text
|
|
215
|
+
left: (_configs.cellSize / 2) + 'px', // Center horizontally
|
|
216
|
+
transformOrigin: "left center", // Change origin to bottom
|
|
217
|
+
transform: "rotate(-90deg)", // Adjust transform
|
|
218
|
+
} }, dd.labels.tooltipLabel))); })),
|
|
219
|
+
data.map(function (d) { return (react_1.default.createElement("div", { style: {
|
|
220
|
+
display: "flex",
|
|
221
|
+
alignItems: "center",
|
|
222
|
+
gap: _configs.gridGap + "px",
|
|
223
|
+
} }, d.map(function (dd) {
|
|
224
|
+
// console.log({
|
|
225
|
+
// color: mapValueToColor(dd.labels.count, 0, dataMaxValue),
|
|
226
|
+
// });
|
|
227
|
+
return react_1.default.createElement(HeatMapCell, { showPercent: false, dataMaxValue: dataMaxValue, value: dd });
|
|
228
|
+
}))); })))));
|
|
229
|
+
};
|
|
230
|
+
exports.HeatMapGrid = HeatMapGrid;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CountVizLabels {
|
|
2
|
+
percentage?: number;
|
|
3
|
+
count: number;
|
|
4
|
+
name: string;
|
|
5
|
+
dataIndex: number;
|
|
6
|
+
color: string;
|
|
7
|
+
tooltipLabel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CountVizDatum {
|
|
10
|
+
labels: CountVizLabels;
|
|
11
|
+
}
|
|
12
|
+
export type CountVizData = (CountVizDatum | CountVizDatum[])[];
|