bento-charts 2.2.0 → 2.4.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.
Files changed (68) hide show
  1. package/README.md +94 -23
  2. package/dist/ChartConfigProvider.d.ts +4 -2
  3. package/dist/ChartConfigProvider.js +6 -1
  4. package/dist/ChartConfigProvider.js.map +1 -1
  5. package/dist/Components/Charts/BentoBarChart.js.map +1 -1
  6. package/dist/Components/Charts/BentoPie.d.ts +1 -1
  7. package/dist/Components/Charts/BentoPie.js +39 -37
  8. package/dist/Components/Charts/BentoPie.js.map +1 -1
  9. package/dist/Components/Maps/BentoChoroplethMap.d.ts +3 -0
  10. package/dist/Components/Maps/BentoChoroplethMap.js +90 -0
  11. package/dist/Components/Maps/BentoChoroplethMap.js.map +1 -0
  12. package/dist/Components/Maps/BentoMapContainer.d.ts +7 -0
  13. package/dist/Components/Maps/BentoMapContainer.js +33 -0
  14. package/dist/Components/Maps/BentoMapContainer.js.map +1 -0
  15. package/dist/Components/Maps/BentoOSMTileLayer.d.ts +2 -0
  16. package/dist/Components/Maps/BentoOSMTileLayer.js +6 -0
  17. package/dist/Components/Maps/BentoOSMTileLayer.js.map +1 -0
  18. package/dist/Components/Maps/BentoPointMap.d.ts +3 -0
  19. package/dist/Components/Maps/BentoPointMap.js +25 -0
  20. package/dist/Components/Maps/BentoPointMap.js.map +1 -0
  21. package/dist/Components/Maps/controls/MapLegendContinuous.d.ts +10 -0
  22. package/dist/Components/Maps/controls/MapLegendContinuous.js +19 -0
  23. package/dist/Components/Maps/controls/MapLegendContinuous.js.map +1 -0
  24. package/dist/Components/Maps/controls/MapLegendDiscrete.d.ts +8 -0
  25. package/dist/Components/Maps/controls/MapLegendDiscrete.js +22 -0
  26. package/dist/Components/Maps/controls/MapLegendDiscrete.js.map +1 -0
  27. package/dist/Components/Maps/controls/utils.d.ts +4 -0
  28. package/dist/Components/Maps/controls/utils.js +7 -0
  29. package/dist/Components/Maps/controls/utils.js.map +1 -0
  30. package/dist/constants/chartConstants.d.ts +0 -1
  31. package/dist/constants/chartConstants.js +0 -1
  32. package/dist/constants/chartConstants.js.map +1 -1
  33. package/dist/constants/mapConstants.d.ts +2 -0
  34. package/dist/constants/mapConstants.js +3 -0
  35. package/dist/constants/mapConstants.js.map +1 -0
  36. package/dist/index.js +5 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/maps.d.ts +3 -0
  39. package/dist/maps.js +5 -0
  40. package/dist/maps.js.map +1 -0
  41. package/dist/types/chartTypes.d.ts +12 -9
  42. package/dist/types/geoJSONTypes.d.ts +18 -0
  43. package/dist/types/geoJSONTypes.js +2 -0
  44. package/dist/types/geoJSONTypes.js.map +1 -0
  45. package/dist/types/mapTypes.d.ts +43 -0
  46. package/dist/types/mapTypes.js +2 -0
  47. package/dist/types/mapTypes.js.map +1 -0
  48. package/package.json +30 -4
  49. package/src/ChartConfigProvider.tsx +17 -2
  50. package/src/Components/Charts/BentoBarChart.tsx +2 -2
  51. package/src/Components/Charts/BentoPie.tsx +64 -57
  52. package/src/Components/Maps/BentoChoroplethMap.tsx +137 -0
  53. package/src/Components/Maps/BentoMapContainer.tsx +35 -0
  54. package/src/Components/Maps/BentoOSMTileLayer.tsx +7 -0
  55. package/src/Components/Maps/BentoPointMap.tsx +30 -0
  56. package/src/Components/Maps/controls/MapLegendContinuous.tsx +32 -0
  57. package/src/Components/Maps/controls/MapLegendDiscrete.tsx +31 -0
  58. package/src/Components/Maps/controls/utils.ts +8 -0
  59. package/src/constants/chartConstants.ts +0 -1
  60. package/src/constants/mapConstants.ts +4 -0
  61. package/src/index.ts +7 -0
  62. package/src/maps.ts +4 -0
  63. package/src/react-app-env.d.ts +1 -0
  64. package/src/styles.css +48 -0
  65. package/src/types/chartTypes.ts +13 -9
  66. package/src/types/geoJSONTypes.ts +21 -0
  67. package/src/types/mapTypes.ts +52 -0
  68. package/webpack.config.js +60 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BentoPointMap.js","s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aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ControlPosition } from 'leaflet';
