@hisptz/dhis2-analytics 1.0.9 → 1.0.11

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 (162) hide show
  1. package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +6 -6
  2. package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +2 -4
  3. package/build/cjs/components/ChartAnalytics/index.js +25 -17
  4. package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
  5. package/build/cjs/components/Map/Map.stories.js +1 -1
  6. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  7. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  8. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +3 -12
  9. package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  10. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  11. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  12. package/build/cjs/components/PivotTable/PivotTable.stories.js +277 -0
  13. package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +32 -0
  14. package/build/cjs/components/PivotTable/components/PivotTable.js +60 -0
  15. package/build/cjs/components/PivotTable/components/PivotTableBody.js +41 -0
  16. package/build/cjs/components/PivotTable/components/PivotTableCell.js +40 -0
  17. package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +26 -0
  18. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +71 -0
  19. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +60 -0
  20. package/build/cjs/components/PivotTable/components/PivotTableContainer.js +33 -0
  21. package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +77 -0
  22. package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +22 -0
  23. package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +33 -0
  24. package/build/cjs/components/PivotTable/components/PivotTableEngineContext.js +25 -0
  25. package/build/cjs/components/PivotTable/components/PivotTableHead.js +35 -0
  26. package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +37 -0
  27. package/build/cjs/components/PivotTable/components/PivotTableRow.js +65 -0
  28. package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +49 -0
  29. package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +52 -0
  30. package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +46 -0
  31. package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +69 -0
  32. package/build/cjs/components/PivotTable/constants/dataTypes.js +129 -0
  33. package/build/cjs/components/PivotTable/constants/pivotTable.js +64 -0
  34. package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +62 -0
  35. package/build/cjs/components/PivotTable/constants/valueTypes.js +55 -0
  36. package/build/cjs/components/PivotTable/data/column-data.json +210 -0
  37. package/build/cjs/components/PivotTable/hooks/useParentSize.js +41 -0
  38. package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +38 -0
  39. package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +34 -0
  40. package/build/cjs/components/PivotTable/hooks/useTableClipping.js +53 -0
  41. package/build/cjs/components/PivotTable/index.js +47 -0
  42. package/build/cjs/components/PivotTable/interfaces/index.js +1 -0
  43. package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +197 -0
  44. package/build/cjs/components/PivotTable/services/engine.js +901 -0
  45. package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +71 -0
  46. package/build/cjs/components/PivotTable/utils/index.js +322 -0
  47. package/build/cjs/components/PivotTable/utils/isColorBright.js +29 -0
  48. package/build/cjs/components/PivotTable/utils/layout/dimension.js +61 -0
  49. package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +12 -0
  50. package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +12 -0
  51. package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +9 -0
  52. package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +9 -0
  53. package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +25 -0
  54. package/build/cjs/components/PivotTable/utils/legend.js +40 -0
  55. package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +27 -0
  56. package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  57. package/build/cjs/index.js +11 -0
  58. package/build/cjs/locales/en/translations.json +33 -0
  59. package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +3 -3
  60. package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +2 -3
  61. package/build/es/components/ChartAnalytics/index.js +2 -3
  62. package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
  63. package/build/es/components/Map/Map.stories.js +1 -1
  64. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  65. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  66. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +9 -8
  67. package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  68. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  69. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  70. package/build/es/components/PivotTable/PivotTable.stories.js +268 -0
  71. package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +24 -0
  72. package/build/es/components/PivotTable/components/PivotTable.js +51 -0
  73. package/build/es/components/PivotTable/components/PivotTableBody.js +33 -0
  74. package/build/es/components/PivotTable/components/PivotTableCell.js +32 -0
  75. package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +18 -0
  76. package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +62 -0
  77. package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +52 -0
  78. package/build/es/components/PivotTable/components/PivotTableContainer.js +25 -0
  79. package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +68 -0
  80. package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +14 -0
  81. package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +25 -0
  82. package/build/es/components/PivotTable/components/PivotTableEngineContext.js +14 -0
  83. package/build/es/components/PivotTable/components/PivotTableHead.js +27 -0
  84. package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +29 -0
  85. package/build/es/components/PivotTable/components/PivotTableRow.js +57 -0
  86. package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +41 -0
  87. package/build/es/components/PivotTable/components/PivotTableTitleRow.js +42 -0
  88. package/build/es/components/PivotTable/components/PivotTableTitleRows.js +37 -0
  89. package/build/es/components/PivotTable/components/PivotTableValueCell.js +60 -0
  90. package/build/es/components/PivotTable/constants/dataTypes.js +98 -0
  91. package/build/es/components/PivotTable/constants/pivotTable.js +29 -0
  92. package/build/es/components/PivotTable/constants/predefinedDimensions.js +44 -0
  93. package/build/es/components/PivotTable/constants/valueTypes.js +27 -0
  94. package/build/es/components/PivotTable/data/column-data.json +210 -0
  95. package/build/es/components/PivotTable/hooks/useParentSize.js +33 -0
  96. package/build/es/components/PivotTable/hooks/useScrollPosition.js +30 -0
  97. package/build/es/components/PivotTable/hooks/useSortableColumns.js +27 -0
  98. package/build/es/components/PivotTable/hooks/useTableClipping.js +46 -0
  99. package/build/es/components/PivotTable/index.js +26 -0
  100. package/build/es/components/PivotTable/interfaces/index.js +1 -0
  101. package/build/es/components/PivotTable/services/adaptiveClippingController.js +191 -0
  102. package/build/es/components/PivotTable/services/engine.js +894 -0
  103. package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +63 -0
  104. package/build/es/components/PivotTable/utils/index.js +309 -0
  105. package/build/es/components/PivotTable/utils/isColorBright.js +22 -0
  106. package/build/es/components/PivotTable/utils/layout/dimension.js +48 -0
  107. package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +5 -0
  108. package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +5 -0
  109. package/build/es/components/PivotTable/utils/layout/dimensionIs.js +2 -0
  110. package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +2 -0
  111. package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +18 -0
  112. package/build/es/components/PivotTable/utils/legend.js +27 -0
  113. package/build/es/components/PivotTable/utils/ouIdHelper/index.js +17 -0
  114. package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  115. package/build/es/index.js +1 -0
  116. package/build/es/locales/en/translations.json +33 -0
  117. package/build/types/components/ChartAnalytics/components/DownloadMenu/index.d.ts +1 -2
  118. package/build/types/components/ChartAnalytics/index.d.ts +3 -3
  119. package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +3 -0
  120. package/build/types/components/PivotTable/components/PivotTable.d.ts +12 -0
  121. package/build/types/components/PivotTable/components/PivotTableBody.d.ts +7 -0
  122. package/build/types/components/PivotTable/components/PivotTableCell.d.ts +17 -0
  123. package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +7 -0
  124. package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +13 -0
  125. package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +11 -0
  126. package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +8 -0
  127. package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +13 -0
  128. package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +7 -0
  129. package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +5 -0
  130. package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +8 -0
  131. package/build/types/components/PivotTable/components/PivotTableHead.d.ts +21 -0
  132. package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +22 -0
  133. package/build/types/components/PivotTable/components/PivotTableRow.d.ts +19 -0
  134. package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +8 -0
  135. package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +21 -0
  136. package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +12 -0
  137. package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +8 -0
  138. package/build/types/components/PivotTable/constants/dataTypes.d.ts +90 -0
  139. package/build/types/components/PivotTable/constants/pivotTable.d.ts +29 -0
  140. package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +80 -0
  141. package/build/types/components/PivotTable/constants/valueTypes.d.ts +22 -0
  142. package/build/types/components/PivotTable/hooks/useParentSize.d.ts +8 -0
  143. package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +5 -0
  144. package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +8 -0
  145. package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +24 -0
  146. package/build/types/components/PivotTable/index.d.ts +26 -0
  147. package/build/types/components/PivotTable/interfaces/index.d.ts +72 -0
  148. package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +44 -0
  149. package/build/types/components/PivotTable/services/engine.d.ts +252 -0
  150. package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +1 -0
  151. package/build/types/components/PivotTable/utils/index.d.ts +38 -0
  152. package/build/types/components/PivotTable/utils/isColorBright.d.ts +1 -0
  153. package/build/types/components/PivotTable/utils/layout/dimension.d.ts +35 -0
  154. package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +3 -0
  155. package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +3 -0
  156. package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +1 -0
  157. package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +3 -0
  158. package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +5 -0
  159. package/build/types/components/PivotTable/utils/legend.d.ts +11 -0
  160. package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +10 -0
  161. package/build/types/index.d.ts +1 -0
  162. package/package.json +6 -3
