@mwater/visualization 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (860) hide show
  1. package/.prettierrc +11 -0
  2. package/.storybook/config.js +7 -0
  3. package/.storybook/head.html +4 -0
  4. package/.storybook/webpack.config.js +15 -0
  5. package/.vscode/launch.json +40 -0
  6. package/LICENSE +21 -0
  7. package/README.md +19 -0
  8. package/build-demo.ts +54 -0
  9. package/lib/CheckboxComponent.d.ts +15 -0
  10. package/lib/CheckboxComponent.js +25 -0
  11. package/lib/ColorComponent.d.ts +24 -0
  12. package/lib/ColorComponent.js +77 -0
  13. package/lib/ColorSchemeFactory.d.ts +8 -0
  14. package/lib/ColorSchemeFactory.js +164 -0
  15. package/lib/CsvBuilder.d.ts +5 -0
  16. package/lib/CsvBuilder.js +63 -0
  17. package/lib/DateRangeComponent.d.ts +81 -0
  18. package/lib/DateRangeComponent.js +190 -0
  19. package/lib/FiltersDesignerComponent.d.ts +25 -0
  20. package/lib/FiltersDesignerComponent.js +38 -0
  21. package/lib/ImplicitFilterBuilder.d.ts +8 -0
  22. package/lib/ImplicitFilterBuilder.js +114 -0
  23. package/lib/JsonQLFilter.d.ts +7 -0
  24. package/lib/JsonQLFilter.js +2 -0
  25. package/lib/LocaleContextInjector.d.ts +14 -0
  26. package/lib/LocaleContextInjector.js +20 -0
  27. package/lib/MWaterAddRelatedFormComponent.d.ts +25 -0
  28. package/lib/MWaterAddRelatedFormComponent.js +155 -0
  29. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +31 -0
  30. package/lib/MWaterAddRelatedIndicatorComponent.js +129 -0
  31. package/lib/MWaterAssetSystemsListComponent.d.ts +17 -0
  32. package/lib/MWaterAssetSystemsListComponent.js +78 -0
  33. package/lib/MWaterCompleteTableSelectComponent.d.ts +224 -0
  34. package/lib/MWaterCompleteTableSelectComponent.js +680 -0
  35. package/lib/MWaterContextComponent.d.ts +31 -0
  36. package/lib/MWaterContextComponent.js +111 -0
  37. package/lib/MWaterCustomTablesetListComponent.d.ts +17 -0
  38. package/lib/MWaterCustomTablesetListComponent.js +87 -0
  39. package/lib/MWaterGlobalFiltersComponent.d.ts +16 -0
  40. package/lib/MWaterGlobalFiltersComponent.js +103 -0
  41. package/lib/MWaterLoaderComponent.d.ts +42 -0
  42. package/lib/MWaterLoaderComponent.js +77 -0
  43. package/lib/MWaterMetricsTableListComponent.d.ts +17 -0
  44. package/lib/MWaterMetricsTableListComponent.js +79 -0
  45. package/lib/MWaterResponsesFilterComponent.d.ts +42 -0
  46. package/lib/MWaterResponsesFilterComponent.js +145 -0
  47. package/lib/MWaterTableSelectComponent.d.ts +36 -0
  48. package/lib/MWaterTableSelectComponent.js +206 -0
  49. package/lib/MenuItemComponent.d.ts +0 -0
  50. package/lib/MenuItemComponent.js +3 -0
  51. package/lib/PopoverComponent.d.ts +15 -0
  52. package/lib/PopoverComponent.js +49 -0
  53. package/lib/RadioButtonComponent.d.ts +16 -0
  54. package/lib/RadioButtonComponent.js +25 -0
  55. package/lib/TableSelectComponent.d.ts +21 -0
  56. package/lib/TableSelectComponent.js +68 -0
  57. package/lib/UIComponents.d.ts +85 -0
  58. package/lib/UIComponents.js +195 -0
  59. package/lib/UndoStack.d.ts +11 -0
  60. package/lib/UndoStack.js +51 -0
  61. package/lib/VerticalLayoutComponent.d.ts +21 -0
  62. package/lib/VerticalLayoutComponent.js +76 -0
  63. package/lib/WidgetScope.d.ts +13 -0
  64. package/lib/WidgetScope.js +2 -0
  65. package/lib/axes/Axis.d.ts +81 -0
  66. package/lib/axes/Axis.js +2 -0
  67. package/lib/axes/AxisBuilder.d.ts +66 -0
  68. package/lib/axes/AxisBuilder.js +1202 -0
  69. package/lib/axes/AxisColorEditorComponent.d.ts +39 -0
  70. package/lib/axes/AxisColorEditorComponent.js +133 -0
  71. package/lib/axes/AxisComponent.d.ts +65 -0
  72. package/lib/axes/AxisComponent.js +359 -0
  73. package/lib/axes/BinsComponent.d.ts +21 -0
  74. package/lib/axes/BinsComponent.js +96 -0
  75. package/lib/axes/CategoryMapComponent.d.ts +41 -0
  76. package/lib/axes/CategoryMapComponent.js +175 -0
  77. package/lib/axes/ColorPaletteCollectionComponent.d.ts +17 -0
  78. package/lib/axes/ColorPaletteCollectionComponent.js +130 -0
  79. package/lib/axes/RangesComponent.d.ts +35 -0
  80. package/lib/axes/RangesComponent.js +119 -0
  81. package/lib/componenttest.d.ts +1 -0
  82. package/lib/componenttest.js +47 -0
  83. package/lib/compressJson.d.ts +4 -0
  84. package/lib/compressJson.js +19 -0
  85. package/lib/dashboards/DashboardComponent.d.ts +115 -0
  86. package/lib/dashboards/DashboardComponent.js +297 -0
  87. package/lib/dashboards/DashboardDataSource.d.ts +9 -0
  88. package/lib/dashboards/DashboardDataSource.js +14 -0
  89. package/lib/dashboards/DashboardDesign.d.ts +45 -0
  90. package/lib/dashboards/DashboardDesign.js +2 -0
  91. package/lib/dashboards/DashboardUpgrader.d.ts +4 -0
  92. package/lib/dashboards/DashboardUpgrader.js +95 -0
  93. package/lib/dashboards/DashboardUtils.d.ts +7 -0
  94. package/lib/dashboards/DashboardUtils.js +69 -0
  95. package/lib/dashboards/DashboardViewComponent.d.ts +71 -0
  96. package/lib/dashboards/DashboardViewComponent.js +235 -0
  97. package/lib/dashboards/DirectDashboardDataSource.d.ts +31 -0
  98. package/lib/dashboards/DirectDashboardDataSource.js +62 -0
  99. package/lib/dashboards/LayoutOptionsComponent.d.ts +11 -0
  100. package/lib/dashboards/LayoutOptionsComponent.js +119 -0
  101. package/lib/dashboards/README.md +13 -0
  102. package/lib/dashboards/ServerDashboardDataSource.d.ts +96 -0
  103. package/lib/dashboards/ServerDashboardDataSource.js +383 -0
  104. package/lib/dashboards/SettingsModalComponent.d.ts +33 -0
  105. package/lib/dashboards/SettingsModalComponent.js +122 -0
  106. package/lib/dashboards/WidgetComponent.d.ts +53 -0
  107. package/lib/dashboards/WidgetComponent.js +66 -0
  108. package/lib/dashboards/layoutOptions.d.ts +19 -0
  109. package/lib/dashboards/layoutOptions.js +19 -0
  110. package/lib/datagrids/DatagridComponent.d.ts +122 -0
  111. package/lib/datagrids/DatagridComponent.js +285 -0
  112. package/lib/datagrids/DatagridDataSource.d.ts +9 -0
  113. package/lib/datagrids/DatagridDataSource.js +13 -0
  114. package/lib/datagrids/DatagridDesign.d.ts +75 -0
  115. package/lib/datagrids/DatagridDesign.js +2 -0
  116. package/lib/datagrids/DatagridDesignerComponent.d.ts +114 -0
  117. package/lib/datagrids/DatagridDesignerComponent.js +389 -0
  118. package/lib/datagrids/DatagridQueryBuilder.d.ts +68 -0
  119. package/lib/datagrids/DatagridQueryBuilder.js +540 -0
  120. package/lib/datagrids/DatagridUtils.d.ts +8 -0
  121. package/lib/datagrids/DatagridUtils.js +91 -0
  122. package/lib/datagrids/DatagridViewComponent.d.ts +86 -0
  123. package/lib/datagrids/DatagridViewComponent.js +321 -0
  124. package/lib/datagrids/DirectDatagridDataSource.d.ts +20 -0
  125. package/lib/datagrids/DirectDatagridDataSource.js +62 -0
  126. package/lib/datagrids/EditExprCellComponent.d.ts +77 -0
  127. package/lib/datagrids/EditExprCellComponent.js +212 -0
  128. package/lib/datagrids/ExprCellComponent.d.ts +34 -0
  129. package/lib/datagrids/ExprCellComponent.js +81 -0
  130. package/lib/datagrids/FindReplaceModalComponent.d.ts +52 -0
  131. package/lib/datagrids/FindReplaceModalComponent.js +248 -0
  132. package/lib/datagrids/LabeledExprGenerator.d.ts +40 -0
  133. package/lib/datagrids/LabeledExprGenerator.js +252 -0
  134. package/lib/datagrids/OrderBysDesignerComponent.d.ts +22 -0
  135. package/lib/datagrids/OrderBysDesignerComponent.js +67 -0
  136. package/lib/datagrids/README.md +3 -0
  137. package/lib/datagrids/ServerDatagridDataSource.d.ts +40 -0
  138. package/lib/datagrids/ServerDatagridDataSource.js +79 -0
  139. package/lib/demo.d.ts +1 -0
  140. package/lib/demo.js +4006 -0
  141. package/lib/demoBlocks.d.ts +1 -0
  142. package/lib/demoBlocks.js +112 -0
  143. package/lib/index.css +550 -0
  144. package/lib/index.d.ts +69 -0
  145. package/lib/index.js +156 -0
  146. package/lib/injectTableAlias.d.ts +2 -0
  147. package/lib/injectTableAlias.js +30 -0
  148. package/lib/languages.d.ts +9 -0
  149. package/lib/languages.js +926 -0
  150. package/lib/layout-styles.css +263 -0
  151. package/lib/layouts/DecoratedBlockComponent.d.ts +44 -0
  152. package/lib/layouts/DecoratedBlockComponent.js +96 -0
  153. package/lib/layouts/DragSourceComponent.d.ts +2 -0
  154. package/lib/layouts/DragSourceComponent.js +26 -0
  155. package/lib/layouts/LayoutManager.d.ts +50 -0
  156. package/lib/layouts/LayoutManager.js +41 -0
  157. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +75 -0
  158. package/lib/layouts/blocks/BlocksDisplayComponent.js +336 -0
  159. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +36 -0
  160. package/lib/layouts/blocks/BlocksLayoutManager.js +74 -0
  161. package/lib/layouts/blocks/ClipboardPaletteItemComponent.d.ts +9 -0
  162. package/lib/layouts/blocks/ClipboardPaletteItemComponent.js +59 -0
  163. package/lib/layouts/blocks/DraggableBlockComponent.d.ts +2 -0
  164. package/lib/layouts/blocks/DraggableBlockComponent.js +163 -0
  165. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +31 -0
  166. package/lib/layouts/blocks/HorizontalBlockComponent.js +191 -0
  167. package/lib/layouts/blocks/PaletteItemComponent.d.ts +14 -0
  168. package/lib/layouts/blocks/PaletteItemComponent.js +15 -0
  169. package/lib/layouts/blocks/README.md +11 -0
  170. package/lib/layouts/blocks/blockUtils.d.ts +22 -0
  171. package/lib/layouts/blocks/blockUtils.js +155 -0
  172. package/lib/layouts/decorated-block.css +100 -0
  173. package/lib/layouts/grid/GridLayoutComponent.d.ts +23 -0
  174. package/lib/layouts/grid/GridLayoutComponent.js +49 -0
  175. package/lib/layouts/grid/GridLayoutManager.d.ts +29 -0
  176. package/lib/layouts/grid/GridLayoutManager.js +141 -0
  177. package/lib/layouts/grid/LegoLayoutEngine.d.ts +33 -0
  178. package/lib/layouts/grid/LegoLayoutEngine.js +129 -0
  179. package/lib/layouts/grid/PaletteItemComponent.d.ts +14 -0
  180. package/lib/layouts/grid/PaletteItemComponent.js +15 -0
  181. package/lib/layouts/grid/README.md +14 -0
  182. package/lib/layouts/grid/WidgetContainerComponent.d.ts +9 -0
  183. package/lib/layouts/grid/WidgetContainerComponent.js +333 -0
  184. package/lib/mWaterLoader.d.ts +26 -0
  185. package/lib/mWaterLoader.js +55 -0
  186. package/lib/mapdemo.d.ts +0 -0
  187. package/lib/mapdemo.js +115 -0
  188. package/lib/maps/AddLayerComponent.d.ts +22 -0
  189. package/lib/maps/AddLayerComponent.js +85 -0
  190. package/lib/maps/AdminScopeAndDetailLevelComponent.d.ts +19 -0
  191. package/lib/maps/AdminScopeAndDetailLevelComponent.js +59 -0
  192. package/lib/maps/BaseLayerDesignerComponent.d.ts +28 -0
  193. package/lib/maps/BaseLayerDesignerComponent.js +57 -0
  194. package/lib/maps/BingLayer.d.ts +1 -0
  195. package/lib/maps/BingLayer.js +151 -0
  196. package/lib/maps/BufferLayer.d.ts +51 -0
  197. package/lib/maps/BufferLayer.js +816 -0
  198. package/lib/maps/BufferLayerDesign.d.ts +37 -0
  199. package/lib/maps/BufferLayerDesign.js +2 -0
  200. package/lib/maps/BufferLayerDesignerComponent.d.ts +49 -0
  201. package/lib/maps/BufferLayerDesignerComponent.js +217 -0
  202. package/lib/maps/ChoroplethLayer.d.ts +74 -0
  203. package/lib/maps/ChoroplethLayer.js +1515 -0
  204. package/lib/maps/ChoroplethLayerDesign.d.ts +56 -0
  205. package/lib/maps/ChoroplethLayerDesign.js +2 -0
  206. package/lib/maps/ChoroplethLayerDesigner.d.ts +53 -0
  207. package/lib/maps/ChoroplethLayerDesigner.js +382 -0
  208. package/lib/maps/ClusterLayer.d.ts +38 -0
  209. package/lib/maps/ClusterLayer.js +746 -0
  210. package/lib/maps/ClusterLayerDesign.d.ts +22 -0
  211. package/lib/maps/ClusterLayerDesign.js +2 -0
  212. package/lib/maps/ClusterLayerDesignerComponent.d.ts +37 -0
  213. package/lib/maps/ClusterLayerDesignerComponent.js +110 -0
  214. package/lib/maps/DetailLevelSelectComponent.d.ts +122 -0
  215. package/lib/maps/DetailLevelSelectComponent.js +91 -0
  216. package/lib/maps/DirectMapDataSource.d.ts +68 -0
  217. package/lib/maps/DirectMapDataSource.js +265 -0
  218. package/lib/maps/EditHoverOver.d.ts +18 -0
  219. package/lib/maps/EditHoverOver.js +88 -0
  220. package/lib/maps/EditPopupComponent.d.ts +26 -0
  221. package/lib/maps/EditPopupComponent.js +75 -0
  222. package/lib/maps/Grid Functions.sql +167 -0
  223. package/lib/maps/GridLayer.d.ts +48 -0
  224. package/lib/maps/GridLayer.js +684 -0
  225. package/lib/maps/GridLayerDesign.d.ts +35 -0
  226. package/lib/maps/GridLayerDesign.js +2 -0
  227. package/lib/maps/GridLayerDesigner.d.ts +38 -0
  228. package/lib/maps/GridLayerDesigner.js +229 -0
  229. package/lib/maps/HoverContent.d.ts +13 -0
  230. package/lib/maps/HoverContent.js +92 -0
  231. package/lib/maps/HtmlUrlLegend.d.ts +16 -0
  232. package/lib/maps/HtmlUrlLegend.js +38 -0
  233. package/lib/maps/Layer.d.ts +164 -0
  234. package/lib/maps/Layer.js +193 -0
  235. package/lib/maps/LayerFactory.d.ts +5 -0
  236. package/lib/maps/LayerFactory.js +47 -0
  237. package/lib/maps/LayerLegendComponent.d.ts +23 -0
  238. package/lib/maps/LayerLegendComponent.js +68 -0
  239. package/lib/maps/LayerSwitcherComponent.d.ts +7 -0
  240. package/lib/maps/LayerSwitcherComponent.js +97 -0
  241. package/lib/maps/LeafletLoading.css +24 -0
  242. package/lib/maps/LeafletLoading.d.ts +42 -0
  243. package/lib/maps/LeafletLoading.js +318 -0
  244. package/lib/maps/LeafletMapComponent.d.ts +141 -0
  245. package/lib/maps/LeafletMapComponent.js +438 -0
  246. package/lib/maps/LegendComponent.d.ts +14 -0
  247. package/lib/maps/LegendComponent.js +74 -0
  248. package/lib/maps/LegendGroup.d.ts +24 -0
  249. package/lib/maps/LegendGroup.js +86 -0
  250. package/lib/maps/MWaterServerLayer.d.ts +40 -0
  251. package/lib/maps/MWaterServerLayer.js +101 -0
  252. package/lib/maps/MapBoundsCalculator.d.ts +16 -0
  253. package/lib/maps/MapBoundsCalculator.js +85 -0
  254. package/lib/maps/MapComponent.d.ts +98 -0
  255. package/lib/maps/MapComponent.js +186 -0
  256. package/lib/maps/MapControlComponent.d.ts +17 -0
  257. package/lib/maps/MapControlComponent.js +25 -0
  258. package/lib/maps/MapDataSource.d.ts +18 -0
  259. package/lib/maps/MapDataSource.js +2 -0
  260. package/lib/maps/MapDesign.d.ts +77 -0
  261. package/lib/maps/MapDesign.js +2 -0
  262. package/lib/maps/MapDesignerComponent.d.ts +39 -0
  263. package/lib/maps/MapDesignerComponent.js +215 -0
  264. package/lib/maps/MapFiltersDesignerComponent.d.ts +21 -0
  265. package/lib/maps/MapFiltersDesignerComponent.js +70 -0
  266. package/lib/maps/MapLayerDataSource.d.ts +22 -0
  267. package/lib/maps/MapLayerDataSource.js +2 -0
  268. package/lib/maps/MapLayerViewDesignerComponent.d.ts +87 -0
  269. package/lib/maps/MapLayerViewDesignerComponent.js +151 -0
  270. package/lib/maps/MapLayersDesignerComponent.d.ts +32 -0
  271. package/lib/maps/MapLayersDesignerComponent.js +98 -0
  272. package/lib/maps/MapUtils.d.ts +21 -0
  273. package/lib/maps/MapUtils.js +119 -0
  274. package/lib/maps/MapViewComponent.d.ts +38 -0
  275. package/lib/maps/MapViewComponent.js +20 -0
  276. package/lib/maps/Maptiler-logo.png +0 -0
  277. package/lib/maps/MarkerSymbolSelectComponent.d.ts +10 -0
  278. package/lib/maps/MarkerSymbolSelectComponent.js +28 -0
  279. package/lib/maps/MarkersLayer.d.ts +66 -0
  280. package/lib/maps/MarkersLayer.js +838 -0
  281. package/lib/maps/MarkersLayerDesign.d.ts +44 -0
  282. package/lib/maps/MarkersLayerDesign.js +2 -0
  283. package/lib/maps/MarkersLayerDesignerComponent.d.ts +56 -0
  284. package/lib/maps/MarkersLayerDesignerComponent.js +269 -0
  285. package/lib/maps/PopupFilterJoinsEditComponent.d.ts +30 -0
  286. package/lib/maps/PopupFilterJoinsEditComponent.js +75 -0
  287. package/lib/maps/PopupFilterJoinsUtils.d.ts +15 -0
  288. package/lib/maps/PopupFilterJoinsUtils.js +91 -0
  289. package/lib/maps/RasterMapViewComponent.d.ts +108 -0
  290. package/lib/maps/RasterMapViewComponent.js +283 -0
  291. package/lib/maps/RegionSelectComponent.d.ts +55 -0
  292. package/lib/maps/RegionSelectComponent.js +61 -0
  293. package/lib/maps/ScopeAndDetailLevelComponent.d.ts +21 -0
  294. package/lib/maps/ScopeAndDetailLevelComponent.js +76 -0
  295. package/lib/maps/ServerMapDataSource.d.ts +86 -0
  296. package/lib/maps/ServerMapDataSource.js +273 -0
  297. package/lib/maps/SwitchableTileUrlLayer.d.ts +53 -0
  298. package/lib/maps/SwitchableTileUrlLayer.js +69 -0
  299. package/lib/maps/SwitchableTileUrlLayerDesigner.d.ts +14 -0
  300. package/lib/maps/SwitchableTileUrlLayerDesigner.js +26 -0
  301. package/lib/maps/TileUrlLayer.d.ts +40 -0
  302. package/lib/maps/TileUrlLayer.js +96 -0
  303. package/lib/maps/UtfGridLayer.d.ts +1 -0
  304. package/lib/maps/UtfGridLayer.js +216 -0
  305. package/lib/maps/VectorMapViewComponent.css +21 -0
  306. package/lib/maps/VectorMapViewComponent.d.ts +44 -0
  307. package/lib/maps/VectorMapViewComponent.js +565 -0
  308. package/lib/maps/ZoomLevelsComponent.d.ts +15 -0
  309. package/lib/maps/ZoomLevelsComponent.js +37 -0
  310. package/lib/maps/mapSymbols.d.ts +6 -0
  311. package/lib/maps/mapSymbols.js +167 -0
  312. package/lib/maps/mapboxUtils.d.ts +6 -0
  313. package/lib/maps/mapboxUtils.js +60 -0
  314. package/lib/maps/maps.d.ts +36 -0
  315. package/lib/maps/maps.js +2 -0
  316. package/lib/maps/marker-icon-2x.png +0 -0
  317. package/lib/maps/marker-icon.png +0 -0
  318. package/lib/maps/marker-shadow.png +0 -0
  319. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  320. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  321. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  322. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  323. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  324. package/lib/maps/symbols/font-awesome/building.png +0 -0
  325. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  326. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  327. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  328. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  329. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  330. package/lib/maps/symbols/font-awesome/check.png +0 -0
  331. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  332. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  333. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  334. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  335. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  336. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  337. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  338. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  339. package/lib/maps/symbols/font-awesome/female.png +0 -0
  340. package/lib/maps/symbols/font-awesome/file.png +0 -0
  341. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  342. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  343. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  344. package/lib/maps/symbols/font-awesome/home.png +0 -0
  345. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  346. package/lib/maps/symbols/font-awesome/male.png +0 -0
  347. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  348. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  349. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  350. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  351. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  352. package/lib/maps/symbols/font-awesome/square.png +0 -0
  353. package/lib/maps/symbols/font-awesome/star.png +0 -0
  354. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  355. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  356. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  357. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  358. package/lib/maps/symbols/font-awesome/times.png +0 -0
  359. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  360. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  361. package/lib/maps/symbols/font-awesome/university.png +0 -0
  362. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  363. package/lib/maps/symbols/font-awesome/user.png +0 -0
  364. package/lib/maps/symbols/font-awesome/users.png +0 -0
  365. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  366. package/lib/maps/vectorMaps.d.ts +42 -0
  367. package/lib/maps/vectorMaps.js +331 -0
  368. package/lib/memoizedDebounce.d.ts +6 -0
  369. package/lib/memoizedDebounce.js +21 -0
  370. package/lib/quickfilter/DateExprComponent.d.ts +81 -0
  371. package/lib/quickfilter/DateExprComponent.js +197 -0
  372. package/lib/quickfilter/IdArrayQuickfilterComponent.d.ts +24 -0
  373. package/lib/quickfilter/IdArrayQuickfilterComponent.js +30 -0
  374. package/lib/quickfilter/Quickfilter.d.ts +21 -0
  375. package/lib/quickfilter/Quickfilter.js +2 -0
  376. package/lib/quickfilter/QuickfilterCompiler.d.ts +16 -0
  377. package/lib/quickfilter/QuickfilterCompiler.js +167 -0
  378. package/lib/quickfilter/QuickfilterUtils.d.ts +7 -0
  379. package/lib/quickfilter/QuickfilterUtils.js +106 -0
  380. package/lib/quickfilter/QuickfiltersComponent.d.ts +293 -0
  381. package/lib/quickfilter/QuickfiltersComponent.js +257 -0
  382. package/lib/quickfilter/QuickfiltersDataSource.d.ts +7 -0
  383. package/lib/quickfilter/QuickfiltersDataSource.js +2 -0
  384. package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +46 -0
  385. package/lib/quickfilter/QuickfiltersDesignComponent.js +176 -0
  386. package/lib/quickfilter/README.md +8 -0
  387. package/lib/quickfilter/TextLiteralComponent.d.ts +216 -0
  388. package/lib/quickfilter/TextLiteralComponent.js +128 -0
  389. package/lib/richtext/ExprItemsHtmlConverter.d.ts +39 -0
  390. package/lib/richtext/ExprItemsHtmlConverter.js +118 -0
  391. package/lib/richtext/FontColorPaletteItem.d.ts +23 -0
  392. package/lib/richtext/FontColorPaletteItem.js +84 -0
  393. package/lib/richtext/FontSizePaletteItem.d.ts +29 -0
  394. package/lib/richtext/FontSizePaletteItem.js +70 -0
  395. package/lib/richtext/ItemsHtmlConverter.d.ts +31 -0
  396. package/lib/richtext/ItemsHtmlConverter.js +209 -0
  397. package/lib/richtext/README.md +3 -0
  398. package/lib/richtext/RichTextComponent.d.ts +84 -0
  399. package/lib/richtext/RichTextComponent.js +255 -0
  400. package/lib/valueFormatter.d.ts +16 -0
  401. package/lib/valueFormatter.js +93 -0
  402. package/lib/widgets/DirectWidgetDataSource.d.ts +43 -0
  403. package/lib/widgets/DirectWidgetDataSource.js +39 -0
  404. package/lib/widgets/DropdownWidgetComponent.d.ts +31 -0
  405. package/lib/widgets/DropdownWidgetComponent.js +41 -0
  406. package/lib/widgets/IFrameWidget.d.ts +16 -0
  407. package/lib/widgets/IFrameWidget.js +38 -0
  408. package/lib/widgets/IFrameWidgetComponent.d.ts +33 -0
  409. package/lib/widgets/IFrameWidgetComponent.js +101 -0
  410. package/lib/widgets/ImageUploaderComponent.d.ts +29 -0
  411. package/lib/widgets/ImageUploaderComponent.js +91 -0
  412. package/lib/widgets/ImageWidget.d.ts +49 -0
  413. package/lib/widgets/ImageWidget.js +112 -0
  414. package/lib/widgets/ImageWidgetComponent.d.ts +125 -0
  415. package/lib/widgets/ImageWidgetComponent.js +368 -0
  416. package/lib/widgets/ImagelistCarouselComponent.d.ts +29 -0
  417. package/lib/widgets/ImagelistCarouselComponent.js +64 -0
  418. package/lib/widgets/MapWidget.d.ts +55 -0
  419. package/lib/widgets/MapWidget.js +167 -0
  420. package/lib/widgets/MarkdownWidget.d.ts +53 -0
  421. package/lib/widgets/MarkdownWidget.js +134 -0
  422. package/lib/widgets/TOCWidget.d.ts +39 -0
  423. package/lib/widgets/TOCWidget.js +254 -0
  424. package/lib/widgets/Widget.d.ts +61 -0
  425. package/lib/widgets/Widget.js +33 -0
  426. package/lib/widgets/WidgetDataSource.d.ts +20 -0
  427. package/lib/widgets/WidgetDataSource.js +2 -0
  428. package/lib/widgets/WidgetFactory.d.ts +4 -0
  429. package/lib/widgets/WidgetFactory.js +40 -0
  430. package/lib/widgets/WidgetScoper.d.ts +9 -0
  431. package/lib/widgets/WidgetScoper.js +49 -0
  432. package/lib/widgets/WidgetScopesViewComponent.d.ts +26 -0
  433. package/lib/widgets/WidgetScopesViewComponent.js +36 -0
  434. package/lib/widgets/charts/Chart.d.ts +57 -0
  435. package/lib/widgets/charts/Chart.js +83 -0
  436. package/lib/widgets/charts/ChartViewComponent.d.ts +72 -0
  437. package/lib/widgets/charts/ChartViewComponent.js +120 -0
  438. package/lib/widgets/charts/ChartWidget.d.ts +87 -0
  439. package/lib/widgets/charts/ChartWidget.js +248 -0
  440. package/lib/widgets/charts/calendar/CalendarChart.d.ts +39 -0
  441. package/lib/widgets/charts/calendar/CalendarChart.js +175 -0
  442. package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.d.ts +35 -0
  443. package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +142 -0
  444. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +56 -0
  445. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +263 -0
  446. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +21 -0
  447. package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +183 -0
  448. package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.d.ts +28 -0
  449. package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +105 -0
  450. package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.d.ts +31 -0
  451. package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.js +87 -0
  452. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +20 -0
  453. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.js +38 -0
  454. package/lib/widgets/charts/layered/LayeredChart.d.ts +28 -0
  455. package/lib/widgets/charts/layered/LayeredChart.js +324 -0
  456. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +113 -0
  457. package/lib/widgets/charts/layered/LayeredChartCompiler.js +1092 -0
  458. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +76 -0
  459. package/lib/widgets/charts/layered/LayeredChartDesign.js +2 -0
  460. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +80 -0
  461. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +317 -0
  462. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +72 -0
  463. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +329 -0
  464. package/lib/widgets/charts/layered/LayeredChartSvgFileSaver.d.ts +5 -0
  465. package/lib/widgets/charts/layered/LayeredChartSvgFileSaver.js +138 -0
  466. package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +1 -0
  467. package/lib/widgets/charts/layered/LayeredChartUtils.js +25 -0
  468. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +44 -0
  469. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +406 -0
  470. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +115 -0
  471. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +235 -0
  472. package/lib/widgets/charts/pivot/PivotChart.d.ts +36 -0
  473. package/lib/widgets/charts/pivot/PivotChart.js +343 -0
  474. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +88 -0
  475. package/lib/widgets/charts/pivot/PivotChartDesign.js +2 -0
  476. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +37 -0
  477. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +159 -0
  478. package/lib/widgets/charts/pivot/PivotChartLayout.d.ts +73 -0
  479. package/lib/widgets/charts/pivot/PivotChartLayout.js +2 -0
  480. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +37 -0
  481. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +676 -0
  482. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +74 -0
  483. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +333 -0
  484. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +31 -0
  485. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +263 -0
  486. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +12 -0
  487. package/lib/widgets/charts/pivot/PivotChartUtils.js +195 -0
  488. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +84 -0
  489. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +205 -0
  490. package/lib/widgets/charts/pivot/README.md +30 -0
  491. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +96 -0
  492. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +216 -0
  493. package/lib/widgets/charts/table/OrderingsComponent.d.ts +15 -0
  494. package/lib/widgets/charts/table/OrderingsComponent.js +66 -0
  495. package/lib/widgets/charts/table/TableChart.d.ts +57 -0
  496. package/lib/widgets/charts/table/TableChart.js +310 -0
  497. package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +48 -0
  498. package/lib/widgets/charts/table/TableChartDesignerComponent.js +291 -0
  499. package/lib/widgets/charts/table/TableChartViewComponent.d.ts +28 -0
  500. package/lib/widgets/charts/table/TableChartViewComponent.js +206 -0
  501. package/lib/widgets/text/ExprInsertModalComponent.d.ts +35 -0
  502. package/lib/widgets/text/ExprInsertModalComponent.js +51 -0
  503. package/lib/widgets/text/ExprItemEditorComponent.d.ts +34 -0
  504. package/lib/widgets/text/ExprItemEditorComponent.js +92 -0
  505. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +33 -0
  506. package/lib/widgets/text/ExprUpdateModalComponent.js +47 -0
  507. package/lib/widgets/text/README.md +2 -0
  508. package/lib/widgets/text/TextComponent.d.ts +48 -0
  509. package/lib/widgets/text/TextComponent.js +109 -0
  510. package/lib/widgets/text/TextWidget.d.ts +29 -0
  511. package/lib/widgets/text/TextWidget.js +243 -0
  512. package/lib/widgets/text/TextWidgetComponent.d.ts +33 -0
  513. package/lib/widgets/text/TextWidgetComponent.js +88 -0
  514. package/lib/widgets/text/TextWidgetDesign.d.ts +6 -0
  515. package/lib/widgets/text/TextWidgetDesign.js +2 -0
  516. package/mocha.html +10 -0
  517. package/package.json +113 -0
  518. package/server.js +10 -0
  519. package/src/CheckboxComponent.ts +33 -0
  520. package/src/ColorComponent.ts +117 -0
  521. package/src/ColorSchemeFactory.ts +144 -0
  522. package/src/CsvBuilder.ts +65 -0
  523. package/src/DateRangeComponent.ts +279 -0
  524. package/src/FiltersDesignerComponent.ts +55 -0
  525. package/src/ImplicitFilterBuilder.ts +135 -0
  526. package/src/JsonQLFilter.ts +8 -0
  527. package/src/LocaleContextInjector.tsx +17 -0
  528. package/src/MWaterAddRelatedFormComponent.ts +213 -0
  529. package/src/MWaterAddRelatedIndicatorComponent.ts +205 -0
  530. package/src/MWaterAssetSystemsListComponent.tsx +114 -0
  531. package/src/MWaterCompleteTableSelectComponent.tsx +984 -0
  532. package/src/MWaterContextComponent.ts +144 -0
  533. package/src/MWaterCustomTablesetListComponent.tsx +141 -0
  534. package/src/MWaterGlobalFiltersComponent.ts +117 -0
  535. package/src/MWaterLoaderComponent.ts +118 -0
  536. package/src/MWaterMetricsTableListComponent.tsx +120 -0
  537. package/src/MWaterResponsesFilterComponent.ts +194 -0
  538. package/src/MWaterTableSelectComponent.ts +316 -0
  539. package/src/MenuItemComponent.ts +2 -0
  540. package/src/PopoverComponent.ts +59 -0
  541. package/src/RadioButtonComponent.ts +34 -0
  542. package/src/TableSelectComponent.ts +60 -0
  543. package/src/UIComponents.ts +289 -0
  544. package/src/UndoStack.ts +59 -0
  545. package/src/VerticalLayoutComponent.ts +108 -0
  546. package/src/WidgetScope.ts +17 -0
  547. package/src/axes/Axis.ts +89 -0
  548. package/src/axes/AxisBuilder.ts +1325 -0
  549. package/src/axes/AxisColorEditorComponent.ts +210 -0
  550. package/src/axes/AxisComponent.ts +449 -0
  551. package/src/axes/BinsComponent.tsx +169 -0
  552. package/src/axes/CategoryMapComponent.ts +278 -0
  553. package/src/axes/ColorPaletteCollectionComponent.ts +163 -0
  554. package/src/axes/RangesComponent.ts +234 -0
  555. package/src/color-mixer.d.ts +1 -0
  556. package/src/componenttest.ts +64 -0
  557. package/src/compressJson.ts +13 -0
  558. package/src/dashboards/DashboardComponent.ts +468 -0
  559. package/src/dashboards/DashboardDataSource.ts +15 -0
  560. package/src/dashboards/DashboardDesign.ts +57 -0
  561. package/src/dashboards/DashboardUpgrader.ts +103 -0
  562. package/src/dashboards/DashboardUtils.ts +82 -0
  563. package/src/dashboards/DashboardViewComponent.ts +304 -0
  564. package/src/dashboards/DirectDashboardDataSource.ts +69 -0
  565. package/src/dashboards/LayoutOptionsComponent.tsx +227 -0
  566. package/src/dashboards/README.md +13 -0
  567. package/src/dashboards/ServerDashboardDataSource.ts +520 -0
  568. package/src/dashboards/SettingsModalComponent.ts +169 -0
  569. package/src/dashboards/WidgetComponent.tsx +131 -0
  570. package/src/dashboards/layoutOptions.ts +40 -0
  571. package/src/datagrids/DatagridComponent.ts +430 -0
  572. package/src/datagrids/DatagridDataSource.ts +21 -0
  573. package/src/datagrids/DatagridDesign.ts +94 -0
  574. package/src/datagrids/DatagridDesignerComponent.tsx +585 -0
  575. package/src/datagrids/DatagridQueryBuilder.ts +722 -0
  576. package/src/datagrids/DatagridUtils.ts +74 -0
  577. package/src/datagrids/DatagridViewComponent.ts +460 -0
  578. package/src/datagrids/DirectDatagridDataSource.ts +57 -0
  579. package/src/datagrids/EditExprCellComponent.tsx +305 -0
  580. package/src/datagrids/ExprCellComponent.ts +104 -0
  581. package/src/datagrids/FindReplaceModalComponent.ts +354 -0
  582. package/src/datagrids/LabeledExprGenerator.ts +302 -0
  583. package/src/datagrids/OrderBysDesignerComponent.tsx +128 -0
  584. package/src/datagrids/README.md +3 -0
  585. package/src/datagrids/ServerDatagridDataSource.ts +119 -0
  586. package/src/datagrids/react-linkify.d.ts +1 -0
  587. package/src/demo.ts +4148 -0
  588. package/src/demoBlocks.ts +130 -0
  589. package/src/globals.d.ts +2 -0
  590. package/src/index.css +550 -0
  591. package/src/index.ts +112 -0
  592. package/src/injectTableAlias.ts +31 -0
  593. package/src/languages.ts +931 -0
  594. package/src/layout-styles.css +263 -0
  595. package/src/layouts/DecoratedBlockComponent.ts +167 -0
  596. package/src/layouts/DragSourceComponent.ts +35 -0
  597. package/src/layouts/LayoutManager.ts +86 -0
  598. package/src/layouts/blocks/BlocksDisplayComponent.ts +461 -0
  599. package/src/layouts/blocks/BlocksLayoutManager.ts +78 -0
  600. package/src/layouts/blocks/ClipboardPaletteItemComponent.ts +89 -0
  601. package/src/layouts/blocks/DraggableBlockComponent.ts +219 -0
  602. package/src/layouts/blocks/HorizontalBlockComponent.ts +288 -0
  603. package/src/layouts/blocks/PaletteItemComponent.ts +27 -0
  604. package/src/layouts/blocks/README.md +11 -0
  605. package/src/layouts/blocks/blockUtils.ts +207 -0
  606. package/src/layouts/decorated-block.css +100 -0
  607. package/src/layouts/grid/GridLayoutComponent.ts +67 -0
  608. package/src/layouts/grid/GridLayoutManager.ts +185 -0
  609. package/src/layouts/grid/LegoLayoutEngine.ts +142 -0
  610. package/src/layouts/grid/PaletteItemComponent.ts +28 -0
  611. package/src/layouts/grid/README.md +14 -0
  612. package/src/layouts/grid/WidgetContainerComponent.ts +420 -0
  613. package/src/mWaterLoader.ts +82 -0
  614. package/src/mapdemo.ts +127 -0
  615. package/src/maps/AddLayerComponent.ts +125 -0
  616. package/src/maps/AdminScopeAndDetailLevelComponent.ts +90 -0
  617. package/src/maps/BaseLayerDesignerComponent.ts +104 -0
  618. package/src/maps/BingLayer.ts +156 -0
  619. package/src/maps/BufferLayer.ts +927 -0
  620. package/src/maps/BufferLayerDesign.ts +48 -0
  621. package/src/maps/BufferLayerDesignerComponent.ts +311 -0
  622. package/src/maps/ChoroplethLayer.ts +1712 -0
  623. package/src/maps/ChoroplethLayerDesign.ts +73 -0
  624. package/src/maps/ChoroplethLayerDesigner.tsx +558 -0
  625. package/src/maps/ClusterLayer.ts +836 -0
  626. package/src/maps/ClusterLayerDesign.ts +29 -0
  627. package/src/maps/ClusterLayerDesignerComponent.ts +190 -0
  628. package/src/maps/DetailLevelSelectComponent.ts +119 -0
  629. package/src/maps/DirectMapDataSource.ts +386 -0
  630. package/src/maps/EditHoverOver.tsx +151 -0
  631. package/src/maps/EditPopupComponent.ts +121 -0
  632. package/src/maps/Grid Functions.sql +167 -0
  633. package/src/maps/GridLayer.ts +776 -0
  634. package/src/maps/GridLayerDesign.ts +53 -0
  635. package/src/maps/GridLayerDesigner.tsx +332 -0
  636. package/src/maps/HoverContent.tsx +96 -0
  637. package/src/maps/HtmlUrlLegend.tsx +44 -0
  638. package/src/maps/Layer.ts +338 -0
  639. package/src/maps/LayerFactory.ts +51 -0
  640. package/src/maps/LayerLegendComponent.ts +88 -0
  641. package/src/maps/LayerSwitcherComponent.tsx +91 -0
  642. package/src/maps/LeafletLoading.css +24 -0
  643. package/src/maps/LeafletLoading.ts +355 -0
  644. package/src/maps/LeafletMapComponent.tsx +587 -0
  645. package/src/maps/LegendComponent.tsx +101 -0
  646. package/src/maps/LegendGroup.ts +120 -0
  647. package/src/maps/MWaterServerLayer.ts +116 -0
  648. package/src/maps/MapBoundsCalculator.ts +88 -0
  649. package/src/maps/MapComponent.ts +312 -0
  650. package/src/maps/MapControlComponent.ts +46 -0
  651. package/src/maps/MapDataSource.ts +20 -0
  652. package/src/maps/MapDesign.ts +103 -0
  653. package/src/maps/MapDesignerComponent.ts +356 -0
  654. package/src/maps/MapFiltersDesignerComponent.ts +95 -0
  655. package/src/maps/MapLayerDataSource.ts +27 -0
  656. package/src/maps/MapLayerViewDesignerComponent.ts +243 -0
  657. package/src/maps/MapLayersDesignerComponent.ts +144 -0
  658. package/src/maps/MapUtils.ts +148 -0
  659. package/src/maps/MapViewComponent.tsx +62 -0
  660. package/src/maps/Maptiler-logo.png +0 -0
  661. package/src/maps/MarkerSymbolSelectComponent.ts +41 -0
  662. package/src/maps/MarkersLayer.ts +941 -0
  663. package/src/maps/MarkersLayerDesign.ts +56 -0
  664. package/src/maps/MarkersLayerDesignerComponent.ts +374 -0
  665. package/src/maps/PopupFilterJoinsEditComponent.ts +114 -0
  666. package/src/maps/PopupFilterJoinsUtils.ts +99 -0
  667. package/src/maps/RasterMapViewComponent.ts +382 -0
  668. package/src/maps/RegionSelectComponent.ts +80 -0
  669. package/src/maps/ScopeAndDetailLevelComponent.ts +82 -0
  670. package/src/maps/ServerMapDataSource.ts +399 -0
  671. package/src/maps/SwitchableTileUrlLayer.tsx +130 -0
  672. package/src/maps/SwitchableTileUrlLayerDesigner.tsx +60 -0
  673. package/src/maps/TileUrlLayer.tsx +142 -0
  674. package/src/maps/UtfGridLayer.ts +286 -0
  675. package/src/maps/VectorMapViewComponent.css +21 -0
  676. package/src/maps/VectorMapViewComponent.tsx +743 -0
  677. package/src/maps/ZoomLevelsComponent.ts +72 -0
  678. package/src/maps/mapSymbols.ts +162 -0
  679. package/src/maps/mapboxUtils.ts +61 -0
  680. package/src/maps/maps.ts +38 -0
  681. package/src/maps/marker-icon-2x.png +0 -0
  682. package/src/maps/marker-icon.png +0 -0
  683. package/src/maps/marker-shadow.png +0 -0
  684. package/src/maps/png.d.ts +1 -0
  685. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  686. package/src/maps/symbols/font-awesome/ban.png +0 -0
  687. package/src/maps/symbols/font-awesome/beer.png +0 -0
  688. package/src/maps/symbols/font-awesome/bell.png +0 -0
  689. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  690. package/src/maps/symbols/font-awesome/building.png +0 -0
  691. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  692. package/src/maps/symbols/font-awesome/bus.png +0 -0
  693. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  694. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  695. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  696. package/src/maps/symbols/font-awesome/check.png +0 -0
  697. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  698. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  699. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  700. package/src/maps/symbols/font-awesome/comment.png +0 -0
  701. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  702. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  703. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  704. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  705. package/src/maps/symbols/font-awesome/female.png +0 -0
  706. package/src/maps/symbols/font-awesome/file.png +0 -0
  707. package/src/maps/symbols/font-awesome/flag.png +0 -0
  708. package/src/maps/symbols/font-awesome/flask.png +0 -0
  709. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  710. package/src/maps/symbols/font-awesome/home.png +0 -0
  711. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  712. package/src/maps/symbols/font-awesome/male.png +0 -0
  713. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  714. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  715. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  716. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  717. package/src/maps/symbols/font-awesome/plus.png +0 -0
  718. package/src/maps/symbols/font-awesome/square.png +0 -0
  719. package/src/maps/symbols/font-awesome/star.png +0 -0
  720. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  721. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  722. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  723. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  724. package/src/maps/symbols/font-awesome/times.png +0 -0
  725. package/src/maps/symbols/font-awesome/tint.png +0 -0
  726. package/src/maps/symbols/font-awesome/tree.png +0 -0
  727. package/src/maps/symbols/font-awesome/university.png +0 -0
  728. package/src/maps/symbols/font-awesome/usd.png +0 -0
  729. package/src/maps/symbols/font-awesome/user.png +0 -0
  730. package/src/maps/symbols/font-awesome/users.png +0 -0
  731. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  732. package/src/maps/vectorMaps.tsx +410 -0
  733. package/src/memoizedDebounce.tsx +32 -0
  734. package/src/quickfilter/DateExprComponent.ts +284 -0
  735. package/src/quickfilter/IdArrayQuickfilterComponent.ts +58 -0
  736. package/src/quickfilter/Quickfilter.ts +29 -0
  737. package/src/quickfilter/QuickfilterCompiler.ts +167 -0
  738. package/src/quickfilter/QuickfilterUtils.ts +123 -0
  739. package/src/quickfilter/QuickfiltersComponent.ts +416 -0
  740. package/src/quickfilter/QuickfiltersDataSource.ts +15 -0
  741. package/src/quickfilter/QuickfiltersDesignComponent.tsx +257 -0
  742. package/src/quickfilter/README.md +8 -0
  743. package/src/quickfilter/TextLiteralComponent.ts +161 -0
  744. package/src/quickfilter/react-onclickout.d.ts +1 -0
  745. package/src/richtext/ExprItemsHtmlConverter.ts +144 -0
  746. package/src/richtext/FontColorPaletteItem.ts +172 -0
  747. package/src/richtext/FontSizePaletteItem.ts +110 -0
  748. package/src/richtext/ItemsHtmlConverter.ts +246 -0
  749. package/src/richtext/README.md +3 -0
  750. package/src/richtext/RichTextComponent.tsx +390 -0
  751. package/src/richtext/react-float-affixed.d.ts +1 -0
  752. package/src/update-object.d.ts +1 -0
  753. package/src/valueFormatter.ts +110 -0
  754. package/src/widgets/DirectWidgetDataSource.ts +67 -0
  755. package/src/widgets/DropdownWidgetComponent.ts +78 -0
  756. package/src/widgets/IFrameWidget.ts +36 -0
  757. package/src/widgets/IFrameWidgetComponent.ts +116 -0
  758. package/src/widgets/ImageUploaderComponent.tsx +143 -0
  759. package/src/widgets/ImageWidget.ts +147 -0
  760. package/src/widgets/ImageWidgetComponent.ts +546 -0
  761. package/src/widgets/ImagelistCarouselComponent.ts +109 -0
  762. package/src/widgets/MapWidget.ts +219 -0
  763. package/src/widgets/MarkdownWidget.ts +201 -0
  764. package/src/widgets/TOCWidget.ts +326 -0
  765. package/src/widgets/Widget.ts +83 -0
  766. package/src/widgets/WidgetDataSource.ts +23 -0
  767. package/src/widgets/WidgetFactory.ts +37 -0
  768. package/src/widgets/WidgetScoper.ts +51 -0
  769. package/src/widgets/WidgetScopesViewComponent.ts +54 -0
  770. package/src/widgets/charts/Chart.ts +140 -0
  771. package/src/widgets/charts/ChartViewComponent.ts +209 -0
  772. package/src/widgets/charts/ChartWidget.ts +345 -0
  773. package/src/widgets/charts/calendar/CalendarChart.ts +227 -0
  774. package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +187 -0
  775. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +320 -0
  776. package/src/widgets/charts/calendar/d3-tip.d.ts +1 -0
  777. package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +213 -0
  778. package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +121 -0
  779. package/src/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.ts +117 -0
  780. package/src/widgets/charts/imagemosaic/ImagePopupComponent.ts +51 -0
  781. package/src/widgets/charts/imagemosaic/react-lazy-load-image-component.d.ts +1 -0
  782. package/src/widgets/charts/layered/LayeredChart.ts +361 -0
  783. package/src/widgets/charts/layered/LayeredChartCompiler.ts +1299 -0
  784. package/src/widgets/charts/layered/LayeredChartDesign.ts +106 -0
  785. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +523 -0
  786. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +448 -0
  787. package/src/widgets/charts/layered/LayeredChartSvgFileSaver.ts +146 -0
  788. package/src/widgets/charts/layered/LayeredChartUtils.ts +24 -0
  789. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +486 -0
  790. package/src/widgets/charts/layered/save-svg-as-png.d.ts +1 -0
  791. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +338 -0
  792. package/src/widgets/charts/pivot/PivotChart.ts +377 -0
  793. package/src/widgets/charts/pivot/PivotChartDesign.ts +115 -0
  794. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +240 -0
  795. package/src/widgets/charts/pivot/PivotChartLayout.ts +99 -0
  796. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +779 -0
  797. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +504 -0
  798. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +273 -0
  799. package/src/widgets/charts/pivot/PivotChartUtils.ts +219 -0
  800. package/src/widgets/charts/pivot/PivotChartViewComponent.ts +276 -0
  801. package/src/widgets/charts/pivot/README.md +30 -0
  802. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +353 -0
  803. package/src/widgets/charts/table/OrderingsComponent.tsx +119 -0
  804. package/src/widgets/charts/table/TableChart.ts +420 -0
  805. package/src/widgets/charts/table/TableChartDesignerComponent.ts +441 -0
  806. package/src/widgets/charts/table/TableChartViewComponent.ts +327 -0
  807. package/src/widgets/text/ExprInsertModalComponent.ts +77 -0
  808. package/src/widgets/text/ExprItemEditorComponent.tsx +164 -0
  809. package/src/widgets/text/ExprUpdateModalComponent.ts +70 -0
  810. package/src/widgets/text/README.md +2 -0
  811. package/src/widgets/text/TextComponent.tsx +151 -0
  812. package/src/widgets/text/TextWidget.ts +265 -0
  813. package/src/widgets/text/TextWidgetComponent.ts +120 -0
  814. package/src/widgets/text/TextWidgetDesign.ts +7 -0
  815. package/stories/UpdateableComponent.js +29 -0
  816. package/stories/consoles.js +202 -0
  817. package/stories/dashboards.js +217 -0
  818. package/stories/datagridDesign.js +114 -0
  819. package/stories/datagrids.js +69 -0
  820. package/stories/dates.js +80 -0
  821. package/stories/exprcomponent.js +43 -0
  822. package/stories/index.js +18 -0
  823. package/stories/leaflet.js +59 -0
  824. package/stories/maps.js +24 -0
  825. package/stories/pivotChart.js +235 -0
  826. package/test/AxisBuilderTests.ts +931 -0
  827. package/test/ChartWidgetTests.ts +85 -0
  828. package/test/ColorSchemeFactoryTests.ts +29 -0
  829. package/test/CsvBuilderTests.ts +22 -0
  830. package/test/DashboardUpgraderTests.ts +170 -0
  831. package/test/ImplicitFilterBuilderTests.ts +161 -0
  832. package/test/LayeredChartCompilerTests.ts +1067 -0
  833. package/test/LayeredChartTests.ts +88 -0
  834. package/test/LegoLayoutEngineTests.ts +69 -0
  835. package/test/MWaterGlobalFiltersComponentTests.ts +130 -0
  836. package/test/MWaterResponsesFilterComponentTests.ts +164 -0
  837. package/test/QuickfilterCompilerTests.ts +167 -0
  838. package/test/TestComponent.ts +49 -0
  839. package/test/UndoStackTests.ts +73 -0
  840. package/test/WidgetScoperTests.ts +35 -0
  841. package/test/blockUtilsTests.ts +290 -0
  842. package/test/canonical-json.d.ts +1 -0
  843. package/test/dashboards/DashboardUtilsTests.ts +131 -0
  844. package/test/datagrids/DatagridQueryBuilderTests.ts +445 -0
  845. package/test/datagrids/DatagridUtilsTests.ts +54 -0
  846. package/test/datagrids/LabeledExprGeneratorTests.ts +121 -0
  847. package/test/fixtures.ts +263 -0
  848. package/test/index.ts +2 -0
  849. package/test/maps/MapUtilsTests.ts +168 -0
  850. package/test/maps/PopupFilterJoinsUtilsTests.ts +105 -0
  851. package/test/richtext/ItemsHtmlConverterTests.ts +41 -0
  852. package/test/test_index.ts +4 -0
  853. package/test/widgets/TextWidgetTests.ts +42 -0
  854. package/test/widgets/charts/pivot/PivotChartLayoutBuilderTests.ts +817 -0
  855. package/test/widgets/charts/pivot/PivotChartQueryBuilderTests.ts +359 -0
  856. package/test/widgets/charts/pivot/PivotChartTests.ts +64 -0
  857. package/test/widgets/charts/pivot/PivotChartUtilsTests.ts +184 -0
  858. package/test/widgets/charts/table/TableChartTests.ts +253 -0
  859. package/tsconfig.build.json +26 -0
  860. package/types/utm.d.ts +10 -0
