bento-charts 2.4.0 → 2.4.2

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.
Files changed (43) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/README.md +1 -1
  3. package/dist/ChartConfigProvider.js +1 -12
  4. package/dist/ChartConfigProvider.js.map +1 -1
  5. package/dist/Components/Charts/BentoBarChart.d.ts +1 -1
  6. package/dist/Components/Charts/BentoBarChart.js +21 -35
  7. package/dist/Components/Charts/BentoBarChart.js.map +1 -1
  8. package/dist/Components/Charts/BentoPie.d.ts +1 -1
  9. package/dist/Components/Charts/BentoPie.js +55 -46
  10. package/dist/Components/Charts/BentoPie.js.map +1 -1
  11. package/dist/Components/Maps/BentoChoroplethMap.d.ts +1 -1
  12. package/dist/Components/Maps/BentoChoroplethMap.js +16 -32
  13. package/dist/Components/Maps/BentoChoroplethMap.js.map +1 -1
  14. package/dist/Components/Maps/BentoMapContainer.js +1 -12
  15. package/dist/Components/Maps/BentoMapContainer.js.map +1 -1
  16. package/dist/Components/Maps/BentoPointMap.js +6 -14
  17. package/dist/Components/Maps/BentoPointMap.js.map +1 -1
  18. package/dist/Components/Maps/controls/MapLegendContinuous.js +1 -12
  19. package/dist/Components/Maps/controls/MapLegendContinuous.js.map +1 -1
  20. package/dist/Components/Maps/controls/MapLegendDiscrete.js +2 -13
  21. package/dist/Components/Maps/controls/MapLegendDiscrete.js.map +1 -1
  22. package/dist/Components/NoData.js +2 -13
  23. package/dist/Components/NoData.js.map +1 -1
  24. package/dist/constants/chartConstants.d.ts +0 -1
  25. package/dist/constants/chartConstants.js +0 -1
  26. package/dist/constants/chartConstants.js.map +1 -1
  27. package/dist/styles.css +48 -0
  28. package/dist/types/chartTypes.d.ts +9 -6
  29. package/dist/types/mapTypes.d.ts +2 -3
  30. package/dist/util/chartUtils.d.ts +2 -0
  31. package/dist/util/chartUtils.js +30 -0
  32. package/dist/util/chartUtils.js.map +1 -1
  33. package/package.json +19 -17
  34. package/src/Components/Charts/BentoBarChart.tsx +15 -25
  35. package/src/Components/Charts/BentoPie.tsx +74 -76
  36. package/src/Components/Maps/BentoChoroplethMap.tsx +6 -13
  37. package/src/Components/Maps/BentoPointMap.tsx +13 -1
  38. package/src/constants/chartConstants.ts +0 -1
  39. package/src/types/chartTypes.ts +10 -7
  40. package/src/types/mapTypes.ts +3 -3
  41. package/src/util/chartUtils.ts +29 -0
  42. package/tsconfig.json +1 -1
  43. package/webpack.config.js +9 -1
