oolib 2.156.0 → 2.157.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/custom/index.d.ts +1 -0
- package/dist/icons/custom/index.js +13 -1
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -4
- package/dist/stories/v2/components/BarChart.stories.js +3 -3
- package/dist/v2/components/BarChart/comps/CustomizedLabel/index.d.ts +1 -2
- package/dist/v2/components/BarChart/comps/CustomizedLabel/index.js +30 -6
- package/dist/v2/components/BarChart/comps/TruncatedSVGText/index.d.ts +7 -0
- package/dist/v2/components/BarChart/comps/TruncatedSVGText/index.js +56 -0
- package/dist/v2/components/BarChart/index.d.ts +1 -1
- package/dist/v2/components/BarChart/index.js +8 -9
- package/dist/v2/components/DataVizAccordion/index.d.ts +11 -4
- package/dist/v2/components/DataVizAccordion/index.js +6 -9
- package/dist/v2/themes/colors.d.ts +1 -0
- package/dist/v2/themes/colors.js +11 -15
- package/package.json +1 -1
- package/dist/components/PercentBarChart/comps/CustomizedLabel/index.d.ts +0 -20
- package/dist/components/PercentBarChart/comps/CustomizedLabel/index.js +0 -30
- package/dist/components/PercentBarChart/index.d.ts +0 -22
- package/dist/components/PercentBarChart/index.js +0 -153
- package/dist/stories/Oolib/components/PercentBarChart.stories.d.ts +0 -6
- package/dist/stories/Oolib/components/PercentBarChart.stories.js +0 -25
|
@@ -64,6 +64,7 @@ export declare const ChileFlag: (props: any) => React.JSX.Element;
|
|
|
64
64
|
export declare const PakistanFlag: (props: any) => React.JSX.Element;
|
|
65
65
|
export declare const SpainFlag: (props: any) => React.JSX.Element;
|
|
66
66
|
export declare const Stars: (props: any) => React.JSX.Element;
|
|
67
|
+
export declare const ArgentinaFlag: (props: any) => React.JSX.Element;
|
|
67
68
|
export declare const Celebrate: (props: any) => React.JSX.Element;
|
|
68
69
|
export declare const Inspiring: (props: any) => React.JSX.Element;
|
|
69
70
|
export declare const Learning: (props: any) => React.JSX.Element;
|
|
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.UKFlag = exports.MalaysiaFlag = exports.ColombiaFlag = exports.BrazilFlag = exports.AudioEmbedIcon = exports.VideoEmbedIcon = exports.Attachment2 = exports.PDFIcon = exports.RichFormatToolOrderedList = exports.RichFormatToolUnorderedList = exports.RichFormatToolH2 = exports.RichFormatToolBlockquote = exports.LinkIcon = exports.UnderlineBtn = exports.ItalicBtn = exports.BoldBtn = exports.SettingsSM = exports.Close_S = exports.UploadImage = exports.KebabMenu = exports.Website_solid_SM = exports.Phone_solid_SM = exports.Mail_solid_SM = exports.Youtube_solid_SM = exports.Instagram_solid_SM = exports.Twitter_solid_SM = exports.Linkedin_solid_SM = exports.Facebook_solid_SM = exports.EditSM = exports.AddXS = exports.UploadSM = exports.Download = exports.Download__nofill = exports.Index = exports.Person14 = exports.Location14 = exports.ModalBulbIcon = exports.SenegalFlag = exports.KenyaFlag = exports.NigeriaFlag = exports.IndiaFlag = exports.BadgeVetted = exports.BadgeMod = exports.BadgeSuperAdmin = exports.BadgeAdmin = exports.OkeGoogleIcon = exports.LetterH = exports.LanguageIcon = exports.MultipleImages = exports.IndexIcon = void 0;
|
|
18
|
-
exports.WarningDiamond = exports.Reactions = exports.Like = exports.Learning = exports.Inspiring = exports.Celebrate = exports.Stars = exports.SpainFlag = exports.PakistanFlag = exports.ChileFlag = exports.IndonesiaFlag = exports.USAFlag = void 0;
|
|
18
|
+
exports.WarningDiamond = exports.Reactions = exports.Like = exports.Learning = exports.Inspiring = exports.Celebrate = exports.ArgentinaFlag = exports.Stars = exports.SpainFlag = exports.PakistanFlag = exports.ChileFlag = exports.IndonesiaFlag = exports.USAFlag = void 0;
|
|
19
19
|
var react_1 = __importDefault(require("react"));
|
|
20
20
|
var themes_1 = require("../../themes");
|
|
21
21
|
var DisplayIcon_1 = require("../../utils/comps/DisplayIcon");
|
|
@@ -438,6 +438,18 @@ var Stars = function (props) {
|
|
|
438
438
|
react_1.default.createElement("path", { fill: "#000", d: "M17.027 11.35 12.19 9.562l-1.78-4.84a1.493 1.493 0 0 0-2.802 0l-1.793 4.84-4.84 1.78a1.492 1.492 0 0 0 0 2.802l4.84 1.793 1.782 4.839a1.493 1.493 0 0 0 2.8 0l1.793-4.84 4.84-1.78a1.492 1.492 0 0 0 0-2.802l-.004-.006Zm-5.68 3.296a.75.75 0 0 0-.444.444l-1.9 5.146-1.895-5.142a.75.75 0 0 0-.448-.448L1.518 12.75l5.142-1.896a.75.75 0 0 0 .448-.448l1.896-5.142 1.895 5.142a.75.75 0 0 0 .445.445l5.146 1.899-5.142 1.896ZM12.005 3a.75.75 0 0 1 .75-.75h1.5V.75a.75.75 0 1 1 1.5 0v1.5h1.5a.75.75 0 1 1 0 1.5h-1.5v1.5a.75.75 0 1 1-1.5 0v-1.5h-1.5a.75.75 0 0 1-.75-.75Zm9.75 4.5a.75.75 0 0 1-.75.75h-.75V9a.75.75 0 1 1-1.5 0v-.75h-.75a.75.75 0 1 1 0-1.5h.75V6a.75.75 0 1 1 1.5 0v.75h.75a.75.75 0 0 1 .75.75Z" })));
|
|
439
439
|
};
|
|
440
440
|
exports.Stars = Stars;
|
|
441
|
+
var ArgentinaFlag = function (props) {
|
|
442
|
+
return (react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: props.size || 30, height: props.size || 30, viewBox: "0 0 40 25", fill: "none" },
|
|
443
|
+
react_1.default.createElement("g", { "clip-path": "url(#clip0_4586_13270)" },
|
|
444
|
+
react_1.default.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M0 17C0 19.8003 0 21.2004 0.544967 22.27C1.02433 23.2108 1.78924 23.9757 2.73005 24.455C3.79961 25 5.19974 25 8 25H32C34.8003 25 36.2004 25 37.27 24.455C38.2108 23.9757 38.9757 23.2108 39.455 22.27C40 21.2004 40 19.8003 40 17V8C40 5.19974 40 3.79961 39.455 2.73005C38.9757 1.78924 38.2108 1.02433 37.27 0.544967C36.2004 0 34.8003 0 32 0H8C5.19974 0 3.79961 0 2.73005 0.544967C1.78924 1.02433 1.02433 1.78924 0.544967 2.73005C0 3.79961 0 5.19974 0 8V17Z", fill: "#74ACDF" }),
|
|
445
|
+
react_1.default.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M0 17H40V8H0V17Z", fill: "white" }),
|
|
446
|
+
react_1.default.createElement("path", { d: "M24 12.5C24 14.9853 22.2091 16.5 20 16.5C17.7909 16.5 16 14.9853 16 12.5C16 10.0147 17.7909 8.5 20 8.5C22.2091 8.5 24 10.0147 24 12.5Z", fill: "#FFE298" }),
|
|
447
|
+
react_1.default.createElement("path", { d: "M22.5 12.5C22.5 14.0533 21.3807 15 20 15C18.6193 15 17.5 14.0533 17.5 12.5C17.5 10.9467 18.6193 10 20 10C21.3807 10 22.5 10.9467 22.5 12.5Z", fill: "#DEA108" })),
|
|
448
|
+
react_1.default.createElement("defs", null,
|
|
449
|
+
react_1.default.createElement("clipPath", { id: "clip0_4586_13270" },
|
|
450
|
+
react_1.default.createElement("rect", { width: "40", height: "25", fill: "white" })))));
|
|
451
|
+
};
|
|
452
|
+
exports.ArgentinaFlag = ArgentinaFlag;
|
|
441
453
|
// reactions
|
|
442
454
|
var Celebrate = function (props) {
|
|
443
455
|
return (react_1.default.createElement("svg", { width: props.size || 30, height: props.size || 30, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -165,6 +165,7 @@ export namespace icons {
|
|
|
165
165
|
export { VideoEmbedIcon };
|
|
166
166
|
export { AudioEmbedIcon };
|
|
167
167
|
export { IndonesiaFlag };
|
|
168
|
+
export { ArgentinaFlag };
|
|
168
169
|
export { USAFlag };
|
|
169
170
|
export { UKFlag };
|
|
170
171
|
export { MalaysiaFlag };
|
|
@@ -347,6 +348,7 @@ import { Attachment2 } from "./custom";
|
|
|
347
348
|
import { VideoEmbedIcon } from "./custom";
|
|
348
349
|
import { AudioEmbedIcon } from "./custom";
|
|
349
350
|
import { IndonesiaFlag } from "./custom";
|
|
351
|
+
import { ArgentinaFlag } from "./custom";
|
|
350
352
|
import { USAFlag } from "./custom";
|
|
351
353
|
import { UKFlag } from "./custom";
|
|
352
354
|
import { MalaysiaFlag } from "./custom";
|
package/dist/icons/index.js
CHANGED
|
@@ -171,6 +171,7 @@ exports.icons = {
|
|
|
171
171
|
VideoEmbedIcon: custom_1.VideoEmbedIcon,
|
|
172
172
|
AudioEmbedIcon: custom_1.AudioEmbedIcon,
|
|
173
173
|
IndonesiaFlag: custom_1.IndonesiaFlag,
|
|
174
|
+
ArgentinaFlag: custom_1.ArgentinaFlag,
|
|
174
175
|
USAFlag: custom_1.USAFlag,
|
|
175
176
|
UKFlag: custom_1.UKFlag,
|
|
176
177
|
MalaysiaFlag: custom_1.MalaysiaFlag,
|
package/dist/index.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export { Tooltip } from "./components/Tooltip";
|
|
|
32
32
|
export { ActionMenu } from "./components/ActionMenu";
|
|
33
33
|
export { Accordion } from "./components/Accordion";
|
|
34
34
|
export { PercentCompletedPie } from "./components/PercentCompletedPie";
|
|
35
|
-
export { PercentBarChart } from "./components/PercentBarChart";
|
|
36
35
|
export { Divider } from "./components/Divider";
|
|
37
36
|
export { SkeletonLoader } from "./components/LoadersAndProgress/SkeletonLoader";
|
|
38
37
|
export { ModalConfirm } from "./components/Modals/ModalConfirm";
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ResourceInput = exports.IFrameInput = exports.PDFInput = exports.AudioInput = exports.VideoInput = exports.ProfileImageInput = exports.ImageInput = exports.MetaBlock = exports.genTagComp = exports.generateOptions = exports.OptionsSingle = exports.DropdownMulti = exports.DropdownSingle = exports.parseCardConfig = exports.ListProfile = exports.CardProfile = exports.CardEmbed = exports.DataVizAccordion = exports.BarChart = exports.DateTimeRangePicker = exports.DateTimePicker = exports.TimeRangePicker = exports.TimePicker = exports.DateRangePicker = exports.DatePicker = exports.TextLoader = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.Modal = exports.ModalForms = exports.ModalConfirm = exports.SkeletonLoader = exports.Divider = exports.
|
|
21
|
-
exports.HintsProvider = exports.colors2 = exports.TableCellResizerPlugin = exports.styledOKELinkCSS = exports.SimpleTable = exports.ModalConfirmAction = exports.BannerProvider = exports.useBannerContext = exports.BannerContext = exports.BannerInfo = exports.BannerAlert =
|
|
20
|
+
exports.GroupQuestionsInputSingle = exports.ResourceInput = exports.IFrameInput = exports.PDFInput = exports.AudioInput = exports.VideoInput = exports.ProfileImageInput = exports.ImageInput = exports.MetaBlock = exports.genTagComp = exports.generateOptions = exports.OptionsSingle = exports.DropdownMulti = exports.DropdownSingle = exports.parseCardConfig = exports.ListProfile = exports.CardProfile = exports.CardEmbed = exports.DataVizAccordion = exports.BarChart = exports.DateTimeRangePicker = exports.DateTimePicker = exports.TimeRangePicker = exports.TimePicker = exports.DateRangePicker = exports.DatePicker = exports.TextLoader = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.Modal = exports.ModalForms = exports.ModalConfirm = exports.SkeletonLoader = exports.Divider = exports.PercentCompletedPie = exports.Accordion = exports.ActionMenu = exports.Tooltip = exports.OKELink = exports.UserRoleBadge = exports.Section = exports.LoaderOverlay = exports.Loader = exports.ProgressBar = exports.LoaderCircle = exports.icons = exports.colors = exports.GlobalStyles = void 0;
|
|
21
|
+
exports.HintsProvider = exports.colors2 = exports.TableCellResizerPlugin = exports.styledOKELinkCSS = exports.SimpleTable = exports.ModalConfirmAction = exports.BannerProvider = exports.useBannerContext = exports.BannerContext = exports.BannerInfo = exports.BannerAlert = void 0;
|
|
22
22
|
//css and styling related ( styled-components )
|
|
23
23
|
var globalStyles_1 = require("./globalStyles");
|
|
24
24
|
Object.defineProperty(exports, "GlobalStyles", { enumerable: true, get: function () { return globalStyles_1.GlobalStyles; } });
|
|
@@ -64,8 +64,6 @@ var Accordion_1 = require("./components/Accordion");
|
|
|
64
64
|
Object.defineProperty(exports, "Accordion", { enumerable: true, get: function () { return Accordion_1.Accordion; } });
|
|
65
65
|
var PercentCompletedPie_1 = require("./components/PercentCompletedPie");
|
|
66
66
|
Object.defineProperty(exports, "PercentCompletedPie", { enumerable: true, get: function () { return PercentCompletedPie_1.PercentCompletedPie; } });
|
|
67
|
-
var PercentBarChart_1 = require("./components/PercentBarChart");
|
|
68
|
-
Object.defineProperty(exports, "PercentBarChart", { enumerable: true, get: function () { return PercentBarChart_1.PercentBarChart; } });
|
|
69
67
|
var Divider_1 = require("./components/Divider");
|
|
70
68
|
Object.defineProperty(exports, "Divider", { enumerable: true, get: function () { return Divider_1.Divider; } });
|
|
71
69
|
var SkeletonLoader_1 = require("./components/LoadersAndProgress/SkeletonLoader");
|
|
@@ -129,7 +129,7 @@ var BarChart = function (args) {
|
|
|
129
129
|
// valuePath="stack1"
|
|
130
130
|
labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
|
|
131
131
|
// showPercent={true}
|
|
132
|
-
colorIdx:
|
|
132
|
+
colorIdx: 2 })),
|
|
133
133
|
react_1.default.createElement("div", null,
|
|
134
134
|
react_1.default.createElement("div", { style: { display: "flex", flexDirection: "column", gap: "40px" } },
|
|
135
135
|
react_1.default.createElement(BarChart_1.BarChart, { data: [
|
|
@@ -192,7 +192,7 @@ var BarChart = function (args) {
|
|
|
192
192
|
// valuePath={["stack1", "stack2", "stack3", "stack4", "stack5", "stack6"]}
|
|
193
193
|
valuePath: "stack1", labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
|
|
194
194
|
// showPercent={true}
|
|
195
|
-
colorIdx:
|
|
195
|
+
colorIdx: 2 }),
|
|
196
196
|
react_1.default.createElement(BarChart_1.BarChart, { data: [
|
|
197
197
|
{
|
|
198
198
|
display: "Logged In Once",
|
|
@@ -260,6 +260,6 @@ var BarChart = function (args) {
|
|
|
260
260
|
// valuePath="stack1"
|
|
261
261
|
breakdownDisplayType: "stacked", labelPath: "display", title: "This is a Stacked BarChart", onClick: handleBarClick,
|
|
262
262
|
// showPercent={true}
|
|
263
|
-
colorIdx:
|
|
263
|
+
colorIdx: 2 })))));
|
|
264
264
|
};
|
|
265
265
|
exports.BarChart = BarChart;
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.CustomizedLabel = void 0;
|
|
7
|
-
var react_1 =
|
|
27
|
+
var react_1 = __importStar(require("react"));
|
|
8
28
|
var themes_1 = require("../../../../themes");
|
|
9
29
|
var colors_1 = require("../../../../themes/colors");
|
|
30
|
+
var TruncatedSVGText_1 = require("../TruncatedSVGText");
|
|
10
31
|
var CustomizedLabel = function (_a) {
|
|
11
32
|
var y = _a.y, width = _a.width, height = _a.height, value = _a.value, showPercent = _a.showPercent, showCount = _a.showCount, opacity = _a.opacity, _base_configs = _a._base_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;
|
|
12
33
|
if (!value)
|
|
@@ -37,12 +58,15 @@ var CustomizedLabel = function (_a) {
|
|
|
37
58
|
return value.count;
|
|
38
59
|
}
|
|
39
60
|
};
|
|
61
|
+
var widthRef = (0, react_1.useRef)(null);
|
|
62
|
+
var textContainerRef = (0, react_1.useRef)(null);
|
|
40
63
|
return (react_1.default.createElement("g", null,
|
|
41
|
-
react_1.default.createElement("text", { opacity: opacity, x: _base_configs.marginLeft, dy: y - (_base_configs.labelToBarGap), fill: themes_1.colors.grey80, textAnchor: "start", className: "UI_BODY_BOLD_SM" },
|
|
64
|
+
react_1.default.createElement("text", { ref: textContainerRef, opacity: opacity, x: _base_configs.marginLeft, dy: y - (_base_configs.labelToBarGap), fill: themes_1.colors.grey80, textAnchor: "start", className: "UI_BODY_BOLD_SM" },
|
|
42
65
|
formatValue(),
|
|
43
66
|
showPercent && !isBreakdown && (react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 }, getCount())),
|
|
44
|
-
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 },
|
|
45
|
-
|
|
67
|
+
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, fill: themes_1.colors.grey80 },
|
|
68
|
+
react_1.default.createElement(TruncatedSVGText_1.TruncatedSVGText, { text: name, textContainerRef: textContainerRef, widthRef: widthRef, widthOffset: -(_base_configs.marginLeft + _base_configs.marginRight) }))),
|
|
69
|
+
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_configs.hoverRectStrokeWidth, y: (!isBreakdown || breakdownDisplayType === 'stacked')
|
|
46
70
|
? _base_configs.hoverRectStrokeWidth + CALC_SINGLE_BAR_SECTION_Y_POS(value.dataIndex)
|
|
47
71
|
: _base_configs.hoverRectStrokeWidth + (TOT_HEIGHT_GROUPED_BAR_SECTION + _base_configs.gapBetweenBarSections) * value[0].dataIndex, width: "calc(100% - ".concat(_base_configs.hoverRectStrokeWidth * 2, "px)"), height: (!isBreakdown || breakdownDisplayType === 'stacked') ? TOT_HEIGHT_SINGLE_BAR_SECTION : TOT_HEIGHT_GROUPED_BAR_SECTION, opacity: _debug_controls.mouseEventDetectorOpacity ||
|
|
48
72
|
(activeBar === name ? 1 : 0), stroke: colors_1.colors.grey30, rx: 5, ry: 5, strokeWidth: "".concat(_base_configs.hoverRectStrokeWidth, "px"), fillOpacity: _debug_controls.mouseEventDetectorOpacity })));
|
|
@@ -0,0 +1,56 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TruncatedSVGText = void 0;
|
|
27
|
+
var react_1 = __importStar(require("react"));
|
|
28
|
+
var TruncatedSVGText = function (_a) {
|
|
29
|
+
var _b;
|
|
30
|
+
var text = _a.text, textContainerRef = _a.textContainerRef, widthRef = _a.widthRef, _c = _a.widthOffset, widthOffset = _c === void 0 ? 0 : _c;
|
|
31
|
+
var textRef = (0, react_1.useRef)(null);
|
|
32
|
+
var _d = (0, react_1.useState)(false), isTextTruncated = _d[0], setIsTextTruncated = _d[1];
|
|
33
|
+
(0, react_1.useEffect)(function () {
|
|
34
|
+
var truncateText = function () {
|
|
35
|
+
var _a;
|
|
36
|
+
var element = textRef.current;
|
|
37
|
+
if (!element)
|
|
38
|
+
return;
|
|
39
|
+
var currentText = text;
|
|
40
|
+
var textWidth = textContainerRef.current.getComputedTextLength();
|
|
41
|
+
var totWidth = ((_a = widthRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) + widthOffset;
|
|
42
|
+
// Check if truncation is needed
|
|
43
|
+
if (textWidth > totWidth) {
|
|
44
|
+
setIsTextTruncated(true);
|
|
45
|
+
while (textWidth > totWidth && currentText.length > 0) {
|
|
46
|
+
currentText = currentText.slice(0, -1);
|
|
47
|
+
element.textContent = currentText + '...';
|
|
48
|
+
textWidth = textContainerRef.current.getComputedTextLength();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
truncateText();
|
|
53
|
+
}, [text, (_b = widthRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().width]);
|
|
54
|
+
return (react_1.default.createElement("tspan", { ref: textRef, onMouseOver: function () { return console.log(text); } }, text));
|
|
55
|
+
};
|
|
56
|
+
exports.TruncatedSVGText = TruncatedSVGText;
|
|
@@ -9,7 +9,6 @@ export interface BaseConfigs {
|
|
|
9
9
|
hoverRectStrokeWidth: number;
|
|
10
10
|
marginLeft: number;
|
|
11
11
|
marginRight: number;
|
|
12
|
-
startingColorIdx: number;
|
|
13
12
|
gapBetweenBarsInGroup: number;
|
|
14
13
|
}
|
|
15
14
|
export interface DebugControls {
|
|
@@ -25,5 +24,6 @@ export interface BarChartProps {
|
|
|
25
24
|
showCount?: boolean;
|
|
26
25
|
showPercent?: boolean;
|
|
27
26
|
breakdownDisplayType?: "grouped" | "stacked";
|
|
27
|
+
colorIdx?: number;
|
|
28
28
|
}
|
|
29
29
|
export declare const BarChart: React.FC<BarChartProps>;
|
|
@@ -120,7 +120,6 @@ var _base_configs = {
|
|
|
120
120
|
//overall chart margin
|
|
121
121
|
marginLeft: 6,
|
|
122
122
|
marginRight: 6,
|
|
123
|
-
startingColorIdx: 0, //this defines the idx in dataVizColors, from where color values should start being used.
|
|
124
123
|
//grouped bar chart related properties
|
|
125
124
|
gapBetweenBarsInGroup: 3,
|
|
126
125
|
};
|
|
@@ -169,21 +168,21 @@ var barConfigs = {
|
|
|
169
168
|
getDataKey: function (stackIndex) { return "".concat(stackIndex, ".labels.count"); },
|
|
170
169
|
getStackId: function (stackIndex, breakdownDisplayType //replaced breakdownDisplayType
|
|
171
170
|
) { return (breakdownDisplayType === "stacked" ? "stack" : "stack-".concat(stackIndex)); },
|
|
172
|
-
getCellFill: function (stackIndex, dataVizColors) {
|
|
173
|
-
return dataVizColors[(
|
|
171
|
+
getCellFill: function (colorIdx, stackIndex, dataVizColors) {
|
|
172
|
+
return dataVizColors[(colorIdx + stackIndex) % dataVizColors.length];
|
|
174
173
|
},
|
|
175
174
|
},
|
|
176
175
|
isNotBreakdown: {
|
|
177
176
|
getBarRadius: function () { return _base_configs.barRadius; },
|
|
178
177
|
getDataKey: function () { return "labels.count"; },
|
|
179
178
|
getStackId: function () { return undefined; },
|
|
180
|
-
getCellFill: function (_stackIndex, dataVizColors) {
|
|
181
|
-
return dataVizColors[
|
|
179
|
+
getCellFill: function (colorIdx, _stackIndex, dataVizColors) {
|
|
180
|
+
return dataVizColors[colorIdx];
|
|
182
181
|
},
|
|
183
182
|
},
|
|
184
183
|
};
|
|
185
184
|
var BarChart = function (_a) {
|
|
186
|
-
var _data = _a.data, valuePath = _a.valuePath, _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 ?
|
|
185
|
+
var _data = _a.data, valuePath = _a.valuePath, _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;
|
|
187
186
|
var isBreakdown = Array.isArray(valuePath);
|
|
188
187
|
var data = usePrepareData({
|
|
189
188
|
_data: _data,
|
|
@@ -192,7 +191,7 @@ var BarChart = function (_a) {
|
|
|
192
191
|
isBreakdown: isBreakdown,
|
|
193
192
|
showPercent: showPercent
|
|
194
193
|
});
|
|
195
|
-
var
|
|
194
|
+
var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
|
|
196
195
|
// menu options for grouped and stacked
|
|
197
196
|
var renderBar = function (stackIndex, lastIndex) {
|
|
198
197
|
if (stackIndex === void 0) { stackIndex = 0; }
|
|
@@ -209,7 +208,7 @@ var BarChart = function (_a) {
|
|
|
209
208
|
width: props.width,
|
|
210
209
|
height: props.height,
|
|
211
210
|
value: isBreakdown
|
|
212
|
-
? data[props.index].map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.
|
|
211
|
+
? data[props.index].map(function (item, idx) { return (__assign(__assign({}, item.labels), { color: colors_1.dataVizColorsText[(colorIdx + idx) % colors_1.dataVizColorsText.length] })); })
|
|
213
212
|
: props.value, showPercent: showPercent, showCount: showCount, opacity: 1, activeBar: activeBar, _base_configs: _base_configs, _debug_controls: _debug_controls }, (onClick
|
|
214
213
|
? {
|
|
215
214
|
onMouseOver: function (e, value) {
|
|
@@ -229,7 +228,7 @@ var BarChart = function (_a) {
|
|
|
229
228
|
: {})))); } })),
|
|
230
229
|
data.map(function (d, index) { return (react_1.default.createElement(recharts_1.Cell, { y: (!isBreakdown || breakdownDisplayType === "stacked")
|
|
231
230
|
? CALC_SINGLE_BAR_SECTION_Y_POS(index) + CHART_OFFSET_TOP
|
|
232
|
-
: CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, data[0].length) + CHART_OFFSET_TOP, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_configs.barHeight, fill: activeConfig.getCellFill(stackIndex, colors_1.dataVizColors) })); }))));
|
|
231
|
+
: CALC_GROUPED_BAR_SECTION_Y_POS(index, stackIndex, data[0].length) + CHART_OFFSET_TOP, key: "cell-".concat(index, "-").concat(stackIndex), opacity: 1, height: _base_configs.barHeight, fill: activeConfig.getCellFill(colorIdx, stackIndex, colors_1.dataVizColors) })); }))));
|
|
233
232
|
};
|
|
234
233
|
return (react_1.default.createElement("div", { style: {
|
|
235
234
|
height: "".concat(isBreakdown && breakdownDisplayType === "grouped"
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { BarChartProps } from "../BarChart";
|
|
3
|
+
type ChartOptionConfig = {
|
|
4
|
+
display: string;
|
|
5
|
+
comp: 'PieChart' | 'BarChart';
|
|
6
|
+
props: BarChartProps;
|
|
7
|
+
};
|
|
8
|
+
interface DataVizAccordionProps extends BarChartProps {
|
|
4
9
|
title?: string;
|
|
5
|
-
chartOptions
|
|
6
|
-
}
|
|
10
|
+
chartOptions: ChartOptionConfig[];
|
|
11
|
+
}
|
|
12
|
+
export declare const DataVizAccordion: React.FC<DataVizAccordionProps>;
|
|
13
|
+
export {};
|
|
@@ -32,7 +32,7 @@ var BarChart_1 = require("../BarChart");
|
|
|
32
32
|
var PieChart_1 = require("../PieChart");
|
|
33
33
|
var Accordion_1 = require("../Accordion");
|
|
34
34
|
var DataVizAccordion = function (_a) {
|
|
35
|
-
var
|
|
35
|
+
var title = _a.title, _b = _a.chartOptions, chartOptions = _b === void 0 ? [] : _b, props = __rest(_a, ["title", "chartOptions"]);
|
|
36
36
|
var ChartComps = {
|
|
37
37
|
PieChart: {
|
|
38
38
|
comp: PieChart_1.PieChart,
|
|
@@ -40,23 +40,20 @@ var DataVizAccordion = function (_a) {
|
|
|
40
40
|
},
|
|
41
41
|
BarChart: {
|
|
42
42
|
comp: BarChart_1.BarChart,
|
|
43
|
-
wrapperStyle: { padding: "0 1rem 0.6rem 1rem" }
|
|
43
|
+
wrapperStyle: { padding: "0 1rem 0.6rem 1rem" }
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
-
var
|
|
46
|
+
var _c = (0, react_2.useState)(chartOptions[0]), activeCompConfig = _c[0], setActiveCompConfig = _c[1];
|
|
47
47
|
var genActiveChartComp = function (activeCompConfig) {
|
|
48
48
|
var ActiveChartComp = ChartComps[activeCompConfig.comp].comp;
|
|
49
49
|
var wrapperStyle = ChartComps[activeCompConfig.comp].wrapperStyle;
|
|
50
50
|
return (react_1.default.createElement("div", { style: __assign({ padding: "0 1.6rem 1rem 1.6rem" }, (wrapperStyle || {})) },
|
|
51
|
-
react_1.default.createElement(ActiveChartComp, __assign({}, props,
|
|
51
|
+
react_1.default.createElement(ActiveChartComp, __assign({}, props, activeCompConfig.props))));
|
|
52
52
|
};
|
|
53
|
-
return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.map(function (d) { return ({
|
|
53
|
+
return (react_1.default.createElement(Accordion_1.Accordion, { key: JSON.stringify(activeCompConfig), title: title, actionsConfig: chartOptions.length > 1 && chartOptions.map(function (d) { return ({
|
|
54
54
|
display: d.display,
|
|
55
55
|
onClick: function () {
|
|
56
|
-
return setActiveCompConfig(
|
|
57
|
-
comp: d.comp,
|
|
58
|
-
props: d.props,
|
|
59
|
-
});
|
|
56
|
+
return setActiveCompConfig(d);
|
|
60
57
|
},
|
|
61
58
|
}); }) }, genActiveChartComp(activeCompConfig)));
|
|
62
59
|
};
|
package/dist/v2/themes/colors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colors = exports.dataVizColors = void 0;
|
|
3
|
+
exports.colors = exports.dataVizColorsText = exports.dataVizColors = void 0;
|
|
4
4
|
var primary = "#006686";
|
|
5
5
|
var secondary = "#456272";
|
|
6
6
|
var tertiary = "#764F8B";
|
|
@@ -61,20 +61,16 @@ exports.dataVizColors = [
|
|
|
61
61
|
"#AC8E68",
|
|
62
62
|
"#CF8AF2",
|
|
63
63
|
];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// "rgb(254, 187, 178)",
|
|
75
|
-
// "rgb(204, 128, 217)",
|
|
76
|
-
// "rgb(91, 184, 175)",
|
|
77
|
-
// ]
|
|
64
|
+
exports.dataVizColorsText = [
|
|
65
|
+
"#E92519",
|
|
66
|
+
"#0A8D1E",
|
|
67
|
+
"#C57800",
|
|
68
|
+
"#197BDE",
|
|
69
|
+
"#997F00",
|
|
70
|
+
"#13918C",
|
|
71
|
+
"#93662D",
|
|
72
|
+
"#B554E6",
|
|
73
|
+
];
|
|
78
74
|
exports.colors = {
|
|
79
75
|
primary: primary,
|
|
80
76
|
secondary: secondary,
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { TBaseConfigs } from "../..";
|
|
3
|
-
type TCustomizedLabeValue = {
|
|
4
|
-
percentage: number;
|
|
5
|
-
count: number;
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const CustomizedLabel: ({ y, width, height, value, plotDataPoint, opacity, _base_configs, onMouseOver, onMouseOut, onMouseDown, }: {
|
|
9
|
-
y?: number | string;
|
|
10
|
-
width?: number | string;
|
|
11
|
-
height?: number | string;
|
|
12
|
-
value?: TCustomizedLabeValue;
|
|
13
|
-
opacity: number;
|
|
14
|
-
plotDataPoint?: "percentage" | "count";
|
|
15
|
-
_base_configs: TBaseConfigs;
|
|
16
|
-
onMouseOver?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
|
|
17
|
-
onMouseOut?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
|
|
18
|
-
onMouseDown?: (e: React.MouseEvent<SVGRectElement, MouseEvent>, v: TCustomizedLabeValue) => void;
|
|
19
|
-
}) => React.JSX.Element;
|
|
20
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
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.CustomizedLabel = void 0;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var themes_1 = require("../../../../themes");
|
|
9
|
-
var CustomizedLabel = function (_a) {
|
|
10
|
-
var y = _a.y, width = _a.width, //i think this is the width and the height of the bar. dont need it just yet..
|
|
11
|
-
height = _a.height, value = _a.value, plotDataPoint = _a.plotDataPoint, opacity = _a.opacity, _base_configs = _a._base_configs, onMouseOver = _a.onMouseOver, onMouseOut = _a.onMouseOut, onMouseDown = _a.onMouseDown;
|
|
12
|
-
var yOffset = -(_base_configs.labelToBarGap + _base_configs.barHeight);
|
|
13
|
-
var percent = value.percentage;
|
|
14
|
-
var count = value.count;
|
|
15
|
-
var name = value.name;
|
|
16
|
-
var percentXOffset = 0;
|
|
17
|
-
var xOffsetRelative = 10;
|
|
18
|
-
return (react_1.default.createElement("g", null,
|
|
19
|
-
react_1.default.createElement("text", { opacity: opacity, x: percentXOffset, y: y + yOffset, fill: themes_1.colors.greyColor100, textAnchor: "start", dominantBaseline: "middle", className: "UI_BODY_BOLD_SM" },
|
|
20
|
-
plotDataPoint === "percentage"
|
|
21
|
-
? percent + "%"
|
|
22
|
-
: plotDataPoint === "count"
|
|
23
|
-
? count
|
|
24
|
-
: "",
|
|
25
|
-
plotDataPoint === "percentage" && ( // basically no need to show this only if plotDataPoint is count, since in that case, count is already shown above
|
|
26
|
-
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, count)),
|
|
27
|
-
react_1.default.createElement("tspan", { className: "UI_BODY_SM", dx: xOffsetRelative, y: y + yOffset, fill: themes_1.colors.greyColor80 }, name)),
|
|
28
|
-
react_1.default.createElement("rect", { 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: percentXOffset, y: y + _base_configs.mouseEventDetectorYOffset, width: width, height: _base_configs.mouseEventDetectorHeight, fill: "red", "fill-opacity": _base_configs.mouseEventDetectorOpacity })));
|
|
29
|
-
};
|
|
30
|
-
exports.CustomizedLabel = CustomizedLabel;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export type TBaseConfigs = {
|
|
3
|
-
barHeight: number;
|
|
4
|
-
labelToBarGap: number;
|
|
5
|
-
barGap: number;
|
|
6
|
-
mouseEventDetectorYOffset: number;
|
|
7
|
-
mouseEventDetectorHeight: number;
|
|
8
|
-
mouseEventDetectorOpacity: number;
|
|
9
|
-
};
|
|
10
|
-
export declare const PercentBarChart: ({ data: _data, title, valuePath, labelPath, onClick, colors, colorIdx, plotDataPoint, }: {
|
|
11
|
-
data: any;
|
|
12
|
-
valuePath: string;
|
|
13
|
-
labelPath: string;
|
|
14
|
-
title?: string;
|
|
15
|
-
onClick?: (name: string) => void;
|
|
16
|
-
colors?: string[];
|
|
17
|
-
colorIdx?: number;
|
|
18
|
-
valueSuffix?: string;
|
|
19
|
-
plotDataPoint?: 'percentage' | 'count';
|
|
20
|
-
showCount?: boolean;
|
|
21
|
-
showPercent?: boolean;
|
|
22
|
-
}) => React.JSX.Element;
|
|
@@ -1,153 +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 (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
-
if (ar || !(i in from)) {
|
|
39
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
-
ar[i] = from[i];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
-
};
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.PercentBarChart = void 0;
|
|
47
|
-
var react_1 = __importStar(require("react"));
|
|
48
|
-
var recharts_1 = require("recharts");
|
|
49
|
-
var _EXPORTS_1 = require("../../utils/_EXPORTS");
|
|
50
|
-
var Typo_1 = require("../Typo");
|
|
51
|
-
var getTotalCount_1 = require("../../utils/getTotalCount");
|
|
52
|
-
var CustomizedLabel_1 = require("./comps/CustomizedLabel");
|
|
53
|
-
var chartColors = [
|
|
54
|
-
"#5C80FF",
|
|
55
|
-
"#FFA800",
|
|
56
|
-
"#00BC8F",
|
|
57
|
-
"#FF51CE",
|
|
58
|
-
"rgb(173, 89, 108)",
|
|
59
|
-
"rgb(114, 190, 244)",
|
|
60
|
-
"rgb(255, 178, 122)",
|
|
61
|
-
"rgb(14, 126, 161)",
|
|
62
|
-
"rgb(60, 169, 116)",
|
|
63
|
-
"rgb(254, 187, 178)",
|
|
64
|
-
"rgb(204, 128, 217)",
|
|
65
|
-
"rgb(91, 184, 175)",
|
|
66
|
-
];
|
|
67
|
-
//if any changes are being made to the spacing and such of
|
|
68
|
-
//this comps design, all these properties need to be carefully
|
|
69
|
-
//observed and tweaked to ensure no ui has gotten warped due to sideeffects
|
|
70
|
-
var _base_configs = {
|
|
71
|
-
barRadius: 16,
|
|
72
|
-
barHeight: 6,
|
|
73
|
-
labelToBarGap: 6,
|
|
74
|
-
barGap: 30,
|
|
75
|
-
wrapperMarginBottom: -16,
|
|
76
|
-
barCategoryGap: 18, // does some wierd shit really, simply pushes the entire graph down by this number. We need to to unhide the first label, which is happening only because we are using <Cell/> comp. too many inconsistencies in recharts
|
|
77
|
-
mouseEventDetectorYOffset: -34, //this is inside CustomizedLabel. a big rect spread across the bar and label and gap to detect mouse events and transition smoothly to the next bar.
|
|
78
|
-
mouseEventDetectorHeight: 40,
|
|
79
|
-
mouseEventDetectorOpacity: 0 //only increase this for debugging. nothing else.
|
|
80
|
-
};
|
|
81
|
-
var PercentBarChart = function (_a) {
|
|
82
|
-
var _data = _a.data, title = _a.title, _b = _a.valuePath, valuePath = _b === void 0 ? "value" : _b, // is relevant only for the initial data setting in useMemo. after that, the actual percentage is always stored against the 'percentage' key, and the count against the 'count' key
|
|
83
|
-
_c = _a.labelPath, // is relevant only for the initial data setting in useMemo. after that, the actual percentage is always stored against the 'percentage' key, and the count against the 'count' key
|
|
84
|
-
labelPath = _c === void 0 ? "name" : _c, // same as above for label path
|
|
85
|
-
onClick = _a.onClick, _d = _a.colors, colors = _d === void 0 ? chartColors : _d, _e = _a.colorIdx, colorIdx = _e === void 0 ? 0 : _e, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
|
|
86
|
-
_f = _a.plotDataPoint, //if you are rendering a grid of such charts, then maybe you want each of their colors to be different. in that case, increment this idx from the parent component
|
|
87
|
-
plotDataPoint = _f === void 0 ? 'percentage' : _f;
|
|
88
|
-
var totalCount = (0, getTotalCount_1.getTotalCount)({ data: _data, countPath: valuePath });
|
|
89
|
-
var data = (0, react_1.useMemo)(function () {
|
|
90
|
-
var finalData = __spreadArray([], _data, true);
|
|
91
|
-
finalData = finalData.map(function (d, i) {
|
|
92
|
-
var count = (0, _EXPORTS_1.getVal)(d, valuePath);
|
|
93
|
-
return ({
|
|
94
|
-
labels: __assign(__assign({}, (plotDataPoint === 'percentage' ? { percentage: (0, _EXPORTS_1.getPercentage)((0, _EXPORTS_1.getVal)(d, valuePath), totalCount) } : {})), { count: count, name: (0, _EXPORTS_1.getVal)(d, labelPath) }),
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
finalData.sort(function (a, b) {
|
|
98
|
-
return Number((0, _EXPORTS_1.getVal)(b, "labels.".concat(plotDataPoint)) || 0) - Number((0, _EXPORTS_1.getVal)(a, "labels.".concat(plotDataPoint)) || 0);
|
|
99
|
-
});
|
|
100
|
-
return finalData;
|
|
101
|
-
}, [_data, labelPath, valuePath]);
|
|
102
|
-
var _g = (0, react_1.useState)(undefined), activeBar = _g[0], setActiveBar = _g[1];
|
|
103
|
-
var changeBarOpacityFn = function (name) {
|
|
104
|
-
return activeBar && activeBar !== name ? 0.4 : 1;
|
|
105
|
-
};
|
|
106
|
-
return (react_1.default.createElement("div", null,
|
|
107
|
-
title && (react_1.default.createElement(Typo_1.SANS_4_5, { style: { paddingBottom: "2rem" }, semibold: true }, title)),
|
|
108
|
-
react_1.default.createElement("div", { style: {
|
|
109
|
-
height: "".concat(((_base_configs.barHeight + _base_configs.barGap) * data.length), "px"),
|
|
110
|
-
width: "100%",
|
|
111
|
-
} },
|
|
112
|
-
react_1.default.createElement(recharts_1.ResponsiveContainer, { width: "100%", height: "100%" },
|
|
113
|
-
react_1.default.createElement(recharts_1.BarChart, { width: 500, height: 500, barCategoryGap: _base_configs.barCategoryGap,
|
|
114
|
-
// barSize={_base_configs.barHeight}
|
|
115
|
-
data: data, layout: "vertical", margin: {
|
|
116
|
-
top: 0,
|
|
117
|
-
right: 0,
|
|
118
|
-
left: 0,
|
|
119
|
-
bottom: _base_configs.wrapperMarginBottom,
|
|
120
|
-
}, onMouseEnter: function () {
|
|
121
|
-
var args = [];
|
|
122
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
123
|
-
args[_i] = arguments[_i];
|
|
124
|
-
}
|
|
125
|
-
return console.log('mouse enter', args);
|
|
126
|
-
}, onMouseLeave: function () {
|
|
127
|
-
var args = [];
|
|
128
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
129
|
-
args[_i] = arguments[_i];
|
|
130
|
-
}
|
|
131
|
-
return console.log('mouse leave', args);
|
|
132
|
-
} },
|
|
133
|
-
react_1.default.createElement(recharts_1.XAxis, { hide: true, type: "number" }),
|
|
134
|
-
react_1.default.createElement(recharts_1.YAxis, { hide: true, type: "category" }),
|
|
135
|
-
react_1.default.createElement(recharts_1.Bar, { radius: _base_configs.barRadius, style: onClick ? { cursor: "pointer" } : {}, dataKey: "labels.".concat(plotDataPoint) },
|
|
136
|
-
react_1.default.createElement(recharts_1.LabelList, { dataKey: "labels", offset: 0, content: function (props) { return react_1.default.createElement(CustomizedLabel_1.CustomizedLabel, __assign({ y: props.y,
|
|
137
|
-
width: props.width,
|
|
138
|
-
height: props.height,
|
|
139
|
-
value: props.value, //here value is the percentage
|
|
140
|
-
plotDataPoint: plotDataPoint, opacity: changeBarOpacityFn(props.value.name), _base_configs: _base_configs }, (onClick
|
|
141
|
-
? {
|
|
142
|
-
onMouseOver: function (e, value) { return setActiveBar(value.name); },
|
|
143
|
-
onMouseOut: function () { return setActiveBar(undefined); },
|
|
144
|
-
onMouseDown: function (e, value) {
|
|
145
|
-
setActiveBar(value.name);
|
|
146
|
-
onClick(value.name);
|
|
147
|
-
},
|
|
148
|
-
}
|
|
149
|
-
: {}))); } }),
|
|
150
|
-
data.map(function (d, index) { return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
151
|
-
react_1.default.createElement(recharts_1.Cell, { opacity: changeBarOpacityFn(d.labels.name), key: "cell-".concat(index), height: _base_configs.barHeight, fill: colors[colorIdx] }))); })))))));
|
|
152
|
-
};
|
|
153
|
-
exports.PercentBarChart = PercentBarChart;
|
|
@@ -1,25 +0,0 @@
|
|
|
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.PercentBarChart_ = void 0;
|
|
7
|
-
var react_1 = __importDefault(require("react"));
|
|
8
|
-
var PercentBarChart_1 = require("../../../components/PercentBarChart");
|
|
9
|
-
exports.default = {
|
|
10
|
-
title: "Components/PercentBarChart",
|
|
11
|
-
};
|
|
12
|
-
var data = [
|
|
13
|
-
{ display: 'Logged In Once', value: 60 },
|
|
14
|
-
{ display: 'Registered Users', value: 100 },
|
|
15
|
-
{ display: 'Created Profile', value: 20 },
|
|
16
|
-
{ display: 'Wrote at least 1 story', value: 8 }
|
|
17
|
-
];
|
|
18
|
-
var PercentBarChart_ = function (args) {
|
|
19
|
-
var handleBarClick = function (name) {
|
|
20
|
-
console.log("Bar clicked: ".concat(name));
|
|
21
|
-
};
|
|
22
|
-
return (react_1.default.createElement("div", null,
|
|
23
|
-
react_1.default.createElement(PercentBarChart_1.PercentBarChart, { data: data, labelPath: "display", valuePath: "value", title: "This is PercentBarChart representing the data", onClick: handleBarClick })));
|
|
24
|
-
};
|
|
25
|
-
exports.PercentBarChart_ = PercentBarChart_;
|