2
+ export interface MapLegendDiscreteProps {
3
+ position: ControlPosition;
4
+ minValue: number;
5
+ minColor: string;
6
+ maxValue: number;
7
+ maxColor: string;
8
+ }
9
+ declare const MapLegendContinuous: ({ position, minValue, minColor, maxValue, maxColor }: MapLegendDiscreteProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default MapLegendContinuous;
@@ -0,0 +1,19 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { controlPositionClasses } from './utils';
14
+ var MapLegendContinuous = function (_a) {
15
+ 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 })] }))] })) })) })));
17
+ };
18
+ export default MapLegendContinuous;
19
+ //# sourceMappingURL=MapLegendContinuous.js.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ import type { ControlPosition } from 'leaflet';
2
+ import type { MapDiscreteLegendItem } from '../../../types/mapTypes';
3
+ export interface MapLegendDiscreteProps {
4
+ position: ControlPosition;
5
+ legendItems: MapDiscreteLegendItem[];
6
+ }
7
+ declare const MapLegendDiscrete: ({ position, legendItems }: MapLegendDiscreteProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default MapLegendDiscrete;
@@ -0,0 +1,22 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { controlPositionClasses } from './utils';
14
+ var MapLegendDiscrete = function (_a) {
15
+ 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) {
17
+ var label = _a.label, color = _a.color;
18
+ 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
+ }) }) })) })));
20
+ };
21
+ export default MapLegendDiscrete;
22
+ //# sourceMappingURL=MapLegendDiscrete.js.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { ControlPosition } from 'leaflet';
2
+ export declare const controlPositionClasses: {
3
+ [x in ControlPosition]: string;
4
+ };
@@ -0,0 +1,7 @@
1
+ export var controlPositionClasses = {
2
+ bottomleft: 'leaflet-bottom leaflet-left',
3
+ bottomright: 'leaflet-bottom leaflet-right',
4
+ topleft: 'leaflet-top leaflet-left',
5
+ topright: 'leaflet-bottom leaflet-right',
6
+ };
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/Components/Maps/controls/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,sBAAsB,GAAuC;IACxE,UAAU,EAAE,6BAA6B;IACzC,WAAW,EAAE,8BAA8B;IAC3C,OAAO,EAAE,0BAA0B;IACnC,QAAQ,EAAE,8BAA8B;CACzC,CAAC"}
@@ -19,6 +19,5 @@ 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 MAX_LABEL_CHARS = 14;
23
22
  export declare const OTHER_THRESHOLD = 0.01;
24
23
  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 MAX_LABEL_CHARS = 14;
102
101
  export var OTHER_THRESHOLD = 0.01;
103
102
  // ################### UTIL CONSTANTS ###################
104
103
  export var RADIAN = Math.PI / 180;
@@ -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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Q;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;AACpC,MAAM,CAAC,IAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,yDAAyD;AACzD,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const OSM_TILE_LAYER_ATTRIBUTION = "\n&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors\n";
2
+ export declare const OSM_TILE_LAYER_TEMPLATE = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
@@ -0,0 +1,3 @@
1
+ export var OSM_TILE_LAYER_ATTRIBUTION = "\n&copy; <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors\n";
2
+ export var OSM_TILE_LAYER_TEMPLATE = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
3
+ //# sourceMappingURL=mapConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapConstants.js","sourceRoot":"","sources":["../../src/constants/mapConstants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,0BAA0B,GAAG,6FAEzC,CAAC;AACF,MAAM,CAAC,IAAM,uBAAuB,GAAG,oDAAoD,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,10 @@
1
+ // Disable unused item linting in WebStorm:
2
+ // noinspection JSUnusedGlobalSymbols
3
+ // Categorical charts
1
4
  export { default as BarChart } from './Components/Charts/BentoBarChart';
2
5
  export { default as PieChart } from './Components/Charts/BentoPie';
