oolib 2.194.1 → 2.195.1
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/icons/index.d.ts +8 -0
- package/dist/icons/index.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/stories/v2/components/BarChart.stories.js +126 -220
- package/dist/stories/v2/components/List.stories.js +1 -1
- package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.d.ts +1 -0
- package/dist/v2/components/dataviz/BarChart/_base_barchart_ui_configs.js +1 -0
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.d.ts +2 -0
- package/dist/v2/components/dataviz/BarChart/comps/CustomTooltip/index.js +11 -12
- package/dist/v2/components/dataviz/BarChart/comps/CustomizedLabel/index.d.ts +3 -1
- package/dist/v2/components/dataviz/BarChart/comps/CustomizedLabel/index.js +24 -44
- package/dist/v2/components/dataviz/BarChart/comps/Legend/index.d.ts +12 -0
- package/dist/v2/components/dataviz/BarChart/comps/Legend/index.js +35 -0
- package/dist/v2/components/dataviz/BarChart/comps/LegendTooltipGlyph/index.d.ts +7 -0
- package/dist/v2/components/dataviz/BarChart/comps/LegendTooltipGlyph/index.js +17 -0
- package/dist/v2/components/dataviz/BarChart/index.d.ts +3 -0
- package/dist/v2/components/dataviz/BarChart/index.js +161 -108
- package/dist/v2/components/dataviz/types.d.ts +2 -1
- package/dist/v2/components/dataviz/utils/usePrepareData.d.ts +2 -1
- package/dist/v2/components/dataviz/utils/usePrepareData.js +52 -10
- package/dist/v2/themes/colors.js +1 -1
- package/package.json +2 -2
|
@@ -1,44 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.CustomizedLabel = void 0;
|
|
37
|
-
var react_1 =
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
38
8
|
var themes_1 = require("../../../../../themes");
|
|
39
|
-
var TruncatedSVGText_1 = require("../TruncatedSVGText");
|
|
40
9
|
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, _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;
|
|
10
|
+
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_STACKED_BAR_SECTION = _a.TOT_HEIGHT_STACKED_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, CALC_STACKED_BAR_SECTION_Y_POS = _a.CALC_STACKED_BAR_SECTION_Y_POS, breakdownDisplayType = _a.breakdownDisplayType, _b = _a.showSumOfBreakdownValues, showSumOfBreakdownValues = _b === void 0 ? false : _b;
|
|
42
11
|
if (!value)
|
|
43
12
|
return null;
|
|
44
13
|
var yOffset = -(_base_barchart_ui_configs.labelToBarGap + (_base_barchart_ui_configs.barHeight / 2));
|
|
@@ -57,7 +26,7 @@ var CustomizedLabel = function (_a) {
|
|
|
57
26
|
return totValue;
|
|
58
27
|
}
|
|
59
28
|
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.
|
|
29
|
+
return values_1.map(function (v, index) { return (react_1.default.createElement("tspan", { key: index, fill: v.textColor, className: "UI_BODY_BOLD_SM" },
|
|
61
30
|
showPercent ? v.percentage.toFixed(1) + '%' : v.count,
|
|
62
31
|
index < values_1.length - 1 && (react_1.default.createElement("tspan", { fill: themes_1.colors.grey80 }, " + ")))); });
|
|
63
32
|
}
|
|
@@ -77,17 +46,28 @@ var CustomizedLabel = function (_a) {
|
|
|
77
46
|
return value.count;
|
|
78
47
|
}
|
|
79
48
|
};
|
|
80
|
-
var widthRef = (0, react_1.useRef)(null);
|
|
81
|
-
var textContainerRef = (0, react_1.useRef)(null);
|
|
82
49
|
return (react_1.default.createElement("g", null,
|
|
83
|
-
|
|
50
|
+
(isBreakdown && !showSumOfBreakdownValues) && //meaning if its a breakdown and we are showing values as v1 + v2 + v3 which occupies too much space and hence we need double line
|
|
51
|
+
react_1.default.createElement("text", { className: "UI_BODY_SM", opacity: opacity, x: _base_barchart_ui_configs.marginLeft, dy: y - (_base_barchart_ui_configs.labelToBarGap + _base_barchart_ui_configs.labelHeight + _base_barchart_ui_configs.gapBetweenTwoLabels), fill: themes_1.colors.grey80, textAnchor: "start" }, name),
|
|
52
|
+
react_1.default.createElement("text", { 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" },
|
|
84
53
|
formatValue(),
|
|
85
54
|
showPercent && !isBreakdown && (react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, getCount())),
|
|
86
|
-
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 },
|
|
87
|
-
|
|
88
|
-
|
|
55
|
+
(isBreakdown && !showSumOfBreakdownValues) ? null : react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, name)),
|
|
56
|
+
react_1.default.createElement("rect", { style: onMouseDown ? { cursor: 'pointer' } : {}, onMouseDown: function (e) { return onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, value); }, onMouseOver: function (e) {
|
|
57
|
+
onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, value);
|
|
58
|
+
}, onMouseOut: function (e) {
|
|
59
|
+
onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, value);
|
|
60
|
+
}, x: _base_barchart_ui_configs.hoverRectStrokeWidth, y: (!isBreakdown || showSumOfBreakdownValues)
|
|
89
61
|
? _base_barchart_ui_configs.hoverRectStrokeWidth + CALC_SINGLE_BAR_SECTION_Y_POS(value.dataIndex)
|
|
90
|
-
:
|
|
62
|
+
: breakdownDisplayType === 'stacked'
|
|
63
|
+
? _base_barchart_ui_configs.hoverRectStrokeWidth + CALC_STACKED_BAR_SECTION_Y_POS(value[0].dataIndex)
|
|
64
|
+
: breakdownDisplayType === 'grouped' &&
|
|
65
|
+
_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 || showSumOfBreakdownValues)
|
|
66
|
+
? TOT_HEIGHT_SINGLE_BAR_SECTION
|
|
67
|
+
: breakdownDisplayType === 'stacked'
|
|
68
|
+
? TOT_HEIGHT_STACKED_BAR_SECTION
|
|
69
|
+
: breakdownDisplayType === 'grouped' &&
|
|
70
|
+
TOT_HEIGHT_GROUPED_BAR_SECTION, opacity: _debug_controls.mouseEventDetectorOpacity ||
|
|
91
71
|
(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 })));
|
|
92
72
|
};
|
|
93
73
|
exports.CustomizedLabel = CustomizedLabel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface LegendData {
|
|
3
|
+
color: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
interface LegendProps {
|
|
7
|
+
data: LegendData[];
|
|
8
|
+
label?: string;
|
|
9
|
+
orientation?: "vertical" | "horizontal";
|
|
10
|
+
}
|
|
11
|
+
export declare const Legend: React.FC<LegendProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Legend = void 0;
|
|
18
|
+
var react_1 = __importDefault(require("react"));
|
|
19
|
+
var __1 = require("../../../../../..");
|
|
20
|
+
var Typo2_1 = require("../../../../Typo2");
|
|
21
|
+
var LegendTooltipGlyph_1 = require("../LegendTooltipGlyph");
|
|
22
|
+
var Legend = function (_a) {
|
|
23
|
+
var data = _a.data, label = _a.label, _b = _a.orientation, orientation = _b === void 0 ? "vertical" : _b;
|
|
24
|
+
return (react_1.default.createElement("div", { style: __assign(__assign({}, (orientation === 'vertical' ? { maxWidth: '200px' } : {})), { padding: "12px", borderRadius: '8px', border: "1px solid ".concat(__1.colors2.grey5), background: "linear-gradient(to bottom, hsla(0, 0%, 96%, 1), hsla(0, 0%, 100%, 0))" }) },
|
|
25
|
+
label && orientation === 'vertical' && (react_1.default.createElement("div", { style: { paddingBottom: "8px" } },
|
|
26
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, label))),
|
|
27
|
+
react_1.default.createElement("div", { style: __assign(__assign({ display: "flex", flexDirection: orientation === "vertical" ? "column" : "row" }, (orientation === 'horizontal' ? { flexWrap: 'wrap' } : {})), { gap: "8px" }) },
|
|
28
|
+
label && orientation === 'horizontal' && (react_1.default.createElement(Typo2_1.UI_CAPTION_BOLD_DF, null, label)),
|
|
29
|
+
data.map(function (d, index) {
|
|
30
|
+
return (react_1.default.createElement("div", { key: index, style: { display: "flex", alignItems: "center", gap: "6px" } },
|
|
31
|
+
react_1.default.createElement(LegendTooltipGlyph_1.LegendTooltipGlyph, { color: d.color }),
|
|
32
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION_DF, null, d.text)));
|
|
33
|
+
}))));
|
|
34
|
+
};
|
|
35
|
+
exports.Legend = Legend;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LegendTooltipGlyph = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var LegendTooltipGlyph = function (_a) {
|
|
9
|
+
var color = _a.color, _b = _a.size, size = _b === void 0 ? 10 : _b;
|
|
10
|
+
return (react_1.default.createElement("div", { style: {
|
|
11
|
+
width: size + 'px',
|
|
12
|
+
height: size + 'px',
|
|
13
|
+
borderRadius: "50%",
|
|
14
|
+
backgroundColor: color,
|
|
15
|
+
} }));
|
|
16
|
+
};
|
|
17
|
+
exports.LegendTooltipGlyph = LegendTooltipGlyph;
|
|
@@ -18,6 +18,7 @@ export interface BarChartProps {
|
|
|
18
18
|
[key: string]: string;
|
|
19
19
|
};
|
|
20
20
|
tooltipLabelsPath: string | string[];
|
|
21
|
+
breakdownCategoryName?: string;
|
|
21
22
|
labelPath: string;
|
|
22
23
|
onClick?: (name: string) => void;
|
|
23
24
|
valueSuffix?: string;
|
|
@@ -26,6 +27,8 @@ export interface BarChartProps {
|
|
|
26
27
|
breakdownDisplayType?: BreakdownDisplayType;
|
|
27
28
|
colorIdx?: number;
|
|
28
29
|
summarizeAfterIdx?: number;
|
|
30
|
+
overflowAfterHeight?: number;
|
|
31
|
+
style?: React.CSSProperties;
|
|
29
32
|
}
|
|
30
33
|
export declare const BarChart: React.FC<BarChartProps>;
|
|
31
34
|
export {};
|
|
@@ -51,10 +51,11 @@ exports.BarChart = exports.useTrackMousePosition = void 0;
|
|
|
51
51
|
var react_1 = __importStar(require("react"));
|
|
52
52
|
var recharts_1 = require("recharts");
|
|
53
53
|
var CustomizedLabel_1 = require("./comps/CustomizedLabel");
|
|
54
|
-
var colors_1 = require("../../../themes/colors");
|
|
55
54
|
var CustomTooltip_1 = __importDefault(require("./comps/CustomTooltip"));
|
|
56
55
|
var usePrepareData_1 = require("../utils/usePrepareData");
|
|
57
56
|
var _base_barchart_ui_configs_1 = require("./_base_barchart_ui_configs");
|
|
57
|
+
var Legend_1 = require("./comps/Legend");
|
|
58
|
+
var __1 = require("../../../..");
|
|
58
59
|
var useTrackMousePosition = function () {
|
|
59
60
|
var _a = (0, react_1.useState)({
|
|
60
61
|
x: 0,
|
|
@@ -73,23 +74,39 @@ var useTrackMousePosition = function () {
|
|
|
73
74
|
return ({ mousePosition: mousePosition });
|
|
74
75
|
};
|
|
75
76
|
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
|
+
// 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
|
|
77
78
|
var CHART_OFFSET_TOP = _base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
78
79
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
79
80
|
(_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
|
|
81
|
+
var CHART_OFFSET_TOP_BREAKDOWN = _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.gapBetweenTwoLabels +
|
|
84
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight + //twice because the text and the percent are on separate lines
|
|
85
|
+
(_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
86
|
var TOT_HEIGHT_SINGLE_BAR_SECTION = _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
|
|
81
87
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
82
88
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
83
89
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap;
|
|
90
|
+
var TOT_HEIGHT_STACKED_BAR_SECTION = _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
|
|
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.gapBetweenTwoLabels +
|
|
94
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
95
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap;
|
|
84
96
|
var CALC_SINGLE_BAR_SECTION_Y_POS = function (index) {
|
|
85
97
|
return (TOT_HEIGHT_SINGLE_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) * index;
|
|
86
98
|
};
|
|
99
|
+
var CALC_STACKED_BAR_SECTION_Y_POS = function (index) {
|
|
100
|
+
return (TOT_HEIGHT_STACKED_BAR_SECTION + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections) * index;
|
|
101
|
+
};
|
|
87
102
|
var CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION = function (noOfBarsInGroup) {
|
|
88
103
|
var totalHeightOfAllBars = noOfBarsInGroup * _base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight +
|
|
89
104
|
(noOfBarsInGroup - 1) * _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup;
|
|
90
105
|
return (totalHeightOfAllBars +
|
|
91
106
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToBarGap +
|
|
92
107
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight +
|
|
108
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenTwoLabels +
|
|
109
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelHeight + //twice because the text and the percent are on separate lines
|
|
93
110
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.labelToNextBarGap);
|
|
94
111
|
};
|
|
95
112
|
var CALC_GROUPED_BAR_SECTION_Y_POS = function (index, barIndex, noOfBarsInGroup) {
|
|
@@ -100,15 +117,19 @@ var CALC_GROUPED_BAR_SECTION_Y_POS = function (index, barIndex, noOfBarsInGroup)
|
|
|
100
117
|
barIndex * (_base_barchart_ui_configs_1._base_barchart_ui_configs.barHeight + _base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarsInGroup));
|
|
101
118
|
};
|
|
102
119
|
var CALC_TOTAL_HEIGHT_OF_CHART = function (_a) {
|
|
103
|
-
var isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, data = _a.data;
|
|
120
|
+
var isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, data = _a.data, showSumOfBreakdownValues = _a.showSumOfBreakdownValues;
|
|
104
121
|
return isBreakdown && breakdownDisplayType === "grouped"
|
|
105
122
|
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length) *
|
|
106
123
|
data.length +
|
|
107
124
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
|
|
108
125
|
_base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2
|
|
109
|
-
:
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
: isBreakdown && breakdownDisplayType === 'stacked' && !showSumOfBreakdownValues
|
|
127
|
+
? (TOT_HEIGHT_STACKED_BAR_SECTION * data.length) +
|
|
128
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
|
|
129
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2
|
|
130
|
+
: TOT_HEIGHT_SINGLE_BAR_SECTION * data.length +
|
|
131
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.gapBetweenBarSections * (data.length - 1) +
|
|
132
|
+
_base_barchart_ui_configs_1._base_barchart_ui_configs.hoverRectStrokeWidth * 2;
|
|
112
133
|
};
|
|
113
134
|
var _debug_controls = {
|
|
114
135
|
mouseEventDetectorOpacity: 0, //only increase this for debugging. nothing else.
|
|
@@ -139,110 +160,157 @@ var barConfigs = {
|
|
|
139
160
|
},
|
|
140
161
|
};
|
|
141
162
|
var renderBar = function (_a) {
|
|
142
|
-
var _b = _a.stackIndex, stackIndex = _b === void 0 ? 0 : _b,
|
|
143
|
-
|
|
144
|
-
colorIdx = _a.colorIdx, showPercent = _a.showPercent, showCount = _a.showCount, activeBar = _a.activeBar, setActiveBar = _a.setActiveBar, onClick = _a.onClick;
|
|
145
|
-
var activeConfig = isBreakdownToRender
|
|
163
|
+
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;
|
|
164
|
+
var activeConfig = isBreakdown
|
|
146
165
|
? barConfigs.isBreakdown
|
|
147
166
|
: barConfigs.isNotBreakdown;
|
|
148
|
-
var totalStacks =
|
|
149
|
-
?
|
|
167
|
+
var totalStacks = isBreakdown
|
|
168
|
+
? data[0].length
|
|
150
169
|
: 1;
|
|
151
|
-
var currentStackId = activeConfig.getStackId(stackIndex,
|
|
152
|
-
return (react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex,
|
|
153
|
-
(!
|
|
154
|
-
|
|
155
|
-
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(
|
|
156
|
-
: undefined,
|
|
157
|
-
breakdownDisplayType: breakdownDisplayTypeToRender,
|
|
158
|
-
y: props.y,
|
|
170
|
+
var currentStackId = activeConfig.getStackId(stackIndex, breakdownDisplayType);
|
|
171
|
+
return (react_1.default.createElement(recharts_1.Bar, { key: "stack-".concat(stackIndex), radius: activeConfig.getBarRadius(stackIndex, breakdownDisplayType, totalStacks), dataKey: activeConfig.getDataKey(stackIndex), stackId: currentStackId },
|
|
172
|
+
(!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 &&
|
|
173
|
+
breakdownDisplayType === "grouped"
|
|
174
|
+
? CALC_TOTAL_HEIGHT_GROUPED_BAR_SECTION(data[0].length)
|
|
175
|
+
: undefined, breakdownDisplayType: breakdownDisplayType, y: props.y,
|
|
159
176
|
width: props.width,
|
|
160
177
|
height: props.height,
|
|
161
|
-
value:
|
|
162
|
-
?
|
|
178
|
+
value: isBreakdown
|
|
179
|
+
? data[props.index].map(function (item, idx) { return (__assign({}, item.labels)); })
|
|
163
180
|
: 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
|
|
164
181
|
? {
|
|
165
182
|
onMouseOver: function (e, value) {
|
|
166
|
-
setActiveBar(
|
|
167
|
-
?
|
|
183
|
+
setActiveBar(isBreakdown
|
|
184
|
+
? data[props.index][0].labels.name
|
|
168
185
|
: value.name);
|
|
169
186
|
},
|
|
170
|
-
onMouseOut: function () {
|
|
187
|
+
onMouseOut: function () {
|
|
188
|
+
setActiveBar(undefined);
|
|
189
|
+
},
|
|
171
190
|
onMouseDown: function (e, value) {
|
|
172
|
-
var name =
|
|
173
|
-
?
|
|
191
|
+
var name = isBreakdown
|
|
192
|
+
? data[props.index][0].labels.name
|
|
174
193
|
: value.name;
|
|
175
194
|
setActiveBar(name);
|
|
176
195
|
onClick(name);
|
|
177
196
|
},
|
|
178
197
|
}
|
|
179
198
|
: {})))); } })),
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
199
|
+
data.map(function (d, index) {
|
|
200
|
+
/**
|
|
201
|
+
* note this this map works differently for breakdown & not breakdown
|
|
202
|
+
* for not breakdown - this map renders each of the inidividual bars.
|
|
203
|
+
* for breakdown - this map renders each of the individual bar groups
|
|
204
|
+
*/
|
|
205
|
+
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
|
|
206
|
+
? CALC_SINGLE_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP
|
|
207
|
+
: (breakdownDisplayType === "stacked" && !showSumOfBreakdownValues) //show summ happens in the summarized bar, were we dont want the double label approach
|
|
208
|
+
? CALC_STACKED_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP_BREAKDOWN
|
|
209
|
+
: breakdownDisplayType === "grouped" &&
|
|
210
|
+
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
|
|
211
|
+
? d.labels.barColor
|
|
212
|
+
: d[stackIndex].labels.barColor }));
|
|
213
|
+
})));
|
|
214
|
+
};
|
|
215
|
+
var useDecideLegendOrientation = function (options) {
|
|
216
|
+
if (options === void 0) { options = {}; }
|
|
217
|
+
var _a = options.widthThreshold, widthThreshold = _a === void 0 ? 500 : _a;
|
|
218
|
+
var vizWrapperRef = (0, react_1.useRef)(null);
|
|
219
|
+
var _b = (0, react_1.useState)('horizontal'), orientation = _b[0], setOrientation = _b[1];
|
|
220
|
+
(0, react_1.useEffect)(function () {
|
|
221
|
+
var element = vizWrapperRef.current;
|
|
222
|
+
if (!element)
|
|
223
|
+
return;
|
|
224
|
+
var resizeObserver = new ResizeObserver(function (entries) {
|
|
225
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
226
|
+
var entry = entries_1[_i];
|
|
227
|
+
var width = entry.contentRect.width;
|
|
228
|
+
// If width is >= threshold, use horizontal, otherwise vertical
|
|
229
|
+
var newOrientation = width >= widthThreshold ? 'vertical' : 'horizontal';
|
|
230
|
+
setOrientation(newOrientation);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
resizeObserver.observe(element);
|
|
234
|
+
// Set initial orientation
|
|
235
|
+
var initialWidth = element.getBoundingClientRect().width;
|
|
236
|
+
setOrientation(initialWidth >= widthThreshold ? 'vertical' : 'horizontal');
|
|
237
|
+
// Cleanup
|
|
238
|
+
return function () {
|
|
239
|
+
resizeObserver.disconnect();
|
|
240
|
+
};
|
|
241
|
+
}, [widthThreshold]);
|
|
242
|
+
return {
|
|
243
|
+
vizWrapperRef: vizWrapperRef,
|
|
244
|
+
orientation: orientation
|
|
245
|
+
};
|
|
183
246
|
};
|
|
184
247
|
var BarChartRenderer = function (_a) {
|
|
185
|
-
var data = _a.data, isBreakdown = _a.isBreakdown, breakdownDisplayType = _a.breakdownDisplayType, showSumOfBreakdownValues = _a.showSumOfBreakdownValues,
|
|
248
|
+
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,
|
|
186
249
|
//
|
|
187
|
-
mousePosition = _a.mousePosition, dataMaxValue = _a.dataMaxValue,
|
|
188
|
-
return (
|
|
189
|
-
// <ResponsiveContainer width="100%" height="100%">
|
|
190
|
-
react_1.default.createElement(recharts_1.BarChart, { width: containerWidth, height: CALC_TOTAL_HEIGHT_OF_CHART({
|
|
250
|
+
mousePosition = _a.mousePosition, dataMaxValue = _a.dataMaxValue, breakdownCategoryName = _a.breakdownCategoryName;
|
|
251
|
+
return (react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: CALC_TOTAL_HEIGHT_OF_CHART({
|
|
191
252
|
isBreakdown: isBreakdown,
|
|
192
253
|
breakdownDisplayType: breakdownDisplayType,
|
|
254
|
+
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
193
255
|
data: data
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
256
|
+
}) },
|
|
257
|
+
react_1.default.createElement(recharts_1.BarChart, { data: data, layout: "vertical", margin: {
|
|
258
|
+
top: 0,
|
|
259
|
+
right: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginRight,
|
|
260
|
+
left: _base_barchart_ui_configs_1._base_barchart_ui_configs.marginLeft,
|
|
261
|
+
bottom: 0,
|
|
262
|
+
} },
|
|
263
|
+
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number", domain: [0, dataMaxValue] }),
|
|
264
|
+
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
265
|
+
isBreakdown && (react_1.default.createElement(recharts_1.Tooltip, { content: function (props) {
|
|
266
|
+
var _a;
|
|
267
|
+
return (react_1.default.createElement(CustomTooltip_1.default, __assign({}, props, { breakdownCategoryName: breakdownCategoryName, activeBar: activeBar, mousePosition: mousePosition, showPercent: showPercent,
|
|
268
|
+
// god knows why the dataindex gets stored against props.label.
|
|
269
|
+
// this is some internal recharts thing for tooltips specifically.
|
|
270
|
+
// we dont do this.
|
|
271
|
+
value: (_a = data[props.label]) === null || _a === void 0 ? void 0 : _a.map(function (item, idx) { return (__assign({}, item.labels)); }) })));
|
|
272
|
+
}, cursor: false, allowEscapeViewBox: { x: true, y: true } })),
|
|
273
|
+
isBreakdown
|
|
274
|
+
? data[0].map(function (_, stackIndex) {
|
|
275
|
+
//note that this map renders the individual bars within a breakdown group
|
|
276
|
+
return renderBar({
|
|
277
|
+
stackIndex: stackIndex,
|
|
278
|
+
data: data,
|
|
279
|
+
isBreakdown: isBreakdown,
|
|
280
|
+
breakdownDisplayType: breakdownDisplayType,
|
|
281
|
+
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
282
|
+
showPercent: showPercent,
|
|
283
|
+
showCount: showCount,
|
|
284
|
+
activeBar: activeBar,
|
|
285
|
+
setActiveBar: setActiveBar,
|
|
286
|
+
onClick: onClick,
|
|
287
|
+
});
|
|
288
|
+
})
|
|
289
|
+
: renderBar({
|
|
290
|
+
stackIndex: undefined,
|
|
214
291
|
data: data,
|
|
215
292
|
isBreakdown: isBreakdown,
|
|
216
293
|
breakdownDisplayType: breakdownDisplayType,
|
|
217
294
|
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
218
|
-
colorIdx: colorIdx,
|
|
219
295
|
showPercent: showPercent,
|
|
220
296
|
showCount: showCount,
|
|
221
297
|
activeBar: activeBar,
|
|
222
298
|
setActiveBar: setActiveBar,
|
|
223
299
|
onClick: onClick,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
isBreakdown: isBreakdown,
|
|
230
|
-
breakdownDisplayType: breakdownDisplayType,
|
|
231
|
-
showSumOfBreakdownValues: showSumOfBreakdownValues,
|
|
232
|
-
colorIdx: colorIdx,
|
|
233
|
-
showPercent: showPercent,
|
|
234
|
-
showCount: showCount,
|
|
235
|
-
activeBar: activeBar,
|
|
236
|
-
setActiveBar: setActiveBar,
|
|
237
|
-
onClick: onClick,
|
|
238
|
-
}))
|
|
239
|
-
// </ResponsiveContainer>
|
|
240
|
-
);
|
|
300
|
+
}))));
|
|
301
|
+
};
|
|
302
|
+
var FadeGradientWhenScroll = function (_a) {
|
|
303
|
+
var _b = _a.style, style = _b === void 0 ? {} : _b;
|
|
304
|
+
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) }));
|
|
241
305
|
};
|
|
242
306
|
var BarChart = function (_a) {
|
|
243
|
-
var _data = _a.data, valuePath = _a.valuePath,
|
|
307
|
+
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
|
|
308
|
+
_c = _a.labelPath, // basically, if lets say tagCat1 is broken down by tagCat2. then tagCat2's display would be this property
|
|
309
|
+
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, //if a number is defined, then from that 'index' onwards, bars will be compressed into a single bar with a tooltip explaining distribution
|
|
310
|
+
_j = _a.overflowAfterHeight, //if a number is defined, then from that 'index' onwards, bars will be compressed into a single bar with a tooltip explaining distribution
|
|
311
|
+
overflowAfterHeight = _j === void 0 ? 550 : _j;
|
|
244
312
|
var isBreakdown = Array.isArray(valuePath);
|
|
245
|
-
var
|
|
313
|
+
var _k = (0, usePrepareData_1.usePrepareData)({
|
|
246
314
|
_data: _data,
|
|
247
315
|
labelPath: labelPath,
|
|
248
316
|
valuePath: valuePath,
|
|
@@ -251,44 +319,29 @@ var BarChart = function (_a) {
|
|
|
251
319
|
isBreakdown: isBreakdown,
|
|
252
320
|
showPercent: showPercent,
|
|
253
321
|
summarizeAfterIdx: summarizeAfterIdx,
|
|
254
|
-
|
|
255
|
-
|
|
322
|
+
colorIdx: colorIdx
|
|
323
|
+
}), data = _k.data, dataMaxValue = _k.dataMaxValue, dataToSummarize = _k.dataToSummarize;
|
|
324
|
+
var _l = useDecideLegendOrientation({
|
|
325
|
+
widthThreshold: 500
|
|
326
|
+
}), vizWrapperRef = _l.vizWrapperRef, orientation = _l.orientation;
|
|
327
|
+
var _m = (0, react_1.useState)(undefined), activeBar = _m[0], setActiveBar = _m[1];
|
|
256
328
|
var mousePosition = (0, exports.useTrackMousePosition)().mousePosition;
|
|
257
329
|
// menu options for grouped and stacked
|
|
258
330
|
if (data.length === 0)
|
|
259
331
|
return react_1.default.createElement("div", null, "No data available");
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
(0, react_1.useEffect)(function () {
|
|
265
|
-
var updateWidth = function () {
|
|
266
|
-
if (containerRef.current) {
|
|
267
|
-
setContainerWidth(containerRef.current.getBoundingClientRect().width);
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
updateWidth();
|
|
271
|
-
window.addEventListener('resize', updateWidth);
|
|
272
|
-
return function () { return window.removeEventListener('resize', updateWidth); };
|
|
273
|
-
}, []);
|
|
274
|
-
return (react_1.default.createElement("div", { style: {
|
|
275
|
-
height: "".concat(CALC_TOTAL_HEIGHT_OF_CHART({
|
|
276
|
-
isBreakdown: isBreakdown,
|
|
277
|
-
breakdownDisplayType: breakdownDisplayType,
|
|
278
|
-
data: data
|
|
279
|
-
}) + (isBreakdown ? 0 : CALC_TOTAL_HEIGHT_OF_CHART({
|
|
280
|
-
isBreakdown: true,
|
|
281
|
-
breakdownDisplayType: 'stacked',
|
|
282
|
-
data: dataToSummarize
|
|
283
|
-
})), "px"),
|
|
284
|
-
width: "100%",
|
|
285
|
-
background: _debug_controls.chartWrapperBgColor,
|
|
286
|
-
} },
|
|
287
|
-
react_1.default.createElement("div", { ref: containerRef, style: { width: '100%', height: '100%' } },
|
|
288
|
-
react_1.default.createElement(BarChartRenderer, { containerWidth: containerWidth, data: data, isBreakdown: isBreakdown, breakdownDisplayType: breakdownDisplayType, showSumOfBreakdownValues: false, colorIdx: colorIdx, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue }),
|
|
289
|
-
dataToSummarize && (react_1.default.createElement(BarChartRenderer, { containerWidth: containerWidth, data: dataToSummarize,
|
|
332
|
+
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', maxHeight: overflowAfterHeight, overflow: 'scroll' }) },
|
|
333
|
+
react_1.default.createElement("div", { style: { flexGrow: 1, position: 'relative' } },
|
|
334
|
+
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, mousePosition: mousePosition, dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName }),
|
|
335
|
+
dataToSummarize && (react_1.default.createElement(BarChartRenderer, { data: dataToSummarize,
|
|
290
336
|
isBreakdown: true,
|
|
291
337
|
breakdownDisplayType: "stacked",
|
|
292
|
-
showSumOfBreakdownValues: true,
|
|
338
|
+
showSumOfBreakdownValues: true, showPercent: showPercent, showCount: showCount, activeBar: activeBar, setActiveBar: setActiveBar, onClick: onClick, mousePosition: mousePosition, dataMaxValue: dataMaxValue, breakdownCategoryName: breakdownCategoryName })),
|
|
339
|
+
orientation === 'vertical' && react_1.default.createElement(FadeGradientWhenScroll, null)),
|
|
340
|
+
isBreakdown && react_1.default.createElement("div", { style: __assign({ position: 'sticky' }, (orientation === 'vertical' ? { top: 0 } : { bottom: 0, background: __1.colors2.white })) },
|
|
341
|
+
orientation === 'horizontal' && react_1.default.createElement(FadeGradientWhenScroll, { style: { transform: 'translateY(-100%)', top: 0, bottom: 'unset', position: 'absolute', } }),
|
|
342
|
+
react_1.default.createElement(Legend_1.Legend, { orientation: orientation, label: breakdownCategoryName, data: data[0].map(function (d) { return ({
|
|
343
|
+
text: d.labels.tooltipLabel,
|
|
344
|
+
color: d.labels.barColor
|
|
345
|
+
}); }) }))));
|
|
293
346
|
};
|
|
294
347
|
exports.BarChart = BarChart;
|
|
@@ -10,11 +10,12 @@ interface PrepareDataParams {
|
|
|
10
10
|
};
|
|
11
11
|
tooltipLabelsPath: string | string[];
|
|
12
12
|
summarizeAfterIdx?: number;
|
|
13
|
+
colorIdx?: number;
|
|
13
14
|
}
|
|
14
15
|
interface PreparedData {
|
|
15
16
|
data: CountVizData;
|
|
16
17
|
dataToSummarize: CountVizData;
|
|
17
18
|
dataMaxValue: number;
|
|
18
19
|
}
|
|
19
|
-
export declare const usePrepareData: ({ _data, labelPath, valuePath, tooltipLabelsMapping, tooltipLabelsPath, isBreakdown, showPercent, summarizeAfterIdx, }: PrepareDataParams) => PreparedData;
|
|
20
|
+
export declare const usePrepareData: ({ _data, labelPath, valuePath, tooltipLabelsMapping, tooltipLabelsPath, isBreakdown, showPercent, summarizeAfterIdx, colorIdx }: PrepareDataParams) => PreparedData;
|
|
20
21
|
export {};
|