@hisptz/dhis2-analytics 1.0.11 → 1.0.13

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 (239) hide show
  1. package/build/cjs/components/CustomPivotTable/CustomPivotTable.stories.js +69 -0
  2. package/build/cjs/components/CustomPivotTable/components/Table/index.js +16 -0
  3. package/build/cjs/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
  4. package/build/cjs/components/CustomPivotTable/components/TableBody/index.js +109 -0
  5. package/build/cjs/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
  6. package/build/cjs/components/CustomPivotTable/components/TableHeaders/index.js +89 -0
  7. package/build/cjs/components/CustomPivotTable/index.js +30 -0
  8. package/build/cjs/components/{PivotTable → CustomPivotTable}/interfaces/index.js +0 -0
  9. package/build/cjs/components/CustomPivotTable/services/engine.js +89 -0
  10. package/build/cjs/components/{PivotTable/components/PivotTableEngineContext.js → CustomPivotTable/state/engine.js} +11 -13
  11. package/build/cjs/dataProviders/map.js +1 -1
  12. package/build/cjs/index.js +4 -4
  13. package/build/cjs/locales/en/translations.json +0 -33
  14. package/build/es/components/CustomPivotTable/CustomPivotTable.stories.js +59 -0
  15. package/build/es/components/CustomPivotTable/components/Table/index.js +9 -0
  16. package/build/es/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
  17. package/build/es/components/CustomPivotTable/components/TableBody/index.js +100 -0
  18. package/build/es/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
  19. package/build/es/components/CustomPivotTable/components/TableHeaders/index.js +82 -0
  20. package/build/es/components/CustomPivotTable/index.js +22 -0
  21. package/build/es/components/{PivotTable → CustomPivotTable}/interfaces/index.js +0 -0
  22. package/build/es/components/CustomPivotTable/services/engine.js +82 -0
  23. package/build/es/components/CustomPivotTable/state/engine.js +14 -0
  24. package/build/es/dataProviders/map.js +1 -1
  25. package/build/es/index.js +1 -1
  26. package/build/es/locales/en/translations.json +0 -33
  27. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/components/Menu.d.ts +0 -0
  28. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/constants/menu.d.ts +0 -0
  29. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/index.d.ts +0 -0
  30. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/interfaces/menu.d.ts +0 -0
  31. package/build/types/{components → src/components}/ChartAnalytics/hooks/useChart.d.ts +0 -0
  32. package/build/types/{components → src/components}/ChartAnalytics/index.d.ts +0 -0
  33. package/build/types/{components → src/components}/ChartAnalytics/models/column.d.ts +0 -0
  34. package/build/types/{components → src/components}/ChartAnalytics/models/index.d.ts +0 -0
  35. package/build/types/{components → src/components}/ChartAnalytics/models/line.d.ts +0 -0
  36. package/build/types/{components → src/components}/ChartAnalytics/models/multi-series.d.ts +0 -0
  37. package/build/types/{components → src/components}/ChartAnalytics/models/pie.d.ts +0 -0
  38. package/build/types/{components → src/components}/ChartAnalytics/services/export.d.ts +0 -0
  39. package/build/types/{components → src/components}/ChartAnalytics/types/props.d.ts +0 -0
  40. package/build/types/{components → src/components}/ChartAnalytics/utils/chart.d.ts +0 -0
  41. package/build/types/{components → src/components}/CircularProgressDashboard/index.d.ts +0 -0
  42. package/build/types/{components → src/components}/CircularProgressDashboard/types/props.d.ts +0 -0
  43. package/build/types/src/components/CustomPivotTable/components/Table/index.d.ts +11 -0
  44. package/build/types/src/components/CustomPivotTable/components/TableBody/index.d.ts +2 -0
  45. package/build/types/src/components/CustomPivotTable/components/TableHeaders/index.d.ts +2 -0
  46. package/build/types/{components/PivotTable → src/components/CustomPivotTable}/index.d.ts +19 -5
  47. package/build/types/src/components/CustomPivotTable/interfaces/index.d.ts +1 -0
  48. package/build/types/src/components/CustomPivotTable/services/engine.d.ts +58 -0
  49. package/build/types/src/components/CustomPivotTable/state/engine.d.ts +7 -0
  50. package/build/types/{components → src/components}/Map/components/EarthEngineLayerConfiguration/index.d.ts +0 -0
  51. package/build/types/{components → src/components}/Map/components/MapArea/index.d.ts +0 -0
  52. package/build/types/{components → src/components}/Map/components/MapArea/interfaces/index.d.ts +0 -0
  53. package/build/types/{components → src/components}/Map/components/MapControls/components/CustomControl/index.d.ts +0 -0
  54. package/build/types/{components → src/components}/Map/components/MapControls/components/DownloadControl/index.d.ts +0 -0
  55. package/build/types/{components → src/components}/Map/components/MapControls/components/FullscreenControl/index.d.ts +0 -0
  56. package/build/types/{components → src/components}/Map/components/MapControls/index.d.ts +0 -0
  57. package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.d.ts +0 -0
  58. package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/index.d.ts +0 -0
  59. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.d.ts +0 -0
  60. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.d.ts +0 -0
  61. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.d.ts +0 -0
  62. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/index.d.ts +0 -0
  63. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.d.ts +0 -0
  64. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/api.d.ts +0 -0
  65. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.d.ts +0 -0
  66. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.d.ts +0 -0
  67. package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.d.ts +0 -0
  68. package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/index.d.ts +0 -0
  69. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.d.ts +0 -0
  70. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/hooks/index.d.ts +0 -0
  71. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/index.d.ts +0 -0
  72. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.d.ts +0 -0
  73. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.d.ts +0 -0
  74. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.d.ts +0 -0
  75. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.d.ts +0 -0
  76. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.d.ts +0 -0
  77. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +0 -0
  78. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.d.ts +0 -0
  79. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/hooks/config.d.ts +0 -0
  80. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/index.d.ts +0 -0
  81. package/build/types/{components → src/components}/Map/components/MapLayer/index.d.ts +0 -0
  82. package/build/types/{components → src/components}/Map/components/MapLayer/interfaces/index.d.ts +0 -0
  83. package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/hooks/index.d.ts +0 -0
  84. package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/index.d.ts +0 -0
  85. package/build/types/{components → src/components}/Map/components/MapProvider/hooks/index.d.ts +0 -0
  86. package/build/types/{components → src/components}/Map/components/MapProvider/index.d.ts +0 -0
  87. package/build/types/{components → src/components}/Map/components/MapUpdater/index.d.ts +0 -0
  88. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.d.ts +0 -0
  89. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.d.ts +0 -0
  90. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.d.ts +0 -0
  91. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.d.ts +0 -0
  92. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.d.ts +0 -0
  93. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.d.ts +0 -0
  94. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.d.ts +0 -0
  95. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/index.d.ts +0 -0
  96. package/build/types/{components → src/components}/Map/constants/colors.d.ts +0 -0
  97. package/build/types/{components → src/components}/Map/constants/legendSet.d.ts +0 -0
  98. package/build/types/{components → src/components}/Map/hooks/map.d.ts +0 -0
  99. package/build/types/{components → src/components}/Map/index.d.ts +0 -0
  100. package/build/types/{components → src/components}/Map/interfaces/index.d.ts +0 -0
  101. package/build/types/{components → src/components}/Map/state/index.d.ts +0 -0
  102. package/build/types/{components → src/components}/Map/utils/colors.d.ts +0 -0
  103. package/build/types/{components → src/components}/Map/utils/helpers.d.ts +0 -0
  104. package/build/types/{components → src/components}/Map/utils/map.d.ts +0 -0
  105. package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValueItem.d.ts +0 -0
  106. package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.d.ts +0 -0
  107. package/build/types/{components → src/components}/SingleValueContainer/index.d.ts +0 -0
  108. package/build/types/{components → src/components}/SingleValueContainer/types/props.d.ts +0 -0
  109. package/build/types/{dataProviders → src/dataProviders}/map.d.ts +0 -0
  110. package/build/types/{index.d.ts → src/index.d.ts} +1 -1
  111. package/package.json +4 -4
  112. package/build/cjs/components/PivotTable/PivotTable.stories.js +0 -277
  113. package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +0 -32
  114. package/build/cjs/components/PivotTable/components/PivotTable.js +0 -60
  115. package/build/cjs/components/PivotTable/components/PivotTableBody.js +0 -41
  116. package/build/cjs/components/PivotTable/components/PivotTableCell.js +0 -40
  117. package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +0 -26
  118. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +0 -71
  119. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +0 -60
  120. package/build/cjs/components/PivotTable/components/PivotTableContainer.js +0 -33
  121. package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +0 -77
  122. package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +0 -22
  123. package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +0 -33
  124. package/build/cjs/components/PivotTable/components/PivotTableHead.js +0 -35
  125. package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +0 -37
  126. package/build/cjs/components/PivotTable/components/PivotTableRow.js +0 -65
  127. package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +0 -49
  128. package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +0 -52
  129. package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +0 -46
  130. package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +0 -69
  131. package/build/cjs/components/PivotTable/constants/dataTypes.js +0 -129
  132. package/build/cjs/components/PivotTable/constants/pivotTable.js +0 -64
  133. package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +0 -62
  134. package/build/cjs/components/PivotTable/constants/valueTypes.js +0 -55
  135. package/build/cjs/components/PivotTable/data/column-data.json +0 -210
  136. package/build/cjs/components/PivotTable/hooks/useParentSize.js +0 -41
  137. package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +0 -38
  138. package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +0 -34
  139. package/build/cjs/components/PivotTable/hooks/useTableClipping.js +0 -53
  140. package/build/cjs/components/PivotTable/index.js +0 -47
  141. package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +0 -197
  142. package/build/cjs/components/PivotTable/services/engine.js +0 -901
  143. package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +0 -71
  144. package/build/cjs/components/PivotTable/utils/index.js +0 -322
  145. package/build/cjs/components/PivotTable/utils/isColorBright.js +0 -29
  146. package/build/cjs/components/PivotTable/utils/layout/dimension.js +0 -61
  147. package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +0 -12
  148. package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +0 -12
  149. package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +0 -9
  150. package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +0 -9
  151. package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +0 -25
  152. package/build/cjs/components/PivotTable/utils/legend.js +0 -40
  153. package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +0 -27
  154. package/build/cjs/data/map.json +0 -5984
  155. package/build/es/components/PivotTable/PivotTable.stories.js +0 -268
  156. package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +0 -24
  157. package/build/es/components/PivotTable/components/PivotTable.js +0 -51
  158. package/build/es/components/PivotTable/components/PivotTableBody.js +0 -33
  159. package/build/es/components/PivotTable/components/PivotTableCell.js +0 -32
  160. package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +0 -18
  161. package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +0 -62
  162. package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +0 -52
  163. package/build/es/components/PivotTable/components/PivotTableContainer.js +0 -25
  164. package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +0 -68
  165. package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +0 -14
  166. package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +0 -25
  167. package/build/es/components/PivotTable/components/PivotTableEngineContext.js +0 -14
  168. package/build/es/components/PivotTable/components/PivotTableHead.js +0 -27
  169. package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +0 -29
  170. package/build/es/components/PivotTable/components/PivotTableRow.js +0 -57
  171. package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +0 -41
  172. package/build/es/components/PivotTable/components/PivotTableTitleRow.js +0 -42
  173. package/build/es/components/PivotTable/components/PivotTableTitleRows.js +0 -37
  174. package/build/es/components/PivotTable/components/PivotTableValueCell.js +0 -60
  175. package/build/es/components/PivotTable/constants/dataTypes.js +0 -98
  176. package/build/es/components/PivotTable/constants/pivotTable.js +0 -29
  177. package/build/es/components/PivotTable/constants/predefinedDimensions.js +0 -44
  178. package/build/es/components/PivotTable/constants/valueTypes.js +0 -27
  179. package/build/es/components/PivotTable/data/column-data.json +0 -210
  180. package/build/es/components/PivotTable/hooks/useParentSize.js +0 -33
  181. package/build/es/components/PivotTable/hooks/useScrollPosition.js +0 -30
  182. package/build/es/components/PivotTable/hooks/useSortableColumns.js +0 -27
  183. package/build/es/components/PivotTable/hooks/useTableClipping.js +0 -46
  184. package/build/es/components/PivotTable/index.js +0 -26
  185. package/build/es/components/PivotTable/services/adaptiveClippingController.js +0 -191
  186. package/build/es/components/PivotTable/services/engine.js +0 -894
  187. package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +0 -63
  188. package/build/es/components/PivotTable/utils/index.js +0 -309
  189. package/build/es/components/PivotTable/utils/isColorBright.js +0 -22
  190. package/build/es/components/PivotTable/utils/layout/dimension.js +0 -48
  191. package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +0 -5
  192. package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +0 -5
  193. package/build/es/components/PivotTable/utils/layout/dimensionIs.js +0 -2
  194. package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +0 -2
  195. package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +0 -18
  196. package/build/es/components/PivotTable/utils/legend.js +0 -27
  197. package/build/es/components/PivotTable/utils/ouIdHelper/index.js +0 -17
  198. package/build/es/data/map.json +0 -5984
  199. package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +0 -3
  200. package/build/types/components/PivotTable/components/PivotTable.d.ts +0 -12
  201. package/build/types/components/PivotTable/components/PivotTableBody.d.ts +0 -7
  202. package/build/types/components/PivotTable/components/PivotTableCell.d.ts +0 -17
  203. package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +0 -7
  204. package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +0 -13
  205. package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +0 -11
  206. package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +0 -8
  207. package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +0 -13
  208. package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +0 -7
  209. package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +0 -5
  210. package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +0 -8
  211. package/build/types/components/PivotTable/components/PivotTableHead.d.ts +0 -21
  212. package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +0 -22
  213. package/build/types/components/PivotTable/components/PivotTableRow.d.ts +0 -19
  214. package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +0 -8
  215. package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +0 -21
  216. package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +0 -12
  217. package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +0 -8
  218. package/build/types/components/PivotTable/constants/dataTypes.d.ts +0 -90
  219. package/build/types/components/PivotTable/constants/pivotTable.d.ts +0 -29
  220. package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +0 -80
  221. package/build/types/components/PivotTable/constants/valueTypes.d.ts +0 -22
  222. package/build/types/components/PivotTable/hooks/useParentSize.d.ts +0 -8
  223. package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +0 -5
  224. package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +0 -8
  225. package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +0 -24
  226. package/build/types/components/PivotTable/interfaces/index.d.ts +0 -72
  227. package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +0 -44
  228. package/build/types/components/PivotTable/services/engine.d.ts +0 -252
  229. package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +0 -1
  230. package/build/types/components/PivotTable/utils/index.d.ts +0 -38
  231. package/build/types/components/PivotTable/utils/isColorBright.d.ts +0 -1
  232. package/build/types/components/PivotTable/utils/layout/dimension.d.ts +0 -35
  233. package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +0 -3
  234. package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +0 -3
  235. package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +0 -1
  236. package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +0 -3
  237. package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +0 -5
  238. package/build/types/components/PivotTable/utils/legend.d.ts +0 -11
  239. package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +0 -10