@@ -0,0 +1,1202 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const lodash_1 = __importDefault(require("lodash"));
30
+ const uuid_1 = __importDefault(require("uuid"));
31
+ const expressions_1 = require("@mwater/expressions");
32
+ const expressions_2 = require("@mwater/expressions");
33
+ const expressions_3 = require("@mwater/expressions");
34
+ const expressions_4 = require("@mwater/expressions");
35
+ const d3Format = __importStar(require("d3-format"));
36
+ const moment_1 = __importDefault(require("moment"));
37
+ const react_1 = __importDefault(require("react"));
38
+ const R = react_1.default.createElement;
39
+ const immer_1 = __importDefault(require("immer"));
40
+ const valueFormatter_1 = require("../valueFormatter");
41
+ const xforms = [
42
+ { type: "bin", input: "number", output: "enum" },
43
+ { type: "ranges", input: "number", output: "enum" },
44
+ { type: "floor", input: "number", output: "enum" },
45
+ { type: "date", input: "datetime", output: "date" },
46
+ { type: "year", input: "date", output: "date" },
47
+ { type: "year", input: "datetime", output: "date" },
48
+ { type: "yearmonth", input: "date", output: "date" },
49
+ { type: "yearmonth", input: "datetime", output: "date" },
50
+ { type: "yearquarter", input: "date", output: "enum" },
51
+ { type: "yearquarter", input: "datetime", output: "enum" },
52
+ { type: "yearweek", input: "date", output: "enum" },
53
+ { type: "yearweek", input: "datetime", output: "enum" },
54
+ { type: "month", input: "date", output: "enum" },
55
+ { type: "month", input: "datetime", output: "enum" },
56
+ { type: "week", input: "date", output: "enum" },
57
+ { type: "week", input: "datetime", output: "enum" }
58
+ ];
59
+ // Small number to prevent width_bucket errors on auto binning with only one value
60
+ const epsilon = 0.000000001;
61
+ // Understands axes. Contains methods to clean/validate etc. an axis of any type.
62
+ class AxisBuilder {
63
+ schema;
64
+ exprUtils;
65
+ exprCleaner;
66
+ exprValidator;
67
+ // Options are: schema
68
+ constructor(options) {
69
+ this.schema = options.schema;
70
+ this.exprUtils = new expressions_3.ExprUtils(this.schema);
71
+ this.exprCleaner = new expressions_4.ExprCleaner(this.schema);
72
+ this.exprValidator = new expressions_2.ExprValidator(this.schema);
73
+ }
74
+ /** Clean an axis with respect to a specific table
75
+ options:
76
+ axis: axis to clean
77
+ table: table that axis is to be for
78
+ aggrNeed is "none", "optional" or "required"
79
+ types: optional list of types to require it to be one of
80
+ */
81
+ cleanAxis(options) {
82
+ let aggrStatuses = undefined;
83
+ let { axis } = options;
84
+ if (!axis) {
85
+ return null;
86
+ }
87
+ let { expr } = axis;
88
+ // Move aggr inside since aggr is deprecated at axis level DEPRECATED
89
+ if (axis.aggr && axis.expr) {
90
+ // @ts-ignore
91
+ expr = { type: "op", op: axis.aggr, table: axis.expr.table, exprs: axis.aggr !== "count" ? [axis.expr] : [] };
92
+ }
93
+ // Determine aggrStatuses that are possible
94
+ switch (options.aggrNeed) {
95
+ case "none":
96
+ aggrStatuses = ["literal", "individual"];
97
+ break;
98
+ case "optional":
99
+ aggrStatuses = ["literal", "individual", "aggregate"];
100
+ break;
101
+ case "required":
102
+ aggrStatuses = ["literal", "aggregate"];
103
+ break;
104
+ }
105
+ // Clean expression
106
+ expr = this.exprCleaner.cleanExpr(expr, { table: options.table || undefined, aggrStatuses });
107
+ if (!expr) {
108
+ return null;
109
+ }
110
+ const type = this.exprUtils.getExprType(expr);
111
+ // Validate xform type
112
+ let xform = null;
113
+ if (axis.xform) {
114
+ // Find valid xform
115
+ xform = lodash_1.default.find(xforms, function (xf) {
116
+ // xform type must match
117
+ if (xf.type !== axis.xform.type) {
118
+ return false;
119
+ }
120
+ // Input type must match
121
+ if (xf.input !== type) {
122
+ return false;
123
+ }
124
+ // Output type must match
125
+ if (options.types && !options.types.includes(xf.output)) {
126
+ return false;
127
+ }
128
+ return true;
129
+ });
130
+ }
131
+ // If no xform and using an xform would allow satisfying output types, pick first
132
+ if (!xform && options.types && type && !options.types.includes(type)) {
133
+ xform = lodash_1.default.find(xforms, (xf) => xf.input === type && options.types.includes(xf.output));
134
+ if (!xform) {
135
+ // Unredeemable if no xform possible and cannot use count to get number
136
+ if (options.aggrNeed === "none") {
137
+ return null;
138
+ }
139
+ if (!options.types.includes("number") || type !== "id") {
140
+ return null;
141
+ }
142
+ }
143
+ }
144
+ axis = (0, immer_1.default)(axis, (draft) => {
145
+ draft.expr = expr;
146
+ if (axis.aggr) {
147
+ delete draft.aggr;
148
+ }
149
+ if (!xform && axis.xform) {
150
+ delete draft.xform;
151
+ }
152
+ else if (xform && (!axis.xform || axis.xform.type !== xform.type)) {
153
+ draft.xform = { type: xform.type };
154
+ }
155
+ if (draft.xform && draft.xform.type === "bin") {
156
+ // Add number of bins
157
+ if (!draft.xform.numBins) {
158
+ draft.xform.numBins = 5;
159
+ }
160
+ }
161
+ if (draft.xform && draft.xform.type === "ranges") {
162
+ // Add ranges
163
+ if (!draft.xform.ranges) {
164
+ draft.xform.ranges = [{ id: (0, uuid_1.default)(), minOpen: false, maxOpen: true }];
165
+ }
166
+ }
167
+ });
168
+ return axis;
169
+ }
170
+ /** Checks whether an axis is valid
171
+ options:
172
+ axis: axis to validate
173
+ */
174
+ validateAxis(options) {
175
+ // Nothing is ok
176
+ if (!options.axis) {
177
+ return null;
178
+ }
179
+ // Validate expression (allow all statuses since we don't know aggregation)
180
+ const error = this.exprValidator.validateExpr(options.axis.expr, {
181
+ aggrStatuses: ["individual", "literal", "aggregate"]
182
+ });
183
+ if (error) {
184
+ return error;
185
+ }
186
+ // xform validation
187
+ if (options.axis.xform && options.axis.xform.type === "bin") {
188
+ if (!options.axis.xform.numBins) {
189
+ return "Missing numBins";
190
+ }
191
+ if (options.axis.xform.min == null) {
192
+ return "Missing min";
193
+ }
194
+ if (options.axis.xform.max == null) {
195
+ return "Missing max";
196
+ }
197
+ if (options.axis.xform.max < options.axis.xform.min) {
198
+ return "Max < min";
199
+ }
200
+ }
201
+ // xform validation
202
+ if (options.axis.xform && options.axis.xform.type === "ranges") {
203
+ if (!options.axis.xform.ranges || !lodash_1.default.isArray(options.axis.xform.ranges)) {
204
+ return "Missing ranges";
205
+ }
206
+ for (let range of options.axis.xform.ranges) {
207
+ if (range.minValue != null && range.maxValue != null && range.minValue > range.maxValue) {
208
+ return "Max < min";
209
+ }
210
+ }
211
+ }
212
+ return null;
213
+ }
214
+ /**
215
+ * Compile an axis to JsonQL
216
+ */
217
+ compileAxis(options) {
218
+ if (!options.axis) {
219
+ return null;
220
+ }
221
+ // Legacy support of aggr
222
+ let { expr } = options.axis;
223
+ if (options.axis.aggr) {
224
+ expr = {
225
+ type: "op",
226
+ op: options.axis.aggr,
227
+ table: expr.table,
228
+ exprs: options.axis.aggr !== "count" ? [expr] : []
229
+ };
230
+ }
231
+ const exprCompiler = new expressions_1.ExprCompiler(this.schema);
232
+ let compiledExpr = exprCompiler.compileExpr({ expr, tableAlias: options.tableAlias });
233
+ // Bin
234
+ if (options.axis.xform) {
235
+ if (options.axis.xform.type === "bin") {
236
+ const min = options.axis.xform.min;
237
+ let max = options.axis.xform.max;
238
+ // Add epsilon to prevent width_bucket from crashing
239
+ if (max === min) {
240
+ max += epsilon;
241
+ }
242
+ if (max === min) {
243
+ // If was too big to add epsilon
244
+ max = min * 1.00001;
245
+ }
246
+ // Special case for excludeUpper as we need to include upper bound (e.g. 100 for percentages) in the lower bin. Do it by adding epsilon
247
+ if (options.axis.xform.excludeUpper) {
248
+ const thresholds = lodash_1.default.map(lodash_1.default.range(0, options.axis.xform.numBins), (bin) => min + ((max - min) * bin) / options.axis.xform.numBins);
249
+ thresholds.push(max + epsilon);
250
+ compiledExpr = {
251
+ type: "op",
252
+ op: "width_bucket",
253
+ exprs: [
254
+ { type: "op", op: "::decimal", exprs: [compiledExpr] },
255
+ { type: "literal", value: thresholds }
256
+ ]
257
+ };
258
+ }
259
+ else {
260
+ compiledExpr = {
261
+ type: "op",
262
+ op: "width_bucket",
263
+ exprs: [compiledExpr, min, max, options.axis.xform.numBins]
264
+ };
265
+ }
266
+ }
267
+ if (options.axis.xform.type === "date") {
268
+ compiledExpr = {
269
+ type: "op",
270
+ op: "substr",
271
+ exprs: [compiledExpr, 1, 10]
272
+ };
273
+ }
274
+ if (options.axis.xform.type === "year") {
275
+ compiledExpr = {
276
+ type: "op",
277
+ op: "rpad",
278
+ exprs: [{ type: "op", op: "substr", exprs: [compiledExpr, 1, 4] }, 10, "-01-01"]
279
+ };
280
+ }
281
+ if (options.axis.xform.type === "yearmonth") {
282
+ compiledExpr = {
283
+ type: "op",
284
+ op: "rpad",
285
+ exprs: [{ type: "op", op: "substr", exprs: [compiledExpr, 1, 7] }, 10, "-01"]
286
+ };
287
+ }
288
+ if (options.axis.xform.type === "month") {
289
+ compiledExpr = {
290
+ type: "op",
291
+ op: "substr",
292
+ exprs: [compiledExpr, 6, 2]
293
+ };
294
+ }
295
+ if (options.axis.xform.type === "week") {
296
+ compiledExpr = {
297
+ type: "op",
298
+ op: "to_char",
299
+ exprs: [{ type: "op", op: "::date", exprs: [compiledExpr] }, "IW"]
300
+ };
301
+ }
302
+ if (options.axis.xform.type === "yearquarter") {
303
+ compiledExpr = {
304
+ type: "op",
305
+ op: "to_char",
306
+ exprs: [{ type: "op", op: "::date", exprs: [compiledExpr] }, "YYYY-Q"]
307
+ };
308
+ }
309
+ if (options.axis.xform.type === "yearweek") {
310
+ compiledExpr = {
311
+ type: "op",
312
+ op: "to_char",
313
+ exprs: [{ type: "op", op: "::date", exprs: [compiledExpr] }, "IYYY-IW"]
314
+ };
315
+ }
316
+ // Ranges
317
+ if (options.axis.xform.type === "ranges") {
318
+ const cases = [];
319
+ for (let range of options.axis.xform.ranges) {
320
+ const whens = [];
321
+ if (range.minValue != null) {
322
+ if (range.minOpen) {
323
+ whens.push({ type: "op", op: ">", exprs: [compiledExpr, range.minValue] });
324
+ }
325
+ else {
326
+ whens.push({ type: "op", op: ">=", exprs: [compiledExpr, range.minValue] });
327
+ }
328
+ }
329
+ if (range.maxValue != null) {
330
+ if (range.maxOpen) {
331
+ whens.push({ type: "op", op: "<", exprs: [compiledExpr, range.maxValue] });
332
+ }
333
+ else {
334
+ whens.push({ type: "op", op: "<=", exprs: [compiledExpr, range.maxValue] });
335
+ }
336
+ }
337
+ if (whens.length > 1) {
338
+ cases.push({
339
+ when: {
340
+ type: "op",
341
+ op: "and",
342
+ exprs: whens
343
+ },
344
+ then: range.id
345
+ });
346
+ }
347
+ else if (whens.length === 1) {
348
+ cases.push({
349
+ when: whens[0],
350
+ then: range.id
351
+ });
352
+ }
353
+ }
354
+ if (cases.length > 0) {
355
+ compiledExpr = {
356
+ type: "case",
357
+ cases
358
+ };
359
+ }
360
+ else {
361
+ compiledExpr = null;
362
+ }
363
+ }
364
+ if (options.axis.xform.type === "floor") {
365
+ compiledExpr = {
366
+ type: "op",
367
+ op: "floor",
368
+ exprs: [compiledExpr]
369
+ };
370
+ }
371
+ }
372
+ return compiledExpr;
373
+ }
374
+ // Create query to get min and max for a nice binning. Returns one row with "min" and "max" fields
375
+ // To do so, split into numBins + 2 percentile sections and exclude first and last
376
+ // That will give a nice distribution when using width_bucket so that all are used
377
+ // select max(inner.val), min(inner.val) f
378
+ // from (select expression as val, ntile(numBins + 2) over (order by expression asc) as ntilenum
379
+ // from the_table where exprssion is not null)
380
+ // where inner.ntilenum > 1 and inner.ntilenum < numBins + 2
381
+ // Inspired by: http://dba.stackexchange.com/questions/17086/fast-general-method-to-calculate-percentiles
382
+ // expr is mwater expression on table
383
+ // filterExpr is optional filter on values to include
384
+ // Result can be null if no query could be computed
385
+ compileBinMinMax(expr, table, filterExpr, numBins) {
386
+ const exprCompiler = new expressions_1.ExprCompiler(this.schema);
387
+ const compiledExpr = exprCompiler.compileExpr({ expr, tableAlias: "binrange" });
388
+ if (!compiledExpr) {
389
+ return null;
390
+ }
391
+ // Create expression that selects the min or max
392
+ const minExpr = {
393
+ type: "op",
394
+ op: "min",
395
+ exprs: [{ type: "field", tableAlias: "inner", column: "val" }]
396
+ };
397
+ const maxExpr = {
398
+ type: "op",
399
+ op: "max",
400
+ exprs: [{ type: "field", tableAlias: "inner", column: "val" }]
401
+ };
402
+ // Only include not null values
403
+ let where = {
404
+ type: "op",
405
+ op: "is not null",
406
+ exprs: [compiledExpr]
407
+ };
408
+ // If filtering, compile and add to inner where
409
+ if (filterExpr) {
410
+ const compiledFilterExpr = exprCompiler.compileExpr({ expr: filterExpr, tableAlias: "binrange" });
411
+ if (compiledFilterExpr) {
412
+ where = { type: "op", op: "and", exprs: [where, compiledFilterExpr] };
413
+ }
414
+ }
415
+ const query = {
416
+ type: "query",
417
+ selects: [
418
+ { type: "select", expr: minExpr, alias: "min" },
419
+ { type: "select", expr: maxExpr, alias: "max" }
420
+ ],
421
+ from: {
422
+ type: "subquery",
423
+ query: {
424
+ type: "query",
425
+ selects: [
426
+ { type: "select", expr: compiledExpr, alias: "val" },
427
+ {
428
+ type: "select",
429
+ expr: {
430
+ type: "op",
431
+ op: "ntile",
432
+ exprs: [numBins + 2],
433
+ over: {
434
+ orderBy: [{ expr: compiledExpr, direction: "asc" }]
435
+ }
436
+ },
437
+ alias: "ntilenum"
438
+ }
439
+ ],
440
+ from: { type: "table", table, alias: "binrange" },
441
+ where
442
+ },
443
+ alias: "inner"
444
+ },
445
+ where: {
446
+ type: "op",
447
+ op: "between",
448
+ exprs: [{ type: "field", tableAlias: "inner", column: "ntilenum" }, 2, numBins + 1]
449
+ }
450
+ };
451
+ return query;
452
+ }
453
+ // Get underlying expression types that will give specified output expression types
454
+ // types: array of types
455
+ getExprTypes(types) {
456
+ if (!types) {
457
+ return null;
458
+ }
459
+ types = types.slice();
460
+ // Add xformed types
461
+ for (let xform of xforms) {
462
+ if (types.includes(xform.output)) {
463
+ types = lodash_1.default.union(types, [xform.input]);
464
+ }
465
+ }
466
+ return types;
467
+ }
468
+ // Gets the color for a value (if in colorMap)
469
+ getValueColor(axis, value) {
470
+ const item = lodash_1.default.find(axis.colorMap || [], (item) => item.value === value);
471
+ if (item) {
472
+ return item.color;
473
+ }
474
+ return null;
475
+ }
476
+ /** Get all categories for a given axis type given the known values
477
+ * Returns array of { value, label }
478
+ */
479
+ getCategories(axis, values, options = {}) {
480
+ let categories, current, end, format, label, max, min, value, year;
481
+ const noneCategory = { value: null, label: axis.nullLabel || "None" };
482
+ const hasNone = lodash_1.default.any(values || [], (v) => v == null);
483
+ // Handle ranges
484
+ if (axis.xform && axis.xform.type === "ranges") {
485
+ return lodash_1.default.map(axis.xform.ranges || [], (range) => {
486
+ let label = range.label || "";
487
+ if (!label) {
488
+ if (range.minValue != null) {
489
+ if (range.minOpen) {
490
+ label = `> ${range.minValue}`;
491
+ }
492
+ else {
493
+ label = `>= ${range.minValue}`;
494
+ }
495
+ }
496
+ if (range.maxValue != null) {
497
+ if (label) {
498
+ label += " and ";
499
+ }
500
+ if (range.maxOpen) {
501
+ label += `< ${range.maxValue}`;
502
+ }
503
+ else {
504
+ label += `<= ${range.maxValue}`;
505
+ }
506
+ }
507
+ }
508
+ return {
509
+ value: range.id,
510
+ label
511
+ };
512
+ }).concat([noneCategory]);
513
+ }
514
+ // Handle binning
515
+ if (axis.xform && axis.xform.type === "bin") {
516
+ ;
517
+ ({ min } = axis.xform);
518
+ ({ max } = axis.xform);
519
+ const { numBins } = axis.xform;
520
+ // If not ready, no categories
521
+ if (min == null || max == null || !numBins) {
522
+ return [];
523
+ }
524
+ // Special case of single value (min and max within epsilon or 0.01% of each other since epsilon might be too small to add to a big number)
525
+ if (max - min <= epsilon || Math.abs((max - min) / (max + min)) < 0.0001) {
526
+ return [
527
+ { value: 0, label: `< ${min}` },
528
+ { value: 1, label: `= ${min}` },
529
+ { value: axis.xform.numBins + 1, label: `> ${min}` },
530
+ noneCategory
531
+ ];
532
+ }
533
+ // Calculate precision
534
+ const precision = d3Format.precisionFixed((max - min) / numBins);
535
+ if (lodash_1.default.isNaN(precision)) {
536
+ throw new Error(`Min/max errors: ${min} ${max} ${numBins}`);
537
+ }
538
+ format = d3Format.format(",." + precision + "f");
539
+ categories = [];
540
+ if (!axis.xform.excludeLower) {
541
+ categories.push({ value: 0, label: `< ${format(min)}` });
542
+ }
543
+ for (let i = 1, end1 = numBins, asc = 1 <= end1; asc ? i <= end1 : i >= end1; asc ? i++ : i--) {
544
+ const start = ((i - 1) / numBins) * (max - min) + min;
545
+ end = (i / numBins) * (max - min) + min;
546
+ categories.push({ value: i, label: `${format(start)} - ${format(end)}` });
547
+ }
548
+ if (!axis.xform.excludeUpper) {
549
+ categories.push({ value: axis.xform.numBins + 1, label: `> ${format(max)}` });
550
+ }
551
+ categories.push(noneCategory);
552
+ return categories;
553
+ }
554
+ // Handle floor
555
+ if (axis.xform && axis.xform.type === "floor") {
556
+ // Get min and max
557
+ min = lodash_1.default.min(lodash_1.default.filter(values || [], (v) => v != null));
558
+ max = lodash_1.default.max(lodash_1.default.filter(values || [], (v) => v != null));
559
+ if (!lodash_1.default.isFinite(min) || !lodash_1.default.isFinite(max)) {
560
+ return [noneCategory];
561
+ }
562
+ // Floor and get range
563
+ if (max - min > 50) {
564
+ max = min + 50;
565
+ }
566
+ categories = [];
567
+ for (value of lodash_1.default.range(Math.floor(min), Math.floor(max) + 1)) {
568
+ categories.push({ value, label: "" + value });
569
+ }
570
+ if (hasNone) {
571
+ categories.push(noneCategory);
572
+ }
573
+ return categories;
574
+ }
575
+ if (axis.xform && axis.xform.type === "month") {
576
+ categories = [
577
+ { value: "01", label: "January" },
578
+ { value: "02", label: "February" },
579
+ { value: "03", label: "March" },
580
+ { value: "04", label: "April" },
581
+ { value: "05", label: "May" },
582
+ { value: "06", label: "June" },
583
+ { value: "07", label: "July" },
584
+ { value: "08", label: "August" },
585
+ { value: "09", label: "September" },
586
+ { value: "10", label: "October" },
587
+ { value: "11", label: "November" },
588
+ { value: "12", label: "December" }
589
+ ];
590
+ // Add none if needed
591
+ if (hasNone) {
592
+ categories.push(noneCategory);
593
+ }
594
+ // Filter out other values
595
+ if (options.onlyValuesPresent) {
596
+ categories = categories.filter(c => (values || []).includes(c.value));
597
+ }
598
+ return categories;
599
+ }
600
+ if (axis.xform && axis.xform.type === "week") {
601
+ categories = [];
602
+ for (let week = 1; week <= 53; week++) {
603
+ value = "" + week;
604
+ if (value.length === 1) {
605
+ value = "0" + value;
606
+ }
607
+ categories.push({ value, label: value });
608
+ }
609
+ // Add none if needed
610
+ if (hasNone) {
611
+ categories.push(noneCategory);
612
+ }
613
+ // Filter out other values
614
+ if (options.onlyValuesPresent) {
615
+ categories = categories.filter(c => (values || []).includes(c.value));
616
+ }
617
+ return categories;
618
+ }
619
+ if (axis.xform && axis.xform.type === "year") {
620
+ let asc1, end2;
621
+ values = lodash_1.default.compact(values || []);
622
+ if (values.length === 0) {
623
+ return [noneCategory];
624
+ }
625
+ if (options.onlyValuesPresent) {
626
+ // Sort and take only present
627
+ categories = lodash_1.default.sortBy(lodash_1.default.uniq(values), item => item).map(value => ({ value, label: value.substring(0, 4) }));
628
+ if (hasNone) {
629
+ categories.push(noneCategory);
630
+ }
631
+ return categories;
632
+ }
633
+ // Get min and max
634
+ min = lodash_1.default.min(lodash_1.default.map(values, (date) => parseInt(date.substr(0, 4))));
635
+ max = lodash_1.default.max(lodash_1.default.map(values, (date) => parseInt(date.substr(0, 4))));
636
+ categories = [];
637
+ for (year = min, end2 = max, asc1 = min <= end2; asc1 ? year <= end2 : year >= end2; asc1 ? year++ : year--) {
638
+ categories.push({ value: `${year}-01-01`, label: `${year}` });
639
+ if (categories.length >= 1000) {
640
+ break;
641
+ }
642
+ }
643
+ // Add none if needed
644
+ if (hasNone) {
645
+ categories.push(noneCategory);
646
+ }
647
+ return categories;
648
+ }
649
+ if (axis.xform && axis.xform.type === "yearmonth") {
650
+ values = lodash_1.default.compact(values || []);
651
+ if (values.length === 0) {
652
+ return [noneCategory];
653
+ }
654
+ if (options.onlyValuesPresent) {
655
+ // Sort and take only present
656
+ categories = lodash_1.default.sortBy(lodash_1.default.uniq(values), item => item).map(value => ({ value, label: (0, moment_1.default)(value, "YYYY-MM-DD").format("MMM YYYY") }));
657
+ if (hasNone) {
658
+ categories.push(noneCategory);
659
+ }
660
+ return categories;
661
+ }
662
+ // Get min and max
663
+ min = values.sort()[0];
664
+ max = values.sort().slice(-1)[0];
665
+ // Use moment to get range
666
+ current = (0, moment_1.default)(min, "YYYY-MM-DD");
667
+ end = (0, moment_1.default)(max, "YYYY-MM-DD");
668
+ categories = [];
669
+ while (!current.isAfter(end)) {
670
+ categories.push({ value: current.format("YYYY-MM-DD"), label: current.format("MMM YYYY") });
671
+ current.add(1, "months");
672
+ if (categories.length >= 1000) {
673
+ break;
674
+ }
675
+ }
676
+ // Add none if needed
677
+ if (hasNone) {
678
+ categories.push(noneCategory);
679
+ }
680
+ return categories;
681
+ }
682
+ if (axis.xform && axis.xform.type === "yearweek") {
683
+ values = lodash_1.default.compact(values || []);
684
+ if (values.length === 0) {
685
+ return [noneCategory];
686
+ }
687
+ if (options.onlyValuesPresent) {
688
+ // Sort and take only present
689
+ categories = lodash_1.default.sortBy(lodash_1.default.uniq(values), item => item).map(value => ({ value, label: value }));
690
+ if (hasNone) {
691
+ categories.push(noneCategory);
692
+ }
693
+ return categories;
694
+ }
695
+ // Get min and max
696
+ min = values.sort()[0];
697
+ max = values.sort().slice(-1)[0];
698
+ // Use moment to get range
699
+ current = (0, moment_1.default)(min, "GGGG-WW");
700
+ end = (0, moment_1.default)(max, "GGGG-WW");
701
+ categories = [];
702
+ while (!current.isAfter(end)) {
703
+ categories.push({ value: current.format("GGGG-WW"), label: current.format("GGGG-WW") });
704
+ current.add(1, "weeks");
705
+ if (categories.length >= 1000) {
706
+ break;
707
+ }
708
+ }
709
+ // Add none if needed
710
+ if (hasNone) {
711
+ categories.push(noneCategory);
712
+ }
713
+ return categories;
714
+ }
715
+ if (axis.xform && axis.xform.type === "yearquarter") {
716
+ values = lodash_1.default.compact(values || []);
717
+ if (values.length === 0) {
718
+ return [noneCategory];
719
+ }
720
+ if (options.onlyValuesPresent) {
721
+ // Sort and take only present
722
+ categories = lodash_1.default.sortBy(lodash_1.default.uniq(values), item => item).map(value => {
723
+ const year = value.substr(0, 4);
724
+ const quarter = value.substr(value.length - 1, 1);
725
+ if (quarter === "1") {
726
+ label = `${year} Jan-Mar`;
727
+ }
728
+ else if (quarter === "2") {
729
+ label = `${year} Apr-Jun`;
730
+ }
731
+ else if (quarter === "3") {
732
+ label = `${year} Jul-Sep`;
733
+ }
734
+ else if (quarter === "4") {
735
+ label = `${year} Oct-Dec`;
736
+ }
737
+ else {
738
+ label = "";
739
+ }
740
+ return { value, label };
741
+ });
742
+ if (hasNone) {
743
+ categories.push(noneCategory);
744
+ }
745
+ return categories;
746
+ }
747
+ // Get min and max
748
+ min = values.sort()[0];
749
+ max = values.sort().slice(-1)[0];
750
+ // Use moment to get range
751
+ current = (0, moment_1.default)(min, "YYYY-Q");
752
+ end = (0, moment_1.default)(max, "YYYY-Q");
753
+ categories = [];
754
+ while (!current.isAfter(end)) {
755
+ value = current.format("YYYY-Q");
756
+ const quarter = current.format("Q");
757
+ year = current.format("YYYY");
758
+ if (quarter === "1") {
759
+ label = `${year} Jan-Mar`;
760
+ }
761
+ else if (quarter === "2") {
762
+ label = `${year} Apr-Jun`;
763
+ }
764
+ else if (quarter === "3") {
765
+ label = `${year} Jul-Sep`;
766
+ }
767
+ else if (quarter === "4") {
768
+ label = `${year} Oct-Dec`;
769
+ }
770
+ else {
771
+ label = "";
772
+ }
773
+ categories.push({ value, label });
774
+ current.add(1, "quarters");
775
+ if (categories.length >= 1000) {
776
+ break;
777
+ }
778
+ }
779
+ // Add none if needed
780
+ if (hasNone) {
781
+ categories.push(noneCategory);
782
+ }
783
+ return categories;
784
+ }
785
+ switch (this.getAxisType(axis)) {
786
+ case "enum":
787
+ case "enumset":
788
+ // If enum, return enum values
789
+ // NOTE: Assumes enumset values are flattened out first
790
+ if (options.onlyValuesPresent) {
791
+ categories = [];
792
+ const flatValues = lodash_1.default.flatten(values || [], true);
793
+ for (const ev of this.exprUtils.getExprEnumValues(axis.expr)) {
794
+ if (flatValues.includes(ev.id)) {
795
+ categories.push({
796
+ value: ev.id,
797
+ label: expressions_3.ExprUtils.localizeString(ev.name, options.locale)
798
+ });
799
+ }
800
+ }
801
+ if (hasNone) {
802
+ categories.push(noneCategory);
803
+ }
804
+ return categories;
805
+ }
806
+ return lodash_1.default.map(this.exprUtils.getExprEnumValues(axis.expr), (ev) => ({
807
+ value: ev.id,
808
+ label: expressions_3.ExprUtils.localizeString(ev.name, options.locale)
809
+ })).concat([noneCategory]);
810
+ case "text":
811
+ // Return unique values
812
+ categories = lodash_1.default.map(lodash_1.default.compact(lodash_1.default.uniq(values || [])).sort(), (v) => ({
813
+ value: v,
814
+ label: v || "None"
815
+ }));
816
+ if (hasNone) {
817
+ categories.push(noneCategory);
818
+ }
819
+ return categories;
820
+ case "boolean":
821
+ // Return unique values
822
+ return [{ value: true, label: "True" }, { value: false, label: "False" }, noneCategory];
823
+ case "date":
824
+ values = lodash_1.default.compact(values || []);
825
+ if (values.length === 0) {
826
+ return [noneCategory];
827
+ }
828
+ if (options.onlyValuesPresent) {
829
+ // Sort and take only present
830
+ categories = lodash_1.default.sortBy(lodash_1.default.uniq(values), item => item).map(value => ({ value, label: (0, moment_1.default)(value, "YYYY-MM-DD").format("ll") }));
831
+ if (hasNone) {
832
+ categories.push(noneCategory);
833
+ }
834
+ return categories;
835
+ }
836
+ // Get min and max
837
+ min = values.sort()[0];
838
+ max = values.sort().slice(-1)[0];
839
+ // Use moment to get range
840
+ current = (0, moment_1.default)(min, "YYYY-MM-DD");
841
+ end = (0, moment_1.default)(max, "YYYY-MM-DD");
842
+ categories = [];
843
+ while (!current.isAfter(end)) {
844
+ categories.push({ value: current.format("YYYY-MM-DD"), label: current.format("ll") });
845
+ current.add(1, "days");
846
+ if (categories.length >= 1000) {
847
+ break;
848
+ }
849
+ }
850
+ if (hasNone) {
851
+ categories.push(noneCategory);
852
+ }
853
+ return categories;
854
+ }
855
+ return [];
856
+ }
857
+ // Get type of axis output
858
+ getAxisType(axis) {
859
+ if (!axis) {
860
+ return null;
861
+ }
862
+ // DEPRECATED
863
+ if (axis.aggr === "count") {
864
+ return "number";
865
+ }
866
+ const type = this.exprUtils.getExprType(axis.expr);
867
+ if (axis.xform) {
868
+ const xform = lodash_1.default.findWhere(xforms, { type: axis.xform.type, input: type });
869
+ return xform.output;
870
+ }
871
+ return type;
872
+ }
873
+ // Determines if axis is aggregate
874
+ isAxisAggr(axis) {
875
+ // Legacy support of axis.aggr
876
+ return axis != null && (axis.aggr || this.exprUtils.getExprAggrStatus(axis.expr) === "aggregate");
877
+ }
878
+ // Determines if axis supports cumulative values (number, date or year-quarter)
879
+ doesAxisSupportCumulative(axis) {
880
+ const axisType = this.getAxisType(axis);
881
+ return axisType == "date" || axisType == "number" || axis.xform?.type === "yearquarter";
882
+ }
883
+ // Converts a category to a string (uses label or override)
884
+ formatCategory(axis, category) {
885
+ const categoryLabel = axis.categoryLabels ? axis.categoryLabels[JSON.stringify(category.value)] : undefined;
886
+ if (categoryLabel) {
887
+ return categoryLabel;
888
+ }
889
+ else {
890
+ return category.label;
891
+ }
892
+ }
893
+ // Summarize axis as a string
894
+ summarizeAxis(axis, locale) {
895
+ if (!axis) {
896
+ return "None";
897
+ }
898
+ return this.exprUtils.summarizeExpr(axis.expr, locale);
899
+ }
900
+ // TODO add xform support
901
+ // Get a string (or React DOM actually) representation of an axis value
902
+ formatValue(axis, value, locale, legacyPercentFormat) {
903
+ if (value == null) {
904
+ return axis?.nullLabel || "None";
905
+ }
906
+ const type = this.getAxisType(axis);
907
+ // If has categories, use those
908
+ const categories = this.getCategories(axis, [value], { locale });
909
+ if (categories.length > 0) {
910
+ if (type === "enumset") {
911
+ // Parse if string
912
+ if (lodash_1.default.isString(value)) {
913
+ value = JSON.parse(value);
914
+ }
915
+ return lodash_1.default.map(value, (v) => {
916
+ const category = lodash_1.default.findWhere(categories, { value: v });
917
+ if (category) {
918
+ return this.formatCategory(axis, category);
919
+ }
920
+ else {
921
+ return "???";
922
+ }
923
+ }).join(", ");
924
+ }
925
+ else {
926
+ const category = lodash_1.default.findWhere(categories, { value });
927
+ if (category) {
928
+ return this.formatCategory(axis, category);
929
+ }
930
+ else {
931
+ return "???";
932
+ }
933
+ }
934
+ }
935
+ switch (type) {
936
+ case "text":
937
+ return value;
938
+ case "number":
939
+ var num = parseFloat(value);
940
+ return (0, valueFormatter_1.formatValue)(type, num, axis.format, locale, legacyPercentFormat);
941
+ case "geometry":
942
+ return (0, valueFormatter_1.formatValue)(type, value, axis.format, locale, legacyPercentFormat);
943
+ case "text[]":
944
+ // Parse if string
945
+ if (lodash_1.default.isString(value)) {
946
+ value = JSON.parse(value);
947
+ }
948
+ return R("div", null, lodash_1.default.map(value, (v, i) => R("div", { key: i }, v)));
949
+ case "date":
950
+ return (0, moment_1.default)(value, moment_1.default.ISO_8601).format("ll");
951
+ case "datetime":
952
+ return (0, moment_1.default)(value, moment_1.default.ISO_8601).format("lll");
953
+ }
954
+ return "" + value;
955
+ }
956
+ // Creates a filter (jsonql with {alias} for table name) based on a specific value
957
+ // of the axis. Used to filter by a specific point/bar.
958
+ createValueFilter(axis, value) {
959
+ if (value != null) {
960
+ return {
961
+ type: "op",
962
+ op: "=",
963
+ exprs: [this.compileAxis({ axis, tableAlias: "{alias}" }), { type: "literal", value }]
964
+ };
965
+ }
966
+ else {
967
+ return {
968
+ type: "op",
969
+ op: "is null",
970
+ exprs: [this.compileAxis({ axis, tableAlias: "{alias}" })]
971
+ };
972
+ }
973
+ }
974
+ // Creates a filter expression (mwater-expression) based on a specific value
975
+ // of the axis. Used to filter by a specific point/bar.
976
+ createValueFilterExpr(axis, value) {
977
+ const axisExpr = this.convertAxisToExpr(axis);
978
+ const axisExprType = this.exprUtils.getExprType(axisExpr);
979
+ if (value != null) {
980
+ return {
981
+ table: axis.expr.table,
982
+ type: "op",
983
+ op: "=",
984
+ exprs: [axisExpr, { type: "literal", valueType: axisExprType, value }]
985
+ };
986
+ }
987
+ else {
988
+ return {
989
+ table: axis.expr.table,
990
+ type: "op",
991
+ op: "is null",
992
+ exprs: [axisExpr]
993
+ };
994
+ }
995
+ }
996
+ isCategorical(axis) {
997
+ let type;
998
+ const nonCategoricalTypes = ["bin", "ranges", "date", "yearmonth", "floor"];
999
+ if (axis.xform) {
1000
+ ;
1001
+ ({ type } = axis.xform);
1002
+ }
1003
+ else {
1004
+ type = this.exprUtils.getExprType(axis.expr);
1005
+ }
1006
+ return nonCategoricalTypes.indexOf(type) === -1;
1007
+ }
1008
+ // Converts an axis to an expression (mwater-expression)
1009
+ convertAxisToExpr(axis) {
1010
+ let { expr } = axis;
1011
+ const { table } = expr;
1012
+ // Bin
1013
+ if (axis.xform) {
1014
+ const { xform } = axis;
1015
+ if (xform.type === "bin") {
1016
+ const { min } = xform;
1017
+ let { max } = xform;
1018
+ // Add epsilon to prevent width_bucket from crashing
1019
+ if (max === min) {
1020
+ max += epsilon;
1021
+ }
1022
+ if (max === min) {
1023
+ // If was too big to add epsilon
1024
+ max = min * 1.00001;
1025
+ }
1026
+ // if xform.excludeUpper
1027
+ // Create op least(greatest(floor((expr - min)/((max - min) / numBins)) - (-1), 0), numBins + 1)
1028
+ expr = { table, type: "op", op: "-", exprs: [expr, { type: "literal", valueType: "number", value: min }] };
1029
+ expr = {
1030
+ table,
1031
+ type: "op",
1032
+ op: "/",
1033
+ exprs: [expr, { type: "literal", valueType: "number", value: (max - min) / xform.numBins }]
1034
+ };
1035
+ expr = { table, type: "op", op: "floor", exprs: [expr] };
1036
+ expr = { table, type: "op", op: "+", exprs: [expr, { type: "literal", valueType: "number", value: 1 }] };
1037
+ expr = { table, type: "op", op: "greatest", exprs: [expr, { type: "literal", valueType: "number", value: 0 }] };
1038
+ expr = {
1039
+ table,
1040
+ type: "op",
1041
+ op: "least",
1042
+ exprs: [expr, { type: "literal", valueType: "number", value: xform.numBins + 1 }]
1043
+ };
1044
+ // Handle nulls specially
1045
+ expr = {
1046
+ table,
1047
+ type: "case",
1048
+ cases: [{ when: { table, type: "op", op: "is null", exprs: [axis.expr] }, then: null }],
1049
+ else: expr
1050
+ };
1051
+ // Special case for excludeUpper as we need to include upper bound (e.g. 100 for percentages) in the lower bin
1052
+ if (xform.excludeUpper) {
1053
+ expr.cases.push({
1054
+ when: {
1055
+ table,
1056
+ type: "op",
1057
+ op: "=",
1058
+ exprs: [axis.expr, { type: "literal", valueType: "number", value: max }]
1059
+ },
1060
+ then: { type: "literal", valueType: "number", value: xform.numBins }
1061
+ });
1062
+ }
1063
+ }
1064
+ if (xform.type === "date") {
1065
+ expr = {
1066
+ table,
1067
+ type: "op",
1068
+ op: "to date",
1069
+ exprs: [expr]
1070
+ };
1071
+ }
1072
+ if (xform.type === "year") {
1073
+ expr = {
1074
+ table,
1075
+ type: "op",
1076
+ op: "year",
1077
+ exprs: [expr]
1078
+ };
1079
+ }
1080
+ if (xform.type === "yearmonth") {
1081
+ expr = {
1082
+ table,
1083
+ type: "op",
1084
+ op: "yearmonth",
1085
+ exprs: [expr]
1086
+ };
1087
+ }
1088
+ if (xform.type === "month") {
1089
+ expr = {
1090
+ table,
1091
+ type: "op",
1092
+ op: "month",
1093
+ exprs: [expr]
1094
+ };
1095
+ }
1096
+ if (xform.type === "week") {
1097
+ expr = {
1098
+ table,
1099
+ type: "op",
1100
+ op: "weekofyear",
1101
+ exprs: [expr]
1102
+ };
1103
+ }
1104
+ if (xform.type === "yearquarter") {
1105
+ expr = {
1106
+ table,
1107
+ type: "op",
1108
+ op: "yearquarter",
1109
+ exprs: [expr]
1110
+ };
1111
+ }
1112
+ if (xform.type === "yearweek") {
1113
+ expr = {
1114
+ table,
1115
+ type: "op",
1116
+ op: "yearweek",
1117
+ exprs: [expr]
1118
+ };
1119
+ }
1120
+ // Ranges
1121
+ if (xform.type === "ranges") {
1122
+ const cases = [];
1123
+ for (let range of xform.ranges) {
1124
+ const whens = [];
1125
+ if (range.minValue != null) {
1126
+ if (range.minOpen) {
1127
+ whens.push({
1128
+ table,
1129
+ type: "op",
1130
+ op: ">",
1131
+ exprs: [expr, { type: "literal", valueType: "number", value: range.minValue }]
1132
+ });
1133
+ }
1134
+ else {
1135
+ whens.push({
1136
+ table,
1137
+ type: "op",
1138
+ op: ">=",
1139
+ exprs: [expr, { type: "literal", valueType: "number", value: range.minValue }]
1140
+ });
1141
+ }
1142
+ }
1143
+ if (range.maxValue != null) {
1144
+ if (range.maxOpen) {
1145
+ whens.push({
1146
+ table,
1147
+ type: "op",
1148
+ op: "<",
1149
+ exprs: [expr, { type: "literal", valueType: "number", value: range.maxValue }]
1150
+ });
1151
+ }
1152
+ else {
1153
+ whens.push({
1154
+ table,
1155
+ type: "op",
1156
+ op: "<=",
1157
+ exprs: [expr, { type: "literal", valueType: "number", value: range.maxValue }]
1158
+ });
1159
+ }
1160
+ }
1161
+ if (whens.length > 1) {
1162
+ cases.push({
1163
+ when: {
1164
+ table,
1165
+ type: "op",
1166
+ op: "and",
1167
+ exprs: whens
1168
+ },
1169
+ then: { type: "literal", valueType: "enum", value: range.id }
1170
+ });
1171
+ }
1172
+ else if (whens.length === 1) {
1173
+ cases.push({
1174
+ when: whens[0],
1175
+ then: { type: "literal", valueType: "enum", value: range.id }
1176
+ });
1177
+ }
1178
+ }
1179
+ if (cases.length > 0) {
1180
+ expr = {
1181
+ table,
1182
+ type: "case",
1183
+ cases
1184
+ };
1185
+ }
1186
+ else {
1187
+ expr = null;
1188
+ }
1189
+ }
1190
+ if (xform.type === "floor") {
1191
+ expr = {
1192
+ table,
1193
+ type: "op",
1194
+ op: "floor",
1195
+ exprs: [expr]
1196
+ };
1197
+ }
1198
+ }
1199
+ return expr;
1200
+ }
1201
+ }
1202
+ exports.default = AxisBuilder;