@@ -124,5 +124,38 @@
124
124
  "Legend set is required": "Legend set is required",
125
125
  "Radius": "Radius",
126
126
  "Configure Thematic Layer": "Configure Thematic Layer",
127
+ "Program": "Program",
128
+ "Select a program": "Select a program",
129
+ "Indicators": "Indicators",
130
+ "Indicator group": "Indicator group",
131
+ "All groups": "All groups",
132
+ "Indicator": "Indicator",
133
+ "No indicator groups found": "No indicator groups found",
134
+ "Loading indicator groups": "Loading indicator groups",
135
+ "Data elements": "Data elements",
136
+ "Data element group": "Data element group",
137
+ "Data element": "Data element",
138
+ "No data element groups found": "No data element groups found",
139
+ "Loading data element groups": "Loading data element groups",
140
+ "Data sets": "Data sets",
141
+ "Data set": "Data set",
142
+ "All data sets": "All data sets",
143
+ "No data sets found": "No data sets found",
144
+ "Loading data sets": "Loading data sets",
145
+ "Event data items": "Event data items",
146
+ "All programs": "All programs",
147
+ "Event data item": "Event data item",
148
+ "No programs found": "No programs found",
149
+ "Loading programs": "Loading programs",
150
+ "Program indicators": "Program indicators",
151
+ "Program indicator": "Program indicator",
152
+ "Data": "Data",
153
+ "Organisation unit": "Organisation unit",
154
+ "Assigned Categories": "Assigned Categories",
155
+ "{{dynamicOuNames}} and {{lastOuName}}": "{{dynamicOuNames}} and {{lastOuName}}",
156
+ "{{allDynamicOuNames}} levels": "{{allDynamicOuNames}} levels",
157
+ "{{allDynamicOuNames}} groups": "{{allDynamicOuNames}} groups",
158
+ "{{allDynamicOuNames}} levels in {{staticOuNames}}": "{{allDynamicOuNames}} levels in {{staticOuNames}}",
159
+ "{{allDynamicOuNames}} groups in {{staticOuNames}}": "{{allDynamicOuNames}} groups in {{staticOuNames}}",
127
160
  "Loading ...": "Loading ..."