@@ -1,901 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PivotTableEngine = void 0;
7
- var _times = _interopRequireDefault(require("lodash/times"));
8
- var _dataTypes = require("../constants/dataTypes");
9
- var _predefinedDimensions = require("../constants/predefinedDimensions.js");
10
- var _utils = require("../utils");
11
- var _valueTypes = require("../constants/valueTypes.js");
12
- var _adaptiveClippingController = require("./adaptiveClippingController");
13
- var _pivotTable = require("../constants/pivotTable");
14
- var _lodash = require("lodash");
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
18
- 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); }
19
- const dataFields = ['value', 'numerator', 'denominator', 'factor', 'multiplier', 'divisor'];
20
- const defaultOptions = {
21
- hideEmptyColumns: false,
22
- hideEmptyRows: false,
23
- showRowTotals: false,
24
- showColumnTotals: false,
25
- showRowSubtotals: false,
26
- showColumnSubtotals: false,
27
- fixColumnHeaders: false,
28
- fixRowHeaders: false
29
- };
30
- const defaultVisualizationProps = {
31
- fontSize: _pivotTable.FONT_SIZE_OPTION_NORMAL,
32
- displayDensity: _pivotTable.DISPLAY_DENSITY_OPTION_NORMAL
33
- };
34
- const isDxDimension = dimensionItem => [_dataTypes.DIMENSION_TYPE_DATA, _dataTypes.DIMENSION_TYPE_DATA_ELEMENT_GROUP_SET].includes(dimensionItem.dimensionType);
35
- const countFromDisaggregates = list => {
36
- let count = 1;
37
- list.forEach(x => {
38
- count *= x.items.length;
39
- });
40
- return count;
41
- };
42
- const addSize = list => {
43
- const reversedList = list.slice().reverse();
44
- reversedList.forEach((level, idx) => {
45
- var _lastLevel$count, _lastLevel$size;
46
- // Start at the "leaf" disaggregate
47
- const lastLevel = reversedList[idx - 1];
48
- level.size = lastLevel ? ((_lastLevel$count = lastLevel === null || lastLevel === void 0 ? void 0 : lastLevel.count) !== null && _lastLevel$count !== void 0 ? _lastLevel$count : 1) * ((_lastLevel$size = lastLevel === null || lastLevel === void 0 ? void 0 : lastLevel.size) !== null && _lastLevel$size !== void 0 ? _lastLevel$size : 1) : 1;
49
- });
50
- };
51
- const listByDimension = list => list.reduce((all, item) => {
52
- all[item.dimension] = item;
53
- return all;
54
- }, {});
55
- const sortByHierarchy = items => {
56
- items.sort((a, b) => {
57
- if (!a.hierarchy || !b.hierarchy) {
58
- return 0;
59
- }
60
- return a.hierarchy.join('/').localeCompare(b.hierarchy.join('/'));
61
- });
62
- };
63
- const buildDimensionLookup = (visualization, metadata, headers) => {
64
- var _visualization$rows$m;
65
- if (!metadata) {
66
- return;
67
- }
68
- const rows = (_visualization$rows$m = visualization.rows.map(row => {
69
- var _metadata$dimensions, _metadata$dimensions2, _metadata$dimensions$, _metadata$dimensions3;
70
- return {
71
- dimension: row.dimension,
72
- meta: metadata.items[row.dimension],
73
- count: (_metadata$dimensions = metadata.dimensions[row.dimension]) === null || _metadata$dimensions === void 0 ? void 0 : _metadata$dimensions.length,
74
- itemIds: (_metadata$dimensions2 = metadata.dimensions[row.dimension]) !== null && _metadata$dimensions2 !== void 0 ? _metadata$dimensions2 : [],
75
- items: (_metadata$dimensions$ = (_metadata$dimensions3 = metadata.dimensions[row.dimension]) === null || _metadata$dimensions3 === void 0 ? void 0 : _metadata$dimensions3.map(item => metadata.items[item])) !== null && _metadata$dimensions$ !== void 0 ? _metadata$dimensions$ : [],
76
- isDxDimension: isDxDimension(metadata.items[row.dimension]),
77
- position: 'row'
78
- };
79
- })) !== null && _visualization$rows$m !== void 0 ? _visualization$rows$m : [];
80
- const columns = visualization.columns.map(column => {
81
- var _metadata$dimensions4, _metadata$dimensions5, _metadata$dimensions$2, _metadata$dimensions6;
82
- return {
83
- dimension: column.dimension,
84
- meta: metadata.items[column.dimension],
85
- count: (_metadata$dimensions4 = metadata.dimensions[column.dimension]) === null || _metadata$dimensions4 === void 0 ? void 0 : _metadata$dimensions4.length,
86
- itemIds: (_metadata$dimensions5 = metadata.dimensions[column.dimension]) !== null && _metadata$dimensions5 !== void 0 ? _metadata$dimensions5 : [],
87
- items: (_metadata$dimensions$2 = (_metadata$dimensions6 = metadata.dimensions[column.dimension]) === null || _metadata$dimensions6 === void 0 ? void 0 : _metadata$dimensions6.map(item => metadata.items[item])) !== null && _metadata$dimensions$2 !== void 0 ? _metadata$dimensions$2 : [],
88
- isDxDimension: isDxDimension(metadata.items[column.dimension]),
89
- position: 'column'
90
- };
91
- });
92
- addSize(rows);
93
- addSize(columns);
94
- const allByDimension = {
95
- ...listByDimension(rows),
96
- ...listByDimension(columns)
97
- };
98
- const headerDimensions = (0, _lodash.compact)(headers === null || headers === void 0 ? void 0 : headers.map(header => allByDimension[header.name]));
99
- const rowHeaders = headerDimensions.map((_, idx) => idx).filter(idx => headerDimensions[idx] && headerDimensions[idx].position === 'row');
100
- const columnHeaders = headerDimensions.map((_, idx) => idx).filter(idx => headerDimensions[idx] && headerDimensions[idx].position === 'column');
101
- const dataHeaders = dataFields.reduce((out, field) => {
102
- out[field] = headers === null || headers === void 0 ? void 0 : headers.findIndex(header => header.name === field);
103
- return out;
104
- }, {});
105
- const ouDimension = allByDimension[_predefinedDimensions.DIMENSION_ID_ORGUNIT];
106
- if (visualization.showHierarchy && metadata.ouNameHierarchy && ouDimension) {
107
- ouDimension.items.forEach(ou => {
108
- const hierarchy = metadata.ouNameHierarchy[ou.uid];
109
- if (hierarchy) {
110
- ou.hierarchy = hierarchy.split('/').filter(x => x.length);
111
- }
112
- });
113
- sortByHierarchy(ouDimension.items);
114
- ouDimension.itemIds = ouDimension.items.map(item => item.uid);
115
- }
116
- return {
117
- rows,
118
- columns,
119
- allByDimension,
120
- headerDimensions,
121
- rowHeaders,
122
- columnHeaders,
123
- dataHeaders
124
- };
125
- };
126
- const lookup = (dataRow, dimensionLookup, _ref) => {
127
- let {
128
- doColumnSubtotals,
129
- doRowSubtotals
130
- } = _ref;
131
- let row = 0;
132
- for (const headerIndex of dimensionLookup.rowHeaders) {
133
- const idx = dimensionLookup.headerDimensions[headerIndex].itemIds.indexOf(dataRow[headerIndex]);
134
- if (idx === -1) {
135
- return undefined;
136
- }
137
- const size = dimensionLookup.headerDimensions[headerIndex].size;
138
- row += idx * size;
139
- }
140
- if (doColumnSubtotals) {
141
- row += Math.floor(row / dimensionLookup.rows[0].size);
142
- }
143
- let column = 0;
144
- for (const headerIndex of dimensionLookup.columnHeaders) {
145
- const idx = dimensionLookup.headerDimensions[headerIndex].itemIds.indexOf(dataRow[headerIndex]);
146
- if (idx === -1) {
147
- return undefined;
148
- }
149
- const size = dimensionLookup.headerDimensions[headerIndex].size;
150
- column += idx * size;
151
- }
152
- if (doRowSubtotals) {
153
- column += Math.floor(column / dimensionLookup.columns[0].size);
154
- }
155
- return {
156
- column,
157
- row
158
- };
159
- };
160
- const applyTotalAggregationType = (_ref2, overrideTotalAggregationType) => {
161
- let {
162
- totalAggregationType,
163
- value,
164
- numerator,
165
- denominator,
166
- multiplier,
167
- divisor
168
- } = _ref2;
169
- switch (overrideTotalAggregationType || totalAggregationType) {
170
- case _pivotTable.AGGREGATE_TYPE_NA:
171
- return 'N/A';
172
- case _pivotTable.AGGREGATE_TYPE_AVERAGE:
173
- return (numerator || value) * multiplier / (denominator * divisor || 1);
174
- case _pivotTable.AGGREGATE_TYPE_SUM:
175
- default:
176
- return value;
177
- }
178
- };
179
- class PivotTableEngine {
180
- constructor(visualization, data) {
181
- var _this$dimensionLookup, _this$dimensionLookup2, _this$dimensionLookup3, _this$dimensionLookup4, _this$dimensionLookup5, _this$dimensionLookup6, _this$dimensionLookup7, _this$dimensionLookup8, _this$dimensionLookup9;
182
- let legendSets = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
183
- _defineProperty(this, "visualization", void 0);
184
- _defineProperty(this, "rawData", void 0);
185
- _defineProperty(this, "options", void 0);
186
- _defineProperty(this, "legendSets", void 0);
187
- _defineProperty(this, "dimensionLookup", void 0);
188
- _defineProperty(this, "adaptiveClippingController", void 0);
189
- _defineProperty(this, "columnDepth", 0);
190
- _defineProperty(this, "rowDepth", 0);
191
- _defineProperty(this, "height", 0);
192
- _defineProperty(this, "width", 0);
193
- _defineProperty(this, "data", []);
194
- _defineProperty(this, "rowMap", []);
195
- _defineProperty(this, "columnMap", []);
196
- _defineProperty(this, "doRowTotals", false);
197
- _defineProperty(this, "doColumnTotals", false);
198
- _defineProperty(this, "doRowSubtotals", false);
199
- _defineProperty(this, "doColumnSubtotals", false);
200
- _defineProperty(this, "dataWidth", 0);
201
- _defineProperty(this, "dataHeight", 0);
202
- _defineProperty(this, "rawDataHeight", 0);
203
- this.visualization = Object.assign({}, defaultVisualizationProps, visualization);
204
- this.legendSets = (legendSets || []).reduce((sets, set) => {
205
- return {
206
- ...sets,
207
- [set.id]: set
208
- };
209
- }, {});
210
- this.rawData = data;
211
- this.dimensionLookup = buildDimensionLookup(this.visualization, this.rawData.metaData, this.rawData.headers);
212
- this.options = {
213
- ...defaultOptions,
214
- showColumnTotals: visualization.colTotals,
215
- showRowTotals: visualization.rowTotals,
216
- showColumnSubtotals: visualization.colSubTotals,
217
- showRowSubtotals: visualization.rowSubTotals,
218
- hideEmptyColumns: visualization.hideEmptyColumns,
219
- hideEmptyRows: visualization.hideEmptyRows,
220
- title: visualization.hideTitle ? undefined : visualization.title,
221
- subtitle: visualization.hideSubtitle ? undefined : visualization.subtitle,
222
- // turn on fixed headers only when there are dimensions
223
- fixColumnHeaders: (_this$dimensionLookup = this.dimensionLookup) !== null && _this$dimensionLookup !== void 0 && _this$dimensionLookup.columns.length ? visualization.fixColumnHeaders : false,
224
- fixRowHeaders: (_this$dimensionLookup2 = this.dimensionLookup) !== null && _this$dimensionLookup2 !== void 0 && _this$dimensionLookup2.rows.length ? visualization.fixRowHeaders : false
225
- };
226
- this.adaptiveClippingController = new _adaptiveClippingController.AdaptiveClippingController(this);
227
- const doColumnSubtotals = this.options.showColumnSubtotals && ((_this$dimensionLookup3 = (_this$dimensionLookup4 = this.dimensionLookup) === null || _this$dimensionLookup4 === void 0 ? void 0 : (_this$dimensionLookup5 = _this$dimensionLookup4.rows) === null || _this$dimensionLookup5 === void 0 ? void 0 : _this$dimensionLookup5.length) !== null && _this$dimensionLookup3 !== void 0 ? _this$dimensionLookup3 : 1) > 1;
228
- const singularRow = ((_this$dimensionLookup6 = this.dimensionLookup) === null || _this$dimensionLookup6 === void 0 ? void 0 : _this$dimensionLookup6.rows.length) === 1 && ((_this$dimensionLookup7 = this.dimensionLookup) === null || _this$dimensionLookup7 === void 0 ? void 0 : _this$dimensionLookup7.rows[0].count) === 1;
229
- const firstColumnIsSortable = !doColumnSubtotals && !singularRow;
230
- this.columnDepth = ((_this$dimensionLookup8 = this.dimensionLookup) === null || _this$dimensionLookup8 === void 0 ? void 0 : _this$dimensionLookup8.columns.length) || (this.visualization.showDimensionLabels || firstColumnIsSortable ? 1 : 0);
231
- this.rowDepth = ((_this$dimensionLookup9 = this.dimensionLookup) === null || _this$dimensionLookup9 === void 0 ? void 0 : _this$dimensionLookup9.rows.length) || (this.visualization.showDimensionLabels ? 1 : 0);
232
- this.buildMatrix();
233
- }
234
- get cellPadding() {
235
- switch (this.visualization.displayDensity) {
236
- case _pivotTable.DISPLAY_DENSITY_OPTION_COMPACT:
237
- return _pivotTable.DISPLAY_DENSITY_PADDING_COMPACT;
238
- case _pivotTable.DISPLAY_DENSITY_OPTION_COMFORTABLE:
239
- return _pivotTable.DISPLAY_DENSITY_PADDING_COMFORTABLE;
240
- case _pivotTable.DISPLAY_DENSITY_OPTION_NORMAL:
241
- default:
242
- return _pivotTable.DISPLAY_DENSITY_PADDING_NORMAL;
243
- }
244
- }
245
- get fontSize() {
246
- switch (this.visualization.fontSize) {
247
- case _pivotTable.FONT_SIZE_OPTION_SMALL:
248
- return _pivotTable.FONT_SIZE_SMALL;
249
- case _pivotTable.FONT_SIZE_OPTION_LARGE:
250
- return _pivotTable.FONT_SIZE_LARGE;
251
- case _pivotTable.FONT_SIZE_OPTION_NORMAL:
252
- default:
253
- return _pivotTable.FONT_SIZE_NORMAL;
254
- }
255
- }
256
- get scrollIconBuffer() {
257
- switch (this.visualization.fontSize) {
258
- case _pivotTable.FONT_SIZE_OPTION_SMALL:
259
- return 11;
260
- case _pivotTable.FONT_SIZE_OPTION_LARGE:
261
- return 15;
262
- case _pivotTable.FONT_SIZE_OPTION_NORMAL:
263
- default:
264
- return 13;
265
- }
266
- }
267
- getRaw(_ref3) {
268
- var _headers$find, _headers$find2, _this$dimensionLookup10;
269
- let {
270
- row,
271
- column
272
- } = _ref3;
273
- const cellType = this.getRawCellType({
274
- row,
275
- column
276
- });
277
- const dxDimension = this.getRawCellDxDimension({
278
- row,
279
- column
280
- });
281
- const headers = [...this.getRawRowHeader(row), ...this.getRawColumnHeader(column)];
282
- const peId = (_headers$find = headers.find(header => (header === null || header === void 0 ? void 0 : header.dimensionItemType) === _dataTypes.DIMENSION_TYPE_PERIOD)) === null || _headers$find === void 0 ? void 0 : _headers$find.uid;
283
- const ouId = (_headers$find2 = headers.find(header => (header === null || header === void 0 ? void 0 : header.dimensionItemType) === _dataTypes.DIMENSION_TYPE_ORGANISATION_UNIT)) === null || _headers$find2 === void 0 ? void 0 : _headers$find2.uid;
284
- if (!this.data[row] || !this.data[row][column]) {
285
- return {
286
- cellType,
287
- empty: true,
288
- ouId,
289
- peId
290
- };
291
- }
292
- const dataRow = this.data[row][column];
293
- let rawValue = cellType === _pivotTable.CELL_TYPE_VALUE ? dataRow[(_this$dimensionLookup10 = this.dimensionLookup) === null || _this$dimensionLookup10 === void 0 ? void 0 : _this$dimensionLookup10.dataHeaders.value] : dataRow.value;
294
- let renderedValue = rawValue;
295
- const valueType = (dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) || _valueTypes.VALUE_TYPE_TEXT;
296
- if (valueType === _valueTypes.VALUE_TYPE_NUMBER) {
297
- rawValue = (0, _utils.parseValue)(rawValue);
298
- switch (this.visualization.numberType) {
299
- case _pivotTable.NUMBER_TYPE_ROW_PERCENTAGE:
300
- renderedValue = rawValue / this.percentageTotals[row].value;
301
- break;
302
- case _pivotTable.NUMBER_TYPE_COLUMN_PERCENTAGE:
303
- renderedValue = rawValue / this.percentageTotals[column].value;
304
- break;
305
- default:
306
- break;
307
- }
308
- }
309
- renderedValue = (0, _utils.renderValue)(renderedValue, valueType, this.visualization);
310
- return {
311
- cellType,
312
- empty: false,
313
- valueType,
314
- rawValue,
315
- renderedValue,
316
- dxDimension,
317
- ouId,
318
- peId
319
- };
320
- }
321
- get(_ref4) {
322
- let {
323
- row,
324
- column
325
- } = _ref4;
326
- const mappedRow = this.rowMap[row],
327
- mappedColumn = this.columnMap[column];
328
- if (!mappedRow && mappedRow !== 0 || !mappedColumn && mappedColumn !== 0) {
329
- return undefined;
330
- }
331
- return this.getRaw({
332
- row: mappedRow,
333
- column: mappedColumn
334
- });
335
- }
336
- getRawCellType(_ref5) {
337
- let {
338
- row,
339
- column
340
- } = _ref5;
341
- const isRowTotal = this.doRowTotals && column === this.dataWidth - 1;
342
- const isColumnTotal = this.doColumnTotals && row === this.dataHeight - 1;
343
- if (isRowTotal || isColumnTotal) {
344
- return _pivotTable.CELL_TYPE_TOTAL;
345
- }
346
- const isRowSubtotal = this.doRowSubtotals && (column + 1) % (this.dimensionLookup.columns[0].size + 1) === 0;
347
- const isColumnSubtotal = this.doColumnSubtotals && (row + 1) % (this.dimensionLookup.rows[0].size + 1) === 0;
348
- if (isRowSubtotal || isColumnSubtotal) {
349
- return _pivotTable.CELL_TYPE_SUBTOTAL;
350
- }
351
- return _pivotTable.CELL_TYPE_VALUE;
352
- }
353
- getCellType(_ref6) {
354
- let {
355
- row,
356
- column
357
- } = _ref6;
358
- row = this.rowMap[row];
359
- column = this.columnMap[column];
360
- return this.getRawCellType({
361
- row,
362
- column
363
- });
364
- }
365
- getDimensionLabel(rowLevel, columnLevel) {
366
- const lastRowLevel = this.rowDepth - 1;
367
- const lastColumnLevel = this.columnDepth - 1;
368
- if (rowLevel !== lastRowLevel && columnLevel !== lastColumnLevel) {
369
- return null;
370
- }
371
- if (rowLevel === lastRowLevel && this.dimensionLookup.rows[lastRowLevel] && columnLevel === lastColumnLevel && this.dimensionLookup.columns[lastColumnLevel]) {
372
- return `${this.dimensionLookup.rows[lastRowLevel].meta.name} / ${this.dimensionLookup.columns[lastColumnLevel].meta.name}`;
373
- }
374
- if (lastRowLevel === -1) {
375
- return this.dimensionLookup.columns[columnLevel].meta.name;
376
- }
377
- if (lastColumnLevel === -1) {
378
- return this.dimensionLookup.rows[rowLevel].meta.name;
379
- }
380
- if (rowLevel === lastRowLevel && this.dimensionLookup.columns[columnLevel]) {
381
- return this.dimensionLookup.columns[columnLevel].meta.name;
382
- }
383
- if (columnLevel === lastColumnLevel && this.dimensionLookup.rows[rowLevel]) {
384
- return this.dimensionLookup.rows[rowLevel].meta.name;
385
- }
386
- }
387
- getCellDxDimension(_ref7) {
388
- let {
389
- row,
390
- column
391
- } = _ref7;
392
- return this.getRawCellDxDimension({
393
- row: this.rowMap[row],
394
- column: this.columnMap[column]
395
- });
396
- }
397
- getRawCellDxDimension(_ref8) {
398
- let {
399
- row,
400
- column
401
- } = _ref8;
402
- if (!this.data[row]) {
403
- return undefined;
404
- }
405
- const cellValue = this.data[row][column];
406
- if (!cellValue) {
407
- return undefined;
408
- }
409
- if (!Array.isArray(cellValue)) {
410
- // This is a total cell
411
- return {
412
- valueType: cellValue.valueType,
413
- totalAggregationType: cellValue.totalAggregationType,
414
- legendSet: undefined
415
- };
416
- }
417
- const rowHeaders = this.getRawRowHeader(row);
418
- const columnHeaders = this.getRawColumnHeader(column);
419
- const dxRowIndex = this.dimensionLookup.rows.findIndex(dim => dim.isDxDimension);
420
- if (rowHeaders.length && dxRowIndex !== -1) {
421
- return {
422
- valueType: rowHeaders[dxRowIndex].valueType,
423
- totalAggregationType: rowHeaders[dxRowIndex].totalAggregationType,
424
- legendSet: rowHeaders[dxRowIndex].legendSet
425
- };
426
- }
427
- const dxColumnIndex = this.dimensionLookup.columns.findIndex(dim => dim.isDxDimension);
428
- if (columnHeaders.length && dxColumnIndex !== -1) {
429
- return {
430
- valueType: columnHeaders[dxColumnIndex].valueType,
431
- totalAggregationType: columnHeaders[dxColumnIndex].totalAggregationType,
432
- legendSet: columnHeaders[dxColumnIndex].legendSet
433
- };
434
- }
435
-
436
- // Data is in Filter
437
- // TODO : This assumes the server ignores text types, we should confirm this is the case
438
- return {
439
- valueType: _valueTypes.VALUE_TYPE_NUMBER,
440
- totalAggregationType: _pivotTable.AGGREGATE_TYPE_SUM
441
- };
442
- }
443
- rowIsEmpty(row) {
444
- return !this.data[row] || this.data[row].length === 0;
445
- }
446
- columnIsEmpty(column) {
447
- return !this.adaptiveClippingController.columns.sizes[column];
448
- }
449
- getRawColumnHeader(column) {
450
- var _this$dimensionLookup17;
451
- if (this.doRowTotals && column === this.dataWidth - 1) {
452
- return (0, _times.default)(this.columnDepth - 1, () => undefined).concat([{
453
- name: 'Total'
454
- }]);
455
- }
456
- if (this.doRowSubtotals) {
457
- var _this$dimensionLookup11, _this$dimensionLookup12, _this$dimensionLookup13, _this$dimensionLookup14, _this$dimensionLookup15, _this$dimensionLookup16;
458
- if ((column + 1) % (((_this$dimensionLookup11 = (_this$dimensionLookup12 = this.dimensionLookup) === null || _this$dimensionLookup12 === void 0 ? void 0 : (_this$dimensionLookup13 = _this$dimensionLookup12.columns[0]) === null || _this$dimensionLookup13 === void 0 ? void 0 : _this$dimensionLookup13.size) !== null && _this$dimensionLookup11 !== void 0 ? _this$dimensionLookup11 : 0) + 1) === 0) {
459
- return (0, _times.default)(this.columnDepth - 1, () => undefined).concat([{
460
- name: 'Subtotal'
461
- }]);
462
- }
463
- column -= Math.floor(column / (((_this$dimensionLookup14 = (_this$dimensionLookup15 = this.dimensionLookup) === null || _this$dimensionLookup15 === void 0 ? void 0 : (_this$dimensionLookup16 = _this$dimensionLookup15.columns[0]) === null || _this$dimensionLookup16 === void 0 ? void 0 : _this$dimensionLookup16.size) !== null && _this$dimensionLookup14 !== void 0 ? _this$dimensionLookup14 : 0) + 1));
464
- }
465
- return (_this$dimensionLookup17 = this.dimensionLookup) === null || _this$dimensionLookup17 === void 0 ? void 0 : _this$dimensionLookup17.columns.map(dimension => {
466
- var _dimension$size, _dimension$count;
467
- const itemIndex = Math.floor(column / ((_dimension$size = dimension.size) !== null && _dimension$size !== void 0 ? _dimension$size : 1)) % ((_dimension$count = dimension.count) !== null && _dimension$count !== void 0 ? _dimension$count : 1);
468
- return dimension.items[itemIndex];
469
- });
470
- }
471
- getColumnHeader(column) {
472
- return this.getRawColumnHeader(this.columnMap[column]);
473
- }
474
- getRawRowHeader(row) {
475
- var _this$dimensionLookup26, _this$dimensionLookup27;
476
- if (this.doColumnTotals && row === this.dataHeight - 1) {
477
- return (0, _times.default)(this.rowDepth - 1, () => undefined).concat([{
478
- name: 'Total'
479
- }]);
480
- }
481
- if (this.doColumnSubtotals) {
482
- var _this$dimensionLookup18, _this$dimensionLookup19, _this$dimensionLookup20, _this$dimensionLookup21, _this$dimensionLookup22, _this$dimensionLookup23, _this$dimensionLookup24, _this$dimensionLookup25;
483
- if ((row + 1) % (((_this$dimensionLookup18 = (_this$dimensionLookup19 = this.dimensionLookup) === null || _this$dimensionLookup19 === void 0 ? void 0 : (_this$dimensionLookup20 = _this$dimensionLookup19.rows) === null || _this$dimensionLookup20 === void 0 ? void 0 : (_this$dimensionLookup21 = _this$dimensionLookup20[0]) === null || _this$dimensionLookup21 === void 0 ? void 0 : _this$dimensionLookup21.size) !== null && _this$dimensionLookup18 !== void 0 ? _this$dimensionLookup18 : 0) + 1) === 0) {
484
- return (0, _times.default)(this.rowDepth - 1, () => undefined).concat([{
485
- name: 'Subtotal'
486
- }]);
487
- }
488
- row -= Math.floor(row / (((_this$dimensionLookup22 = (_this$dimensionLookup23 = this.dimensionLookup) === null || _this$dimensionLookup23 === void 0 ? void 0 : (_this$dimensionLookup24 = _this$dimensionLookup23.rows) === null || _this$dimensionLookup24 === void 0 ? void 0 : (_this$dimensionLookup25 = _this$dimensionLookup24[0]) === null || _this$dimensionLookup25 === void 0 ? void 0 : _this$dimensionLookup25.size) !== null && _this$dimensionLookup22 !== void 0 ? _this$dimensionLookup22 : 0) + 1));
489
- }
490
- return (_this$dimensionLookup26 = (_this$dimensionLookup27 = this.dimensionLookup) === null || _this$dimensionLookup27 === void 0 ? void 0 : _this$dimensionLookup27.rows.map(dimension => {
491
- var _dimension$size2, _dimension$count2;
492
- const itemIndex = Math.floor(row / ((_dimension$size2 = dimension === null || dimension === void 0 ? void 0 : dimension.size) !== null && _dimension$size2 !== void 0 ? _dimension$size2 : 1)) % ((_dimension$count2 = dimension.count) !== null && _dimension$count2 !== void 0 ? _dimension$count2 : 1);
493
- return dimension.items[itemIndex];
494
- })) !== null && _this$dimensionLookup26 !== void 0 ? _this$dimensionLookup26 : [];
495
- }
496
- getRowHeader(row) {
497
- return this.getRawRowHeader(this.rowMap[row]);
498
- }
499
- getDependantTotalCells(_ref9) {
500
- var _this$dimensionLookup28, _this$dimensionLookup29, _this$dimensionLookup30, _this$dimensionLookup31, _this$dimensionLookup32, _this$dimensionLookup33;
501
- let {
502
- row,
503
- column
504
- } = _ref9;
505
- const rowSubtotalSize = ((_this$dimensionLookup28 = (_this$dimensionLookup29 = this.dimensionLookup) === null || _this$dimensionLookup29 === void 0 ? void 0 : (_this$dimensionLookup30 = _this$dimensionLookup29.columns[0]) === null || _this$dimensionLookup30 === void 0 ? void 0 : _this$dimensionLookup30.size) !== null && _this$dimensionLookup28 !== void 0 ? _this$dimensionLookup28 : 0) + 1;
506
- const rowSubtotal = rowSubtotalSize && this.doRowSubtotals && {
507
- row,
508
- column: Math.ceil((column + 1) / rowSubtotalSize) * rowSubtotalSize - 1,
509
- size: rowSubtotalSize - 1
510
- };
511
- const rowSubtotalColumnTotal = this.doRowSubtotals && this.doColumnTotals && {
512
- row: this.dataHeight - 1,
513
- column: rowSubtotal === null || rowSubtotal === void 0 ? void 0 : rowSubtotal.column,
514
- size: this.rawDataHeight
515
- };
516
- const columnSubtotalSize = ((_this$dimensionLookup31 = (_this$dimensionLookup32 = this.dimensionLookup) === null || _this$dimensionLookup32 === void 0 ? void 0 : (_this$dimensionLookup33 = _this$dimensionLookup32.rows[0]) === null || _this$dimensionLookup33 === void 0 ? void 0 : _this$dimensionLookup33.size) !== null && _this$dimensionLookup31 !== void 0 ? _this$dimensionLookup31 : 0) + 1;
517
- const columnSubtotal = columnSubtotalSize && this.doColumnSubtotals && {
518
- row: Math.ceil((row + 1) / columnSubtotalSize) * columnSubtotalSize - 1,
519
- column,
520
- size: columnSubtotalSize - 1
521
- };
522
- const columnSubtotalRowTotal = this.doColumnSubtotals && this.doRowTotals && {
523
- row: columnSubtotal.row,
524
- column: this.dataWidth - 1,
525
- size: this.rawDataWidth
526
- };
527
- const combinedSubtotal = rowSubtotalSize && columnSubtotalSize && this.doColumnSubtotals && this.doRowSubtotals && {
528
- row: columnSubtotal.row,
529
- column: rowSubtotal.column,
530
- size: columnSubtotalSize * rowSubtotalSize
531
- };
532
- const rowTotal = this.doRowTotals && {
533
- row,
534
- column: this.dataWidth - 1,
535
- size: this.rawDataWidth
536
- };
537
- const columnTotal = this.doColumnTotals && {
538
- row: this.dataHeight - 1,
539
- column,
540
- size: this.rawDataHeight
541
- };
542
- const combinedTotal = this.doColumnTotals && this.doRowTotals && {
543
- row: this.dataHeight - 1,
544
- column: this.dataWidth - 1,
545
- size: this.rawDataHeight * this.rawDataWidth
546
- };
547
- return {
548
- rowSubtotal,
549
- rowSubtotalColumnTotal,
550
- columnSubtotal,
551
- columnSubtotalRowTotal,
552
- rowTotal,
553
- columnTotal,
554
- combinedSubtotal,
555
- combinedTotal
556
- };
557
- }
558
- addCellValueToTotals(pos, dataRow) {
559
- const totals = this.getDependantTotalCells(pos);
560
- const dxDimension = this.getRawCellDxDimension(pos);
561
- Object.values(totals).forEach(totalItem => {
562
- if (!totalItem) {
563
- return;
564
- }
565
- this.data[totalItem.row] = this.data[totalItem.row] || [];
566
- this.data[totalItem.row][totalItem.column] = this.data[totalItem.row][totalItem.column] || {
567
- count: 0,
568
- totalCount: totalItem.size
569
- };
570
- const totalCell = this.data[totalItem.row][totalItem.column];
571
- const currentAggType = dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.totalAggregationType;
572
- const previousAggType = totalCell.totalAggregationType || currentAggType;
573
- if (previousAggType && currentAggType !== previousAggType) {
574
- totalCell.totalAggregationType = _pivotTable.AGGREGATE_TYPE_NA;
575
- } else {
576
- totalCell.totalAggregationType = currentAggType;
577
- }
578
- const currentValueType = dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType;
579
- const previousValueType = totalCell.valueType;
580
- if (previousValueType && currentValueType !== previousValueType) {
581
- totalCell.valueType = _pivotTable.AGGREGATE_TYPE_NA;
582
- } else {
583
- totalCell.valueType = currentValueType;
584
- }
585
- if ((dxDimension === null || dxDimension === void 0 ? void 0 : dxDimension.valueType) === _valueTypes.VALUE_TYPE_NUMBER) {
586
- dataFields.forEach(field => {
587
- const headerIndex = this.dimensionLookup.dataHeaders[field];
588
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
589
- if (value && !isNaN(value)) {
590
- totalCell[field] = (totalCell[field] || 0) + value;
591
- }
592
- });
593
- }
594
- totalCell.count += 1;
595
- });
596
- if (this.visualization.numberType === _pivotTable.NUMBER_TYPE_ROW_PERCENTAGE) {
597
- if (!this.percentageTotals[pos.row]) {
598
- this.percentageTotals[pos.row] = {
599
- count: 0,
600
- totalCount: this.rawDataWidth
601
- };
602
- }
603
- const percentageTotal = this.percentageTotals[pos.row];
604
- dataFields.forEach(field => {
605
- const headerIndex = this.dimensionLookup.dataHeaders[field];
606
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
607
- if (value && !isNaN(value)) {
608
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
609
- }
610
- });
611
- if (totals.columnSubtotal) {
612
- if (!this.percentageTotals[totals.columnSubtotal.row]) {
613
- this.percentageTotals[totals.columnSubtotal.row] = {
614
- count: 0,
615
- totalCount: this.rawDataWidth
616
- };
617
- }
618
- const percentageTotal = this.percentageTotals[totals.columnSubtotal.row];
619
- dataFields.forEach(field => {
620
- const headerIndex = this.dimensionLookup.dataHeaders[field];
621
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
622
- if (value && !isNaN(value)) {
623
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
624
- }
625
- });
626
- }
627
- if (totals.columnTotal) {
628
- if (!this.percentageTotals[totals.columnTotal.row]) {
629
- this.percentageTotals[totals.columnTotal.row] = {
630
- count: 0,
631
- totalCount: this.rawDataWidth
632
- };
633
- }
634
- const percentageTotal = this.percentageTotals[totals.columnTotal.row];
635
- dataFields.forEach(field => {
636
- const headerIndex = this.dimensionLookup.dataHeaders[field];
637
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
638
- if (value && !isNaN(value)) {
639
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
640
- }
641
- });
642
- }
643
- }
644
- if (this.visualization.numberType === _pivotTable.NUMBER_TYPE_COLUMN_PERCENTAGE) {
645
- if (!this.percentageTotals[pos.column]) {
646
- this.percentageTotals[pos.column] = {
647
- count: 0,
648
- totalCount: this.rawDataHeight
649
- };
650
- }
651
- const percentageTotal = this.percentageTotals[pos.column];
652
- dataFields.forEach(field => {
653
- const headerIndex = this.dimensionLookup.dataHeaders[field];
654
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
655
- if (value && !isNaN(value)) {
656
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
657
- }
658
- });
659
- if (totals.rowSubtotal) {
660
- if (!this.percentageTotals[totals.rowSubtotal.column]) {
661
- this.percentageTotals[totals.rowSubtotal.column] = {
662
- count: 0,
663
- totalCount: this.rawDataHeight
664
- };
665
- }
666
- const percentageTotal = this.percentageTotals[totals.rowSubtotal.column];
667
- dataFields.forEach(field => {
668
- const headerIndex = this.dimensionLookup.dataHeaders[field];
669
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
670
- if (value && !isNaN(value)) {
671
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
672
- }
673
- });
674
- }
675
- if (totals.rowTotal) {
676
- if (!this.percentageTotals[totals.rowTotal.column]) {
677
- this.percentageTotals[totals.rowTotal.column] = {
678
- count: 0,
679
- totalCount: this.rawDataHeight
680
- };
681
- }
682
- const percentageTotal = this.percentageTotals[totals.rowTotal.column];
683
- dataFields.forEach(field => {
684
- const headerIndex = this.dimensionLookup.dataHeaders[field];
685
- const value = (0, _utils.parseValue)(dataRow[headerIndex]);
686
- if (value && !isNaN(value)) {
687
- percentageTotal[field] = (percentageTotal[field] || 0) + value;
688
- }
689
- });
690
- }
691
- }
692
- }
693
- finalizeTotal(_ref10) {
694
- let {
695
- row,
696
- column
697
- } = _ref10;
698
- if (!this.data[row]) {
699
- return;
700
- }
701
- const totalCell = this.data[row][column];
702
- if (totalCell && totalCell.count) {
703
- totalCell.value = applyTotalAggregationType(totalCell, this.visualization.numberType !== _pivotTable.NUMBER_TYPE_VALUE && _pivotTable.AGGREGATE_TYPE_SUM);
704
- this.adaptiveClippingController.add({
705
- row,
706
- column
707
- }, (0, _utils.renderValue)(totalCell.value, totalCell.valueType, this.visualization));
708
- }
709
- }
710
- finalizeTotals() {
711
- var _this$dimensionLookup34, _this$dimensionLookup35, _this$dimensionLookup36, _this$dimensionLookup37, _this$dimensionLookup38, _this$dimensionLookup39;
712
- const columnSubtotalSize = ((_this$dimensionLookup34 = (_this$dimensionLookup35 = this.dimensionLookup) === null || _this$dimensionLookup35 === void 0 ? void 0 : (_this$dimensionLookup36 = _this$dimensionLookup35.rows[0]) === null || _this$dimensionLookup36 === void 0 ? void 0 : _this$dimensionLookup36.size) !== null && _this$dimensionLookup34 !== void 0 ? _this$dimensionLookup34 : 0) + 1;
713
- const rowSubtotalSize = ((_this$dimensionLookup37 = (_this$dimensionLookup38 = this.dimensionLookup) === null || _this$dimensionLookup38 === void 0 ? void 0 : (_this$dimensionLookup39 = _this$dimensionLookup38.columns[0]) === null || _this$dimensionLookup39 === void 0 ? void 0 : _this$dimensionLookup39.size) !== null && _this$dimensionLookup37 !== void 0 ? _this$dimensionLookup37 : 0) + 1;
714
- if (this.doRowSubtotals && rowSubtotalSize) {
715
- (0, _times.default)(this.dimensionLookup.columns[0].count, n => (n + 1) * rowSubtotalSize - 1).forEach(column => {
716
- (0, _times.default)(this.dataHeight - (this.doColumnTotals ? 1 : 0), n => n).forEach(row => {
717
- // skip combined subtotal cells
718
- if (!this.doColumnSubtotals || (row + 1) % columnSubtotalSize !== 0) {
719
- this.finalizeTotal({
720
- row,
721
- column
722
- });
723
- }
724
- });
725
- });
726
- }
727
- if (this.doColumnSubtotals && columnSubtotalSize) {
728
- (0, _times.default)(this.dimensionLookup.rows[0].count, n => (n + 1) * columnSubtotalSize - 1).forEach(row => {
729
- (0, _times.default)(this.dataWidth - (this.doRowTotals ? 1 : 0), n => n).forEach(column => {
730
- // skip combined subtotal cells
731
- if (!this.doRowSubtotals || (column + 1) % rowSubtotalSize !== 0) {
732
- this.finalizeTotal({
733
- row,
734
- column
735
- });
736
- }
737
- });
738
- });
739
- }
740
-
741
- // Combined subtotal cells
742
- if (this.doRowSubtotals && this.doColumnSubtotals && rowSubtotalSize && columnSubtotalSize) {
743
- (0, _times.default)(this.dimensionLookup.rows[0].count, n => (n + 1) * columnSubtotalSize - 1).forEach(row => {
744
- (0, _times.default)(this.dimensionLookup.columns[0].count, n => (n + 1) * rowSubtotalSize - 1).forEach(column => {
745
- this.finalizeTotal({
746
- row,
747
- column
748
- });
749
- });
750
- });
751
- }
752
- if (this.doRowTotals) {
753
- const column = this.dataWidth - 1;
754
- const rowCount = this.doColumnTotals ? this.dataHeight - 1 : this.dataHeight;
755
- (0, _times.default)(rowCount, n => n).forEach(row => {
756
- this.finalizeTotal({
757
- row,
758
- column
759
- });
760
- });
761
- }
762
- if (this.doColumnTotals) {
763
- const row = this.dataHeight - 1;
764
- const colCount = this.doRowTotals ? this.dataWidth - 1 : this.dataWidth;
765
- (0, _times.default)(colCount, n => n).forEach(column => {
766
- this.finalizeTotal({
767
- row,
768
- column
769
- });
770
- });
771
- }
772
- if (this.doRowTotals && this.doColumnTotals) {
773
- this.finalizeTotal({
774
- row: this.dataHeight - 1,
775
- column: this.dataWidth - 1
776
- });
777
- }
778
- if (this.percentageTotals) {
779
- this.percentageTotals.forEach(item => {
780
- item.value = applyTotalAggregationType(item);
781
- });
782
- }
783
- }
784
- resetRowMap() {
785
- this.rowMap = this.options.hideEmptyRows ? (0, _times.default)(this.dataHeight, n => n).filter(idx => !!this.data[idx]) : (0, _times.default)(this.dataHeight, n => n);
786
- }
787
- resetColumnMap() {
788
- this.columnMap = this.options.hideEmptyColumns ? (0, _times.default)(this.dataWidth, n => n).filter(idx => !this.columnIsEmpty(idx)) : (0, _times.default)(this.dataWidth, n => n);
789
- }
790
- buildMatrix() {
791
- this.data = [];
792
- this.adaptiveClippingController.reset();
793
- this.dataHeight = this.rawDataHeight = countFromDisaggregates(this.dimensionLookup.rows);
794
- this.dataWidth = this.rawDataWidth = countFromDisaggregates(this.dimensionLookup.columns);
795
-
796
- // TODO: Check last row/col dimension for size===1, skip redundant sub-totals
797
- this.doRowSubtotals = this.options.showRowSubtotals && this.columnDepth > 1;
798
- this.doColumnSubtotals = this.options.showColumnSubtotals && this.rowDepth > 1;
799
- this.doRowTotals = this.options.showRowTotals && this.dataWidth > 1;
800
- this.doColumnTotals = this.options.showColumnTotals && this.dataHeight > 1;
801
- if (this.doRowSubtotals) {
802
- this.dataWidth += this.dimensionLookup.columns[0].count;
803
- }
804
- if (this.doColumnSubtotals) {
805
- this.dataHeight += this.dimensionLookup.rows[0].count;
806
- }
807
- if (this.doRowTotals) {
808
- this.dataWidth += 1;
809
- }
810
- if (this.doColumnTotals) {
811
- this.dataHeight += 1;
812
- }
813
-
814
- // TODO: Use total cell calculation, don't duplicate here
815
- if (this.visualization.numberType === _pivotTable.NUMBER_TYPE_ROW_PERCENTAGE || this.visualization.numberType === _pivotTable.NUMBER_TYPE_COLUMN_PERCENTAGE) {
816
- this.percentageTotals = [];
817
- }
818
- this.rawData.rows.forEach(dataRow => {
819
- const pos = lookup(dataRow, this.dimensionLookup, this);
820
- if (pos) {
821
- this.data[pos.row] = this.data[pos.row] || [];
822
- this.data[pos.row][pos.column] = dataRow;
823
- this.addCellValueToTotals(pos, dataRow);
824
- }
825
- });
826
- this.finalizeTotals();
827
- this.rawData.rows.forEach(dataRow => {
828
- const pos = lookup(dataRow, this.dimensionLookup, this);
829
- if (pos) {
830
- this.adaptiveClippingController.add(pos, this.getRaw(pos).renderedValue);
831
- }
832
- });
833
- this.resetRowMap();
834
- this.resetColumnMap();
835
- this.height = this.rowMap.length;
836
- this.width = this.columnMap.length;
837
- this.adaptiveClippingController.finalize();
838
- }
839
- getColumnType(column) {
840
- column = this.columnMap[column];
841
- if (!column && column !== 0) {
842
- return undefined;
843
- }
844
- if (this.doRowSubtotals && (column + 1) % (this.dimensionLookup.columns[0].size + 1) === 0) {
845
- return _pivotTable.CELL_TYPE_SUBTOTAL;
846
- }
847
- if (this.doRowTotals && column === this.dataWidth - 1) {
848
- return _pivotTable.CELL_TYPE_TOTAL;
849
- }
850
- return _pivotTable.CELL_TYPE_VALUE;
851
- }
852
- isSortable(column) {
853
- return this.dataHeight > 1 && !this.doColumnSubtotals && this.getColumnType(column) !== undefined;
854
- }
855
- sort(column, order) {
856
- if (order !== _pivotTable.SORT_ORDER_ASCENDING && order !== _pivotTable.SORT_ORDER_DESCENDING) {
857
- console.warn(`Invalid sort order ${order}`);
858
- return;
859
- }
860
- if (!this.isSortable(column)) {
861
- console.warn(`Invalid sort column ${column}`);
862
- return;
863
- }
864
- const mappedColumn = this.columnMap[column];
865
- this.rowMap.sort((rowA, rowB) => {
866
- if (this.doColumnTotals && rowA === this.dataHeight - 1) {
867
- return 1;
868
- }
869
- if (this.doColumnTotals && rowB === this.dataHeight - 1) {
870
- return -1;
871
- }
872
- const valueA = this.getRaw({
873
- row: rowA,
874
- column: mappedColumn
875
- });
876
- const valueB = this.getRaw({
877
- row: rowB,
878
- column: mappedColumn
879
- });
880
- if ((!valueA || valueA.empty) && (!valueB || valueB.empty)) {
881
- return 0;
882
- }
883
- if (!valueA || valueA.empty) {
884
- return -1 * order;
885
- }
886
- if (!valueB || valueB.empty) {
887
- return 1 * order;
888
- }
889
- if (valueA.valueType === _valueTypes.VALUE_TYPE_NUMBER && valueB.valueType === _valueTypes.VALUE_TYPE_NUMBER) {
890
- return (valueA.rawValue - valueB.rawValue) * order;
891
- }
892
- return valueA.renderedValue.localeCompare(valueB.renderedValue) * order;
893
- });
894
- this.adaptiveClippingController.resetRowPartitions();
895
- }
896
- clearSort() {
897
- this.resetRowMap();
898
- this.adaptiveClippingController.resetRowPartitions();
899
- }
900
- }
901
- exports.PivotTableEngine = PivotTableEngine;