@mwater/visualization 5.5.0 → 5.6.1

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 (275) hide show
  1. package/lib/ColorComponent.js +2 -2
  2. package/lib/MWaterContextComponent.d.ts +1 -1
  3. package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
  4. package/lib/MWaterGlobalFiltersComponent.js +11 -20
  5. package/lib/MWaterLoaderComponent.d.ts +4 -13
  6. package/lib/MWaterLoaderComponent.js +2 -11
  7. package/lib/TranslationsTabComponent.d.ts +34 -0
  8. package/lib/TranslationsTabComponent.js +256 -0
  9. package/lib/UndoStack.d.ts +2 -1
  10. package/lib/UndoStack.js +12 -6
  11. package/lib/dashboards/DashboardComponent.js +6 -5
  12. package/lib/dashboards/DashboardDesign.d.ts +1 -1
  13. package/lib/dashboards/ServerDashboardDataSource.d.ts +0 -1
  14. package/lib/dashboards/ServerDashboardDataSource.js +0 -25
  15. package/lib/dashboards/SettingsModalComponent.js +9 -233
  16. package/lib/datagrids/DatagridComponent.js +27 -2
  17. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
  18. package/lib/datagrids/DatagridDesignerComponent.js +108 -120
  19. package/lib/datagrids/DatagridViewComponent.js +33 -6
  20. package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
  21. package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
  22. package/lib/index.css +45 -2
  23. package/lib/index.d.ts +5 -5
  24. package/lib/index.js +2 -3
  25. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
  26. package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
  27. package/lib/maps/BufferLayer.d.ts +0 -13
  28. package/lib/maps/BufferLayer.js +24 -237
  29. package/lib/maps/BufferLayerDesign.d.ts +1 -1
  30. package/lib/maps/BufferLayerDesignerComponent.d.ts +1 -1
  31. package/lib/maps/BufferLayerDesignerComponent.js +2 -7
  32. package/lib/maps/ChoroplethLayer.d.ts +1 -16
  33. package/lib/maps/ChoroplethLayer.js +25 -358
  34. package/lib/maps/ChoroplethLayerDesign.d.ts +5 -2
  35. package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -32
  36. package/lib/maps/ChoroplethLayerDesigner.js +58 -89
  37. package/lib/maps/ClusterLayer.d.ts +0 -9
  38. package/lib/maps/ClusterLayer.js +0 -250
  39. package/lib/maps/DirectMapDataSource.js +1 -48
  40. package/lib/maps/EditHoverOver.d.ts +4 -3
  41. package/lib/maps/EditHoverOver.js +3 -3
  42. package/lib/maps/GridLayer.d.ts +0 -15
  43. package/lib/maps/GridLayer.js +0 -212
  44. package/lib/maps/HoverContent.js +1 -1
  45. package/lib/maps/Layer.d.ts +1 -26
  46. package/lib/maps/Layer.js +0 -13
  47. package/lib/maps/LeafletMapComponent.js +10 -19
  48. package/lib/maps/MapComponent.d.ts +19 -35
  49. package/lib/maps/MapComponent.js +135 -77
  50. package/lib/maps/MapControlComponent.d.ts +4 -5
  51. package/lib/maps/MapControlComponent.js +5 -12
  52. package/lib/maps/MapDesign.d.ts +8 -0
  53. package/lib/maps/MapDesignerComponent.d.ts +2 -0
  54. package/lib/maps/MapDesignerComponent.js +7 -2
  55. package/lib/maps/MapLayerDataSource.d.ts +0 -4
  56. package/lib/maps/MapLayerViewDesignerComponent.d.ts +3 -1
  57. package/lib/maps/MapLayerViewDesignerComponent.js +5 -1
  58. package/lib/maps/MapLayersDesignerComponent.d.ts +2 -0
  59. package/lib/maps/MapLayersDesignerComponent.js +2 -1
  60. package/lib/maps/MapTranslationsTab.d.ts +15 -0
  61. package/lib/maps/MapTranslationsTab.js +47 -0
  62. package/lib/maps/MapUtils.d.ts +11 -0
  63. package/lib/maps/MapUtils.js +57 -1
  64. package/lib/maps/MapViewComponent.d.ts +1 -1
  65. package/lib/maps/MapViewComponent.js +1 -8
  66. package/lib/maps/MarkersLayer.d.ts +1 -14
  67. package/lib/maps/MarkersLayer.js +89 -254
  68. package/lib/maps/MarkersLayerDesign.d.ts +5 -1
  69. package/lib/maps/MarkersLayerDesignerComponent.d.ts +32 -57
  70. package/lib/maps/MarkersLayerDesignerComponent.js +158 -134
  71. package/lib/maps/ServerMapDataSource.d.ts +0 -1
  72. package/lib/maps/ServerMapDataSource.js +0 -25
  73. package/lib/maps/SwitchableTileUrlLayer.d.ts +0 -2
  74. package/lib/maps/SwitchableTileUrlLayer.js +0 -9
  75. package/lib/maps/TileUrlLayer.d.ts +0 -1
  76. package/lib/maps/TileUrlLayer.js +0 -5
  77. package/lib/maps/VectorMapViewComponent.js +13 -10
  78. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  79. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  80. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  81. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  82. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  83. package/lib/maps/symbols/font-awesome/building.png +0 -0
  84. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  85. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  86. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  87. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  88. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  89. package/lib/maps/symbols/font-awesome/check.png +0 -0
  90. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  91. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  92. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  93. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  94. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  95. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  96. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  97. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  98. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  99. package/lib/maps/symbols/font-awesome/female.png +0 -0
  100. package/lib/maps/symbols/font-awesome/file.png +0 -0
  101. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  102. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  103. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  104. package/lib/maps/symbols/font-awesome/home.png +0 -0
  105. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  106. package/lib/maps/symbols/font-awesome/male.png +0 -0
  107. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  108. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  109. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  110. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  111. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  112. package/lib/maps/symbols/font-awesome/square.png +0 -0
  113. package/lib/maps/symbols/font-awesome/star.png +0 -0
  114. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  115. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  116. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  117. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  118. package/lib/maps/symbols/font-awesome/times.png +0 -0
  119. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  120. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  121. package/lib/maps/symbols/font-awesome/university.png +0 -0
  122. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  123. package/lib/maps/symbols/font-awesome/user.png +0 -0
  124. package/lib/maps/symbols/font-awesome/users.png +0 -0
  125. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  126. package/lib/maps/symbols/sdf-ize.sh +93 -0
  127. package/lib/maps/vectorMaps.d.ts +6 -6
  128. package/lib/maps/vectorMaps.js +33 -45
  129. package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +4 -2
  130. package/lib/mwater_table_selection/IndicatorsListComponent.js +103 -34
  131. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
  132. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
  133. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +26 -0
  134. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +237 -51
  135. package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +2 -2
  136. package/lib/mwater_table_selection/MWaterTableSelectComponent.js +9 -4
  137. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
  138. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
  139. package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
  140. package/lib/quickfilter/QuickfiltersComponent.js +53 -110
  141. package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
  142. package/lib/quickfilter/TextLiteralComponent.js +85 -82
  143. package/lib/widgets/MapWidget.js +6 -3
  144. package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
  145. package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
  146. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
  147. package/package.json +3 -4
  148. package/src/ColorComponent.tsx +2 -2
  149. package/src/MWaterContextComponent.tsx +1 -1
  150. package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
  151. package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +17 -18
  152. package/src/TranslationsTabComponent.tsx +429 -0
  153. package/src/UndoStack.ts +14 -6
  154. package/src/dashboards/DashboardComponent.tsx +6 -5
  155. package/src/dashboards/DashboardDesign.ts +1 -1
  156. package/src/dashboards/ServerDashboardDataSource.ts +0 -31
  157. package/src/dashboards/SettingsModalComponent.tsx +27 -383
  158. package/src/datagrids/DatagridComponent.tsx +36 -2
  159. package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
  160. package/src/datagrids/DatagridViewComponent.tsx +44 -7
  161. package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
  162. package/src/index.css +45 -2
  163. package/src/index.ts +5 -11
  164. package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
  165. package/src/maps/BufferLayer.ts +30 -263
  166. package/src/maps/BufferLayerDesign.ts +1 -1
  167. package/src/maps/BufferLayerDesignerComponent.tsx +2 -7
  168. package/src/maps/ChoroplethLayer.ts +30 -394
  169. package/src/maps/ChoroplethLayerDesign.ts +5 -2
  170. package/src/maps/ChoroplethLayerDesigner.tsx +169 -165
  171. package/src/maps/ClusterLayer.ts +0 -274
  172. package/src/maps/DirectMapDataSource.ts +2 -61
  173. package/src/maps/EditHoverOver.tsx +9 -5
  174. package/src/maps/GridLayer.ts +0 -224
  175. package/src/maps/HoverContent.tsx +1 -1
  176. package/src/maps/Layer.ts +1 -35
  177. package/src/maps/LeafletMapComponent.tsx +10 -19
  178. package/src/maps/MapComponent.tsx +448 -0
  179. package/src/maps/MapControlComponent.tsx +41 -0
  180. package/src/maps/MapDesign.ts +6 -0
  181. package/src/maps/MapDesignerComponent.tsx +18 -1
  182. package/src/maps/MapLayerDataSource.ts +0 -5
  183. package/src/maps/MapLayerViewDesignerComponent.ts +9 -2
  184. package/src/maps/MapLayersDesignerComponent.ts +4 -1
  185. package/src/maps/MapTranslationsTab.tsx +53 -0
  186. package/src/maps/MapUtils.ts +61 -1
  187. package/src/maps/MapViewComponent.tsx +2 -8
  188. package/src/maps/MarkersLayer.ts +101 -275
  189. package/src/maps/MarkersLayerDesign.ts +7 -1
  190. package/src/maps/MarkersLayerDesignerComponent.tsx +436 -0
  191. package/src/maps/ServerMapDataSource.ts +0 -31
  192. package/src/maps/SwitchableTileUrlLayer.tsx +0 -11
  193. package/src/maps/TileUrlLayer.tsx +0 -6
  194. package/src/maps/VectorMapViewComponent.tsx +15 -15
  195. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  196. package/src/maps/symbols/font-awesome/ban.png +0 -0
  197. package/src/maps/symbols/font-awesome/beer.png +0 -0
  198. package/src/maps/symbols/font-awesome/bell.png +0 -0
  199. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  200. package/src/maps/symbols/font-awesome/building.png +0 -0
  201. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  202. package/src/maps/symbols/font-awesome/bus.png +0 -0
  203. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  204. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  205. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  206. package/src/maps/symbols/font-awesome/check.png +0 -0
  207. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  208. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  209. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  210. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  211. package/src/maps/symbols/font-awesome/comment.png +0 -0
  212. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  213. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  214. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  215. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  216. package/src/maps/symbols/font-awesome/female.png +0 -0
  217. package/src/maps/symbols/font-awesome/file.png +0 -0
  218. package/src/maps/symbols/font-awesome/flag.png +0 -0
  219. package/src/maps/symbols/font-awesome/flask.png +0 -0
  220. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  221. package/src/maps/symbols/font-awesome/home.png +0 -0
  222. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  223. package/src/maps/symbols/font-awesome/male.png +0 -0
  224. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  225. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  226. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  227. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  228. package/src/maps/symbols/font-awesome/plus.png +0 -0
  229. package/src/maps/symbols/font-awesome/square.png +0 -0
  230. package/src/maps/symbols/font-awesome/star.png +0 -0
  231. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  232. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  233. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  234. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  235. package/src/maps/symbols/font-awesome/times.png +0 -0
  236. package/src/maps/symbols/font-awesome/tint.png +0 -0
  237. package/src/maps/symbols/font-awesome/tree.png +0 -0
  238. package/src/maps/symbols/font-awesome/university.png +0 -0
  239. package/src/maps/symbols/font-awesome/usd.png +0 -0
  240. package/src/maps/symbols/font-awesome/user.png +0 -0
  241. package/src/maps/symbols/font-awesome/users.png +0 -0
  242. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  243. package/src/maps/symbols/sdf-ize.sh +93 -0
  244. package/src/maps/vectorMaps.tsx +32 -53
  245. package/src/mwater_table_selection/IndicatorsListComponent.tsx +165 -37
  246. package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
  247. package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +373 -37
  248. package/src/mwater_table_selection/MWaterTableSelectComponent.tsx +12 -8
  249. package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
  250. package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
  251. package/src/quickfilter/TextLiteralComponent.tsx +197 -0
  252. package/src/widgets/MapWidget.tsx +11 -1
  253. package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
  254. package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
  255. package/test/UndoStackTests.ts +52 -1
  256. package/.storybook/config.js +0 -7
  257. package/.storybook/head.html +0 -3
  258. package/.storybook/webpack.config.js +0 -15
  259. package/src/maps/BingLayer.ts +0 -146
  260. package/src/maps/MapComponent.ts +0 -312
  261. package/src/maps/MapControlComponent.ts +0 -46
  262. package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
  263. package/src/maps/RasterMapViewComponent.ts +0 -345
  264. package/src/quickfilter/TextLiteralComponent.ts +0 -165
  265. package/stories/UpdateableComponent.js +0 -29
  266. package/stories/consoles.js +0 -202
  267. package/stories/dashboards.js +0 -217
  268. package/stories/datagridDesign.js +0 -114
  269. package/stories/datagrids.js +0 -69
  270. package/stories/dates.js +0 -80
  271. package/stories/exprcomponent.js +0 -43
  272. package/stories/index.js +0 -18
  273. package/stories/leaflet.js +0 -59
  274. package/stories/maps.js +0 -24
  275. package/stories/pivotChart.js +0 -235
