oolib 2.213.5 → 2.214.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.
Files changed (62) hide show
  1. package/dist/index.d.ts +0 -6
  2. package/dist/index.js +2 -14
  3. package/dist/stories/v2/components/Accordion.stories.js +0 -1
  4. package/package.json +1 -1
  5. package/dist/stories/v2/components/DataVizAccordion.stories.d.ts +0 -7
  6. package/dist/stories/v2/components/DataVizAccordion.stories.js +0 -141
  7. package/dist/stories/v2/components/visualization/BarChart.stories.d.ts +0 -23
  8. package/dist/stories/v2/components/visualization/BarChart.stories.js +0 -251
  9. package/dist/stories/v2/components/visualization/BarGraphCollection.stories.d.ts +0 -19
  10. package/dist/stories/v2/components/visualization/BarGraphCollection.stories.js +0 -1190
  11. package/dist/stories/v2/components/visualization/HeatMapGrid.stories.d.ts +0 -18
  12. package/dist/stories/v2/components/visualization/HeatMapGrid.stories.js +0 -204
  13. package/dist/stories/v2/components/visualization/PieChart.stories.d.ts +0 -7
  14. package/dist/stories/v2/components/visualization/PieChart.stories.js +0 -79
  15. package/dist/stories/v2/components/visualization/configs/props1.d.ts +0 -102
  16. package/dist/stories/v2/components/visualization/configs/props1.js +0 -70
  17. package/dist/stories/v2/components/visualization/configs/props2.d.ts +0 -45
  18. package/dist/stories/v2/components/visualization/configs/props2.js +0 -2962
  19. package/dist/stories/v2/components/visualization/vizPlayground.stories.d.ts +0 -7
  20. package/dist/stories/v2/components/visualization/vizPlayground.stories.js +0 -55
  21. package/dist/v2/components/DataVizAccordion/index.d.ts +0 -13
  22. package/dist/v2/components/DataVizAccordion/index.js +0 -60
  23. package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.d.ts +0 -19
  24. package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.js +0 -25
  25. package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/OptimizedTooltip.d.ts +0 -8
  26. package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/OptimizedTooltip.js +0 -118
  27. package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.d.ts +0 -15
  28. package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.js +0 -120
  29. package/dist/v2/components/dataviz/BarChart/comps/CustomizedLabel/index.d.ts +0 -29
  30. package/dist/v2/components/dataviz/BarChart/comps/CustomizedLabel/index.js +0 -73
  31. package/dist/v2/components/dataviz/BarChart/comps/Legend/index.d.ts +0 -12
  32. package/dist/v2/components/dataviz/BarChart/comps/Legend/index.js +0 -35
  33. package/dist/v2/components/dataviz/BarChart/comps/LegendTooltipGlyph/index.d.ts +0 -7
  34. package/dist/v2/components/dataviz/BarChart/comps/LegendTooltipGlyph/index.js +0 -18
  35. package/dist/v2/components/dataviz/BarChart/comps/TruncatedSVGText/index.d.ts +0 -7
  36. package/dist/v2/components/dataviz/BarChart/comps/TruncatedSVGText/index.js +0 -66
  37. package/dist/v2/components/dataviz/BarChart/index.d.ts +0 -45
  38. package/dist/v2/components/dataviz/BarChart/index.js +0 -383
  39. package/dist/v2/components/dataviz/BarGraphCollection/index.d.ts +0 -24
  40. package/dist/v2/components/dataviz/BarGraphCollection/index.js +0 -162
  41. package/dist/v2/components/dataviz/BarGraphCollection/styled.d.ts +0 -9
  42. package/dist/v2/components/dataviz/BarGraphCollection/styled.js +0 -92
  43. package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.d.ts +0 -2
  44. package/dist/v2/components/dataviz/BarGraphCollection/utils/useGetDimensions.js +0 -60
  45. package/dist/v2/components/dataviz/BarGraphCollection/utils/usePrepareData.d.ts +0 -11
  46. package/dist/v2/components/dataviz/BarGraphCollection/utils/usePrepareData.js +0 -76
  47. package/dist/v2/components/dataviz/HeatMapGrid/index.d.ts +0 -19
  48. package/dist/v2/components/dataviz/HeatMapGrid/index.js +0 -232
  49. package/dist/v2/components/dataviz/HeatMapGrid/utils/mapValueToColor.d.ts +0 -20
  50. package/dist/v2/components/dataviz/HeatMapGrid/utils/mapValueToColor.js +0 -45
  51. package/dist/v2/components/dataviz/HeatMapGrid/utils/useAxisMeasure.d.ts +0 -6
  52. package/dist/v2/components/dataviz/HeatMapGrid/utils/useAxisMeasure.js +0 -53
  53. package/dist/v2/components/dataviz/HeatMapGrid/utils/useFader.d.ts +0 -6
  54. package/dist/v2/components/dataviz/HeatMapGrid/utils/useFader.js +0 -36
  55. package/dist/v2/components/dataviz/HeatMapGrid/utils/usePrepareHeatMapData.d.ts +0 -33
  56. package/dist/v2/components/dataviz/HeatMapGrid/utils/usePrepareHeatMapData.js +0 -122
  57. package/dist/v2/components/dataviz/PieChart/index.d.ts +0 -21
  58. package/dist/v2/components/dataviz/PieChart/index.js +0 -186
  59. package/dist/v2/components/dataviz/types.d.ts +0 -13
  60. package/dist/v2/components/dataviz/types.js +0 -2
  61. package/dist/v2/components/dataviz/utils/usePrepareData.d.ts +0 -21
  62. package/dist/v2/components/dataviz/utils/usePrepareData.js +0 -213
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TruncatedSVGText = void 0;
37
- var react_1 = __importStar(require("react"));
38
- var TruncatedSVGText = function (_a) {
39
- var _b;
40
- var text = _a.text, textContainerRef = _a.textContainerRef, widthRef = _a.widthRef, _c = _a.widthOffset, widthOffset = _c === void 0 ? 0 : _c;
41
- var textRef = (0, react_1.useRef)(null);
42
- var _d = (0, react_1.useState)(false), isTextTruncated = _d[0], setIsTextTruncated = _d[1];
43
- (0, react_1.useEffect)(function () {
44
- var truncateText = function () {
45
- var _a;
46
- var element = textRef.current;
47
- if (!element)
48
- return;
49
- var currentText = text;
50
- var textWidth = textContainerRef.current.getComputedTextLength();
51
- var totWidth = ((_a = widthRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) + widthOffset;
52
- // Check if truncation is needed
53
- if (textWidth > totWidth) {
54
- setIsTextTruncated(true);
55
- while (textWidth > totWidth && currentText.length > 0) {
56
- currentText = currentText.slice(0, -1);
57
- element.textContent = currentText + '...';
58
- textWidth = textContainerRef.current.getComputedTextLength();
59
- }
60
- }
61
- };
62
- truncateText();
63
- }, [text, (_b = widthRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width]);
64
- return (react_1.default.createElement("tspan", { ref: textRef, onMouseOver: function () { return console.log(text); } }, text));
65
- };
66
- exports.TruncatedSVGText = TruncatedSVGText;
@@ -1,45 +0,0 @@
1
- import React from "react";
2
- import { CountVizData } from "../types";
3
- export interface DebugControls {
4
- mouseEventDetectorOpacity: number;
5
- chartWrapperBgColor: string;
6
- }
7
- export declare const useTrackMousePosition: ({ containerRef }: {
8
- containerRef: React.RefObject<HTMLDivElement>;
9
- }) => {
10
- mousePosition: {
11
- x: number;
12
- y: number;
13
- };
14
- isHovering: boolean;
15
- };
16
- type BreakdownDisplayType = "grouped" | "stacked";
17
- export interface BarChartProps {
18
- data: CountVizData;
19
- valuePath: string | string[];
20
- tooltipLabelsMapping: {
21
- [key: string]: string;
22
- };
23
- tooltipLabelsPath: string | string[];
24
- breakdownCategoryName?: string;
25
- labelPath: string;
26
- onClick?: (name: string) => void;
27
- valueSuffix?: string;
28
- showCount?: boolean;
29
- showPercent?: boolean;
30
- breakdownDisplayType?: BreakdownDisplayType;
31
- colorIdx?: number;
32
- summarizeAfterIdx?: number;
33
- style?: React.CSSProperties;
34
- }
35
- export declare const useDecideLegendOrientation: (options?: {
36
- widthThreshold?: number;
37
- }) => {
38
- vizWrapperRef: React.MutableRefObject<HTMLDivElement>;
39
- orientation: "horizontal" | "vertical";
40
- };
41
- export declare const FadeGradientWhenScroll: ({ style }: {
42
- style?: {};
43
- }) => React.JSX.Element;
44
- export declare const BarChart: React.FunctionComponent<BarChartProps>;
45
- export {};
@@ -1,383 +0,0 @@
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.FadeGradientWhenScroll = exports.useDecideLegendOrientation = exports.useTrackMousePosition = void 0;
51
- var lodash_1 = __importDefault(require("lodash"));
52
- var react_1 = __importStar(require("react"));
53
- var recharts_1 = require("recharts");
54
- var CustomizedLabel_1 = require("./comps/CustomizedLabel");
55
- var __1 = require("../../../..");
56
- var usePrepareData_1 = require("../utils/usePrepareData");
57
- var _base_barchart_ui_configs_1 = require("./_base_barchart_ui_configs");
58
- var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
59
- var Legend_1 = require("./comps/Legend");
60
- var useTrackMousePosition = function (_a) {
61
- var containerRef = _a.containerRef;
62
- var _b = (0, react_1.useState)(null), mousePosition = _b[0], setMousePosition = _b[1];
63
- var isHoveringRef = (0, react_1.useRef)(false);
64
- var throttledHandleMouseMove = (0, react_1.useRef)(lodash_1.default.throttle(function (e) {
65
- var element = containerRef.current;
66
- if (!element)
67
- return;
68
- var rect = element.getBoundingClientRect();
69
- var isInside = (e.clientX >= rect.left &&
70
- e.clientX <= rect.right &&
71
- e.clientY >= rect.top &&
72
- e.clientY <= rect.bottom);
73
- if (isInside) {
74
- var newPosition = { x: e.clientX, y: e.clientY };
75
- setMousePosition(newPosition);
76
- isHoveringRef.current = true;
77
- }
78
- else if (isHoveringRef.current) {
79
- // Only update state when transitioning from inside to outside
80
- setMousePosition(null);
81
- isHoveringRef.current = false;
82
- }
83
- }, 16));
84
- (0, react_1.useEffect)(function () {
85
- document.addEventListener("mousemove", throttledHandleMouseMove.current);
86
- return function () {
87
- document.removeEventListener("mousemove", throttledHandleMouseMove.current);
88
- throttledHandleMouseMove.current.cancel();
89
- };
90
- }, []);
91
- // Only return isHovering as a boolean when mousePosition exists
92
- return {
93
- mousePosition: mousePosition,
94
- isHovering: mousePosition !== null
95
- };
96
- };
97
- exports.useTrackMousePosition = useTrackMousePosition;
98
- // CHART_OFFSET_TOP & CHART_OFFSET_TOP_BREAKDOWN is the y shift on top of the entire chart, because otherwise the chart starts with bar 1 at 0,0 coordinates
99
- var CHART_OFFSET_TOP = _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
100
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
101
- (_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
102
- var CHART_OFFSET_TOP_BREAKDOWN = _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
103
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
104
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenTwoLabels +
105
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight + //twice because the text and the percent are on separate lines
106
- (_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
107
- var TOT_HEIGHT_SINGLE_BAR_SECTION = _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
108
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
109
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
110
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap;
111
- var TOT_HEIGHT_STACKED_BAR_SECTION = _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
112
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
113
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
114
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenTwoLabels +
115
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
116
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap;
117
- var CALC_SINGLE_BAR_SECTION_Y_POS = function (index) {
118
- return (TOT_HEIGHT_SINGLE_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) * index;
119
- };
120
- var CALC_STACKED_BAR_SECTION_Y_POS = function (index) {
121
- return (TOT_HEIGHT_STACKED_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) * index;
122
- };
123
- var CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION = function (noOfBarsInGroup) {
124
- var totalHeightOfAllBars = noOfBarsInGroup * _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
125
- (noOfBarsInGroup - 1) * _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup;
126
- return (totalHeightOfAllBars +
127
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
128
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
129
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenTwoLabels +
130
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight + //twice because the text and the percent are on separate lines
131
- _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap);
132
- };
133
- var CALC_GROUPED_BAR_SECTION_Y_POS = function (index, barIndex, noOfBarsInGroup) {
134
- var TOTAL_HEIGHT_GROUPED_BAR_SECTION = CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(noOfBarsInGroup);
135
- var startYPosOfGroup = (TOTAL_HEIGHT_GROUPED_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) *
136
- index;
137
- return (startYPosOfGroup +
138
- barIndex * (_base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup));
139
- };
140
- var CALC_TOTAL_HEIGHT_OF_CHART = function (_a) {
141
- var isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, data = _a.data, showSumOfBreakdownValues = _a.showSumOfBreakdownValues;
142
- return isBreakdown && breakdownDisplayType === "grouped"
143
- ? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length) *
144
- data.length +
145
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
146
- _base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2
147
- : isBreakdown && breakdownDisplayType === 'stacked' && !showSumOfBreakdownValues
148
- ? (TOT_HEIGHT_STACKED_BAR_SECTION * data.length) +
149
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
150
- _base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2
151
- : TOT_HEIGHT_SINGLE_BAR_SECTION * data.length +
152
- _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
153
- _base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2;
154
- };
155
- var _debug_controls = {
156
- mouseEventDetectorOpacity: 0, //only increase this for debugging. nothing else.
157
- chartWrapperBgColor: "", //set this to some color value for debugging
158
- };
159
- var barConfigs = {
160
- isBreakdown: {
161
- getBarRadius: function (stackIndex, breakdownDisplayType, //replaced breakdownDisplayType
162
- totalStacks) {
163
- return breakdownDisplayType === "grouped" //replaced breakdownDisplayType
164
- ? _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius
165
- : stackIndex === totalStacks - 1
166
- ? [0, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, 0]
167
- : stackIndex === 0
168
- ? [_base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius, 0, 0, _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius]
169
- : 0;
170
- },
171
- getDataKey: function (stackIndex) { return "".concat(stackIndex, ".labels.count"); },
172
- getStackId: function (stackIndex, breakdownDisplayType //replaced breakdownDisplayType
173
- ) { return (breakdownDisplayType === "stacked" ? "stack" : "stack-".concat(stackIndex)); },
174
- getCellFill: function (colorIdx, stackIndex, dataVizColors) { return dataVizColors[(colorIdx + stackIndex) % dataVizColors.length]; },
175
- },
176
- isNotBreakdown: {
177
- getBarRadius: function () { return _base_barchart_ui_configs_1._base_barchart_ui_configs.barRadius; },
178
- getDataKey: function () { return "labels.count"; },
179
- getStackId: function () { return undefined; },
180
- getCellFill: function (colorIdx, _stackIndex, dataVizColors) { return dataVizColors[colorIdx]; },
181
- },
182
- };
183
- var renderBar = function (_a) {
184
- var _b = _a.stackIndex, stackIndex = _b === void 0 ? 0 : _b, data = _a.data, isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick;
185
- var activeConfig = isBreakdown
186
- ? barConfigs.isBreakdown
187
- : barConfigs.isNotBreakdown;
188
- var totalStacks = isBreakdown
189
- ? data[0].length
190
- : 1;
191
- var currentStackId = activeConfig.getStackId(stackIndex, breakdownDisplayType);
192
- return (react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex, breakdownDisplayType, totalStacks), dataKey: activeConfig.getDataKey(stackIndex), stackId: currentStackId, isAnimationActive: false },
193
- (!isBreakdown || stackIndex === 0) && (react_1.default.createElement(recharts_1.LabelList, { dataKey: isBreakdown ? 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, CALC_STACKED_BAR_SECTION_Y_POS: CALC_STACKED_BAR_SECTION_Y_POS, TOT_HEIGHT_SINGLE_BAR_SECTION: TOT_HEIGHT_SINGLE_BAR_SECTION, TOT_HEIGHT_STACKED_BAR_SECTION: TOT_HEIGHT_STACKED_BAR_SECTION, TOT_HEIGHT_GROUPED_BAR_SECTION: isBreakdown &&
194
- breakdownDisplayType === "grouped"
195
- ? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length)
196
- : undefined, breakdownDisplayType: breakdownDisplayType, y: props.y,
197
- width: props.width,
198
- height: props.height,
199
- value: isBreakdown
200
- ? data[props.index].map(function (item, idx) { return (__assign({}, item.labels)); })
201
- : 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
202
- ? {
203
- onMouseOver: function (e, value) {
204
- setActiveBar(isBreakdown
205
- ? data[props.index][0].labels.name
206
- : value.name);
207
- },
208
- onMouseOut: function () {
209
- setActiveBar(undefined);
210
- },
211
- onMouseDown: function (e, value) {
212
- var name = isBreakdown
213
- ? data[props.index][0].labels.name
214
- : value.name;
215
- setActiveBar(name);
216
- onClick(name);
217
- },
218
- }
219
- : {})))); } })),
220
- data.map(function (d, index) {
221
- /**
222
- * note this this map works differently for breakdown & not breakdown
223
- * for not breakdown - this map renders each of the inidividual bars.
224
- * for breakdown - this map renders each of the individual bar groups
225
- */
226
- return (react_1.default.createElement(recharts_1.Cell, { y: (!isBreakdown || showSumOfBreakdownValues) // this is confusing, but showSumOfBreakdownValues is only used to render the 'compressed' other bar in normal bar charts. hence it has to have properties like a normal, non breakdown bar chart
227
- ? CALC_SINGLE_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP
228
- : (breakdownDisplayType === "stacked" && !showSumOfBreakdownValues) //show summ happens in the summarized bar, were we dont want the double label approach
229
- ? CALC_STACKED_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP_BREAKDOWN
230
- : breakdownDisplayType === "grouped" &&
231
- CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, data[0].length) + CHART_OFFSET_TOP_BREAKDOWN, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight, fill: !isBreakdown
232
- ? d.labels.barColor
233
- : d[stackIndex].labels.barColor }));
234
- })));
235
- };
236
- var useDecideLegendOrientation = function (options) {
237
- if (options === void 0) { options = {}; }
238
- var _a = options.widthThreshold, widthThreshold = _a === void 0 ? 600 : _a;
239
- var vizWrapperRef = (0, react_1.useRef)(null);
240
- var _b = (0, react_1.useState)('horizontal'), orientation = _b[0], setOrientation = _b[1];
241
- (0, react_1.useEffect)(function () {
242
- var element = vizWrapperRef.current;
243
- if (!element)
244
- return;
245
- var resizeObserver = new ResizeObserver(function (entries) {
246
- for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
247
- var entry = entries_1[_i];
248
- var width = entry.contentRect.width;
249
- // If width is >= threshold, use horizontal, otherwise vertical
250
- var newOrientation = width >= widthThreshold ? 'vertical' : 'horizontal';
251
- setOrientation(newOrientation);
252
- }
253
- });
254
- resizeObserver.observe(element);
255
- // Set initial orientation
256
- var initialWidth = element.getBoundingClientRect().width;
257
- setOrientation(initialWidth >= widthThreshold ? 'vertical' : 'horizontal');
258
- // Cleanup
259
- return function () {
260
- resizeObserver.disconnect();
261
- };
262
- }, [widthThreshold]);
263
- return {
264
- vizWrapperRef: vizWrapperRef,
265
- orientation: orientation
266
- };
267
- };
268
- exports.useDecideLegendOrientation = useDecideLegendOrientation;
269
- var BarChartRenderer = function (_a) {
270
- var data = _a.data, isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick,
271
- //
272
- // mousePosition,
273
- dataMaxValue = _a.dataMaxValue, breakdownCategoryName = _a.breakdownCategoryName;
274
- var containerRef = (0, react_1.useRef)();
275
- var _b = (0, exports.useTrackMousePosition)({ containerRef: containerRef }), mousePosition = _b.mousePosition, isHovering = _b.isHovering;
276
- return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", ref: containerRef, height: CALC_TOTAL_HEIGHT_OF_CHART({
277
- isBreakdown: isBreakdown,
278
- breakdownDisplayType: breakdownDisplayType,
279
- showSumOfBreakdownValues: showSumOfBreakdownValues,
280
- data: data
281
- }) },
282
- react_1.default.createElement(recharts_1.BarChart, { data: data, layout: "vertical", margin: {
283
- top: 0,
284
- right: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginRight,
285
- left: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginLeft,
286
- bottom: 0,
287
- } },
288
- react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number", domain: [0, dataMaxValue] }),
289
- react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
290
- (isBreakdown && mousePosition && isHovering) && (react_1.default.createElement(recharts_1.Tooltip, { cursor: false,
291
- // content={<OptimizedTooltip />}
292
- // animationDuration={0}
293
- // isAnimationActive={false}
294
- // allowEscapeViewBox={{ x: false, y: false }}
295
- // position={{ x: undefined, y: undefined }}
296
- content: function (props) {
297
- var _a;
298
- return (react_1.default.createElement(CustomTooltip_1.default, __assign({}, props, { breakdownCategoryName: breakdownCategoryName, activeBar: activeBar, mousePosition: mousePosition, showPercent: showPercent,
299
- // god knows why the dataindex gets stored against props.label.
300
- // this is some internal recharts thing for tooltips specifically.
301
- // we dont do this.
302
- value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign({}, item.labels)); }) })));
303
- }, allowEscapeViewBox: { x: true, y: true } })),
304
- isBreakdown
305
- ? data[0].map(function (_, stackIndex) {
306
- //note that this map renders the individual bars within a breakdown group
307
- return renderBar({
308
- stackIndex: stackIndex,
309
- data: data,
310
- isBreakdown: isBreakdown,
311
- breakdownDisplayType: breakdownDisplayType,
312
- showSumOfBreakdownValues: showSumOfBreakdownValues,
313
- showPercent: showPercent,
314
- showCount: showCount,
315
- activeBar: activeBar,
316
- setActiveBar: setActiveBar,
317
- onClick: onClick,
318
- });
319
- })
320
- : renderBar({
321
- stackIndex: undefined,
322
- data: data,
323
- isBreakdown: isBreakdown,
324
- breakdownDisplayType: breakdownDisplayType,
325
- showSumOfBreakdownValues: showSumOfBreakdownValues,
326
- showPercent: showPercent,
327
- showCount: showCount,
328
- activeBar: activeBar,
329
- setActiveBar: setActiveBar,
330
- onClick: onClick,
331
- }))));
332
- };
333
- var FadeGradientWhenScroll = function (_a) {
334
- var _b = _a.style, style = _b === void 0 ? {} : _b;
335
- return (react_1.default.createElement("div", { style: __assign({ width: '100%', height: '40px', position: 'sticky', left: 0, bottom: 0, background: "linear-gradient(to top, ".concat(__1.colors2.white, ", hsla(0, 0%, 100%, 0))") }, style) }));
336
- };
337
- exports.FadeGradientWhenScroll = FadeGradientWhenScroll;
338
- var BarChart = function (_a) {
339
- var _data = _a.data, valuePath = _a.valuePath, _b = _a.style, style = _b === void 0 ? {} : _b, tooltipLabelsMapping = _a.tooltipLabelsMapping, tooltipLabelsPath = _a.tooltipLabelsPath, breakdownCategoryName = _a.breakdownCategoryName, // basically, if lets say tagCat1 is broken down by tagCat2. then tagCat2's display would be this property
340
- _c = _a.labelPath, // basically, if lets say tagCat1 is broken down by tagCat2. then tagCat2's display would be this property
341
- labelPath = _c === void 0 ? "name" : _c, onClick = _a.onClick, _d = _a.breakdownDisplayType, breakdownDisplayType = _d === void 0 ? "grouped" : _d, _e = _a.showCount, showCount = _e === void 0 ? true : _e, _f = _a.showPercent, showPercent = _f === void 0 ? true : _f, _g = _a.colorIdx, colorIdx = _g === void 0 ? 0 : _g, _h = _a.summarizeAfterIdx, summarizeAfterIdx = _h === void 0 ? undefined : _h;
342
- var isBreakdown = Array.isArray(valuePath);
343
- var _j = (0, usePrepareData_1.usePrepareData)({
344
- _data: _data,
345
- labelPath: labelPath,
346
- valuePath: valuePath,
347
- tooltipLabelsMapping: tooltipLabelsMapping,
348
- tooltipLabelsPath: tooltipLabelsPath,
349
- isBreakdown: isBreakdown,
350
- showPercent: showPercent,
351
- summarizeAfterIdx: summarizeAfterIdx,
352
- colorIdx: colorIdx
353
- }), data = _j.data, dataMaxValue = _j.dataMaxValue, dataToSummarize = _j.dataToSummarize;
354
- var _k = (0, exports.useDecideLegendOrientation)({
355
- widthThreshold: 500
356
- }), vizWrapperRef = _k.vizWrapperRef, orientation = _k.orientation;
357
- var _l = (0, react_1.useState)(undefined), activeBar = _l[0], setActiveBar = _l[1];
358
- // const mousePosition = {x: 0, y: 0}
359
- // const { mousePosition, isHovering } = useTrackMousePosition({ wrapperRef: vizWrapperRef});
360
- // { mousePosition : 0 }
361
- // menu options for grouped and stacked
362
- if (data.length === 0)
363
- return react_1.default.createElement("div", null, "No data available");
364
- return (react_1.default.createElement("div", { ref: vizWrapperRef, style: __assign(__assign({}, style), { width: "100%", background: _debug_controls.chartWrapperBgColor, display: 'flex', gap: '8px', flexDirection: orientation === 'vertical' ? 'row' : 'column', position: 'relative', overflow: 'auto' }) },
365
- react_1.default.createElement("div", { style: { flexGrow: 1, position: 'relative' } },
366
- react_1.default.createElement(BarChartRenderer, { data: data, dataToSummarize: dataToSummarize, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
367
- // mousePosition: isHovering ? mousePosition : null,
368
- dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName }),
369
- dataToSummarize && (react_1.default.createElement(BarChartRenderer, { data: dataToSummarize,
370
- isBreakdown: true,
371
- breakdownDisplayType: "stacked",
372
- showSumOfBreakdownValues: true, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick,
373
- // mousePosition: isHovering ? mousePosition : null,
374
- dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName })),
375
- orientation === 'vertical' && react_1.default.createElement(exports.FadeGradientWhenScroll, null)),
376
- isBreakdown && react_1.default.createElement("div", { style: __assign({ position: 'sticky' }, (orientation === 'vertical' ? { top: 0 } : { bottom: 0, background: __1.colors2.white })) },
377
- orientation === 'horizontal' && react_1.default.createElement(exports.FadeGradientWhenScroll, { style: { transform: 'translateY(-100%)', top: 0, bottom: 'unset', position: 'absolute', } }),
378
- react_1.default.createElement(Legend_1.Legend, { orientation: orientation, label: breakdownCategoryName, data: data[0].map(function (d) { return ({
379
- text: d.labels.tooltipLabel,
380
- color: d.labels.barColor
381
- }); }) }))));
382
- };
383
- exports.BarChart = BarChart;
@@ -1,24 +0,0 @@
1
- export const BAR_GRAPH_HEIGHT: 250;
2
- export const DEFAULT_SINGLE_BAR_WIDTH: 24;
3
- export const BAR_GAP: 0.3;
4
- export function BarGraphCollection({ data: originalData, valuePath, labelPath, tooltipLabelsMapping, onClick, showCount, showPercent, groupBy, totalDataCount, debug }: {
5
- data: any;
6
- valuePath: any;
7
- labelPath?: string;
8
- tooltipLabelsMapping?: {};
9
- onClick: any;
10
- showCount?: boolean;
11
- showPercent?: boolean;
12
- groupBy: any;
13
- totalDataCount: any;
14
- debug: any;
15
- }): React.JSX.Element;
16
- export function BarGraph({ tagCategory, index1, showCount, showPercent, onClick, debug, }: {
17
- tagCategory: any;
18
- index1: any;
19
- showCount?: boolean;
20
- showPercent?: boolean;
21
- onClick: any;
22
- debug: any;
23
- }): React.JSX.Element;
24
- import React from "react";