oolib 2.114.0 → 2.116.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/PercentBarChart/index.d.ts +4 -5
- package/dist/components/PercentBarChart/index.js +21 -13
- package/dist/stories/{PercentageBarChart.stories.js → PercentBarChart.stories.js} +1 -2
- package/package.json +1 -1
- /package/dist/stories/{PercentageBarChart.stories.d.ts → PercentBarChart.stories.d.ts} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const PercentBarChart: ({ data: _data, valuePath, display,
|
|
2
|
+
export declare const PercentBarChart: ({ data: _data, title, valuePath, display, onClick, colors }: {
|
|
3
3
|
data: any;
|
|
4
4
|
valuePath: string;
|
|
5
|
+
title?: string;
|
|
5
6
|
display: string;
|
|
6
|
-
|
|
7
|
-
colors?:
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
7
|
+
onClick?: (name: string) => void;
|
|
8
|
+
colors?: string[];
|
|
10
9
|
}) => React.JSX.Element;
|
|
@@ -46,16 +46,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
46
|
exports.PercentBarChart = void 0;
|
|
47
47
|
var react_1 = __importStar(require("react"));
|
|
48
48
|
var recharts_1 = require("recharts");
|
|
49
|
+
var Typo_1 = require("../Typo");
|
|
50
|
+
var colors_1 = require("../../themes/colors");
|
|
51
|
+
var chartColors = [
|
|
52
|
+
"#F53D65",
|
|
53
|
+
"#666666",
|
|
54
|
+
"#EBAF4D",
|
|
55
|
+
"#0ACC22",
|
|
56
|
+
"#E60000",
|
|
57
|
+
"#66DAB0",
|
|
58
|
+
"#6A2B99",
|
|
59
|
+
"#ff836d",
|
|
60
|
+
"#b4a8d0",
|
|
61
|
+
"#ff7167",
|
|
62
|
+
];
|
|
49
63
|
var renderCustomizedLabel = function (_a) {
|
|
50
64
|
var y = _a.y, value = _a.value, opacity = _a.opacity;
|
|
51
65
|
var offset = 12;
|
|
52
|
-
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, x: 0, y: y - offset, fill: "black", textAnchor: "start", dominantBaseline: "middle" }, value));
|
|
66
|
+
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, x: 0, y: y - offset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: 'SANS_2' }, value));
|
|
53
67
|
};
|
|
54
68
|
var renderCustomizedValue = function (_a) {
|
|
55
69
|
var y = _a.y, width = _a.width, height = _a.height, value = _a.value, suffix = _a.suffix, opacity = _a.opacity;
|
|
56
70
|
var xOffset = 6;
|
|
57
71
|
var yOffset = 2;
|
|
58
|
-
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle" }, "".concat(value).concat(suffix || "")));
|
|
72
|
+
return (react_1.default.createElement("text", { opacity: opacity, fontSize: 14, fontWeight: "600", x: width + xOffset, y: y + height / 2 + yOffset, fill: "black", textAnchor: "start", dominantBaseline: "middle", className: 'SANS_2' }, "".concat(value).concat(suffix || "")));
|
|
59
73
|
};
|
|
60
74
|
var _dataSample = [
|
|
61
75
|
{ name: "AAA/A1+", value: 72.3, Type: 0 },
|
|
@@ -64,27 +78,21 @@ var _dataSample = [
|
|
|
64
78
|
{ name: "AA+", value: 5.63, Type: 3 },
|
|
65
79
|
];
|
|
66
80
|
var PercentBarChart = function (_a) {
|
|
67
|
-
var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, _d = _a.display, display = _d === void 0 ? "name" : _d,
|
|
68
|
-
hoverInvertRed: '#FBC3C3',
|
|
69
|
-
yellow: '#FFCC00',
|
|
70
|
-
green: '#08A84B',
|
|
71
|
-
blue: '#33A4FF'
|
|
72
|
-
} : _e;
|
|
81
|
+
var _b = _a.data, _data = _b === void 0 ? _dataSample : _b, title = _a.title, _c = _a.valuePath, valuePath = _c === void 0 ? "value" : _c, _d = _a.display, display = _d === void 0 ? "name" : _d, onClick = _a.onClick, _e = _a.colors, colors = _e === void 0 ? chartColors : _e;
|
|
73
82
|
var data = (0, react_1.useMemo)(function () {
|
|
74
83
|
var finalData = __spreadArray([], _data, true);
|
|
75
|
-
finalData = finalData.map(function (d, i) { return (__assign(__assign({}, d), { value: d[valuePath], name: d[display], color:
|
|
76
|
-
// console.log({ finalData })
|
|
84
|
+
finalData = finalData.map(function (d, i) { return (__assign(__assign({}, d), { value: d[valuePath], name: d[display], color: (colors)[i % (colors).length] })); });
|
|
77
85
|
finalData.sort(function (a, b) {
|
|
78
86
|
return Number(b.value || 0) - Number(a.value || 0);
|
|
79
87
|
});
|
|
80
88
|
return finalData;
|
|
81
89
|
}, [_data, display, valuePath]);
|
|
82
90
|
var _f = (0, react_1.useState)(undefined), activeBar = _f[0], setActiveBar = _f[1];
|
|
83
|
-
// console.log({ activeBar });
|
|
84
91
|
var changeBarOpacityFn = function (name) {
|
|
85
92
|
return activeBar && activeBar !== name ? 0.4 : 1;
|
|
86
93
|
};
|
|
87
|
-
return (react_1.default.createElement("div", { style: { height: "".concat(80 * data.length, "px"), width: "100%" } },
|
|
94
|
+
return (react_1.default.createElement("div", { style: { height: "".concat(80 * data.length, "px"), width: "100%", border: "1px solid ".concat(colors_1.colors.greyColor15), padding: "3rem 2rem" } },
|
|
95
|
+
title && react_1.default.createElement(Typo_1.SANS_4_5, { style: { marginBottom: "1.5rem", marginTop: "-1rem" }, semibold: true }, title),
|
|
88
96
|
react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
|
|
89
97
|
react_1.default.createElement(recharts_1.BarChart, { width: 500, height: 500, data: data, layout: "vertical", margin: {
|
|
90
98
|
top: 15,
|
|
@@ -96,7 +104,7 @@ var PercentBarChart = function (_a) {
|
|
|
96
104
|
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category", width: 250, dataKey: display }),
|
|
97
105
|
react_1.default.createElement(recharts_1.Bar, { style: { cursor: "pointer" }, dataKey: "value", unit: "%", onMouseOver: function (args) { return setActiveBar(args[display]); }, onMouseOut: function () { return setActiveBar(undefined); }, onMouseDown: function (args) {
|
|
98
106
|
setActiveBar(args[display]);
|
|
99
|
-
|
|
107
|
+
onClick(args[display]);
|
|
100
108
|
} },
|
|
101
109
|
react_1.default.createElement(recharts_1.LabelList, { dataKey: display, position: "top", content: function (props) {
|
|
102
110
|
return renderCustomizedLabel({
|
|
@@ -9,7 +9,6 @@ var PercentBarChart_1 = require("../components/PercentBarChart");
|
|
|
9
9
|
exports.default = {
|
|
10
10
|
title: "Components/PercentBarChart",
|
|
11
11
|
};
|
|
12
|
-
var uid = 0;
|
|
13
12
|
var data = [
|
|
14
13
|
{ name: 'AAA/A1+', value: 72.3, Type: 0 },
|
|
15
14
|
{ name: 'Cash & Cash Equivalents', value: 10.1, Type: 1 },
|
|
@@ -21,6 +20,6 @@ var PercentBarChart_ = function (args) {
|
|
|
21
20
|
console.log("Bar clicked: ".concat(name));
|
|
22
21
|
};
|
|
23
22
|
return (react_1.default.createElement("div", null,
|
|
24
|
-
react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data, valuePath: "value",
|
|
23
|
+
react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data, display: "name", valuePath: "value", title: "This is PercentBarChart representing the data", onClick: handleBarClick })));
|
|
25
24
|
};
|
|
26
25
|
exports.PercentBarChart_ = PercentBarChart_;
|
package/package.json
CHANGED
|
File without changes
|