@@ -32,7 +32,7 @@ export interface MapViewComponentProps {
32
32
  zoomLocked?: boolean;
33
33
  /** Locale to use. Overrides map design locale */
34
34
  locale?: string;
35
- /** Translate function to use for display. TODO: implement this */
35
+ /** Translate function to use for display */
36
36
  translate?: (input: string) => string;
37
37
  /** Increment to force refresh */
38
38
  refreshTrigger?: number;
@@ -6,14 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.MapViewComponent = MapViewComponent;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const VectorMapViewComponent_1 = require("./VectorMapViewComponent");
9
- const RasterMapViewComponent_1 = __importDefault(require("./RasterMapViewComponent"));
10
- const vectorMaps_1 = require("./vectorMaps");
11
9
  /** Component that displays just the map */
12
10
  function MapViewComponent(props) {
13
- if ((0, vectorMaps_1.areVectorMapsEnabled)()) {
14
- return react_1.default.createElement(VectorMapViewComponent_1.VectorMapViewComponent, { ...props });
15
- }
16
- else {
17
- return react_1.default.createElement(RasterMapViewComponent_1.default, { ...props });
18
- }
11
+ return react_1.default.createElement(VectorMapViewComponent_1.VectorMapViewComponent, { ...props });
19
12
  }
@@ -3,26 +3,13 @@ import Layer, { OnGridClickOptions, OnGridHoverOptions, VectorTileDef, LegendOpt
3
3
  import { Schema, DataSource } from "@mwater/expressions";
4
4
  import { OnGridClickResults, OnGridHoverResults } from "./maps";
5
5
  import { JsonQLFilter } from "../index";
6
- import { JsonQLQuery, JsonQLSelectQuery } from "@mwater/jsonql";
6
+ import { JsonQLSelectQuery } from "@mwater/jsonql";
7
7
  import { MarkersLayerDesign } from "./MarkersLayerDesign";
8
8
  export default class MarkersLayer extends Layer<MarkersLayerDesign> {
9
9
  /** Gets the type of layer definition */
10
10
  getLayerDefinitionType(): "VectorTile";
11
11
  getVectorTile(design: MarkersLayerDesign, sourceId: string, schema: Schema, filters: JsonQLFilter[], opacity: number): VectorTileDef;
12
12
  createJsonQL(design: MarkersLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLSelectQuery;
13
- getJsonQLCss(design: MarkersLayerDesign, schema: Schema, filters: JsonQLFilter[]): {
14
- layers: {
15
- id: string;
16
- jsonql: JsonQLQuery;
17
- }[];
18
- css: string;
19
- interactivity: {
20
- layer: string;
21
- fields: string[];
22
- };
23
- };
24
- createMapnikJsonQL(design: MarkersLayerDesign, schema: Schema, filters: JsonQLFilter[]): JsonQLQuery;
25
- createCss(design: MarkersLayerDesign): string;
26
13
  onGridHoverOver(ev: {
27
14
  data: any;
28
15
  event: any;
@@ -121,6 +121,8 @@ class MarkersLayer extends Layer_1.default {
121
121
  });
122
122
  }
123
123
  else {
124
+ // For some reason, scales down from 20 to 14. No idea why
125
+ const iconSize = (design.markerSize || 10) / 14;
124
126
  mapLayers.push({
125
127
  id: `${sourceId}:points`,
126
128
  type: "symbol",
@@ -129,11 +131,58 @@ class MarkersLayer extends Layer_1.default {
129
131
  layout: {
130
132
  "icon-image": design.symbol,
131
133
  "icon-allow-overlap": true,
132
- "icon-size": (design.markerSize || 10) / 14 // For some reason, scales down from 20 to 14. No idea why
134
+ "icon-size": iconSize,
133
135
  },
134
136
  paint: {
135
137
  "icon-color": color,
136
- "icon-opacity": opacity
138
+ "icon-opacity": opacity,
139
+ "icon-halo-color": (0, mapboxUtils_1.compileColorToMapbox)("#FFFFFFCC", design.axes.color?.excludedValues),
140
+ "icon-halo-width": iconSize * 5,
141
+ },
142
+ filter: addFilter(["==", ["geometry-type"], "Point"])
143
+ });
144
+ }
145
+ // Add labels layer if label axis is defined (points only)
146
+ if (design.axes.label) {
147
+ // Determine text-anchor and text-offset based on labelPosition
148
+ let textAnchor;
149
+ let textOffset;
150
+ switch (design.labelPosition) {
151
+ case "top":
152
+ textAnchor = "bottom";
153
+ textOffset = [0, -0.8];
154
+ break;
155
+ case "left":
156
+ textAnchor = "right";
157
+ textOffset = [-0.8, 0];
158
+ break;
159
+ case "right":
160
+ textAnchor = "left";
161
+ textOffset = [0.8, 0];
162
+ break;
163
+ case "bottom":
164
+ default:
165
+ textAnchor = "top";
166
+ textOffset = [0, 0.8];
167
+ break;
168
+ }
169
+ mapLayers.push({
170
+ id: `${sourceId}:labels`,
171
+ type: "symbol",
172
+ source: sourceId,
173
+ "source-layer": "main",
174
+ layout: {
175
+ "text-field": ["to-string", ["get", "label"]],
176
+ "text-size": 10,
177
+ "text-anchor": textAnchor,
178
+ "text-offset": textOffset,
179
+ "text-allow-overlap": false
180
+ },
181
+ paint: {
182
+ "text-color": (0, mapboxUtils_1.compileColorToMapbox)("#000000", design.axes.color?.excludedValues),
183
+ "text-halo-color": (0, mapboxUtils_1.compileColorToMapbox)("rgba(255, 255, 255, 0.8)", design.axes.color?.excludedValues),
184
+ "text-halo-width": 1.5,
185
+ "text-opacity": opacity
137
186
  },
138
187
  filter: addFilter(["==", ["geometry-type"], "Point"])
139
188
  });
@@ -175,6 +224,11 @@ class MarkersLayer extends Layer_1.default {
175
224
  const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "basequery" });
176
225
  basequery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
177
226
  }
227
+ // Add label select if label axis
228
+ if (design.axes.label) {
229
+ const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "basequery" });
230
+ basequery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
231
+ }
178
232
  // Create filters
179
233
  let whereClauses = [];
180
234
  // Add filters baked into layer
@@ -198,252 +252,6 @@ class MarkersLayer extends Layer_1.default {
198
252
  const markersQuery = createMarkersVectorQuery(basequery);
199
253
  return markersQuery;
200
254
  }
201
- // Gets the layer definition as JsonQL + CSS in format:
202
- // {
203
- // layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
204
- // css: carto css
205
- // interactivity: (optional) { layer: id of layer, fields: array of field names }
206
- // }
207
- // arguments:
208
- // design: design of layer
209
- // schema: schema to use
210
- // filters: array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to put in table alias
211
- getJsonQLCss(design, schema, filters) {
212
- // Create design
213
- const layerDef = {
214
- layers: [
215
- {
216
- id: "layer0",
217
- jsonql: this.createMapnikJsonQL(design, schema, filters)
218
- }
219
- ],
220
- css: this.createCss(design),
221
- interactivity: {
222
- layer: "layer0",
223
- fields: ["id"]
224
- }
225
- };
226
- return layerDef;
227
- }
228
- createMapnikJsonQL(design, schema, filters) {
229
- const axisBuilder = new AxisBuilder_1.default({ schema });
230
- const exprCompiler = new expressions_1.ExprCompiler(schema);
231
- // Compile geometry axis
232
- let geometryExpr = axisBuilder.compileAxis({ axis: design.axes.geometry, tableAlias: "innerquery" });
233
- // row_number() over (partition by round(ST_XMin(location)/!(pixel_width!*5)), round(ST_YMin(location)/(!pixel_height!*5))) AS r
234
- const cluster = {
235
- type: "select",
236
- expr: {
237
- type: "op",
238
- op: "row_number",
239
- exprs: [],
240
- over: {
241
- partitionBy: [
242
- {
243
- type: "op",
244
- op: "round",
245
- exprs: [
246
- {
247
- type: "op",
248
- op: "/",
249
- exprs: [
250
- { type: "op", op: "ST_XMin", exprs: [geometryExpr] },
251
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_width!" }, 5] }
252
- ]
253
- }
254
- ]
255
- },
256
- {
257
- type: "op",
258
- op: "round",
259
- exprs: [
260
- {
261
- type: "op",
262
- op: "/",
263
- exprs: [
264
- { type: "op", op: "ST_YMin", exprs: [geometryExpr] },
265
- { type: "op", op: "*", exprs: [{ type: "token", token: "!pixel_height!" }, 5] }
266
- ]
267
- }
268
- ]
269
- }
270
- ]
271
- }
272
- },
273
- alias: "r"
274
- };
275
- // Select _id, location and clustered row number
276
- const innerquery = {
277
- type: "query",
278
- selects: [
279
- {
280
- type: "select",
281
- expr: { type: "field", tableAlias: "innerquery", column: schema.getTable(design.table).primaryKey },
282
- alias: "id"
283
- }, // main primary key as id
284
- { type: "select", expr: geometryExpr, alias: "the_geom_webmercator" }, // geometry as the_geom_webmercator
285
- cluster
286
- ],
287
- from: exprCompiler.compileTable(design.table, "innerquery")
288
- };
289
- // Add color select if color axis
290
- if (design.axes.color) {
291
- const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "innerquery" });
292
- innerquery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
293
- }
294
- // Create filters. First limit to bounding box
295
- let whereClauses = [
296
- {
297
- type: "op",
298
- op: "&&",
299
- exprs: [geometryExpr, { type: "token", token: "!bbox!" }]
300
- }
301
- ];
302
- // Then add filters baked into layer
303
- if (design.filter) {
304
- whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }));
305
- }
306
- // Then add extra filters passed in, if relevant
307
- // Get relevant filters
308
- const relevantFilters = lodash_1.default.where(filters, { table: design.table });
309
- for (let filter of relevantFilters) {
310
- whereClauses.push((0, expressions_1.injectTableAlias)(filter.jsonql, "innerquery"));
311
- }
312
- whereClauses = lodash_1.default.compact(whereClauses);
313
- // Wrap if multiple
314
- if (whereClauses.length > 1) {
315
- innerquery.where = { type: "op", op: "and", exprs: whereClauses };
316
- }
317
- else {
318
- innerquery.where = whereClauses[0];
319
- }
320
- // Create outer query which takes where r <= 3 to limit # of points in a cluster
321
- const outerquery = {
322
- type: "query",
323
- selects: [
324
- {
325
- type: "select",
326
- expr: { type: "field", tableAlias: "innerquery", column: "id" },
327
- alias: "id"
328
- }, // innerquery._id as id
329
- {
330
- type: "select",
331
- expr: { type: "field", tableAlias: "innerquery", column: "the_geom_webmercator" },
332
- alias: "the_geom_webmercator"
333
- }, // innerquery.the_geom_webmercator as the_geom_webmercator
334
- {
335
- type: "select",
336
- expr: {
337
- type: "op",
338
- op: "ST_GeometryType",
339
- exprs: [{ type: "field", tableAlias: "innerquery", column: "the_geom_webmercator" }]
340
- },
341
- alias: "geometry_type"
342
- } // ST_GeometryType(innerquery.the_geom_webmercator) as geometry_type
343
- ],
344
- from: { type: "subquery", query: innerquery, alias: "innerquery" },
345
- where: { type: "op", op: "<=", exprs: [{ type: "field", tableAlias: "innerquery", column: "r" }, 3] }
346
- };
347
- // Add color select if color axis
348
- if (design.axes.color) {
349
- outerquery.selects.push({
350
- type: "select",
351
- expr: { type: "field", tableAlias: "innerquery", column: "color" },
352
- alias: "color"
353
- }); // innerquery.color as color
354
- }
355
- return outerquery;
356
- }
357
- // Creates CartoCSS
358
- createCss(design) {
359
- let stroke, symbol;
360
- let css = "";
361
- if (design.symbol) {
362
- symbol = `marker-file: url(${design.symbol});`;
363
- stroke = "marker-line-width: 60;";
364
- }
365
- else {
366
- symbol = "marker-type: ellipse;";
367
- stroke = "marker-line-width: 1;";
368
- }
369
- // Should only display markers when it is a point geometry
370
- css +=
371
- `\
372
- #layer0[geometry_type='ST_Point'] {
373
- marker-fill: ` +
374
- (design.color || "#666666") +
375
- `;
376
- marker-width: ` +
377
- (design.markerSize || 10) +
378
- `;
379
- marker-line-color: white;\
380
- ` +
381
- stroke +
382
- `\
383
- marker-line-opacity: 0.6;
384
- marker-placement: point;\
385
- ` +
386
- symbol +
387
- `\
388
- marker-allow-overlap: true;
389
- }
390
- #layer0 {
391
- line-color: ` +
392
- (design.color || "#666666") +
393
- `;
394
- line-width: ` +
395
- (design.lineWidth != null ? design.lineWidth : "3") +
396
- `;
397
- }
398
- #layer0[geometry_type='ST_Polygon'],#layer0[geometry_type='ST_MultiPolygon'] {
399
- polygon-fill: ` +
400
- (design.color || "#666666") +
401
- `;
402
- polygon-opacity: ${design.polygonFillOpacity ?? 0.25};
403
- }
404
- \
405
- `;
406
- // If color axes, add color conditions
407
- if (design.axes.color && design.axes.color.colorMap) {
408
- for (let item of design.axes.color.colorMap) {
409
- // If invisible
410
- if (lodash_1.default.includes(design.axes.color.excludedValues || [], item.value)) {
411
- css +=
412
- `\
413
- #layer0[color=` +
414
- JSON.stringify(item.value) +
415
- `] { line-opacity: 0; marker-line-opacity: 0; marker-fill-opacity: 0; polygon-opacity: 0; }\
416
- `;
417
- }
418
- else {
419
- css +=
420
- `\
421
- #layer0[color=` +
422
- JSON.stringify(item.value) +
423
- "] { line-color: " +
424
- item.color +
425
- ` }
426
- #layer0[color=` +
427
- JSON.stringify(item.value) +
428
- "][geometry_type='ST_Point'] { marker-fill: " +
429
- item.color +
430
- ` }
431
- #layer0[color=` +
432
- JSON.stringify(item.value) +
433
- "][geometry_type='ST_Polygon'],#layer0[color=" +
434
- JSON.stringify(item.value) +
435
- `][geometry_type='ST_MultiPolygon'] {
436
- polygon-fill: ` +
437
- item.color +
438
- `;\
439
- ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" : ""}\
440
- }\
441
- `;
442
- }
443
- }
444
- }
445
- return css;
446
- }
447
255
  // same as onGridClick but handles hover over
