oolib 2.53.0 → 2.54.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.
@@ -0,0 +1 @@
1
+ export function BarChart(props: any): any;
@@ -0,0 +1,164 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.BarChart = void 0;
30
+ var react_1 = __importStar(require("react"));
31
+ var d3Modules_1 = __importDefault(require("../../../../d3Modules"));
32
+ var utils_1 = require("../../utils");
33
+ var testJSON_1 = require("../../../../utils/testJSON");
34
+ var getVal_1 = require("../../../../utils/getterSetterDeleter/getVal");
35
+ var themes_1 = require("../../../../themes");
36
+ var styled_components_1 = require("styled-components");
37
+ var utilsOolib_1 = require("../../../../utilsOolib");
38
+ var BarChart = function (props) {
39
+ var config = {
40
+ width: 550,
41
+ height: 100,
42
+ margin: { top: 50, right: 50, bottom: 50, left: 100 },
43
+ };
44
+ var theme = (0, styled_components_1.useTheme)();
45
+ var width = props.width || config.width;
46
+ var height = props.height || config.height;
47
+ var marginProp = (0, testJSON_1.testJSON)(props.margin)
48
+ ? JSON.parse(props.margin)
49
+ : undefined;
50
+ var margin = marginProp
51
+ ? {
52
+ top: marginProp.top || config.margin.top,
53
+ bottom: marginProp.bottom || config.margin.bottom,
54
+ left: marginProp.left || config.margin.left,
55
+ right: marginProp.right || config.margin.right,
56
+ }
57
+ : config.margin;
58
+ var data = props.data, id = props.id, className = props.className, numValuePath = props.numValuePath, categoryValuePath = props.categoryValuePath, _a = props.categoryAxis, categoryAxis = _a === void 0 ? 'y' : _a, _b = props.barWidth, barWidth = _b === void 0 ? 20 : _b, numberAxisLabel = props.numberAxisLabel;
59
+ var wrapperId = "OKE_PiChart".concat(id ? "_" + id : "");
60
+ var wrapperClass = "OKE-PiChart ".concat(className || "");
61
+ (0, react_1.useEffect)(function () { return drawChart(data); }, [data]);
62
+ var drawChart = function (data) {
63
+ // console.log({DATA : data})
64
+ //first clear the div
65
+ d3Modules_1.default.select("#" + wrapperId + ">svg").remove();
66
+ //then draw
67
+ var svg = (0, utils_1.genResponsiveSvgCanvas)({
68
+ width: width,
69
+ height: height,
70
+ wrapperId: wrapperId,
71
+ margin: margin,
72
+ translate: "".concat(margin.left, ",").concat(margin.right)
73
+ });
74
+ // X axis
75
+ var categoryAxisGenerator = d3Modules_1.default
76
+ .scaleBand()
77
+ // .range([0, width]) alt
78
+ .range([0, height])
79
+ .domain(data.map(function (d) {
80
+ return (0, getVal_1.getVal)(d, categoryValuePath);
81
+ }))
82
+ .padding(0.2);
83
+ var categoryAxis = svg
84
+ .append("g")
85
+ //.attr("transform", "translate(0," + height + ")") //alt
86
+ .attr("transform", "translate(0, 0)")
87
+ //.call(d3.axisBottom(categoryAxis)) //alt
88
+ .call(d3Modules_1.default.axisLeft(categoryAxisGenerator));
89
+ categoryAxis.selectAll("text")
90
+ // .attr("transform", "translate(-5,0)")
91
+ .style("text-anchor", "end")
92
+ .attr("color", themes_1.colors.greyColor100);
93
+ categoryAxis.select('.domain').remove();
94
+ categoryAxis.selectAll('.tick line').remove();
95
+ // Add Y axis
96
+ var numbersAxisGenerator = d3Modules_1.default
97
+ .scaleLinear()
98
+ .domain([0, (0, utils_1.getMax)({ data: data, valuePath: numValuePath })])
99
+ // .range([height, 0]) // alt
100
+ .range([0, width]);
101
+ var numberAxisG = svg.append("g");
102
+ var numberAxis = numberAxisG
103
+ //.attr("transform", "translate(0, 0)") alt
104
+ .attr("transform", "translate(0," + height + ")") //alt
105
+ //.call(d3.axisLeft(numbersAxis)); //alt
106
+ .call(d3Modules_1.default.axisBottom(numbersAxisGenerator));
107
+ numberAxis.select('.domain').attr('stroke', themes_1.colors.greyColor40);
108
+ numberAxis.selectAll('.tick text').attr('color', themes_1.colors.greyColor70);
109
+ numberAxis.selectAll('.tick line').attr('stroke', themes_1.colors.greyColor40);
110
+ if (numberAxisLabel) {
111
+ svg.append('text')
112
+ .text(numberAxisLabel)
113
+ .attr("x", 0)
114
+ .attr("y", height + 35)
115
+ .attr('fill', themes_1.colors.greyColor100);
116
+ }
117
+ // Bars
118
+ svg
119
+ .selectAll("mybar")
120
+ .data(data)
121
+ .enter()
122
+ .append("rect")
123
+ // .attr("x", function (d) {
124
+ // return categoryAxis(getVal(d, categoryValuePath)) + 10;
125
+ // }) //alt
126
+ .attr("y", function (d) {
127
+ return categoryAxisGenerator((0, getVal_1.getVal)(d, categoryValuePath)) + (categoryAxisGenerator.bandwidth() / 2) - (barWidth / 2);
128
+ })
129
+ // .attr("y", function (d) {
130
+ // return numbersAxis(getVal(d, numValuePath));
131
+ // }) //alt
132
+ .attr("x", 0)
133
+ //.attr("width", barWidth) //alt
134
+ .attr("height", barWidth)
135
+ // .attr("height", function (d) {
136
+ // return height - numbersAxis(getVal(d, numValuePath));
137
+ // }) //alt
138
+ .attr("width", function (d) {
139
+ return numbersAxisGenerator((0, getVal_1.getVal)(d, numValuePath));
140
+ })
141
+ .attr('rx', 5)
142
+ .attr("transform", 'translateX(50%)')
143
+ .attr("fill", function (d) {
144
+ return (0, utils_1.getMax)({ data: data, valuePath: numValuePath }) === (0, getVal_1.getVal)(d, numValuePath)
145
+ ? (0, utilsOolib_1.getPrimaryColor40)(theme === null || theme === void 0 ? void 0 : theme.colors)
146
+ : themes_1.colors.greyColor15;
147
+ });
148
+ //Bar Number Labels
149
+ svg
150
+ .selectAll("barnumlabels")
151
+ .data(data)
152
+ .enter()
153
+ .append("text")
154
+ .text(function (d) { return (0, getVal_1.getVal)(d, numValuePath); })
155
+ .attr("y", function (d) {
156
+ return categoryAxisGenerator((0, getVal_1.getVal)(d, categoryValuePath)) + (categoryAxisGenerator.bandwidth() / 2) + 4;
157
+ })
158
+ .attr("x", function (d) {
159
+ return numbersAxisGenerator((0, getVal_1.getVal)(d, numValuePath)) + 5;
160
+ });
161
+ };
162
+ return react_1.default.createElement("div", { id: wrapperId, className: wrapperClass });
163
+ };
164
+ exports.BarChart = BarChart;
@@ -0,0 +1,24 @@
1
+ export function genResponsiveSvgCanvas({ margin, width, height, wrapperId, translate }: {
2
+ margin: any;
3
+ width: any;
4
+ height: any;
5
+ wrapperId: any;
6
+ translate: any;
7
+ }): any;
8
+ export function getMinMax({ data, valuePath }: {
9
+ data: any;
10
+ valuePath: any;
11
+ }): number[];
12
+ export function getMax({ data, valuePath }: {
13
+ data: any;
14
+ valuePath: any;
15
+ }): number;
16
+ export function getMin({ data, valuePath }: {
17
+ data: any;
18
+ valuePath: any;
19
+ }): number;
20
+ export function calcSvgElemScaleFactor({ setWidth, actualWidth, setValueToScale, }: {
21
+ setWidth: any;
22
+ actualWidth: any;
23
+ setValueToScale: any;
24
+ }): number;
@@ -0,0 +1,50 @@
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.calcSvgElemScaleFactor = exports.getMin = exports.getMax = exports.getMinMax = exports.genResponsiveSvgCanvas = void 0;
7
+ var d3Modules_1 = __importDefault(require("../../../d3Modules"));
8
+ var getVal_1 = require("../../../utils/getterSetterDeleter/getVal");
9
+ var genResponsiveSvgCanvas = function (_a) {
10
+ var margin = _a.margin, width = _a.width, height = _a.height, wrapperId = _a.wrapperId, translate = _a.translate;
11
+ return d3Modules_1.default
12
+ .select("#" + wrapperId)
13
+ .append("svg")
14
+ // Responsive SVG needs these 2 attributes and no width and height attr.
15
+ .attr("preserveAspectRatio", "xMinYMin meet")
16
+ .attr("viewBox", "0 0 ".concat(width + margin.left + margin.right, " ").concat(height + margin.top + margin.bottom))
17
+ .append("g")
18
+ .classed("vizCanvas", true)
19
+ .attr("transform", "translate(".concat(translate || "".concat(width / 2, ",").concat(height / 2), ")"))
20
+ .attr("font-family", "'noto_sans', 'noto_sans_devanagari', 'noto_sans_gu','noto_sans_te', 'noto_sans_kn', 'noto_sans_or', sans-serif");
21
+ };
22
+ exports.genResponsiveSvgCanvas = genResponsiveSvgCanvas;
23
+ var getOnlyNumbersAry = function (_a) {
24
+ var data = _a.data, valuePath = _a.valuePath;
25
+ return data.map(function (d) { return parseInt((0, getVal_1.getVal)(d, valuePath)); });
26
+ };
27
+ var getMinMax = function (_a) {
28
+ var data = _a.data, valuePath = _a.valuePath;
29
+ var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
30
+ return [Math.min.apply(Math, onlyNumbers), Math.max.apply(Math, onlyNumbers)];
31
+ };
32
+ exports.getMinMax = getMinMax;
33
+ var getMax = function (_a) {
34
+ var data = _a.data, valuePath = _a.valuePath;
35
+ var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
36
+ return Math.max.apply(Math, onlyNumbers);
37
+ };
38
+ exports.getMax = getMax;
39
+ var getMin = function (_a) {
40
+ var data = _a.data, valuePath = _a.valuePath;
41
+ var onlyNumbers = getOnlyNumbersAry({ data: data, valuePath: valuePath });
42
+ return Math.min.apply(Math, onlyNumbers);
43
+ };
44
+ exports.getMin = getMin;
45
+ var calcSvgElemScaleFactor = function (_a) {
46
+ var setWidth = _a.setWidth, actualWidth = _a.actualWidth, setValueToScale = _a.setValueToScale;
47
+ var scaleFactor = actualWidth / setWidth;
48
+ return setValueToScale * (1 / scaleFactor);
49
+ };
50
+ exports.calcSvgElemScaleFactor = calcSvgElemScaleFactor;
@@ -0,0 +1,29 @@
1
+ declare namespace _default {
2
+ export { line };
3
+ export { area };
4
+ export { scaleLinear };
5
+ export { scaleTime };
6
+ export { scaleBand };
7
+ export { select };
8
+ export { selectAll };
9
+ export { format };
10
+ export { pie };
11
+ export { arc };
12
+ export { curveMonotoneX };
13
+ export { timeParse };
14
+ export { extent };
15
+ export { min };
16
+ export { max };
17
+ export { bisector };
18
+ export { mouse };
19
+ export { axisBottom };
20
+ export { axisLeft };
21
+ export { axisRight };
22
+ export { axisTop };
23
+ export { geoMercator };
24
+ export { geoPath };
25
+ export { transition };
26
+ export { scaleOrdinal };
27
+ export { entries };
28
+ }
29
+ export default _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var d3_shape_1 = require("d3-shape");
4
+ var d3_scale_1 = require("d3-scale");
5
+ var d3_axis_1 = require("d3-axis");
6
+ var d3_time_format_1 = require("d3-time-format");
7
+ /**
8
+ * @note
9
+ * mouse is deprecated d3 6 onnwards. read : https://observablehq.com/@d3/d3v6-migration-guide#pointer
10
+ */
11
+ var d3_collection_1 = require("d3-collection");
12
+ var d3_selection_1 = require("d3-selection");
13
+ var d3_transition_1 = require("d3-transition");
14
+ var d3_array_1 = require("d3-array");
15
+ var d3_format_1 = require("d3-format");
16
+ var d3_geo_1 = require("d3-geo");
17
+ exports.default = {
18
+ line: d3_shape_1.line,
19
+ area: d3_shape_1.area,
20
+ scaleLinear: d3_scale_1.scaleLinear,
21
+ scaleTime: d3_scale_1.scaleTime,
22
+ scaleBand: d3_scale_1.scaleBand,
23
+ select: d3_selection_1.select,
24
+ selectAll: d3_selection_1.selectAll,
25
+ format: d3_format_1.format,
26
+ pie: d3_shape_1.pie,
27
+ arc: d3_shape_1.arc,
28
+ curveMonotoneX: d3_shape_1.curveMonotoneX,
29
+ timeParse: d3_time_format_1.timeParse,
30
+ extent: d3_array_1.extent,
31
+ min: d3_array_1.min,
32
+ max: d3_array_1.max,
33
+ bisector: d3_array_1.bisector,
34
+ mouse: d3_selection_1.mouse,
35
+ get event() { return d3_selection_1.event; },
36
+ axisBottom: d3_axis_1.axisBottom,
37
+ axisLeft: d3_axis_1.axisLeft,
38
+ axisRight: d3_axis_1.axisRight,
39
+ axisTop: d3_axis_1.axisTop,
40
+ geoMercator: d3_geo_1.geoMercator,
41
+ geoPath: d3_geo_1.geoPath,
42
+ transition: d3_transition_1.transition,
43
+ scaleOrdinal: d3_scale_1.scaleOrdinal,
44
+ entries: d3_collection_1.entries
45
+ };
package/dist/index.d.ts CHANGED
@@ -35,5 +35,6 @@ export { HomeCover } from "./components/HomeCover";
35
35
  export { PageScrollIndicator } from "./components/PageScrollIndicator";