6
+ // Maps are not included in index.ts - instead, they need to be included from `bento-charts/maps`.
7
+ // This way, we can have optional peer dependencies.
3
8
  export { default as ChartConfigProvider } from './ChartConfigProvider';
4
9
  export * from './types/chartTypes';
5
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,qCAAqC;AAErC,qBAAqB;AACrB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAEnE,kGAAkG;AAClG,oDAAoD;AAEpD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,cAAc,oBAAoB,CAAC"}
package/dist/maps.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as PointMap } from './Components/Maps/BentoPointMap';
2
+ export { default as ChoroplethMap } from './Components/Maps/BentoChoroplethMap';
3
+ export * from './types/mapTypes';
package/dist/maps.js ADDED
@@ -0,0 +1,5 @@
1
+ // Maps
2
+ export { default as PointMap } from './Components/Maps/BentoPointMap';
3
+ export { default as ChoroplethMap } from './Components/Maps/BentoChoroplethMap';
4
+ export * from './types/mapTypes';
5
+ //# sourceMappingURL=maps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps.js","sourceRoot":"","sources":["../src/maps.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAChF,cAAc,kBAAkB,CAAC"}
@@ -1,6 +1,6 @@
1
- import { PieProps, BarProps } from 'recharts';
2
- export type ChartDataType = ChartDataItem[];
3
- export interface ChartDataItem {
1
+ import type { PieProps, BarProps } from 'recharts';
2
+ export type CategoricalChartDataType = CategoricalChartDataItem[];
3
+ export interface CategoricalChartDataItem {
4
4
  x: string;
5
5
  y: number;
6
6
  }
@@ -33,7 +33,7 @@ export type ChartTheme = {
33
33
  };
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
- export type ChartFilterCallback = FilterCallback<ChartDataItem>;
36
+ export type ChartFilterCallback = FilterCallback<CategoricalChartDataItem>;
37
37
  export type SupportedLng = 'en' | 'fr';
38
38
  type TranslationWords = 'Count' | 'Other';
39
39
  export type LngDictionary = {
@@ -42,21 +42,24 @@ export type LngDictionary = {
42
42
  export type TranslationObject = {
43
43
  [key in SupportedLng]: LngDictionary;
44
44
  };
45
- interface BaseChartProps {
46
- data: ChartDataType;
45
+ export interface BaseChartComponentProps {
47
46
  height: number;
48
47
  preFilter?: ChartFilterCallback;
49
- dataMap?: UnitaryMapCallback<ChartDataItem>;
48
+ dataMap?: UnitaryMapCallback<CategoricalChartDataItem>;
50
49
  postFilter?: ChartFilterCallback;
50
+ }
51
+ interface BaseCategoricalChartProps extends BaseChartComponentProps {
52
+ data: CategoricalChartDataType;
51
53
  removeEmpty?: boolean;
52
54
  }
53
- export interface PieChartProps extends BaseChartProps {
55
+ export interface PieChartProps extends BaseCategoricalChartProps {
54
56
  colorTheme?: keyof ChartTheme['pie'];
55
57
  sort?: boolean;
56
58
  onClick?: PieProps['onClick'];
57
59
  chartThreshold?: number;
60
+ maxLabelChars?: number;
58
61
  }
59
- export interface BarChartProps extends BaseChartProps {
62
+ export interface BarChartProps extends BaseCategoricalChartProps {
60
63
  colorTheme?: keyof ChartTheme['bar'];
61
64
  title?: string;
62
65
  units: string;
@@ -0,0 +1,18 @@
1
+ export interface GeoJSONGeomPolygon {
2
+ type: 'Polygon';
3
+ coordinates: number[][][];
4
+ }
5
+ export interface BentoGeoJSONProperties {
6
+ title: string;
7
+ [x: string]: unknown;
8
+ }
9
+ export interface GeoJSONPolygonFeature {
10
+ type: 'Feature';
11
+ geometry: GeoJSONGeomPolygon;
12
+ properties: BentoGeoJSONProperties;
13
+ }
14
+ export interface GeoJSONPolygonOnlyFeatureCollection {
15
+ type: 'FeatureCollection';
16
+ features: GeoJSONPolygonFeature[];
17
+ [x: string]: unknown;
18
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=geoJSONTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoJSONTypes.js","sourceRoot":"","sources":["../../src/types/geoJSONTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import type { Feature as GeoJSONFeatureType } from 'geojson';
3
+ import { BaseChartComponentProps, CategoricalChartDataType } from './chartTypes';
4
+ import type { GeoJSONPolygonOnlyFeatureCollection } from './geoJSONTypes';
5
+ export interface GeoPointDataItem {
6
+ coordinates: [number, number];
7
+ title: string;
8
+ }
9
+ type PointMapOnClick = (point: GeoPointDataItem) => void;
10
+ type GeoJSONShapeOnClick = (shape: GeoJSONFeatureType) => void;
11
+ export interface BaseMapProps extends BaseChartComponentProps {
12
+ center: [number, number];
13
+ zoom: number;
14
+ tileLayer?: ReactElement;
15
+ }
16
+ export interface PointMapProps extends BaseMapProps {
17
+ data: GeoPointDataItem[];
18
+ onClick?: PointMapOnClick;
19
+ renderPopupBody?: (p: GeoPointDataItem) => ReactNode;
20
+ }
21
+ export interface MapDiscreteLegendItem {
22
+ color: string | undefined;
23
+ label: string;
24
+ }
25
+ export interface ChoroplethMapColorModeContinuous {
26
+ mode: 'continuous';
27
+ minColor: string;
28
+ maxColor: string;
29
+ }
30
+ export interface ChoroplethMapColorModeDiscrete {
31
+ mode: 'discrete';
32
+ colorFunction: (x: number | undefined) => string;
33
+ legendItems: MapDiscreteLegendItem[];
34
+ }
35
+ export interface ChoroplethMapProps extends BaseMapProps {
36
+ data: CategoricalChartDataType;
37
+ features: GeoJSONPolygonOnlyFeatureCollection;
38
+ colorMode: ChoroplethMapColorModeContinuous | ChoroplethMapColorModeDiscrete;
39
+ categoryProp: string;
40
+ onClick?: GeoJSONShapeOnClick;
41
+ renderPopupBody?: (f: GeoJSONFeatureType, d: number | undefined) => ReactNode;
42
+ }
43
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mapTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapTypes.js","sourceRoot":"","sources":["../../src/types/mapTypes.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "bento-charts",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
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
8
  "build": "npx tsc",
9
9
  "prepublishOnly": "npm run build",
10
- "lint": "npx eslint src/**",
11
- "buildpack": "rm ./packs/*.tgz && tsc && npm pack --pack-destination ./packs"
10
+ "lint": "npx eslint src",
11
+ "buildpack": "rm ./packs/*.tgz && tsc && npm pack --pack-destination ./packs",
12
+ "test": "npx webpack-dev-server"
12
13
  },
13
14
  "release": {
14
15
  "branches": [
@@ -37,26 +38,48 @@
37
38
  },
38
39
  "homepage": "https://github.com/bento-platform/Bento-Charts#readme",
39
40
  "peerDependencies": {
41
+ "leaflet": "^1.9.4",
40
42
  "react": ">=16.0.0",
41
43
  "react-dom": ">=14.0.0",
44
+ "react-leaflet": "^4.2.1",
42
45
  "recharts": "^2.4.3"
43
46
  },
47
+ "peerDependenciesMeta": {
48
+ "leaflet": {
49
+ "optional": true
50
+ },
51
+ "react-leafet": {
52
+ "optional": true
53
+ }
54
+ },
44
55
  "devDependencies": {
45
56
  "@commitlint/cli": "^17.4.4",
46
57
  "@commitlint/config-conventional": "^17.4.4",
47
58
  "@semantic-release/git": "^10.0.1",
59
+ "@types/leaflet": "^1.9.3",
48
60
  "@types/react": "^18.0.28",
49
61
  "@types/react-dom": "^18.0.10",
62
+ "@types/react-leaflet": "^3.0.0",
50
63
  "@types/recharts": "^1.8.24",
51
64
  "@typescript-eslint/eslint-plugin": "^5.56.0",
52
65
  "@typescript-eslint/parser": "^5.56.0",
66
+ "@webpack-cli/serve": "^2.0.5",
67
+ "antd": "^5.9.2",
68
+ "css-loader": "^6.8.1",
53
69
  "eslint": "^8.36.0",
54
70
  "eslint-plugin-react": "^7.32.2",
71
+ "file-loader": "^6.2.0",
72
+ "geojson": "^0.5.0",
73
+ "html-webpack-plugin": "^5.5.3",
55
74
  "husky": "^8.0.3",
56
75
  "prettier": "2.7.1",
57
76
  "semantic-release": "^20.1.3",
77
+ "style-loader": "^3.3.3",
58
78
  "ts-loader": "^9.4.2",
59
- "typescript": "^4.9.5"
79
+ "typescript": "^4.9.5",
80
+ "webpack": "^5.88.2",
81
+ "webpack-cli": "^5.1.4",
82
+ "webpack-dev-server": "^4.15.1"
60
83
  },
61
84
  "prettier": {
62
85
  "trailingComma": "es5",
@@ -64,5 +87,8 @@
64
87
  "semi": true,
65
88
  "singleQuote": true,
66
89
  "printWidth": 120
90
+ },
91
+ "dependencies": {
92
+ "d3-interpolate": "^3.0.1"
67
93
  }
68
94
  }
@@ -1,18 +1,20 @@
1
1
  import React, { useContext } from 'react';
2
2
 
3
3
  import { DEFAULT_CHART_THEME, defaultTranslationObject } from './constants/chartConstants';
4
- import { ChartTheme, LngDictionary, SupportedLng, TranslationObject } from './types/chartTypes';
4
+ import type { ChartTheme, LngDictionary, SupportedLng, TranslationObject } from './types/chartTypes';
5
5
 
6
6
  type ChartContextType = {
7
7
  theme: ChartTheme;
8
8
  translation: LngDictionary;
9
9
  threshold: number;
10
+ maxLabelChars: number;
10
11
  };
11
12
 
12
13
  const DEFAULT_CONTEXT: ChartContextType = {
13
14
  theme: DEFAULT_CHART_THEME,
14
15
  translation: defaultTranslationObject.en,
15
16
  threshold: 0,
17
+ maxLabelChars: 14,
16
18
  };
17
19
 
18
20
  const ChartContext = React.createContext<ChartContextType>(DEFAULT_CONTEXT);
@@ -29,7 +31,18 @@ export function useChartThreshold() {
29
31
  return useContext(ChartContext).threshold;
30
32
  }
31
33
 
32
- const ChartConfigProvider = ({ theme, Lng, translationMap, children, globalThreshold }: ChartConfigProviderProps) => {
34
+ export function useChartMaxLabelChars() {
35
+ return useContext(ChartContext).maxLabelChars;
36
+ }
37
+
38
+ const ChartConfigProvider = ({
39
+ theme,
40
+ Lng,
41
+ translationMap,
42
+ children,
43
+ globalThreshold,
44
+ maxLabelChars,
45
+ }: ChartConfigProviderProps) => {
33
46
  let lang: SupportedLng = 'en';
34
47
  try {
35
48
  lang = Lng as SupportedLng;
@@ -41,6 +54,7 @@ const ChartConfigProvider = ({ theme, Lng, translationMap, children, globalThres
41
54
  theme: theme ?? DEFAULT_CONTEXT.theme,
42
55
  translation: translationMap ? translationMap[lang] : defaultTranslationObject[lang],
43
56
  threshold: globalThreshold ?? DEFAULT_CONTEXT.threshold,
57
+ maxLabelChars: maxLabelChars ?? DEFAULT_CONTEXT.maxLabelChars,
44
58
  };
45
59
  return <ChartContext.Provider value={contextValue}>{children}</ChartContext.Provider>;
46
60
  };
@@ -51,6 +65,7 @@ type ChartConfigProviderProps = {
51
65
  translationMap?: TranslationObject;
52
66
  children: React.ReactElement;
53
67
  globalThreshold?: number;
68
+ maxLabelChars?: number;
54
69
  };
55
70
 
56
71
  export default ChartConfigProvider;
@@ -13,7 +13,7 @@ import {
13
13
  TICK_MARGIN,
14
14
  } from '../../constants/chartConstants';
15
15
 
16
- import type { BarChartProps, ChartDataItem, TooltipPayload } from '../../types/chartTypes';
16
+ import type { BarChartProps, CategoricalChartDataItem, TooltipPayload } from '../../types/chartTypes';
17
17
  import { useChartTheme, useChartTranslation } from '../../ChartConfigProvider';
18
18
  import NoData from '../NoData';
19
19
 
@@ -39,7 +39,7 @@ const BentoBarChart = ({
39
39
  const t = useChartTranslation();
40
40
  const { fill: chartFill, missing } = useChartTheme().bar[colorTheme];
41
41
 
42
- const fill = (entry: ChartDataItem) => (entry.x === 'missing' ? missing : chartFill);
42
+ const fill = (entry: CategoricalChartDataItem) => (entry.x === 'missing' ? missing : chartFill);
43
43
 
44
44
  data = [...data];
45
45
  if (preFilter) data = data.filter(preFilter);
@@ -9,23 +9,27 @@ import {
9
9
  CHART_MISSING_FILL,
10
10
  CHART_WRAPPER_STYLE,
11
11
  RADIAN,
12
- MAX_LABEL_CHARS,
13
12
  CHART_ASPECT_RATIO,
14
13
  LABEL_THRESHOLD,
15
14
  COUNT_TEXT_STYLE,
16
15
  TEXT_STYLE,
17
16
  } from '../../constants/chartConstants';
18
17
  import type { PieChartProps, TooltipPayload } from '../../types/chartTypes';
19
- import { useChartTheme, useChartTranslation, useChartThreshold } from '../../ChartConfigProvider';
18
+ import {
19
+ useChartTheme,
20
+ useChartTranslation,
21
+ useChartThreshold,
22
+ useChartMaxLabelChars,
23
+ } from '../../ChartConfigProvider';
20
24
  import { polarToCartesian } from '../../util/chartUtils';
21
25
  import NoData from '../NoData';
22
26
 
23
- const labelShortName = (name: string) => {
24
- if (name.length <= MAX_LABEL_CHARS) {
27
+ const labelShortName = (name: string, maxChars: number) => {
28
+ if (name.length <= maxChars) {
25
29
  return name;
26
30
  }
27
31
  // removing 3 character cause ... s add three characters
28
- return `${name.substring(0, MAX_LABEL_CHARS - 3)}\u2026`;
32
+ return `${name.substring(0, maxChars - 3)}\u2026`;
29
33
  };
30
34
 
31
35
  const BentoPie = ({
@@ -39,6 +43,7 @@ const BentoPie = ({
39
43
  removeEmpty = true,
40
44
  colorTheme = 'default',
41
45
  chartThreshold = useChartThreshold(),
46
+ maxLabelChars = useChartMaxLabelChars(),
42
47
  }: PieChartProps) => {
43
48
  const t = useChartTranslation();
44
49
  const theme = useChartTheme().pie[colorTheme];
@@ -103,7 +108,7 @@ const BentoPie = ({
103
108
  cy="50%"
104
109
  innerRadius={35}
105
110
  outerRadius={80}
106
- label={RenderLabel}
111
+ label={RenderLabel(maxLabelChars)}
107
112
  labelLine={false}
108
113
  isAnimationActive={false}
109
114
  onMouseEnter={onEnter}
@@ -139,64 +144,66 @@ const toNumber = (val: number | string | undefined, defaultValue?: number): numb
139
144
  return defaultValue || 0;
140
145
  };
141
146
 
142
- const RenderLabel: PieProps['label'] = (params: PieLabelRenderProps) => {
143
- const { fill, payload, index, activeIndex } = params;
144
- const percent = params.percent || 0;
145
- const midAngle = params.midAngle || 0;
147
+ const RenderLabel =
148
+ (maxLabelChars: number): PieProps['label'] =>
149
+ (params: PieLabelRenderProps) => { // eslint-disable-line
150
+ const { fill, payload, index, activeIndex } = params;
151
+ const percent = params.percent || 0;
152
+ const midAngle = params.midAngle || 0;
146
153
 
147
- // skip rendering this static label if the sector is selected.
148
- // this will let the 'renderActiveState' draw without overlapping.
149
- // also, skip rendering if segment is too small a percentage (avoids label clutter)
150
- if (index === activeIndex || percent < LABEL_THRESHOLD) {
151
- return;
152
- }
154
+ // skip rendering this static label if the sector is selected.
155
+ // this will let the 'renderActiveState' draw without overlapping.
156
+ // also, skip rendering if segment is too small a percentage (avoids label clutter)
157
+ if (index === activeIndex || percent < LABEL_THRESHOLD) {
158
+ return;
159
+ }
153
160
 
154
- const outerRadius = toNumber(params.outerRadius);
155
- const cx = toNumber(params.cx);
156
- const cy = toNumber(params.cy);
161
+ const outerRadius = toNumber(params.outerRadius);
162
+ const cx = toNumber(params.cx);
163
+ const cy = toNumber(params.cy);
157
164
 
158
- const name = payload.name === 'null' ? '(Empty)' : payload.name;
165
+ const name = payload.name === 'null' ? '(Empty)' : payload.name;
159
166
 
160
- const sin = Math.sin(-RADIAN * midAngle);
161
- const cos = Math.cos(-RADIAN * midAngle);
162
- const sx = cx + (outerRadius + 10) * cos;
163
- const sy = cy + (outerRadius + 10) * sin;
164
- const mx = cx + (outerRadius + 20) * cos;
165
- const my = cy + (outerRadius + 20) * sin;
166
- const ex = mx + (cos >= 0 ? 1 : -1) * 22;
167
- const ey = my;
168
- const textAnchor = cos >= 0 ? 'start' : 'end';
167
+ const sin = Math.sin(-RADIAN * midAngle);
168
+ const cos = Math.cos(-RADIAN * midAngle);
169
+ const sx = cx + (outerRadius + 10) * cos;
170
+ const sy = cy + (outerRadius + 10) * sin;
171
+ const mx = cx + (outerRadius + 20) * cos;
172
+ const my = cy + (outerRadius + 20) * sin;
173
+ const ex = mx + (cos >= 0 ? 1 : -1) * 22;
174
+ const ey = my;
175
+ const textAnchor = cos >= 0 ? 'start' : 'end';
169
176
 
170
- const currentTextStyle: CSS.Properties = {
171
- ...TEXT_STYLE,
172
- fontWeight: payload.selected ? 'bold' : 'normal',
173
- fontStyle: payload.name === 'null' ? 'italic' : 'normal',
174
- };
177
+ const currentTextStyle: CSS.Properties = {
178
+ ...TEXT_STYLE,
179
+ fontWeight: payload.selected ? 'bold' : 'normal',
180
+ fontStyle: payload.name === 'null' ? 'italic' : 'normal',
181
+ };
175
182
 
176
- const offsetRadius = 20;
177
- const startPoint = polarToCartesian(cx, cy, outerRadius, midAngle);
178
- const endPoint = polarToCartesian(cx, cy, outerRadius + offsetRadius, midAngle);
179
- const lineProps = {
180
- ...params,
181
- fill: 'none',
182
- stroke: fill,
183
- points: [startPoint, endPoint],
184
- };
183
+ const offsetRadius = 20;
184
+ const startPoint = polarToCartesian(cx, cy, outerRadius, midAngle);
185
+ const endPoint = polarToCartesian(cx, cy, outerRadius + offsetRadius, midAngle);
186
+ const lineProps = {
187
+ ...params,
188
+ fill: 'none',
189
+ stroke: fill,
190
+ points: [startPoint, endPoint],
191
+ };
185
192
 
186
- return (
187
- <g>
188
- <Curve {...lineProps} type="linear" className="recharts-pie-label-line" />
189
- <path d={`M${sx},${sy}L${mx},${my}L${ex},${ey}`} stroke={fill} fill="none" />
190
- <circle cx={ex} cy={ey} r={2} fill={fill} stroke="none" />
191
- <text x={ex + (cos >= 0 ? 1 : -1) * 12} y={ey + 3} textAnchor={textAnchor} style={currentTextStyle}>
192
- {labelShortName(name)}
193
- </text>
194
- <text x={ex + (cos >= 0 ? 1 : -1) * 12} y={ey} dy={14} textAnchor={textAnchor} style={COUNT_TEXT_STYLE}>
195
- {`(${payload.value})`}
196
- </text>
197
- </g>
198
- );
199
- };
193
+ return (
194
+ <g>
195
+ <Curve {...lineProps} type="linear" className="recharts-pie-label-line" />
196
+ <path d={`M${sx},${sy}L${mx},${my}L${ex},${ey}`} stroke={fill} fill="none" />
197
+ <circle cx={ex} cy={ey} r={2} fill={fill} stroke="none" />
198
+ <text x={ex + (cos >= 0 ? 1 : -1) * 12} y={ey + 3} textAnchor={textAnchor} style={currentTextStyle}>
199
+ {labelShortName(name, maxLabelChars)}
200
+ </text>
201
+ <text x={ex + (cos >= 0 ? 1 : -1) * 12} y={ey} dy={14} textAnchor={textAnchor} style={COUNT_TEXT_STYLE}>
202
+ {`(${payload.value})`}
203
+ </text>
204
+ </g>
205
+ );
206
+ };
200
207
 
201
208
  const RenderActiveLabel: PieProps['activeShape'] = (params) => {
202
209
  const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill } = params;