448
256
  onGridHoverOver(ev, hoverOptions) {
449
257
  if (ev.data && ev.data.id && hoverOptions.design.hoverOver && hoverOptions.design.hoverOver.items.length > 0) {
@@ -587,6 +395,13 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
587
395
  }
588
396
  }
589
397
  const axisBuilder = new AxisBuilder_1.default({ schema });
398
+ // Clean and translate axis
399
+ const axis = (0, MapUtils_1.translateAxis)(axisBuilder.cleanAxis({
400
+ axis: design.axes.color || null,
401
+ table: design.table,
402
+ types: ["enum", "text", "boolean", "date"],
403
+ aggrNeed: "none"
404
+ }), translate);
590
405
  return react_1.default.createElement(LayerLegendComponent_1.default, {
591
406
  schema,
592
407
  defaultColor: design.color,
@@ -594,12 +409,7 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
594
409
  markerSize: design.markerSize,
595
410
  name: translate(name),
596
411
  filters: lodash_1.default.compact(_filters),
597
- axis: axisBuilder.cleanAxis({
598
- axis: design.axes.color || null,
599
- table: design.table,
600
- types: ["enum", "text", "boolean", "date"],
601
- aggrNeed: "none"
602
- }),
412
+ axis,
603
413
  locale
604
414
  });