36
36
  export { default as DatePicker } from "./components/DatePicker";
37
37
  export { default as DateRangePicker } from "./components/DateRangePicker";
38
+ export { BarChart } from "./components/dataViz/comps/BarChart";
38
39
  export { HintsProvider } from "./components/Hints/contextApi";
39
40
  export { LoaderCircle, ProgressBar, LoaderCircle as Loader, LoaderOverlay } from "./components/LoadersAndProgress";
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ 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.HintsProvider = exports.DateRangePicker = exports.DatePicker = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.ModalLarge = 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;
20
+ exports.HintsProvider = exports.BarChart = exports.DateRangePicker = exports.DatePicker = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.ModalLarge = 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
21
  //css and styling related ( styled-components )
22
22
  var globalStyles_1 = require("./globalStyles");
23
23
  Object.defineProperty(exports, "GlobalStyles", { enumerable: true, get: function () { return globalStyles_1.GlobalStyles; } });
@@ -83,6 +83,8 @@ var DatePicker_1 = require("./components/DatePicker");
83
83
  Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return __importDefault(DatePicker_1).default; } });
84
84
  var DateRangePicker_1 = require("./components/DateRangePicker");
85
85
  Object.defineProperty(exports, "DateRangePicker", { enumerable: true, get: function () { return __importDefault(DateRangePicker_1).default; } });
86
+ var BarChart_1 = require("./components/dataViz/comps/BarChart");
87
+ Object.defineProperty(exports, "BarChart", { enumerable: true, get: function () { return BarChart_1.BarChart; } });
86
88
  //// context
87
89
  var contextApi_1 = require("./components/Hints/contextApi");
88
90
  Object.defineProperty(exports, "HintsProvider", { enumerable: true, get: function () { return contextApi_1.HintsProvider; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oolib",
3
- "version": "2.53.0",
3
+ "version": "2.54.1",
4
4
  "description": " OKE Component Library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",