bento-charts 2.4.1 → 2.5.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/ChartConfigProvider.js +1 -12
- package/dist/ChartConfigProvider.js.map +1 -1
- package/dist/Components/Charts/BentoBarChart.d.ts +1 -1
- package/dist/Components/Charts/BentoBarChart.js +25 -37
- package/dist/Components/Charts/BentoBarChart.js.map +1 -1
- package/dist/Components/Charts/BentoPie.d.ts +1 -1
- package/dist/Components/Charts/BentoPie.js +55 -47
- package/dist/Components/Charts/BentoPie.js.map +1 -1
- package/dist/Components/Charts/ChartWrapper.d.ts +6 -0
- package/dist/Components/Charts/ChartWrapper.js +10 -0
- package/dist/Components/Charts/ChartWrapper.js.map +1 -0
- package/dist/Components/Maps/BentoChoroplethMap.d.ts +1 -1
- package/dist/Components/Maps/BentoChoroplethMap.js +15 -32
- package/dist/Components/Maps/BentoChoroplethMap.js.map +1 -1
- package/dist/Components/Maps/BentoMapContainer.js +1 -12
- package/dist/Components/Maps/BentoMapContainer.js.map +1 -1
- package/dist/Components/Maps/BentoPointMap.js +4 -15
- package/dist/Components/Maps/BentoPointMap.js.map +1 -1
- package/dist/Components/Maps/controls/MapLegendContinuous.js +1 -12
- package/dist/Components/Maps/controls/MapLegendContinuous.js.map +1 -1
- package/dist/Components/Maps/controls/MapLegendDiscrete.js +2 -13
- package/dist/Components/Maps/controls/MapLegendDiscrete.js.map +1 -1
- package/dist/Components/NoData.js +2 -13
- package/dist/Components/NoData.js.map +1 -1
- package/dist/constants/chartConstants.d.ts +0 -3
- package/dist/constants/chartConstants.js +2 -3
- package/dist/constants/chartConstants.js.map +1 -1
- package/dist/types/chartTypes.d.ts +10 -6
- package/dist/types/mapTypes.d.ts +2 -3
- package/dist/util/chartUtils.d.ts +2 -0
- package/dist/util/chartUtils.js +30 -0
- package/dist/util/chartUtils.js.map +1 -1
- package/package.json +17 -16
- package/src/Components/Charts/BentoBarChart.tsx +46 -53
- package/src/Components/Charts/BentoPie.tsx +63 -56
- package/src/Components/Charts/ChartWrapper.tsx +15 -0
- package/src/Components/Maps/BentoChoroplethMap.tsx +4 -12
- package/src/Components/Maps/BentoPointMap.tsx +13 -4
- package/src/constants/chartConstants.ts +2 -3
- package/src/types/chartTypes.ts +13 -7
- package/src/types/mapTypes.ts +3 -3
- package/src/util/chartUtils.ts +29 -0
- package/webpack.config.js +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BentoPointMap.js","sourceRoot":"","sources":["../../../src/Components/Maps/BentoPointMap.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BentoPointMap.js","sourceRoot":"","sources":["../../../src/Components/Maps/BentoPointMap.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,IAAM,aAAa,GAAG,UAAC,EAAkF;QAAhF,MAAM,YAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,SAAS,eAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,eAAe,qBAAA;IACtF,OAAO,CACL,KAAC,iBAAiB,IAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,YAChF,IAAI,CAAC,GAAG,CAAC,UAAC,KAAK,EAAE,CAAC;YACT,IAAA,WAAW,GAAY,KAAK,YAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;YAErC,0GAA0G;YAC1G,IAAM,uBAAuB,GAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,CACL,KAAC,MAAM,IAAS,QAAQ,EAAE,uBAAuB,YAC/C,MAAC,KAAK,eACJ,aAAI,KAAK,EAAE,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,YACjD,OAAO,CAAC,CAAC,CAAC,CACT,YACE,IAAI,EAAC,GAAG,EACR,OAAO,EAAE,UAAC,CAAC;oCACT,OAAO,CAAC,KAAK,CAAC,CAAC;oCACf,CAAC,CAAC,cAAc,EAAE,CAAC;gCACrB,CAAC,YAEA,KAAK,GACJ,CACL,CAAC,CAAC,CAAC,CACF,4BAAG,KAAK,GAAI,CACb,GACE,EACJ,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAC1C,IAlBG,CAAC,CAmBL,CACV,CAAC;QACJ,CAAC,CAAC,GACgB,CACrB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { controlPositionClasses } from './utils';
|
|
14
3
|
var MapLegendContinuous = function (_a) {
|
|
15
4
|
var position = _a.position, minValue = _a.minValue, minColor = _a.minColor, maxValue = _a.maxValue, maxColor = _a.maxColor;
|
|
16
|
-
return (_jsx("div",
|
|
5
|
+
return (_jsx("div", { className: controlPositionClasses[position], children: _jsx("div", { className: "leaflet-control bento-charts--map--legend", children: _jsxs("div", { className: "bento-charts--map--legend--scale", children: [_jsx("div", { className: "bento-charts--continuous-scale", style: { background: "linear-gradient(0deg, ".concat(minColor, " 0%, ").concat(maxColor, " 100%)") } }), _jsxs("div", { className: "bento-charts--map--legend--values", children: [_jsx("span", { children: maxValue }), _jsx("span", { children: minValue })] })] }) }) }));
|
|
17
6
|
};
|
|
18
7
|
export default MapLegendContinuous;
|
|
19
8
|
//# sourceMappingURL=MapLegendContinuous.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLegendContinuous.js","sourceRoot":"","sources":["../../../../src/Components/Maps/controls/MapLegendContinuous.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapLegendContinuous.js","sourceRoot":"","sources":["../../../../src/Components/Maps/controls/MapLegendContinuous.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAUjD,IAAM,mBAAmB,GAAG,UAAC,EAA4E;QAA1E,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAA;IAC7E,OAAO,CACL,cAAK,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,YAC9C,cAAK,SAAS,EAAC,2CAA2C,YACxD,eAAK,SAAS,EAAC,kCAAkC,aAC/C,cACE,SAAS,EAAC,gCAAgC,EAC1C,KAAK,EAAE,EAAE,UAAU,EAAE,gCAAyB,QAAQ,kBAAQ,QAAQ,WAAQ,EAAE,GAChF,EACF,eAAK,SAAS,EAAC,mCAAmC,aAChD,yBAAO,QAAQ,GAAQ,EACvB,yBAAO,QAAQ,GAAQ,IACnB,IACF,GACF,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { controlPositionClasses } from './utils';
|
|
14
3
|
var MapLegendDiscrete = function (_a) {
|
|
15
4
|
var position = _a.position, legendItems = _a.legendItems;
|
|
16
|
-
return (_jsx("div",
|
|
5
|
+
return (_jsx("div", { className: controlPositionClasses[position], children: _jsx("div", { className: "leaflet-control bento-charts--map--legend", children: _jsx("ul", { children: legendItems.map(function (_a, i) {
|
|
17
6
|
var label = _a.label, color = _a.color;
|
|
18
7
|
return (_jsxs("li", { children: [_jsx("span", { className: "bento-charts--map--legend--patch", style: { backgroundColor: color !== null && color !== void 0 ? color : "rgba(255, 255, 255, 0)" } }), label] }, i));
|
|
19
|
-
}) }) })
|
|
8
|
+
}) }) }) }));
|
|
20
9
|
};
|
|
21
10
|
export default MapLegendDiscrete;
|
|
22
11
|
//# sourceMappingURL=MapLegendDiscrete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapLegendDiscrete.js","sourceRoot":"","sources":["../../../../src/Components/Maps/controls/MapLegendDiscrete.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MapLegendDiscrete.js","sourceRoot":"","sources":["../../../../src/Components/Maps/controls/MapLegendDiscrete.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAOjD,IAAM,iBAAiB,GAAG,UAAC,EAAiD;QAA/C,QAAQ,cAAA,EAAE,WAAW,iBAAA;IAChD,OAAO,CACL,cAAK,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,YAC9C,cAAK,SAAS,EAAC,2CAA2C,YACxD,uBACG,WAAW,CAAC,GAAG,CAAC,UAAC,EAAgB,EAAE,CAAC;wBAAjB,KAAK,WAAA,EAAE,KAAK,WAAA;oBAAU,OAAA,CACxC,yBACE,eACE,SAAS,EAAC,kCAAkC,EAC5C,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,wBAAwB,EAAE,GAC7D,EACD,KAAK,KALC,CAAC,CAML,CACN;gBARyC,CAQzC,CAAC,GACC,GACD,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
var NoData = function (_a) {
|
|
14
3
|
var height = _a.height;
|
|
15
|
-
return (_jsx("div",
|
|
4
|
+
return (_jsx("div", { style: {
|
|
16
5
|
display: 'flex',
|
|
17
6
|
alignItems: 'center',
|
|
18
7
|
justifyContent: 'center',
|
|
19
8
|
height: "".concat(height, "px"),
|
|
20
9
|
width: '100%',
|
|
21
|
-
}
|
|
10
|
+
}, children: "No Data" }));
|
|
22
11
|
};
|
|
23
12
|
export default NoData;
|
|
24
13
|
//# sourceMappingURL=NoData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoData.js","sourceRoot":"","sources":["../../src/Components/NoData.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoData.js","sourceRoot":"","sources":["../../src/Components/NoData.tsx"],"names":[],"mappings":";AAEA,IAAM,MAAM,GAAG,UAAC,EAAuB;QAArB,MAAM,YAAA;IACtB,OAAO,CACL,cACE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,MAAM,EAAE,UAAG,MAAM,OAAI;YACrB,KAAK,EAAE,MAAM;SACd,wBAGG,CACP,CAAC;AACJ,CAAC,CAAC;AAMF,eAAe,MAAM,CAAC"}
|
|
@@ -12,12 +12,9 @@ export declare const CHART_WRAPPER_STYLE: CSS.Properties;
|
|
|
12
12
|
export declare const TITLE_STYLE: CSS.Properties;
|
|
13
13
|
export declare const TEXT_STYLE: CSS.Properties;
|
|
14
14
|
export declare const COUNT_TEXT_STYLE: CSS.Properties;
|
|
15
|
-
export declare const ASPECT_RATIO = 1.2;
|
|
16
15
|
export declare const MAX_TICK_LABEL_CHARS = 15;
|
|
17
16
|
export declare const UNITS_LABEL_OFFSET = -75;
|
|
18
17
|
export declare const TICKS_SHOW_ALL_LABELS_BELOW = 11;
|
|
19
18
|
export declare const TICK_MARGIN = 5;
|
|
20
|
-
export declare const CHART_ASPECT_RATIO = 1.4;
|
|
21
19
|
export declare const LABEL_THRESHOLD = 0.05;
|
|
22
|
-
export declare const OTHER_THRESHOLD = 0.01;
|
|
23
20
|
export declare const RADIAN: number;
|
|
@@ -72,6 +72,8 @@ export var CHART_WRAPPER_STYLE = {
|
|
|
72
72
|
display: 'flex',
|
|
73
73
|
flexDirection: 'column',
|
|
74
74
|
alignItems: 'center',
|
|
75
|
+
overflowX: 'auto',
|
|
76
|
+
overflowY: 'hidden',
|
|
75
77
|
};
|
|
76
78
|
// bar chart
|
|
77
79
|
export var TITLE_STYLE = {
|
|
@@ -90,15 +92,12 @@ export var COUNT_TEXT_STYLE = {
|
|
|
90
92
|
};
|
|
91
93
|
// ################### CHART CONSTANTS ###################
|
|
92
94
|
// bar chart
|
|
93
|
-
export var ASPECT_RATIO = 1.2;
|
|
94
95
|
export var MAX_TICK_LABEL_CHARS = 15;
|
|
95
96
|
export var UNITS_LABEL_OFFSET = -75;
|
|
96
97
|
export var TICKS_SHOW_ALL_LABELS_BELOW = 11; // Below this # of X-axis ticks, force-show all labels
|
|
97
98
|
export var TICK_MARGIN = 5; // vertical spacing between tick line and tick label
|
|
98
99
|
// pie chart
|
|
99
|
-
export var CHART_ASPECT_RATIO = 1.4;
|
|
100
100
|
export var LABEL_THRESHOLD = 0.05;
|
|
101
|
-
export var OTHER_THRESHOLD = 0.01;
|
|
102
101
|
// ################### UTIL CONSTANTS ###################
|
|
103
102
|
export var RADIAN = Math.PI / 180;
|
|
104
103
|
//# sourceMappingURL=chartConstants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartConstants.js","sourceRoot":"","sources":["../../src/constants/chartConstants.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,MAAM,CAAC,IAAM,wBAAwB,GAAsB;IACzD,EAAE,EAAE;QACF,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD,EAAE,EAAE;QACF,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,OAAO;KACf;CACF,CAAC;AAEF,0DAA0D;AAC1D,oBAAoB;AACpB,MAAM,CAAC,IAAM,MAAM,GAAe;IAChC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,IAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,MAAM,CAAC,IAAM,mBAAmB,GAAe;IAC7C,GAAG,EAAE;QACH,OAAO,EAAE,MAAM;KAChB;IACD,GAAG,EAAE;QACH,OAAO,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,kBAAkB;SAC5B;KACF;CACF,CAAC;AAEF,uDAAuD;AAEvD,SAAS;AACT,MAAM,CAAC,IAAM,cAAc,GAAmB;IAC5C,eAAe,EAAE,0BAA0B;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,gCAAgC;IAC3C,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAmB;IACzC,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAmB;IACzC,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,CAAC,IAAM,mBAAmB,GAAmB;IACjD,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"chartConstants.js","sourceRoot":"","sources":["../../src/constants/chartConstants.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,MAAM,CAAC,IAAM,wBAAwB,GAAsB;IACzD,EAAE,EAAE;QACF,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD,EAAE,EAAE;QACF,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,OAAO;KACf;CACF,CAAC;AAEF,0DAA0D;AAC1D,oBAAoB;AACpB,MAAM,CAAC,IAAM,MAAM,GAAe;IAChC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,IAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,IAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,MAAM,CAAC,IAAM,mBAAmB,GAAe;IAC7C,GAAG,EAAE;QACH,OAAO,EAAE,MAAM;KAChB;IACD,GAAG,EAAE;QACH,OAAO,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,kBAAkB;SAC5B;KACF;CACF,CAAC;AAEF,uDAAuD;AAEvD,SAAS;AACT,MAAM,CAAC,IAAM,cAAc,GAAmB;IAC5C,eAAe,EAAE,0BAA0B;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,gCAAgC;IAC3C,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAmB;IACzC,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAmB;IACzC,UAAU,EAAE,QAAQ;IACpB,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,GAAG;IACZ,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,CAAC,IAAM,mBAAmB,GAAmB;IACjD,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,QAAQ;CACpB,CAAC;AAEF,YAAY;AACZ,MAAM,CAAC,IAAM,WAAW,GAAmB;IACzC,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,QAAQ;CACpB,CAAC;AAEF,YAAY;AACZ,MAAM,CAAC,IAAM,UAAU,GAAmB;IACxC,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,MAAM;CACb,CAAC;AACF,MAAM,CAAC,IAAM,gBAAgB,GAAmB;IAC9C,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,0DAA0D;AAC1D,YAAY;AACZ,MAAM,CAAC,IAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,IAAM,kBAAkB,GAAG,CAAC,EAAE,CAAC;AACtC,MAAM,CAAC,IAAM,2BAA2B,GAAG,EAAE,CAAC,CAAC,sDAAsD;AACrG,MAAM,CAAC,IAAM,WAAW,GAAG,CAAC,CAAC,CAAC,oDAAoD;AAElF,YAAY;AACZ,MAAM,CAAC,IAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,yDAAyD;AACzD,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC"}
|
|
@@ -34,6 +34,7 @@ export type ChartTheme = {
|
|
|
34
34
|
export type FilterCallback<T> = (value: T, index: number, array: T[]) => boolean;
|
|
35
35
|
export type UnitaryMapCallback<T> = (value: T, index: number, array: T[]) => T;
|
|
36
36
|
export type ChartFilterCallback = FilterCallback<CategoricalChartDataItem>;
|
|
37
|
+
export type ChartDataMapCallback = UnitaryMapCallback<CategoricalChartDataItem>;
|
|
37
38
|
export type SupportedLng = 'en' | 'fr';
|
|
38
39
|
type TranslationWords = 'Count' | 'Other';
|
|
39
40
|
export type LngDictionary = {
|
|
@@ -42,16 +43,19 @@ export type LngDictionary = {
|
|
|
42
43
|
export type TranslationObject = {
|
|
43
44
|
[key in SupportedLng]: LngDictionary;
|
|
44
45
|
};
|
|
45
|
-
export interface
|
|
46
|
-
|
|
46
|
+
export interface CategoricalChartDataWithTransforms {
|
|
47
|
+
data: CategoricalChartDataType;
|
|
47
48
|
preFilter?: ChartFilterCallback;
|
|
48
|
-
dataMap?:
|
|
49
|
+
dataMap?: ChartDataMapCallback;
|
|
49
50
|
postFilter?: ChartFilterCallback;
|
|
50
|
-
}
|
|
51
|
-
interface BaseCategoricalChartProps extends BaseChartComponentProps {
|
|
52
|
-
data: CategoricalChartDataType;
|
|
53
51
|
removeEmpty?: boolean;
|
|
54
52
|
}
|
|
53
|
+
export interface BaseChartComponentProps {
|
|
54
|
+
height: number;
|
|
55
|
+
width?: number | string;
|
|
56
|
+
}
|
|
57
|
+
export interface BaseCategoricalChartProps extends BaseChartComponentProps, CategoricalChartDataWithTransforms {
|
|
58
|
+
}
|
|
55
59
|
export interface PieChartProps extends BaseCategoricalChartProps {
|
|
56
60
|
colorTheme?: keyof ChartTheme['pie'];
|
|
57
61
|
sort?: boolean;
|
package/dist/types/mapTypes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { Feature as GeoJSONFeatureType } from 'geojson';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseCategoricalChartProps, BaseChartComponentProps } from './chartTypes';
|
|
4
4
|
import type { GeoJSONPolygonOnlyFeatureCollection } from './geoJSONTypes';
|
|
5
5
|
export interface GeoPointDataItem {
|
|
6
6
|
coordinates: [number, number];
|
|
@@ -32,8 +32,7 @@ export interface ChoroplethMapColorModeDiscrete {
|
|
|
32
32
|
colorFunction: (x: number | undefined) => string;
|
|
33
33
|
legendItems: MapDiscreteLegendItem[];
|
|
34
34
|
}
|
|
35
|
-
export interface ChoroplethMapProps extends BaseMapProps {
|
|
36
|
-
data: CategoricalChartDataType;
|
|
35
|
+
export interface ChoroplethMapProps extends BaseCategoricalChartProps, BaseMapProps {
|
|
37
36
|
features: GeoJSONPolygonOnlyFeatureCollection;
|
|
38
37
|
colorMode: ChoroplethMapColorModeContinuous | ChoroplethMapColorModeDiscrete;
|
|
39
38
|
categoryProp: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { CategoricalChartDataWithTransforms } from '../types/chartTypes';
|
|
1
2
|
export declare const polarToCartesian: (cx: number, cy: number, radius: number, angle: number) => {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
4
5
|
};
|
|
6
|
+
export declare const useTransformedChartData: ({ data: originalData, preFilter, dataMap, postFilter, removeEmpty: origRemoveEmpty, }: CategoricalChartDataWithTransforms, defaultRemoveEmpty?: boolean, sortY?: boolean) => import("../types/chartTypes").CategoricalChartDataItem[];
|
package/dist/util/chartUtils.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { useMemo } from 'react';
|
|
1
11
|
import { RADIAN } from '../constants/chartConstants';
|
|
2
12
|
export var polarToCartesian = function (cx, cy, radius, angle) {
|
|
3
13
|
return {
|
|
@@ -5,4 +15,24 @@ export var polarToCartesian = function (cx, cy, radius, angle) {
|
|
|
5
15
|
y: cy + Math.sin(-RADIAN * angle) * radius,
|
|
6
16
|
};
|
|
7
17
|
};
|
|
18
|
+
export var useTransformedChartData = function (_a, defaultRemoveEmpty, sortY) {
|
|
19
|
+
var originalData = _a.data, preFilter = _a.preFilter, dataMap = _a.dataMap, postFilter = _a.postFilter, origRemoveEmpty = _a.removeEmpty;
|
|
20
|
+
if (defaultRemoveEmpty === void 0) { defaultRemoveEmpty = true; }
|
|
21
|
+
if (sortY === void 0) { sortY = false; }
|
|
22
|
+
return useMemo(function () {
|
|
23
|
+
var removeEmpty = origRemoveEmpty !== null && origRemoveEmpty !== void 0 ? origRemoveEmpty : defaultRemoveEmpty;
|
|
24
|
+
var data = __spreadArray([], originalData, true);
|
|
25
|
+
if (preFilter)
|
|
26
|
+
data = data.filter(preFilter);
|
|
27
|
+
if (dataMap)
|
|
28
|
+
data = data.map(dataMap);
|
|
29
|
+
if (postFilter)
|
|
30
|
+
data = data.filter(postFilter);
|
|
31
|
+
if (removeEmpty)
|
|
32
|
+
data = data.filter(function (e) { return e.y !== 0; });
|
|
33
|
+
if (sortY)
|
|
34
|
+
data.sort(function (a, b) { return a.y - b.y; });
|
|
35
|
+
return data;
|
|
36
|
+
}, [originalData, preFilter, dataMap, postFilter, origRemoveEmpty]);
|
|
37
|
+
};
|
|
8
38
|
//# sourceMappingURL=chartUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartUtils.js","sourceRoot":"","sources":["../../src/util/chartUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"chartUtils.js","sourceRoot":"","sources":["../../src/util/chartUtils.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAGrD,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,EAAU,EAAE,EAAU,EAAE,MAAc,EAAE,KAAa;IACpF,OAAO;QACL,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,MAAM;QAC1C,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,MAAM;KAC3C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,uBAAuB,GAAG,UACrC,EAMqC,EACrC,kBAAyB,EACzB,KAAa;QAPL,YAAY,UAAA,EAClB,SAAS,eAAA,EACT,OAAO,aAAA,EACP,UAAU,gBAAA,EACG,eAAe,iBAAA;IAE9B,mCAAA,EAAA,yBAAyB;IACzB,sBAAA,EAAA,aAAa;IAEb,OAAA,OAAO,CAAC;QACN,IAAM,WAAW,GAAG,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,kBAAkB,CAAC;QAE1D,IAAI,IAAI,qBAAO,YAAY,OAAC,CAAC;QAE7B,IAAI,SAAS;YAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,OAAO;YAAE,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,UAAU;YAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE/C,IAAI,WAAW;YAAE,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,KAAK,CAAC,EAAT,CAAS,CAAC,CAAC;QAEtD,IAAI,KAAK;YAAE,IAAI,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAT,CAAS,CAAC,CAAC;QAE1C,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAdnE,CAcmE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bento-charts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Charts library for Bento-platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -54,30 +54,31 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@commitlint/cli": "^17.
|
|
58
|
-
"@commitlint/config-conventional": "^17.
|
|
57
|
+
"@commitlint/cli": "^17.7.2",
|
|
58
|
+
"@commitlint/config-conventional": "^17.7.0",
|
|
59
59
|
"@semantic-release/git": "^10.0.1",
|
|
60
|
-
"@types/leaflet": "^1.9.
|
|
61
|
-
"@types/react": "^18.
|
|
62
|
-
"@types/react-dom": "^18.
|
|
60
|
+
"@types/leaflet": "^1.9.6",
|
|
61
|
+
"@types/react": "^18.2.24",
|
|
62
|
+
"@types/react-dom": "^18.2.8",
|
|
63
63
|
"@types/react-leaflet": "^3.0.0",
|
|
64
|
-
"@types/recharts": "^1.8.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
66
|
-
"@typescript-eslint/parser": "^
|
|
64
|
+
"@types/recharts": "^1.8.25",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
66
|
+
"@typescript-eslint/parser": "^6.7.3",
|
|
67
67
|
"@webpack-cli/serve": "^2.0.5",
|
|
68
|
-
"antd": "^5.9.
|
|
68
|
+
"antd": "^5.9.4",
|
|
69
69
|
"css-loader": "^6.8.1",
|
|
70
|
-
"eslint": "^8.
|
|
71
|
-
"eslint-plugin-react": "^7.
|
|
70
|
+
"eslint": "^8.50.0",
|
|
71
|
+
"eslint-plugin-react": "^7.33.2",
|
|
72
72
|
"file-loader": "^6.2.0",
|
|
73
73
|
"geojson": "^0.5.0",
|
|
74
74
|
"html-webpack-plugin": "^5.5.3",
|
|
75
75
|
"husky": "^8.0.3",
|
|
76
|
-
"prettier": "
|
|
77
|
-
"
|
|
76
|
+
"prettier": "3.0.3",
|
|
77
|
+
"react-router-dom": "^6.16.0",
|
|
78
|
+
"semantic-release": "^22.0.5",
|
|
78
79
|
"style-loader": "^3.3.3",
|
|
79
|
-
"ts-loader": "^9.4.
|
|
80
|
-
"typescript": "^
|
|
80
|
+
"ts-loader": "^9.4.4",
|
|
81
|
+
"typescript": "^5.2.2",
|
|
81
82
|
"webpack": "^5.88.2",
|
|
82
83
|
"webpack-cli": "^5.1.4",
|
|
83
84
|
"webpack-dev-server": "^4.15.1"
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BarChart, Bar, Cell, XAxis, YAxis, Tooltip, Label, BarProps } from 'recharts';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { BarChart, Bar, Cell, XAxis, YAxis, Tooltip, Label, BarProps, ResponsiveContainer } from 'recharts';
|
|
3
3
|
import {
|
|
4
4
|
TOOL_TIP_STYLE,
|
|
5
5
|
COUNT_STYLE,
|
|
6
6
|
LABEL_STYLE,
|
|
7
|
-
CHART_WRAPPER_STYLE,
|
|
8
7
|
MAX_TICK_LABEL_CHARS,
|
|
9
8
|
TITLE_STYLE,
|
|
10
|
-
ASPECT_RATIO,
|
|
11
9
|
TICKS_SHOW_ALL_LABELS_BELOW,
|
|
12
10
|
UNITS_LABEL_OFFSET,
|
|
13
11
|
TICK_MARGIN,
|
|
@@ -16,6 +14,8 @@ import {
|
|
|
16
14
|
import type { BarChartProps, CategoricalChartDataItem, TooltipPayload } from '../../types/chartTypes';
|
|
17
15
|
import { useChartTheme, useChartTranslation } from '../../ChartConfigProvider';
|
|
18
16
|
import NoData from '../NoData';
|
|
17
|
+
import { useTransformedChartData } from '../../util/chartUtils';
|
|
18
|
+
import ChartWrapper from './ChartWrapper';
|
|
19
19
|
|
|
20
20
|
const tickFormatter = (tickLabel: string) => {
|
|
21
21
|
if (tickLabel.length <= MAX_TICK_LABEL_CHARS) {
|
|
@@ -24,38 +24,29 @@ const tickFormatter = (tickLabel: string) => {
|
|
|
24
24
|
return `${tickLabel.substring(0, MAX_TICK_LABEL_CHARS)}...`;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
units,
|
|
31
|
-
title,
|
|
32
|
-
preFilter,
|
|
33
|
-
dataMap,
|
|
34
|
-
postFilter,
|
|
35
|
-
onClick,
|
|
36
|
-
removeEmpty = true,
|
|
37
|
-
colorTheme = 'default',
|
|
38
|
-
}: BarChartProps) => {
|
|
27
|
+
const BAR_CHART_MARGINS = { top: 10, bottom: 100, right: 20 };
|
|
28
|
+
|
|
29
|
+
const BentoBarChart = ({ height, width, units, title, onClick, colorTheme = 'default', ...params }: BarChartProps) => {
|
|
39
30
|
const t = useChartTranslation();
|
|
40
31
|
const { fill: chartFill, missing } = useChartTheme().bar[colorTheme];
|
|
41
32
|
|
|
42
33
|
const fill = (entry: CategoricalChartDataItem) => (entry.x === 'missing' ? missing : chartFill);
|
|
43
34
|
|
|
44
|
-
data =
|
|
45
|
-
if (preFilter) data = data.filter(preFilter);
|
|
46
|
-
if (dataMap) data = data.map(dataMap);
|
|
47
|
-
if (postFilter) data = data.filter(postFilter);
|
|
48
|
-
|
|
49
|
-
if (removeEmpty) data = data.filter((d) => d.y !== 0);
|
|
50
|
-
|
|
51
|
-
if (data.length === 0) return <NoData height={height} />;
|
|
35
|
+
const data = useTransformedChartData(params, true);
|
|
52
36
|
|
|
53
37
|
const totalCount = data.reduce((sum, e) => sum + e.y, 0);
|
|
54
38
|
|
|
55
|
-
const onHover: BarProps['onMouseEnter'] = (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
const onHover: BarProps['onMouseEnter'] = useCallback(
|
|
40
|
+
(_data, _index, e) => {
|
|
41
|
+
const { target } = e;
|
|
42
|
+
if (onClick && target) (target as SVGElement).style.cursor = 'pointer';
|
|
43
|
+
},
|
|
44
|
+
[onClick]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (data.length === 0) {
|
|
48
|
+
return <NoData height={height} />;
|
|
49
|
+
}
|
|
59
50
|
|
|
60
51
|
// Regarding XAxis.ticks below:
|
|
61
52
|
// The weird conditional is added from https://github.com/recharts/recharts/issues/2593#issuecomment-1311678397
|
|
@@ -63,32 +54,34 @@ const BentoBarChart = ({
|
|
|
63
54
|
// on formatting a non-string. This hack manually overrides the ticks for the axis and blanks it out.
|
|
64
55
|
// - David L, 2023-01-03
|
|
65
56
|
return (
|
|
66
|
-
<
|
|
57
|
+
<ChartWrapper>
|
|
67
58
|
<div style={TITLE_STYLE}>{title}</div>
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
59
|
+
<ResponsiveContainer width={width ?? "100%"} height={height}>
|
|
60
|
+
<BarChart data={data} margin={BAR_CHART_MARGINS}>
|
|
61
|
+
<XAxis
|
|
62
|
+
dataKey="x"
|
|
63
|
+
height={20}
|
|
64
|
+
angle={-45}
|
|
65
|
+
ticks={data.length ? undefined : ['']}
|
|
66
|
+
tickFormatter={tickFormatter}
|
|
67
|
+
tickMargin={TICK_MARGIN}
|
|
68
|
+
textAnchor="end"
|
|
69
|
+
interval={data.length < TICKS_SHOW_ALL_LABELS_BELOW ? 0 : 'preserveStartEnd'}
|
|
70
|
+
>
|
|
71
|
+
<Label value={units} offset={UNITS_LABEL_OFFSET} position="insideBottom" />
|
|
72
|
+
</XAxis>
|
|
73
|
+
<YAxis>
|
|
74
|
+
<Label value={t['Count']} offset={-10} position="left" angle={270} />
|
|
75
|
+
</YAxis>
|
|
76
|
+
<Tooltip content={<BarTooltip totalCount={totalCount} />} />
|
|
77
|
+
<Bar dataKey="y" isAnimationActive={false} onClick={onClick} onMouseEnter={onHover}>
|
|
78
|
+
{data.map((entry) => (
|
|
79
|
+
<Cell key={entry.x} fill={fill(entry)} />
|
|
80
|
+
))}
|
|
81
|
+
</Bar>
|
|
82
|
+
</BarChart>
|
|
83
|
+
</ResponsiveContainer>
|
|
84
|
+
</ChartWrapper>
|
|
92
85
|
);
|
|
93
86
|
};
|
|
94
87
|
|