@@ -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", __assign({ className: controlPositionClasses[position] }, { children: _jsx("div", __assign({ className: "leaflet-control bento-charts--map--legend" }, { children: _jsxs("div", __assign({ 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", __assign({ className: "bento-charts--map--legend--values" }, { children: [_jsx("span", { children: maxValue }), _jsx("span", { children: minValue })] }))] })) })) })));
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":";;;;;;;;;;;;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,uBAAK,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,gBAC9C,uBAAK,SAAS,EAAC,2CAA2C,gBACxD,wBAAK,SAAS,EAAC,kCAAkC,iBAC/C,cACE,SAAS,EAAC,gCAAgC,EAC1C,KAAK,EAAE,EAAE,UAAU,EAAE,gCAAyB,QAAQ,kBAAQ,QAAQ,WAAQ,EAAE,GAChF,EACF,wBAAK,SAAS,EAAC,mCAAmC,iBAChD,yBAAO,QAAQ,GAAQ,EACvB,yBAAO,QAAQ,GAAQ,KACnB,KACF,IACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
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", __assign({ className: controlPositionClasses[position] }, { children: _jsx("div", __assign({ className: "leaflet-control bento-charts--map--legend" }, { children: _jsx("ul", { children: legendItems.map(function (_a, i) {
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":";;;;;;;;;;;;AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAOjD,IAAM,iBAAiB,GAAG,UAAC,EAAiD;QAA/C,QAAQ,cAAA,EAAE,WAAW,iBAAA;IAChD,OAAO,CACL,uBAAK,SAAS,EAAE,sBAAsB,CAAC,QAAQ,CAAC,gBAC9C,uBAAK,SAAS,EAAC,2CAA2C,gBACxD,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,IACD,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
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", __assign({ style: {
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
- } }, { children: "No Data" })));
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":";;;;;;;;;;;;AAEA,IAAM,MAAM,GAAG,UAAC,EAAuB;QAArB,MAAM,YAAA;IACtB,OAAO,CACL,uBACE,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,6BAGG,CACP,CAAC;AACJ,CAAC,CAAC;AAMF,eAAe,MAAM,CAAC"}
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"}
@@ -19,5 +19,4 @@ export declare const TICKS_SHOW_ALL_LABELS_BELOW = 11;
19
19
  export declare const TICK_MARGIN = 5;
20
20
  export declare const CHART_ASPECT_RATIO = 1.4;
21
21
  export declare const LABEL_THRESHOLD = 0.05;
22
- export declare const OTHER_THRESHOLD = 0.01;
23
22
  export declare const RADIAN: number;
@@ -98,7 +98,6 @@ export var TICK_MARGIN = 5; // vertical spacing between tick line and tick label
98
98
  // pie chart