128
161
  }
@@ -1,14 +1,14 @@
1
1
  import { CssReset } from "@dhis2/ui";
2
2
  import HighCharts from "highcharts";
3
3
  import React, { useState } from "react";
4
- import ChartDownloadMenu from "./components/DownloadMenu";
4
+ import { ChartDownloadMenu } from "./components/DownloadMenu";
5
5
  import columnData from "./data/column-data.json";
6
6
  import complexMultiSeriesData from "./data/complex-multi-series-data.json";
7
7
  import multiSeriesData from "./data/multi-series-data.json";
8
8
  import pieData from "./data/pie-data.json";
9
9
  import stackedChartData from "./data/stacked-chart-data.json";
10
10
  import { setupHighchartsModules } from "./services/export";
11
- import ChartAnalytics from ".";
11
+ import { ChartAnalytics } from ".";
12
12
  const Template = args => /*#__PURE__*/React.createElement(ChartAnalytics, args);
13
13
  setupHighchartsModules(HighCharts);
14
14
  export const Column = Template.bind({});
@@ -208,7 +208,7 @@ ComplexMultiSeries.args = {
208
208
  }
209
209
  };
210
210
  export default {
211
- title: "Components/Chart Analytics",
211
+ title: "Analytics/Chart Analytics",
212
212
  component: ChartAnalytics,
213
213
  decorators: [ChartStory => {
214
214
  const [chartRef, setChartRef] = useState(null);
@@ -2,7 +2,7 @@ import { IconMore24 } from "@dhis2/ui";
2
2
  import React, { useRef, useState } from "react";
3
3
  import { onCSVDownload, onFullScreenView, onImageDownload, onPDFDownload, onViewAsTable } from "../../services/export";
4
4
  import { ChartMenu } from "./components/Menu";
5
- function ChartDownloadMenu(_ref) {
5
+ export function ChartDownloadMenu(_ref) {
6
6
  let {
7
7
  chartRef,
8
8
  exclude,
@@ -54,5 +54,4 @@ function ChartDownloadMenu(_ref) {
54
54
  onClose: toggleMenu,
55
55
  menuRef: menuRef
56
56
  }));
57
- }
58
- export default ChartDownloadMenu;
57
+ }
@@ -2,12 +2,11 @@ import { uid } from "@hisptz/dhis2-utils";
2
2
  import HighCharts from "highcharts";
3
3
  import HighchartsReact from "highcharts-react-official";
4
4
  import React, { forwardRef, useRef } from "react";
5
- import ChartDownloadMenu from "./components/DownloadMenu";
6
5
  import { useChart } from "./hooks/useChart";
7
- import { ChartAnalyticsProps } from "./types/props";
8
6
  import "./styles/custom-highchart.css";
9
7
  export * from "./services/export";
10
- export { ChartDownloadMenu, ChartAnalyticsProps };
8
+ export * from "./types/props";
9
+ export * from "./components/DownloadMenu";
11
10
  function ChartAnalyticsComponent(_ref, ref) {
12
11
  let {
13
12
  analytics,
@@ -29,6 +29,6 @@ WithTextStyling.args = {
29
29
  }
30
30
  };
31
31
  export default {
32
- title: "Components/Circular Progress Indicator",
32
+ title: "Analytics/Circular Progress Indicator",
33
33
  component: CircularProgressDashboard
34
34
  };
@@ -321,7 +321,7 @@ GoogleEarthEngineLayers.args = {
321
321
  }
322
322
  };
323
323
  export default {
324
- title: "Components/Map",
324
+ title: "Analytics/Map",
325
325
  component: Map,
326
326
  decorators: [MapStory => {
327
327
  return /*#__PURE__*/React.createElement("div", {
@@ -10,7 +10,7 @@ Basic.args = {
10
10
  open: true
11
11
  };
12
12
  export default {
13
- title: "Components/Map/Earth Engine Config Modal",
13
+ title: "Analytics/Map/Earth Engine Config Modal",
14
14
  component: EarthEngineLayerConfiguration,
15
15
  decorators: [MapStory => {
16
16
  return /*#__PURE__*/React.createElement("div", {
@@ -18,7 +18,7 @@ const Template = args => {
18
18
  export const Basic = Template.bind({});
19
19
  Basic.args = {};
20
20
  export default {
21
- title: "Components/Map/Earth Engine Configuration",
21
+ title: "Analytics/Map/Earth Engine Configuration",
22
22
  component: EarthEngineLayerConfiguration,
23
23
  decorators: [MapStory => {
24
24
  return /*#__PURE__*/React.createElement("div", {
@@ -3,15 +3,16 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
3
3
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
4
  import { combineReducers, getFeatureCollectionProperties, getHistogramStatistics, getInfo, getScale, hasClasses } from "../utils";
5
5
  import { find, head, isEmpty } from "lodash";
6
- async function importEEModule() {
7
- // @ts-ignore
8
- if (import.meta.env.STORYBOOK_BUILD === "true") {
9
- return await import("@google/earthengine");
10
- }
11
- return await import("./api");
12
- }
13
- const EE = await importEEModule();
14
6
 
7
+ // async function importEEModule(): Promise<any> {
8
+ // // @ts-ignore
9
+ // if (import.meta.env.STORYBOOK_BUILD === "true") {
10
+ // return await import("@google/earthengine")
11
+ // }
12
+ // return await import("./api")
13
+ // }
14
+ // const EE = await importEEModule();
15
+ import EE from "./api";
15
16
  // @ts-ignore
16
17
  const ee = EE;
17
18
  // @ts-ignore
@@ -163,7 +163,7 @@ export function useThematicLayers() {
163
163
  scale: defaultClasses,
164
164
  colorClass: defaultColorScaleName
165
165
  };
166
- const sortedData = sortBy(layer.data, "data");
166
+ const sortedData = sortBy(layer.data.filter(datum => !!datum.data), "data");
167
167
  const autoLegends = generateLegends((_last$data = (_last = last(sortedData)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 0, (_head$data = (_head = head(sortedData)) === null || _head === void 0 ? void 0 : _head.data) !== null && _head$data !== void 0 ? _head$data : 0, {
168
168
  classesCount: scale,
169
169
  colorClass
@@ -338,10 +338,17 @@ export function useGoogleEngineLayers() {
338
338
  }
339
339
  }
340
340
  const sanitizeLayers = useCallback(async layers => {
341
+ if (isEmpty(layers)) {
342
+ return [];
343
+ }
341
344
  try {
342
345
  const {
343
346
  token
344
347
  } = await refresh();
348
+ if (!token) {
349
+ console.error(`Google token not available in this instance`);
350
+ return [];
351
+ }
345
352
  await EarthEngine.setToken(token, refresh);
346
353
  return map(layers, asyncify(async layer => {
347
354
  try {
@@ -10,7 +10,7 @@ Basic.args = {
10
10
  open: true
11
11
  };
12
12
  export default {
13
- title: "Components/Map/Thematic Layer Config Modal",
13
+ title: "Analytics/Map/Thematic Layer Config Modal",
14
14
  component: ThematicLayerConfigModal,
15
15
  decorators: [MapStory => {
16
16
  return /*#__PURE__*/React.createElement("div", {
@@ -18,7 +18,7 @@ const Template = args => {
18
18
  export const Basic = Template.bind({});
19
19
  Basic.args = {};
20
20
  export default {
21
- title: "Components/Map/Thematic Layer Configuration",
21
+ title: "Analytics/Map/Thematic Layer Configuration",
22
22
  component: ThematicLayerConfiguration,
23
23
  decorators: [MapStory => {
24
24
  return /*#__PURE__*/React.createElement("div", {
@@ -0,0 +1,268 @@
1
+ import React from "react";
2
+ import { CustomPivotTable } from ".";
3
+ const Template = args => /*#__PURE__*/React.createElement(CustomPivotTable, args);
4
+ export const Default = Template.bind({});
5
+ Default.args = {
6
+ analytics: {
7
+ "headers": [{
8
+ "name": "dx",
9
+ "column": "Data",
10
+ "valueType": "TEXT",
11
+ "type": "java.lang.String",
12
+ "hidden": false,
13
+ "meta": true
14
+ }, {
15
+ "name": "pe",
16
+ "column": "Period",
17
+ "valueType": "TEXT",
18
+ "type": "java.lang.String",
19
+ "hidden": false,
20
+ "meta": true
21
+ }, {
22
+ "name": "ou",
23
+ "column": "Organisation unit",
24
+ "valueType": "TEXT",
25
+ "type": "java.lang.String",
26
+ "hidden": false,
27
+ "meta": true
28
+ }, {
29
+ "name": "value",
30
+ "column": "Value",
31
+ "valueType": "NUMBER",
32
+ "type": "java.lang.Double",
33
+ "hidden": false,
34
+ "meta": false
35
+ }, {
36
+ "name": "numerator",
37
+ "column": "Numerator",
38
+ "valueType": "NUMBER",
39
+ "type": "java.lang.Double",
40
+ "hidden": false,
41
+ "meta": false
42
+ }, {
43
+ "name": "denominator",
44
+ "column": "Denominator",
45
+ "valueType": "NUMBER",
46
+ "type": "java.lang.Double",
47
+ "hidden": false,
48
+ "meta": false
49
+ }, {
50
+ "name": "factor",
51
+ "column": "Factor",
52
+ "valueType": "NUMBER",
53
+ "type": "java.lang.Double",
54
+ "hidden": false,
55
+ "meta": false
56
+ }, {
57
+ "name": "multiplier",
58
+ "column": "Multiplier",
59
+ "valueType": "NUMBER",
60
+ "type": "java.lang.Double",
61
+ "hidden": false,
62
+ "meta": false
63
+ }, {
64
+ "name": "divisor",
65
+ "column": "Divisor",
66
+ "valueType": "NUMBER",
67
+ "type": "java.lang.Double",
68
+ "hidden": false,
69
+ "meta": false
70
+ }],
71
+ "metaData": {
72
+ "items": {
73
+ "ou": {
74
+ "uid": "ou",
75
+ "name": "Organisation unit",
76
+ "dimensionType": "ORGANISATION_UNIT"
77
+ },
78
+ "202208": {
79
+ "uid": "202208",
80
+ "code": "202208",
81
+ "name": "August 2022",
82
+ "dimensionItemType": "PERIOD",
83
+ "valueType": "NUMBER",
84
+ "totalAggregationType": "SUM",
85
+ "startDate": "2022-08-01T00:00:00.000",
86
+ "endDate": "2022-08-31T00:00:00.000"
87
+ },
88
+ "202209": {
89
+ "uid": "202209",
90
+ "code": "202209",
91
+ "name": "September 2022",
92
+ "dimensionItemType": "PERIOD",
93
+ "valueType": "NUMBER",
94
+ "totalAggregationType": "SUM",
95
+ "startDate": "2022-09-01T00:00:00.000",
96
+ "endDate": "2022-09-30T00:00:00.000"
97
+ },
98
+ "202206": {
99
+ "uid": "202206",
100
+ "code": "202206",
101
+ "name": "June 2022",
102
+ "dimensionItemType": "PERIOD",
103
+ "valueType": "NUMBER",
104
+ "totalAggregationType": "SUM",
105
+ "startDate": "2022-06-01T00:00:00.000",
106
+ "endDate": "2022-06-30T00:00:00.000"
107
+ },
108
+ "fbfJHSPpUQD": {
109
+ "uid": "fbfJHSPpUQD",
110
+ "code": "DE_359596",
111
+ "name": "ANC 1st visit",
112
+ "legendSet": "fqs276KXCXi",
113
+ "dimensionItemType": "DATA_ELEMENT",
114
+ "valueType": "NUMBER",
115
+ "aggregationType": "SUM",
116
+ "totalAggregationType": "SUM"
117
+ },
118
+ "202207": {
119
+ "uid": "202207",
120
+ "code": "202207",
121
+ "name": "July 2022",
122
+ "dimensionItemType": "PERIOD",
123
+ "valueType": "NUMBER",
124
+ "totalAggregationType": "SUM",
125
+ "startDate": "2022-07-01T00:00:00.000",
126
+ "endDate": "2022-07-31T00:00:00.000"
127
+ },
128
+ "202204": {
129
+ "uid": "202204",
130
+ "code": "202204",
131
+ "name": "April 2022",
132
+ "dimensionItemType": "PERIOD",
133
+ "valueType": "NUMBER",
134
+ "totalAggregationType": "SUM",
135
+ "startDate": "2022-04-01T00:00:00.000",
136
+ "endDate": "2022-04-30T00:00:00.000"
137
+ },
138
+ "202205": {
139
+ "uid": "202205",
140
+ "code": "202205",
141
+ "name": "May 2022",
142
+ "dimensionItemType": "PERIOD",
143
+ "valueType": "NUMBER",
144
+ "totalAggregationType": "SUM",
145
+ "startDate": "2022-05-01T00:00:00.000",
146
+ "endDate": "2022-05-31T00:00:00.000"
147
+ },
148
+ "202202": {
149
+ "uid": "202202",
150
+ "code": "202202",
151
+ "name": "February 2022",
152
+ "dimensionItemType": "PERIOD",
153
+ "valueType": "NUMBER",
154
+ "totalAggregationType": "SUM",
155
+ "startDate": "2022-02-01T00:00:00.000",
156
+ "endDate": "2022-02-28T00:00:00.000"
157
+ },
158
+ "202301": {
159
+ "uid": "202301",
160
+ "code": "202301",
161
+ "name": "January 2023",
162
+ "dimensionItemType": "PERIOD",
163
+ "valueType": "NUMBER",
164
+ "totalAggregationType": "SUM",
165
+ "startDate": "2023-01-01T00:00:00.000",
166
+ "endDate": "2023-01-31T00:00:00.000"
167
+ },
168
+ "202203": {
169
+ "uid": "202203",
170
+ "code": "202203",
171
+ "name": "March 2022",
172
+ "dimensionItemType": "PERIOD",
173
+ "valueType": "NUMBER",
174
+ "totalAggregationType": "SUM",
175
+ "startDate": "2022-03-01T00:00:00.000",
176
+ "endDate": "2022-03-31T00:00:00.000"
177
+ },
178
+ "LAST_12_MONTHS": {
179
+ "name": "Last 12 months"
180
+ },
181
+ "202211": {
182
+ "uid": "202211",
183
+ "code": "202211",
184
+ "name": "November 2022",
185
+ "dimensionItemType": "PERIOD",
186
+ "valueType": "NUMBER",
187
+ "totalAggregationType": "SUM",
188
+ "startDate": "2022-11-01T00:00:00.000",
189
+ "endDate": "2022-11-30T00:00:00.000"
190
+ },
191
+ "202212": {
192
+ "uid": "202212",
193
+ "code": "202212",
194
+ "name": "December 2022",
195
+ "dimensionItemType": "PERIOD",
196
+ "valueType": "NUMBER",
197
+ "totalAggregationType": "SUM",
198
+ "startDate": "2022-12-01T00:00:00.000",
199
+ "endDate": "2022-12-31T00:00:00.000"
200
+ },
201
+ "ImspTQPwCqd": {
202
+ "uid": "ImspTQPwCqd",
203
+ "code": "OU_525",
204
+ "name": "Sierra Leone",
205
+ "dimensionItemType": "ORGANISATION_UNIT",
206
+ "valueType": "NUMBER",
207
+ "totalAggregationType": "SUM"
208
+ },
209
+ "202210": {
210
+ "uid": "202210",
211
+ "code": "202210",
212
+ "name": "October 2022",
213
+ "dimensionItemType": "PERIOD",
214
+ "valueType": "NUMBER",
215
+ "totalAggregationType": "SUM",
216
+ "startDate": "2022-10-01T00:00:00.000",
217
+ "endDate": "2022-10-31T00:00:00.000"
218
+ },
219
+ "dx": {
220
+ "uid": "dx",
221
+ "name": "Data",
222
+ "dimensionType": "DATA_X"
223
+ },
224
+ "pq2XI5kz2BY": {
225
+ "uid": "pq2XI5kz2BY",
226
+ "code": "COC_167661",
227
+ "name": "Fixed",
228
+ "valueType": "NUMBER",
229
+ "totalAggregationType": "SUM"
230
+ },
231
+ "pe": {
232
+ "uid": "pe",
233
+ "name": "Period",
234
+ "dimensionType": "PERIOD"
235
+ },
236
+ "PT59n8BQbqM": {
237
+ "uid": "PT59n8BQbqM",
238
+ "code": "COC_167660",
239
+ "name": "Outreach",
240
+ "valueType": "NUMBER",
241
+ "totalAggregationType": "SUM"
242
+ }
243
+ },
244
+ "dimensions": {
245
+ "dx": ["fbfJHSPpUQD"],
246
+ "pe": ["202202", "202203", "202204", "202205", "202206", "202207", "202208", "202209", "202210", "202211", "202212", "202301"],
247
+ "ou": ["ImspTQPwCqd"],
248
+ "co": ["pq2XI5kz2BY", "PT59n8BQbqM"]
249
+ }
250
+ },
251
+ "rows": [["fbfJHSPpUQD", "202209", "ImspTQPwCqd", "22308", "", "", "", "", ""], ["fbfJHSPpUQD", "202301", "ImspTQPwCqd", "20020", "", "", "", "", ""], ["fbfJHSPpUQD", "202206", "ImspTQPwCqd", "23813", "", "", "", "", ""], ["fbfJHSPpUQD", "202210", "ImspTQPwCqd", "17926", "", "", "", "", ""], ["fbfJHSPpUQD", "202207", "ImspTQPwCqd", "22356", "", "", "", "", ""], ["fbfJHSPpUQD", "202208", "ImspTQPwCqd", "22004", "", "", "", "", ""], ["fbfJHSPpUQD", "202212", "ImspTQPwCqd", "16445", "", "", "", "", ""], ["fbfJHSPpUQD", "202202", "ImspTQPwCqd", "18786", "", "", "", "", ""], ["fbfJHSPpUQD", "202211", "ImspTQPwCqd", "19691", "", "", "", "", ""], ["fbfJHSPpUQD", "202205", "ImspTQPwCqd", "29461", "", "", "", "", ""], ["fbfJHSPpUQD", "202203", "ImspTQPwCqd", "21877", "", "", "", "", ""], ["fbfJHSPpUQD", "202204", "ImspTQPwCqd", "18576", "", "", "", "", ""]],
252
+ "height": 0,
253
+ "width": 0,
254
+ "headerWidth": 0
255
+ },
256
+ config: {
257
+ layout: {
258
+ columns: ["dx"],
259
+ rows: ["ou", "pe"],
260
+ filter: []
261
+ },
262
+ options: {}
263
+ }
264
+ };
265
+ export default {
266
+ title: "Analytics/Pivot table",
267
+ component: CustomPivotTable
268
+ };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ const AssignedCategoriesIcon = () => {
3
+ return /*#__PURE__*/React.createElement("svg", {
4
+ height: "16",
5
+ viewBox: "0 0 16 16",
6
+ width: "16"
7
+ }, /*#__PURE__*/React.createElement("g", {
8
+ fill: "#212934",
9
+ fillRule: "evenodd"
10
+ }, /*#__PURE__*/React.createElement("path", {
11
+ d: "m2 7h11v1h-11z"
12
+ }), /*#__PURE__*/React.createElement("path", {
13
+ d: "m2 13h11v1h-11z"
14
+ }), /*#__PURE__*/React.createElement("path", {
15
+ d: "m2 2h11v1h-11z"
16
+ }), /*#__PURE__*/React.createElement("path", {
17
+ d: "m7 8h1v5h-1z"
18
+ }), /*#__PURE__*/React.createElement("path", {
19
+ d: "m12 3h1v10h-1z"
20
+ }), /*#__PURE__*/React.createElement("path", {
21
+ d: "m2 3h1v10h-1z"
22
+ })));
23
+ };
24
+ export default AssignedCategoriesIcon;
@@ -0,0 +1,51 @@
1
+ import React, { useMemo, useRef } from 'react';
2
+ import { PivotTableEngine } from '../services/engine';
3
+ import { PivotTableBody } from './PivotTableBody';
4
+ import { PivotTableContainer } from './PivotTableContainer';
5
+ import { Provider } from './PivotTableEngineContext';
6
+ import { PivotTableHead } from './PivotTableHead';
7
+ import { useTableClipping } from "../hooks/useTableClipping";
8
+ import { useSortableColumns } from "../hooks/useSortableColumns";
9
+ import { useParentSize } from "../hooks/useParentSize";
10
+ export const PivotTable = _ref => {
11
+ let {
12
+ visualization,
13
+ data,
14
+ legendSets,
15
+ renderCounter,
16
+ tableProps,
17
+ onToggleContextualMenu
18
+ } = _ref;
19
+ const containerRef = useRef(null);
20
+ const {
21
+ width,
22
+ height
23
+ } = useParentSize(containerRef, renderCounter !== null && renderCounter !== void 0 ? renderCounter : 1);
24
+ const engine = useMemo(() => new PivotTableEngine(visualization, data, legendSets), [visualization, data, legendSets]);
25
+ const {
26
+ sortBy,
27
+ onSortByColumn
28
+ } = useSortableColumns(engine);
29
+ const clippingResult = useTableClipping({
30
+ containerRef,
31
+ width,
32
+ height,
33
+ engine
34
+ });
35
+ return /*#__PURE__*/React.createElement(Provider, {
36
+ engine: engine
37
+ }, /*#__PURE__*/React.createElement(PivotTableContainer, {
38
+ tableProps: tableProps,
39
+ ref: containerRef,
40
+ width: width,
41
+ height: height
42
+ }, /*#__PURE__*/React.createElement(PivotTableHead, {
43
+ clippingResult: clippingResult,
44
+ width: width,
45
+ sortBy: sortBy,
46
+ onSortByColumn: onSortByColumn
47
+ }), /*#__PURE__*/React.createElement(PivotTableBody, {
48
+ clippingResult: clippingResult,
49
+ onToggleContextualMenu: onToggleContextualMenu
50
+ })));
51
+ };
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { PivotTableClippedAxis } from './PivotTableClippedAxis.js';
3
+ import { PivotTableEmptyRow } from './PivotTableEmptyRow';
4
+ import { PivotTableRow } from './PivotTableRow.js';
5
+ export const PivotTableBody = _ref => {
6
+ let {
7
+ clippingResult,
8
+ onToggleContextualMenu
9
+ } = _ref;
10
+ return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement(PivotTableClippedAxis, {
11
+ axisClippingResult: clippingResult.rows,
12
+ EmptyComponent: _ref2 => {
13
+ let {
14
+ size
15
+ } = _ref2;
16
+ return /*#__PURE__*/React.createElement(PivotTableEmptyRow, {
17
+ height: size,
18
+ columns: clippingResult.columns.indices
19
+ });
20
+ },
21
+ ItemComponent: _ref3 => {
22
+ let {
23
+ index
24
+ } = _ref3;
25
+ return /*#__PURE__*/React.createElement(PivotTableRow, {
26
+ key: index,
27
+ clippingResult: clippingResult,
28
+ rowIndex: index,
29
+ onToggleContextualMenu: onToggleContextualMenu
30
+ });
31
+ }
32
+ }));
33
+ };
@@ -0,0 +1,32 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React from 'react';
3
+ import { usePivotTableEngine } from './PivotTableEngineContext.js';
4
+ import { DataTableCell, DataTableColumnHeader } from '@dhis2/ui';
5
+ import { SORT_ORDER_ASCENDING, SORT_ORDER_DESCENDING } from "../constants/pivotTable";
6
+ export const PivotTableCell = /*#__PURE__*/React.forwardRef((_ref, ref) => {
7
+ let {
8
+ classes,
9
+ isHeader = false,
10
+ index,
11
+ isSortable,
12
+ sortBy,
13
+ children,
14
+ dataTest,
15
+ onSortClick,
16
+ style = {},
17
+ ...props
18
+ } = _ref;
19
+ const engine = usePivotTableEngine();
20
+ if (!engine) {
21
+ return null;
22
+ }
23
+ style.width = style.minWidth = style.maxWidth = style.width;
24
+ style.height = style.minHeight = style.maxHeight = style.height || engine.fontSize + engine.cellPadding * 2 + 2;
25
+ return isHeader ? /*#__PURE__*/React.createElement(DataTableColumnHeader, _extends({
26
+ onSortIconClick: isSortable ? onSortClick : undefined,
27
+ sortDirection: isSortable ? (sortBy === null || sortBy === void 0 ? void 0 : sortBy.column) === index ? (sortBy === null || sortBy === void 0 ? void 0 : sortBy.order) === SORT_ORDER_DESCENDING ? "desc" : sortBy.order === SORT_ORDER_ASCENDING ? "asc" : "default" : undefined : undefined
28
+ }, props), children) : /*#__PURE__*/React.createElement(DataTableCell, {
29
+ ref: ref
30
+ }, children);
31
+ });
32
+ PivotTableCell.displayName = "PivotTableCell";
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ export const PivotTableClippedAxis = _ref => {
3
+ let {
4
+ axisClippingResult,
5
+ EmptyComponent,
6
+ ItemComponent
7
+ } = _ref;
8
+ return [axisClippingResult.pre ? /*#__PURE__*/React.createElement(EmptyComponent, {
9
+ key: "pre",
10
+ size: axisClippingResult.pre
11
+ }) : null, axisClippingResult.indices.map(index => /*#__PURE__*/React.createElement(ItemComponent, {
12
+ key: index,
13
+ index: index
14
+ })), axisClippingResult.post ? /*#__PURE__*/React.createElement(EmptyComponent, {
15
+ key: "post",
16
+ size: axisClippingResult.post
17
+ }) : null];
18
+ };