605
415
  }
@@ -661,7 +471,25 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
661
471
  types: ["enum", "text", "boolean", "date"],
662
472
  aggrNeed: "none"
663
473
  });
474
+ draft.axes.label = axisBuilder.cleanAxis({
475
+ axis: draft.axes.label ? (0, immer_1.original)(draft.axes.label) || null : null,
476
+ table: design.table,
477
+ types: ["text", "number"],
478
+ aggrNeed: "none"
479
+ }) || undefined;
664
480
  draft.filter = exprCleaner.cleanExpr(design.filter || null, { table: draft.table });
481
+ // Clean hover over expressions
482
+ if (design.table && design.hoverOver && design.hoverOver.items) {
483
+ for (let i = 0; i < design.hoverOver.items.length; i++) {
484
+ const item = design.hoverOver.items[i];
485
+ if (item.value) {
486
+ draft.hoverOver.items[i].value = exprCleaner.cleanExpr(item.value || null, {
487
+ table: design.table,
488
+ aggrStatuses: ["individual", "literal"]
489
+ });
490
+ }
491
+ }
492
+ }
665
493
  });
666
494
  return design;
667
495
  }
@@ -684,6 +512,11 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
684
512
  if (error) {
685
513
  return error;
686
514
  }
515
+ // Validate label
516
+ error = axisBuilder.validateAxis({ axis: design.axes.label || null });
517
+ if (error) {
518
+ return error;
519
+ }
687
520
  // Check that doesn't compile to null (persistent bug that haven't been able to track down)