99
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,CAA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MAAM;IAChB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,0DAA0D;AAC1D,YAAY;AACZ,MAAM,CAAC,IAAM,YAAY,GAAG,GAAG,CAAC;AAChC,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,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,IAAM,eAAe,GAAG,IAAI,CAAC;AACpC,MAAM,CAAC,IAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,yDAAyD;AACzD,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC"}
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,MAA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AEF,0DAA0D;AAC1D,YAAY;AACZ,MAAM,CAAC,IAAM,YAAY,GAAG,GAAG,CAAC;AAChC,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,kBAAkB,GAAG,GAAG,CAAC;AACtC,MAAM,CAAC,IAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,yDAAyD;AACzD,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC"}
@@ -0,0 +1,48 @@
1
+ .bento-charts--map--legend {
2
+ background-color: white;
3
+ padding: 12px;
4
+ border-radius: 12px;
5
+ border: 1px solid rgba(0, 0, 0, 0.2);
6
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
7
+ }
8
+ .leaflet-bottom .bento-charts--map--legend {
9
+ margin-bottom: 28px;
10
+ }
11
+
12
+ .bento-charts--map--legend ul {
13
+ list-style: none;
14
+ margin: 0;
15
+ padding: 0;
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: 6px;
19
+ }
20
+
21
+ .bento-charts--map--legend--patch {
22
+ display: inline-block;
23
+ width: 1rem;
24
+ height: 1rem;
25
+ border: 1px solid white;
26
+ vertical-align: top;
27
+ margin-right: 12px;
28
+ border-radius: 3px;
29
+ }
30
+
31
+ .bento-charts--map--legend--scale {
32
+ height: 100px;
33
+ display: flex;
34
+ gap: 12px;
35
+ }
36
+
37
+ .bento-charts--continuous-scale {
38
+ width: 1rem;
39
+ height: 100%;
40
+ }
41
+
42
+ .bento-charts--map--legend--values {
43
+ display: flex;
44
+ flex-direction: column;
45
+ }
46
+ .bento-charts--map--legend--values > span:first-of-type {
47
+ flex: 1;
48
+ }
@@ -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,18 @@ export type LngDictionary = {
42
43
  export type TranslationObject = {
43
44
  [key in SupportedLng]: LngDictionary;
44
45
  };
45
- export interface BaseChartComponentProps {
46
- height: number;
46
+ export interface CategoricalChartDataWithTransforms {
47
+ data: CategoricalChartDataType;
47
48
  preFilter?: ChartFilterCallback;
48
- dataMap?: UnitaryMapCallback<CategoricalChartDataItem>;
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
+ }
56
+ export interface BaseCategoricalChartProps extends BaseChartComponentProps, CategoricalChartDataWithTransforms {
57
+ }
55
58
  export interface PieChartProps extends BaseCategoricalChartProps {
56
59
  colorTheme?: keyof ChartTheme['pie'];
57
60
  sort?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import type { Feature as GeoJSONFeatureType } from 'geojson';
3
- import { BaseChartComponentProps, CategoricalChartDataType } from './chartTypes';
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[];
@@ -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;AAErD,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"}
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,CAA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3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Charts library for Bento-platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "npx tsc",
8
+ "build": "npx tsc && npm run copy-files",
9
+ "copy-files": "cp ./src/styles.css ./dist/",
9
10
  "prepublishOnly": "npm run build",
10
11
  "lint": "npx eslint src",
11
12
  "buildpack": "rm ./packs/*.tgz && tsc && npm pack --pack-destination ./packs",
@@ -53,30 +54,31 @@
53
54
  }
54
55
  },
55
56
  "devDependencies": {
56
- "@commitlint/cli": "^17.4.4",
57
- "@commitlint/config-conventional": "^17.4.4",
57
+ "@commitlint/cli": "^17.7.2",
58
+ "@commitlint/config-conventional": "^17.7.0",
58
59
  "@semantic-release/git": "^10.0.1",
59
- "@types/leaflet": "^1.9.3",
60
- "@types/react": "^18.0.28",
61
- "@types/react-dom": "^18.0.10",
60
+ "@types/leaflet": "^1.9.6",
61
+ "@types/react": "^18.2.24",
62
+ "@types/react-dom": "^18.2.8",
62
63
  "@types/react-leaflet": "^3.0.0",
63
- "@types/recharts": "^1.8.24",
64
- "@typescript-eslint/eslint-plugin": "^5.56.0",
65
- "@typescript-eslint/parser": "^5.56.0",
64
+ "@types/recharts": "^1.8.25",
65
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
66
+ "@typescript-eslint/parser": "^6.7.3",
66
67
  "@webpack-cli/serve": "^2.0.5",
67
- "antd": "^5.9.2",
68
+ "antd": "^5.9.4",
68
69
  "css-loader": "^6.8.1",
69
- "eslint": "^8.36.0",
70
- "eslint-plugin-react": "^7.32.2",
70
+ "eslint": "^8.50.0",
71
+ "eslint-plugin-react": "^7.33.2",
71
72
  "file-loader": "^6.2.0",
72
73
  "geojson": "^0.5.0",
73
74
  "html-webpack-plugin": "^5.5.3",
74
75
  "husky": "^8.0.3",
75
- "prettier": "2.7.1",
76
- "semantic-release": "^20.1.3",
76
+ "prettier": "3.0.3",
77
+ "react-router-dom": "^6.16.0",
78
+ "semantic-release": "^22.0.5",
77
79
  "style-loader": "^3.3.3",
78
- "ts-loader": "^9.4.2",
79
- "typescript": "^4.9.5",
80
+ "ts-loader": "^9.4.4",
81
+ "typescript": "^5.2.2",
80
82
  "webpack": "^5.88.2",
81
83
  "webpack-cli": "^5.1.4",
82
84
  "webpack-dev-server": "^4.15.1"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import { BarChart, Bar, Cell, XAxis, YAxis, Tooltip, Label, BarProps } from 'recharts';
3
3
  import {
4
4
  TOOL_TIP_STYLE,
@@ -16,6 +16,7 @@ import {
16
16
  import type { BarChartProps, CategoricalChartDataItem, TooltipPayload } from '../../types/chartTypes';
17
17
  import { useChartTheme, useChartTranslation } from '../../ChartConfigProvider';
18
18
  import NoData from '../NoData';
19
+ import { useTransformedChartData } from '../../util/chartUtils';
19
20
 
20
21
  const tickFormatter = (tickLabel: string) => {
21
22
  if (tickLabel.length <= MAX_TICK_LABEL_CHARS) {
@@ -24,38 +25,27 @@ const tickFormatter = (tickLabel: string) => {
24
25
  return `${tickLabel.substring(0, MAX_TICK_LABEL_CHARS)}...`;
25
26
  };
26
27
 
27
- const BentoBarChart = ({
28
- data,
29
- height,
30
- units,
31
- title,
32
- preFilter,
33
- dataMap,
34
- postFilter,
35
- onClick,
36
- removeEmpty = true,
37
- colorTheme = 'default',
38
- }: BarChartProps) => {
28
+ const BentoBarChart = ({ height, units, title, onClick, colorTheme = 'default', ...params }: BarChartProps) => {
39
29
  const t = useChartTranslation();
40
30
  const { fill: chartFill, missing } = useChartTheme().bar[colorTheme];
41
31
 
42
32
  const fill = (entry: CategoricalChartDataItem) => (entry.x === 'missing' ? missing : chartFill);
43
33
 
44
- data = [...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} />;
34
+ const data = useTransformedChartData(params, true);
52
35
 
53
36
  const totalCount = data.reduce((sum, e) => sum + e.y, 0);
54
37
 
55
- const onHover: BarProps['onMouseEnter'] = (_data, _index, e) => {
56
- const { target } = e;
57
- if (onClick && target) (target as SVGElement).style.cursor = 'pointer';
58
- };
38
+ const onHover: BarProps['onMouseEnter'] = useCallback(
39
+ (_data, _index, e) => {
40
+ const { target } = e;
41
+ if (onClick && target) (target as SVGElement).style.cursor = 'pointer';
42
+ },
43
+ [onClick]
44
+ );
45
+
46
+ if (data.length === 0) {
47
+ return <NoData height={height} />;
48
+ }
59
49
 
60
50
  // Regarding XAxis.ticks below:
61
51
  // The weird conditional is added from https://github.com/recharts/recharts/issues/2593#issuecomment-1311678397
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
2
  import { PieChart, Pie, Cell, Curve, Tooltip, Sector, PieProps, PieLabelRenderProps } from 'recharts';
3
3
  import type CSS from 'csstype';
4
4
 
@@ -21,7 +21,7 @@ import {
21
21
  useChartThreshold,
22
22
  useChartMaxLabelChars,
23
23
  } from '../../ChartConfigProvider';
24
- import { polarToCartesian } from '../../util/chartUtils';
24
+ import { polarToCartesian, useTransformedChartData } from '../../util/chartUtils';
25
25
  import NoData from '../NoData';
26
26
 
27
27
  const labelShortName = (name: string, maxChars: number) => {
@@ -32,18 +32,17 @@ const labelShortName = (name: string, maxChars: number) => {
32
32
  return `${name.substring(0, maxChars - 3)}\u2026`;
33
33
  };
34
34
 
35
+ const OUTER_RADIUS_REDUCTION_FACTOR = 3.75; // originally from 300 / 80
36
+ const INNER_RADIUS_REDUCTION_FACTOR = 8.5; // roughly originally from 300 / 35
37
+
35
38
  const BentoPie = ({
36
- data,
37
39
  height,
38
- preFilter,
39
- dataMap,
40
- postFilter,
41
40
  onClick,
42
41
  sort = true,
43
- removeEmpty = true,
44
42
  colorTheme = 'default',
45
43
  chartThreshold = useChartThreshold(),
46
44
  maxLabelChars = useChartMaxLabelChars(),
45
+ ...params
47
46
  }: PieChartProps) => {
48
47
  const t = useChartTranslation();
49
48
  const theme = useChartTheme().pie[colorTheme];
@@ -52,86 +51,83 @@ const BentoPie = ({
52
51
 
53
52
  // ##################### Data processing #####################
54
53
 
55
- data = [...data]; // Changing immutable data to mutable data
56
- if (preFilter) data = data.filter(preFilter);
57
- if (dataMap) data = data.map(dataMap);
58
- if (postFilter) data = data.filter(postFilter);
59
-
60
- // removing empty values
61
- if (removeEmpty) data = data.filter((e) => e.y !== 0);
54
+ const transformedData = useTransformedChartData(params, true, sort);
55
+ const { data, sum } = useMemo(() => {
56
+ let data = [...transformedData];
62
57
 
63
- if (sort) data.sort((a, b) => a.y - b.y);
64
-
65
- // combining sections with less than OTHER_THRESHOLD
66
- const sum = data.reduce((acc, e) => acc + e.y, 0);
67
- const length = data.length;
68
- const threshold = chartThreshold * sum;
69
- const temp = data.filter((e) => e.y > threshold);
58
+ // combining sections with less than chartThreshold
59
+ const sum = data.reduce((acc, e) => acc + e.y, 0);
60
+ const length = data.length;
61
+ const threshold = chartThreshold * sum;
62
+ const dataAboveThreshold = data.filter((e) => e.y > threshold);
63
+ // length - 1 intentional: if there is just one category below threshold, the "Other" category is not necessary.
64
+ data = dataAboveThreshold.length === length - 1 ? data : dataAboveThreshold;
65
+ if (data.length !== length) {
66
+ data.push({
67
+ x: t['Other'],
68
+ y: sum - data.reduce((acc, e) => acc + e.y, 0),
69
+ });
70
+ }
70
71
 
71
- // length - 1 intentional: if there is just one category bellow threshold the "Other" category is not necessary
72
- data = temp.length === length - 1 ? data : temp;
73
- if (data.length !== length) {
74
- data.push({
75
- x: t['Other'],
76
- y: sum - data.reduce((acc, e) => acc + e.y, 0),
77
- });
78
- }
72
+ return {
73
+ data: data.map((e) => ({ name: e.x, value: e.y })),
74
+ sum,
75
+ };
76
+ }, [transformedData, sort, chartThreshold]);
79
77
 
80
78
  if (data.length === 0) {
81
79
  return <NoData height={height} />;
82
80
  }
83
81
 
84
- const bentoFormatData = data.map((e) => ({ name: e.x, value: e.y }));
85
-
86
82
  // ##################### Rendering #####################
87
- const onEnter: PieProps['onMouseEnter'] = (_data, index) => {
83
+ const onEnter: PieProps['onMouseEnter'] = useCallback((_data, index) => {
88
84
  setActiveIndex(index);
89
- };
85
+ }, []);
90
86
 
91
- const onHover: PieProps['onMouseOver'] = (data, _index, e) => {
92
- const { target } = e;
93
- if (onClick && target && data.name !== t['Other']) (target as SVGElement).style.cursor = 'pointer';
94
- };
87
+ const onHover: PieProps['onMouseOver'] = useCallback(
88
+ (data, _index, e) => {
89
+ const { target } = e;
90
+ if (onClick && target && data.name !== t['Other']) (target as SVGElement).style.cursor = 'pointer';
91
+ },
92
+ [onClick]
93
+ );
95
94
 
96
- const onLeave: PieProps['onMouseLeave'] = () => {
95
+ const onLeave: PieProps['onMouseLeave'] = useCallback(() => {
97
96
  setActiveIndex(undefined);
98
- };
97
+ }, []);
99
98
 
100
99
  return (
101
- <>
102
- <div style={CHART_WRAPPER_STYLE}>
103
- <PieChart height={height} width={height * CHART_ASPECT_RATIO}>
104
- <Pie
105
- data={bentoFormatData}
106
- dataKey="value"
107
- cx="50%"
108
- cy="50%"
109
- innerRadius={35}
110
- outerRadius={80}
111
- label={RenderLabel(maxLabelChars)}
112
- labelLine={false}
113
- isAnimationActive={false}
114
- onMouseEnter={onEnter}
115
- onMouseLeave={onLeave}
116
- onMouseOver={onHover}
117
- activeIndex={activeIndex}
118
- activeShape={RenderActiveLabel}
119
- onClick={onClick}
120
- >
121
- {data.map((entry, index) => {
122
- let fill = theme[index % theme.length];
123
- fill = entry.x.toLowerCase() === 'missing' ? CHART_MISSING_FILL : fill;
124
- return <Cell key={index} fill={fill} />;
125
- })}
126
- </Pie>
127
- <Tooltip
128
- content={<CustomTooltip totalCount={sum} />}
129
- isAnimationActive={false}
130
- allowEscapeViewBox={{ x: true, y: true }}
131
- />
132
- </PieChart>
133
- </div>
134
- </>
100
+ <div style={CHART_WRAPPER_STYLE}>
101
+ <PieChart height={height} width={height * CHART_ASPECT_RATIO}>
102
+ <Pie
103
+ data={data}
104
+ dataKey="value"
105
+ cx="50%"
106
+ cy="50%"
107
+ innerRadius={height / INNER_RADIUS_REDUCTION_FACTOR}
108
+ outerRadius={height / OUTER_RADIUS_REDUCTION_FACTOR}
109
+ label={renderLabel(maxLabelChars)}
110
+ labelLine={false}
111
+ isAnimationActive={false}
112
+ onMouseEnter={onEnter}
113
+ onMouseLeave={onLeave}
114
+ onMouseOver={onHover}
115
+ activeIndex={activeIndex}
116
+ activeShape={RenderActiveLabel}
117
+ onClick={onClick}
118
+ >
119
+ {data.map((entry, index) => {
120
+ const fill = entry.name.toLowerCase() === 'missing' ? CHART_MISSING_FILL : theme[index % theme.length];
121
+ return <Cell key={index} fill={fill} />;
122
+ })}
123
+ </Pie>
124
+ <Tooltip
125
+ content={<CustomTooltip totalCount={sum} />}
126
+ isAnimationActive={false}
127
+ allowEscapeViewBox={{ x: true, y: true }}
128
+ />
129
+ </PieChart>
130
+ </div>
135
131
  );
136
132
  };
137
133
 
@@ -144,9 +140,8 @@ const toNumber = (val: number | string | undefined, defaultValue?: number): numb
144
140
  return defaultValue || 0;
145
141
  };
146
142
 
147
- const RenderLabel =
148
- (maxLabelChars: number): PieProps['label'] =>
149
- (params: PieLabelRenderProps) => { // eslint-disable-line
143
+ const renderLabel = (maxLabelChars: number): PieProps['label'] => {
144
+ const BentoPieLabel = (params: PieLabelRenderProps) => {
150
145
  const { fill, payload, index, activeIndex } = params;
151
146
  const percent = params.percent || 0;
152
147
  const midAngle = params.midAngle || 0;
@@ -204,6 +199,9 @@ const RenderLabel =
204
199
  </g>
205
200
  );
206
201
  };
202
+ BentoPieLabel.displayName = BentoPieLabel;
203
+ return BentoPieLabel;
204
+ };
207
205
 
208
206
  const RenderActiveLabel: PieProps['activeShape'] = (params) => {
209
207
  const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill } = params;