bento-charts 2.4.1 → 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.
- 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 +21 -35
- 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 -46
- package/dist/Components/Charts/BentoPie.js.map +1 -1
- 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 -1
- package/dist/constants/chartConstants.js +0 -1
- package/dist/constants/chartConstants.js.map +1 -1
- package/dist/types/chartTypes.d.ts +9 -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 +15 -25
- package/src/Components/Charts/BentoPie.tsx +74 -76
- package/src/Components/Maps/BentoChoroplethMap.tsx +4 -12
- package/src/Components/Maps/BentoPointMap.tsx +13 -4
- package/src/constants/chartConstants.ts +0 -1
- package/src/types/chartTypes.ts +10 -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":"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"}
|
|
@@ -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,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;CACrB,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,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;
|
|
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;CACrB,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,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"}
|
|
@@ -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
|
|
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
|
+
}
|
|
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;
|
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.4.
|
|
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",
|
|
@@ -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,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 =
|
|
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'] = (
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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'] = (
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
<
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
|
148
|
-
(
|
|
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;
|
|
@@ -15,16 +15,13 @@ import type { ChoroplethMapProps } from '../../types/mapTypes';
|
|
|
15
15
|
import BentoMapContainer from './BentoMapContainer';
|
|
16
16
|
import MapLegendContinuous from './controls/MapLegendContinuous';
|
|
17
17
|
import MapLegendDiscrete from './controls/MapLegendDiscrete';
|
|
18
|
+
import { useTransformedChartData } from '../../util/chartUtils';
|
|
18
19
|
|
|
19
20
|
const DEFAULT_CATEGORY = '';
|
|
20
21
|
const POS_BOTTOM_RIGHT: ControlPosition = 'bottomright';
|
|
21
22
|
|
|
22
23
|
const BentoChoroplethMap = ({
|
|
23
24
|
height,
|
|
24
|
-
data: originalData,
|
|
25
|
-
preFilter,
|
|
26
|
-
dataMap,
|
|
27
|
-
postFilter,
|
|
28
25
|
center,
|
|
29
26
|
zoom,
|
|
30
27
|
tileLayer,
|
|
@@ -33,14 +30,9 @@ const BentoChoroplethMap = ({
|
|
|
33
30
|
categoryProp,
|
|
34
31
|
onClick,
|
|
35
32
|
renderPopupBody,
|
|
33
|
+
...params
|
|
36
34
|
}: ChoroplethMapProps) => {
|
|
37
|
-
const data =
|
|
38
|
-
let data = [...originalData];
|
|
39
|
-
if (preFilter) data = data.filter(preFilter);
|
|
40
|
-
if (dataMap) data = data.map(dataMap);
|
|
41
|
-
if (postFilter) data = data.filter(postFilter);
|
|
42
|
-
return data;
|
|
43
|
-
}, [originalData]);
|
|
35
|
+
const data = useTransformedChartData(params);
|
|
44
36
|
|
|
45
37
|
const dataByFeatureCat = useMemo(() => Object.fromEntries(data.map((d) => [d.x, d.y])), [data]);
|
|
46
38
|
|
|
@@ -102,7 +94,7 @@ const BentoChoroplethMap = ({
|
|
|
102
94
|
</div>
|
|
103
95
|
);
|
|
104
96
|
},
|
|
105
|
-
} as LeafletEventHandlerFnMap
|
|
97
|
+
}) as LeafletEventHandlerFnMap,
|
|
106
98
|
[onClick, categoryProp, renderPopupBody]
|
|
107
99
|
);
|
|
108
100
|
|
|
@@ -16,10 +16,19 @@ const BentoPointMap = ({ height, center, zoom, tileLayer, data, onClick, renderP
|
|
|
16
16
|
<Marker key={i} position={coordinatesLatLongOrder}>
|
|
17
17
|
<Popup>
|
|
18
18
|
<h4 style={{ marginBottom: renderPopupBody ? 6 : 0 }}>
|
|
19
|
-
{onClick ?
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
{onClick ? (
|
|
20
|
+
<a
|
|
21
|
+
href="#"
|
|
22
|
+
onClick={(e) => {
|
|
23
|
+
onClick(point);
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
{title}
|
|
28
|
+
</a>
|
|
29
|
+
) : (
|
|
30
|
+
<>{title}</>
|
|
31
|
+
)}
|
|
23
32
|
</h4>
|
|
24
33
|
{renderPopupBody ? renderPopupBody(point) : null}
|
|
25
34
|
</Popup>
|
|
@@ -113,7 +113,6 @@ export const TICK_MARGIN = 5; // vertical spacing between tick line and tick lab
|
|
|
113
113
|
// pie chart
|
|
114
114
|
export const CHART_ASPECT_RATIO = 1.4;
|
|
115
115
|
export const LABEL_THRESHOLD = 0.05;
|
|
116
|
-
export const OTHER_THRESHOLD = 0.01;
|
|
117
116
|
|
|
118
117
|
// ################### UTIL CONSTANTS ###################
|
|
119
118
|
export const RADIAN = Math.PI / 180;
|