688
521
  if (!axisBuilder.compileAxis({ axis: design.axes.geometry, tableAlias: "innerquery" })) {
689
522
  return "Null geometry axis";
@@ -698,6 +531,8 @@ ${design.polygonBorderColor ? "line-color: " + design.polygonBorderColor + ";" :
698
531
  /** Get strings to be translated */
699
532
  getTranslatableStrings(design, schema) {
700
533
  const strings = [];
534
+ // Add strings from axis category labels and null labels
535
+ strings.push(...(0, MapUtils_1.getTranslatableStringsFromAxis)(design.axes.color));
701
536
  // Add strings from hoverOver items
702
537
  if (design.hoverOver && design.hoverOver.items) {
703
538
  for (const item of design.hoverOver.items) {
@@ -13,7 +13,11 @@ export interface MarkersLayerDesign {
13
13
  geometry: Axis;
14
14
  /** Color axis (to split into series based on a color) */
15
15
  color?: Axis;
16
+ /** Label expression to display on/near markers (points only) */
17
+ label?: Axis;
16
18
  };
19
+ /** Position of label relative to marker. Default "bottom" */
20
+ labelPosition?: "top" | "bottom" | "left" | "right";
17
21
  /** Optional logical expression to filter by */
18
22
  filter?: Expr;
19
23
  /** Color of layer (e.g. #FF8800). Color axis overrides */
@@ -33,7 +37,7 @@ export interface MarkersLayerDesign {
33
37
  items: LayoutBlock;
34
38
  };
35
39
  /** Contains items to display when hovering over the layer */
36
- hoverOver: {
40
+ hoverOver?: {
37
41
  items: HoverOverItem[];
38
42
  };
39
43
  /** Customizable filtering for popup */
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
- import { DataSource, Schema } from "@mwater/expressions";
3
- import EditPopupComponent from "./EditPopupComponent";
4
- import MarkerSymbolSelectComponent from "./MarkerSymbolSelectComponent";
2
+ import { DataSource, Expr, Schema } from "@mwater/expressions";
5
3
  import { MarkersLayerDesign } from "./MarkersLayerDesign";
4
+ import { Axis } from "../axes/Axis";
5
+ import { JsonQLFilter } from "../JsonQLFilter";
6
6
  export interface MarkersLayerDesignerComponentProps {
7
7
  /** Schema to use */
8
8
  schema: Schema;
@@ -10,60 +10,35 @@ export interface MarkersLayerDesignerComponentProps {
10
10
  /** Design of the marker layer */
11
11
  design: MarkersLayerDesign;
12
12
  /** Called with new design */
13
- onDesignChange: any;
14
- filters?: any;
13
+ onDesignChange: (design: MarkersLayerDesign) => void;
14
+ filters?: JsonQLFilter[];
15
15
  }
16
+ /** Designer for a markers layer */
16
17
  export default class MarkersLayerDesignerComponent extends React.Component<MarkersLayerDesignerComponentProps> {
17
- update(updates: any): any;
18
- updateAxes(changes: any): any;
19
- handleTableChange: (table: any) => any;
20
- handleGeometryAxisChange: (axis: any) => any;
21
- handleColorAxisChange: (axis: any) => any;
22
- handleFilterChange: (expr: any) => any;
23
- handleColorChange: (color: any) => any;
24
- handlePolygonBorderColorChange: (polygonBorderColor: any) => any;
25
- handlePolygonFillOpacityChange: (polygonFillOpacity: any) => any;
26
- handleSymbolChange: (symbol: any) => any;
27
- handleNameChange: (e: any) => any;
28
- handleMarkerSizeChange: (markerSize: any) => any;
29
- handleLineWidthChange: (lineWidth: any) => any;
30
- renderTable(): React.DetailedReactHTMLElement<{
31
- className: string;
32
- }, HTMLElement>;
33
- renderGeometryAxis(): React.DetailedReactHTMLElement<{
34
- className: string;
35
- }, HTMLElement> | undefined;
36
- renderColor(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement> | undefined;
37
- renderSymbol(): React.CElement<import("./MarkerSymbolSelectComponent").MarkerSymbolSelectComponentProps, MarkerSymbolSelectComponent> | undefined;
38
- renderMarkerSize(): React.DetailedReactHTMLElement<{
39
- className: string;
40
- }, HTMLElement> | undefined;
41
- renderLineWidth(): React.DetailedReactHTMLElement<{
42
- className: string;
43
- }, HTMLElement> | undefined;
44
- renderPolygonBorderColor(): React.DetailedReactHTMLElement<{
45
- className: string;
46
- }, HTMLElement> | undefined;
47
- renderPolygonFillOpacity(): React.DetailedReactHTMLElement<{
48
- className: string;
49
- }, HTMLElement> | undefined;
50
- renderFilter(): React.DetailedReactHTMLElement<{
51
- className: string;
52
- }, HTMLElement> | null;
53
- renderPopup(): React.CElement<any, EditPopupComponent> | null;
54
- renderHoverOver(): React.FunctionComponentElement<{
55
- design: MarkersLayerDesign;
56
- onDesignChange: any;
57
- schema: Schema;
58
- dataSource: DataSource;
59
- table: string;
60
- idTable: string;
61
- defaultPopupFilterJoins: {
62
- [x: number]: {
63
- table: any;
64
- type: string;
65
- };
66
- };
67
- }> | null;
68
- render(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
18
+ handleTableChange: (table: string) => void;
19
+ handleGeometryAxisChange: (axis: Axis) => void;
20
+ handleColorAxisChange: (axis: Axis | null) => void;
21
+ handleFilterChange: (expr: Expr) => void;
22
+ handleColorChange: (color: string) => void;
23
+ handlePolygonBorderColorChange: (polygonBorderColor: string) => void;
24
+ handlePolygonFillOpacityChange: (polygonFillOpacity: number) => void;
25
+ handleSymbolChange: (symbol: string) => void;
26
+ handleMarkerSizeChange: (markerSize: number) => void;
27
+ handleLineWidthChange: (lineWidth: number) => void;
28
+ handleLabelAxisChange: (axis: Axis | null) => void;
29
+ handleLabelPositionChange: (labelPosition: "top" | "bottom" | "left" | "right") => void;
30
+ renderTable(): React.JSX.Element;
31
+ renderGeometryAxis(): React.JSX.Element | undefined;
32
+ renderColor(): React.JSX.Element | undefined;
33
+ renderSymbol(): React.JSX.Element | undefined;
34
+ renderMarkerSize(): React.JSX.Element | undefined;
35
+ renderLineWidth(): React.JSX.Element | undefined;
36
+ renderPolygonBorderColor(): React.JSX.Element | undefined;
37
+ renderPolygonFillOpacity(): React.JSX.Element | undefined;
38
+ renderFilter(): React.JSX.Element | null;
39
+ renderLabelAxis(): React.JSX.Element | undefined;
40
+ renderLabelPosition(): React.JSX.Element | undefined;
41
+ renderPopup(): React.JSX.Element | null;
42
+ renderHoverOver(): React.JSX.Element | null;
43
+ render(): React.JSX.Element;
69
44
  }