@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.
- package/lib/ColorComponent.js +2 -2
- package/lib/MWaterContextComponent.d.ts +1 -1
- package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
- package/lib/MWaterGlobalFiltersComponent.js +11 -20
- package/lib/MWaterLoaderComponent.d.ts +4 -13
- package/lib/MWaterLoaderComponent.js +2 -11
- package/lib/TranslationsTabComponent.d.ts +34 -0
- package/lib/TranslationsTabComponent.js +256 -0
- package/lib/UndoStack.d.ts +2 -1
- package/lib/UndoStack.js +12 -6
- package/lib/dashboards/DashboardComponent.js +6 -5
- package/lib/dashboards/DashboardDesign.d.ts +1 -1
- package/lib/dashboards/ServerDashboardDataSource.d.ts +0 -1
- package/lib/dashboards/ServerDashboardDataSource.js +0 -25
- package/lib/dashboards/SettingsModalComponent.js +9 -233
- package/lib/datagrids/DatagridComponent.js +27 -2
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
- package/lib/datagrids/DatagridDesignerComponent.js +108 -120
- package/lib/datagrids/DatagridViewComponent.js +33 -6
- package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
- package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
- package/lib/index.css +45 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +2 -3
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
- package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
- package/lib/maps/BufferLayer.d.ts +0 -13
- package/lib/maps/BufferLayer.js +24 -237
- package/lib/maps/BufferLayerDesign.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -7
- package/lib/maps/ChoroplethLayer.d.ts +1 -16
- package/lib/maps/ChoroplethLayer.js +25 -358
- package/lib/maps/ChoroplethLayerDesign.d.ts +5 -2
- package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -32
- package/lib/maps/ChoroplethLayerDesigner.js +58 -89
- package/lib/maps/ClusterLayer.d.ts +0 -9
- package/lib/maps/ClusterLayer.js +0 -250
- package/lib/maps/DirectMapDataSource.js +1 -48
- package/lib/maps/EditHoverOver.d.ts +4 -3
- package/lib/maps/EditHoverOver.js +3 -3
- package/lib/maps/GridLayer.d.ts +0 -15
- package/lib/maps/GridLayer.js +0 -212
- package/lib/maps/HoverContent.js +1 -1
- package/lib/maps/Layer.d.ts +1 -26
- package/lib/maps/Layer.js +0 -13
- package/lib/maps/LeafletMapComponent.js +10 -19
- package/lib/maps/MapComponent.d.ts +19 -35
- package/lib/maps/MapComponent.js +135 -77
- package/lib/maps/MapControlComponent.d.ts +4 -5
- package/lib/maps/MapControlComponent.js +5 -12
- package/lib/maps/MapDesign.d.ts +8 -0
- package/lib/maps/MapDesignerComponent.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.js +7 -2
- package/lib/maps/MapLayerDataSource.d.ts +0 -4
- package/lib/maps/MapLayerViewDesignerComponent.d.ts +3 -1
- package/lib/maps/MapLayerViewDesignerComponent.js +5 -1
- package/lib/maps/MapLayersDesignerComponent.d.ts +2 -0
- package/lib/maps/MapLayersDesignerComponent.js +2 -1
- package/lib/maps/MapTranslationsTab.d.ts +15 -0
- package/lib/maps/MapTranslationsTab.js +47 -0
- package/lib/maps/MapUtils.d.ts +11 -0
- package/lib/maps/MapUtils.js +57 -1
- package/lib/maps/MapViewComponent.d.ts +1 -1
- package/lib/maps/MapViewComponent.js +1 -8
- package/lib/maps/MarkersLayer.d.ts +1 -14
- package/lib/maps/MarkersLayer.js +89 -254
- package/lib/maps/MarkersLayerDesign.d.ts +5 -1
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +32 -57
- package/lib/maps/MarkersLayerDesignerComponent.js +158 -134
- package/lib/maps/ServerMapDataSource.d.ts +0 -1
- package/lib/maps/ServerMapDataSource.js +0 -25
- package/lib/maps/SwitchableTileUrlLayer.d.ts +0 -2
- package/lib/maps/SwitchableTileUrlLayer.js +0 -9
- package/lib/maps/TileUrlLayer.d.ts +0 -1
- package/lib/maps/TileUrlLayer.js +0 -5
- package/lib/maps/VectorMapViewComponent.js +13 -10
- package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
- package/lib/maps/symbols/font-awesome/ban.png +0 -0
- package/lib/maps/symbols/font-awesome/beer.png +0 -0
- package/lib/maps/symbols/font-awesome/bell.png +0 -0
- package/lib/maps/symbols/font-awesome/bolt.png +0 -0
- package/lib/maps/symbols/font-awesome/building.png +0 -0
- package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
- package/lib/maps/symbols/font-awesome/bus.png +0 -0
- package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
- package/lib/maps/symbols/font-awesome/certificate.png +0 -0
- package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/check.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/symbols/font-awesome/cloud.png +0 -0
- package/lib/maps/symbols/font-awesome/comment.png +0 -0
- package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/lib/maps/symbols/font-awesome/female.png +0 -0
- package/lib/maps/symbols/font-awesome/file.png +0 -0
- package/lib/maps/symbols/font-awesome/flag.png +0 -0
- package/lib/maps/symbols/font-awesome/flask.png +0 -0
- package/lib/maps/symbols/font-awesome/h-square.png +0 -0
- package/lib/maps/symbols/font-awesome/home.png +0 -0
- package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/male.png +0 -0
- package/lib/maps/symbols/font-awesome/medkit.png +0 -0
- package/lib/maps/symbols/font-awesome/mobile.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
- package/lib/maps/symbols/font-awesome/plus.png +0 -0
- package/lib/maps/symbols/font-awesome/square.png +0 -0
- package/lib/maps/symbols/font-awesome/star.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/lib/maps/symbols/font-awesome/ticket.png +0 -0
- package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
- package/lib/maps/symbols/font-awesome/times.png +0 -0
- package/lib/maps/symbols/font-awesome/tint.png +0 -0
- package/lib/maps/symbols/font-awesome/tree.png +0 -0
- package/lib/maps/symbols/font-awesome/university.png +0 -0
- package/lib/maps/symbols/font-awesome/usd.png +0 -0
- package/lib/maps/symbols/font-awesome/user.png +0 -0
- package/lib/maps/symbols/font-awesome/users.png +0 -0
- package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/lib/maps/symbols/sdf-ize.sh +93 -0
- package/lib/maps/vectorMaps.d.ts +6 -6
- package/lib/maps/vectorMaps.js +33 -45
- package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +4 -2
- package/lib/mwater_table_selection/IndicatorsListComponent.js +103 -34
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
- package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +26 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +237 -51
- package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +2 -2
- package/lib/mwater_table_selection/MWaterTableSelectComponent.js +9 -4
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
- package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
- package/lib/quickfilter/QuickfiltersComponent.js +53 -110
- package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
- package/lib/quickfilter/TextLiteralComponent.js +85 -82
- package/lib/widgets/MapWidget.js +6 -3
- package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
- package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
- package/package.json +3 -4
- package/src/ColorComponent.tsx +2 -2
- package/src/MWaterContextComponent.tsx +1 -1
- package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
- package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +17 -18
- package/src/TranslationsTabComponent.tsx +429 -0
- package/src/UndoStack.ts +14 -6
- package/src/dashboards/DashboardComponent.tsx +6 -5
- package/src/dashboards/DashboardDesign.ts +1 -1
- package/src/dashboards/ServerDashboardDataSource.ts +0 -31
- package/src/dashboards/SettingsModalComponent.tsx +27 -383
- package/src/datagrids/DatagridComponent.tsx +36 -2
- package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
- package/src/datagrids/DatagridViewComponent.tsx +44 -7
- package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
- package/src/index.css +45 -2
- package/src/index.ts +5 -11
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
- package/src/maps/BufferLayer.ts +30 -263
- package/src/maps/BufferLayerDesign.ts +1 -1
- package/src/maps/BufferLayerDesignerComponent.tsx +2 -7
- package/src/maps/ChoroplethLayer.ts +30 -394
- package/src/maps/ChoroplethLayerDesign.ts +5 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +169 -165
- package/src/maps/ClusterLayer.ts +0 -274
- package/src/maps/DirectMapDataSource.ts +2 -61
- package/src/maps/EditHoverOver.tsx +9 -5
- package/src/maps/GridLayer.ts +0 -224
- package/src/maps/HoverContent.tsx +1 -1
- package/src/maps/Layer.ts +1 -35
- package/src/maps/LeafletMapComponent.tsx +10 -19
- package/src/maps/MapComponent.tsx +448 -0
- package/src/maps/MapControlComponent.tsx +41 -0
- package/src/maps/MapDesign.ts +6 -0
- package/src/maps/MapDesignerComponent.tsx +18 -1
- package/src/maps/MapLayerDataSource.ts +0 -5
- package/src/maps/MapLayerViewDesignerComponent.ts +9 -2
- package/src/maps/MapLayersDesignerComponent.ts +4 -1
- package/src/maps/MapTranslationsTab.tsx +53 -0
- package/src/maps/MapUtils.ts +61 -1
- package/src/maps/MapViewComponent.tsx +2 -8
- package/src/maps/MarkersLayer.ts +101 -275
- package/src/maps/MarkersLayerDesign.ts +7 -1
- package/src/maps/MarkersLayerDesignerComponent.tsx +436 -0
- package/src/maps/ServerMapDataSource.ts +0 -31
- package/src/maps/SwitchableTileUrlLayer.tsx +0 -11
- package/src/maps/TileUrlLayer.tsx +0 -6
- package/src/maps/VectorMapViewComponent.tsx +15 -15
- package/src/maps/symbols/font-awesome/asterisk.png +0 -0
- package/src/maps/symbols/font-awesome/ban.png +0 -0
- package/src/maps/symbols/font-awesome/beer.png +0 -0
- package/src/maps/symbols/font-awesome/bell.png +0 -0
- package/src/maps/symbols/font-awesome/bolt.png +0 -0
- package/src/maps/symbols/font-awesome/building.png +0 -0
- package/src/maps/symbols/font-awesome/bullseye.png +0 -0
- package/src/maps/symbols/font-awesome/bus.png +0 -0
- package/src/maps/symbols/font-awesome/caret-up.png +0 -0
- package/src/maps/symbols/font-awesome/certificate.png +0 -0
- package/src/maps/symbols/font-awesome/check-circle.png +0 -0
- package/src/maps/symbols/font-awesome/check.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
- package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/symbols/font-awesome/cloud.png +0 -0
- package/src/maps/symbols/font-awesome/comment.png +0 -0
- package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
- package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
- package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
- package/src/maps/symbols/font-awesome/female.png +0 -0
- package/src/maps/symbols/font-awesome/file.png +0 -0
- package/src/maps/symbols/font-awesome/flag.png +0 -0
- package/src/maps/symbols/font-awesome/flask.png +0 -0
- package/src/maps/symbols/font-awesome/h-square.png +0 -0
- package/src/maps/symbols/font-awesome/home.png +0 -0
- package/src/maps/symbols/font-awesome/info-circle.png +0 -0
- package/src/maps/symbols/font-awesome/male.png +0 -0
- package/src/maps/symbols/font-awesome/medkit.png +0 -0
- package/src/maps/symbols/font-awesome/mobile.png +0 -0
- package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
- package/src/maps/symbols/font-awesome/plus-square.png +0 -0
- package/src/maps/symbols/font-awesome/plus.png +0 -0
- package/src/maps/symbols/font-awesome/square.png +0 -0
- package/src/maps/symbols/font-awesome/star.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
- package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
- package/src/maps/symbols/font-awesome/ticket.png +0 -0
- package/src/maps/symbols/font-awesome/times-circle.png +0 -0
- package/src/maps/symbols/font-awesome/times.png +0 -0
- package/src/maps/symbols/font-awesome/tint.png +0 -0
- package/src/maps/symbols/font-awesome/tree.png +0 -0
- package/src/maps/symbols/font-awesome/university.png +0 -0
- package/src/maps/symbols/font-awesome/usd.png +0 -0
- package/src/maps/symbols/font-awesome/user.png +0 -0
- package/src/maps/symbols/font-awesome/users.png +0 -0
- package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
- package/src/maps/symbols/sdf-ize.sh +93 -0
- package/src/maps/vectorMaps.tsx +32 -53
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +165 -37
- package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +373 -37
- package/src/mwater_table_selection/MWaterTableSelectComponent.tsx +12 -8
- package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
- package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
- package/src/quickfilter/TextLiteralComponent.tsx +197 -0
- package/src/widgets/MapWidget.tsx +11 -1
- package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
- package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
- package/test/UndoStackTests.ts +52 -1
- package/.storybook/config.js +0 -7
- package/.storybook/head.html +0 -3
- package/.storybook/webpack.config.js +0 -15
- package/src/maps/BingLayer.ts +0 -146
- package/src/maps/MapComponent.ts +0 -312
- package/src/maps/MapControlComponent.ts +0 -46
- package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
- package/src/maps/RasterMapViewComponent.ts +0 -345
- package/src/quickfilter/TextLiteralComponent.ts +0 -165
- package/stories/UpdateableComponent.js +0 -29
- package/stories/consoles.js +0 -202
- package/stories/dashboards.js +0 -217
- package/stories/datagridDesign.js +0 -114
- package/stories/datagrids.js +0 -69
- package/stories/dates.js +0 -80
- package/stories/exprcomponent.js +0 -43
- package/stories/index.js +0 -18
- package/stories/leaflet.js +0 -59
- package/stories/maps.js +0 -24
- package/stories/pivotChart.js +0 -235
|
@@ -767,356 +767,6 @@ class ChoroplethLayer extends Layer_1.default {
|
|
|
767
767
|
maxZoom: design.maxZoom
|
|
768
768
|
};
|
|
769
769
|
}
|
|
770
|
-
/** Gets the layer definition as JsonQL + CSS in format:
|
|
771
|
-
* {
|
|
772
|
-
* layers: array of { id: layer id, jsonql: jsonql that includes "the_webmercator_geom" as a column }
|
|
773
|
-
* css: carto css
|
|
774
|
-
* interactivity: (optional) { layer: id of layer, fields: array of field names }
|
|
775
|
-
* }
|
|
776
|
-
* arguments:
|
|
777
|
-
* design: design of layer
|
|
778
|
-
* schema: schema to use
|
|
779
|
-
* filters: array of filters to apply
|
|
780
|
-
*/
|
|
781
|
-
getJsonQLCss(design, schema, filters) {
|
|
782
|
-
// Create design
|
|
783
|
-
const layerDef = {
|
|
784
|
-
layers: [{ id: "layer0", jsonql: this.createMapnikJsonQL(design, schema, filters) }],
|
|
785
|
-
css: this.createCss(design, schema, filters),
|
|
786
|
-
interactivity: {
|
|
787
|
-
layer: "layer0",
|
|
788
|
-
fields: ["id", "name"]
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
return layerDef;
|
|
792
|
-
}
|
|
793
|
-
createMapnikJsonQL(design, schema, filters) {
|
|
794
|
-
const axisBuilder = new AxisBuilder_1.default({ schema });
|
|
795
|
-
const exprCompiler = new expressions_1.ExprCompiler(schema);
|
|
796
|
-
// Verify that scopeLevel is an integer to prevent injection
|
|
797
|
-
if (design.scopeLevel != null && ![0, 1, 2, 3, 4, 5].includes(design.scopeLevel)) {
|
|
798
|
-
throw new Error("Invalid scope level");
|
|
799
|
-
}
|
|
800
|
-
// Verify that detailLevel is an integer to prevent injection
|
|
801
|
-
if (![0, 1, 2, 3, 4, 5].includes(design.detailLevel)) {
|
|
802
|
-
throw new Error("Invalid detail level");
|
|
803
|
-
}
|
|
804
|
-
const regionsTable = design.regionsTable || "admin_regions";
|
|
805
|
-
if (design.regionMode === "plain") {
|
|
806
|
-
/*
|
|
807
|
-
E.g:
|
|
808
|
-
select name, shape_simplified from
|
|
809
|
-
admin_regions as regions
|
|
810
|
-
where regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
|
|
811
|
-
and regions.level = 2
|
|
812
|
-
*/
|
|
813
|
-
const query = {
|
|
814
|
-
type: "query",
|
|
815
|
-
selects: [
|
|
816
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
|
|
817
|
-
{
|
|
818
|
-
type: "select",
|
|
819
|
-
expr: { type: "field", tableAlias: "regions", column: "shape_simplified" },
|
|
820
|
-
alias: "the_geom_webmercator"
|
|
821
|
-
},
|
|
822
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
|
|
823
|
-
],
|
|
824
|
-
from: { type: "table", table: regionsTable, alias: "regions" },
|
|
825
|
-
where: {
|
|
826
|
-
type: "op",
|
|
827
|
-
op: "and",
|
|
828
|
-
exprs: [
|
|
829
|
-
// Level to display
|
|
830
|
-
{
|
|
831
|
-
type: "op",
|
|
832
|
-
op: "=",
|
|
833
|
-
exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
|
|
834
|
-
}
|
|
835
|
-
]
|
|
836
|
-
}
|
|
837
|
-
};
|
|
838
|
-
// Scope overall
|
|
839
|
-
if (design.scope) {
|
|
840
|
-
;
|
|
841
|
-
query.where.exprs.push({
|
|
842
|
-
type: "op",
|
|
843
|
-
op: "=",
|
|
844
|
-
exprs: [
|
|
845
|
-
{ type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
|
|
846
|
-
{ type: "literal", value: design.scope }
|
|
847
|
-
]
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
// Add filters on regions to outer query
|
|
851
|
-
for (const filter of filters) {
|
|
852
|
-
if (filter.table == regionsTable) {
|
|
853
|
-
;
|
|
854
|
-
query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
return query;
|
|
858
|
-
}
|
|
859
|
-
if (design.regionMode === "indirect" || !design.regionMode) {
|
|
860
|
-
/*
|
|
861
|
-
E.g:
|
|
862
|
-
select name, shape_simplified, regions.color from
|
|
863
|
-
admin_regions as regions2
|
|
864
|
-
left outer join
|
|
865
|
-
(
|
|
866
|
-
select admin_regions.level2 as id,
|
|
867
|
-
count(innerquery.*) as color
|
|
868
|
-
from
|
|
869
|
-
admin_regions inner join
|
|
870
|
-
entities.water_point as innerquery
|
|
871
|
-
on innerquery.admin_region = admin_regions._id
|
|
872
|
-
where admin_regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
|
|
873
|
-
group by 1
|
|
874
|
-
) as regions on regions.id = regions2._id
|
|
875
|
-
where regions2.level = 2 and regions2.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
|
|
876
|
-
*/
|
|
877
|
-
const compiledAdminRegionExpr = exprCompiler.compileExpr({
|
|
878
|
-
expr: design.adminRegionExpr || null,
|
|
879
|
-
tableAlias: "innerquery"
|
|
880
|
-
});
|
|
881
|
-
// Create inner query
|
|
882
|
-
const innerQuery = {
|
|
883
|
-
type: "query",
|
|
884
|
-
selects: [
|
|
885
|
-
{
|
|
886
|
-
type: "select",
|
|
887
|
-
expr: { type: "field", tableAlias: "regions", column: `level${design.detailLevel}` },
|
|
888
|
-
alias: "id"
|
|
889
|
-
}
|
|
890
|
-
],
|
|
891
|
-
from: {
|
|
892
|
-
type: "join",
|
|
893
|
-
kind: "inner",
|
|
894
|
-
left: { type: "table", table: regionsTable, alias: "regions" },
|
|
895
|
-
right: exprCompiler.compileTable(design.table, "innerquery"),
|
|
896
|
-
on: {
|
|
897
|
-
type: "op",
|
|
898
|
-
op: "=",
|
|
899
|
-
exprs: [compiledAdminRegionExpr, { type: "field", tableAlias: "regions", column: "_id" }]
|
|
900
|
-
}
|
|
901
|
-
},
|
|
902
|
-
groupBy: [1]
|
|
903
|
-
};
|
|
904
|
-
// Add color select if color axis
|
|
905
|
-
if (design.axes.color) {
|
|
906
|
-
const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "innerquery" });
|
|
907
|
-
innerQuery.selects.push({ type: "select", expr: colorExpr, alias: "color" });
|
|
908
|
-
}
|
|
909
|
-
// Add label select if color axis
|
|
910
|
-
if (design.axes.label) {
|
|
911
|
-
const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "innerquery" });
|
|
912
|
-
innerQuery.selects.push({ type: "select", expr: labelExpr, alias: "label" });
|
|
913
|
-
}
|
|
914
|
-
let whereClauses = [];
|
|
915
|
-
if (design.scope) {
|
|
916
|
-
whereClauses.push({
|
|
917
|
-
type: "op",
|
|
918
|
-
op: "=",
|
|
919
|
-
exprs: [{ type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` }, design.scope]
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
// Then add filters
|
|
923
|
-
if (design.filter) {
|
|
924
|
-
whereClauses.push(exprCompiler.compileExpr({ expr: design.filter, tableAlias: "innerquery" }));
|
|
925
|
-
}
|
|
926
|
-
// Then add extra filters passed in, if relevant
|
|
927
|
-
const relevantFilters = lodash_1.default.where(filters, { table: design.table });
|
|
928
|
-
for (let filter of relevantFilters) {
|
|
929
|
-
whereClauses.push((0, expressions_1.injectTableAlias)(filter.jsonql, "innerquery"));
|
|
930
|
-
}
|
|
931
|
-
whereClauses = lodash_1.default.compact(whereClauses);
|
|
932
|
-
if (whereClauses.length > 0) {
|
|
933
|
-
innerQuery.where = { type: "op", op: "and", exprs: whereClauses };
|
|
934
|
-
}
|
|
935
|
-
// Now create outer query
|
|
936
|
-
const query = {
|
|
937
|
-
type: "query",
|
|
938
|
-
selects: [
|
|
939
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions2", column: "_id" }, alias: "id" },
|
|
940
|
-
{
|
|
941
|
-
type: "select",
|
|
942
|
-
expr: { type: "field", tableAlias: "regions2", column: "shape_simplified" },
|
|
943
|
-
alias: "the_geom_webmercator"
|
|
944
|
-
},
|
|
945
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions2", column: "name" }, alias: "name" }
|
|
946
|
-
],
|
|
947
|
-
from: {
|
|
948
|
-
type: "join",
|
|
949
|
-
kind: "left",
|
|
950
|
-
left: { type: "table", table: regionsTable, alias: "regions2" },
|
|
951
|
-
right: { type: "subquery", query: innerQuery, alias: "regions" },
|
|
952
|
-
on: {
|
|
953
|
-
type: "op",
|
|
954
|
-
op: "=",
|
|
955
|
-
exprs: [
|
|
956
|
-
{ type: "field", tableAlias: "regions", column: "id" },
|
|
957
|
-
{ type: "field", tableAlias: "regions2", column: "_id" }
|
|
958
|
-
]
|
|
959
|
-
}
|
|
960
|
-
},
|
|
961
|
-
where: {
|
|
962
|
-
type: "op",
|
|
963
|
-
op: "and",
|
|
964
|
-
exprs: [
|
|
965
|
-
// Level to display
|
|
966
|
-
{
|
|
967
|
-
type: "op",
|
|
968
|
-
op: "=",
|
|
969
|
-
exprs: [{ type: "field", tableAlias: "regions2", column: "level" }, design.detailLevel]
|
|
970
|
-
}
|
|
971
|
-
]
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
// Scope overall
|
|
975
|
-
if (design.scope) {
|
|
976
|
-
;
|
|
977
|
-
query.where.exprs.push({
|
|
978
|
-
type: "op",
|
|
979
|
-
op: "=",
|
|
980
|
-
exprs: [
|
|
981
|
-
{ type: "field", tableAlias: "regions2", column: `level${design.scopeLevel || 0}` },
|
|
982
|
-
{ type: "literal", value: design.scope }
|
|
983
|
-
]
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
// Add filters on regions to outer query
|
|
987
|
-
for (const filter of filters) {
|
|
988
|
-
if (filter.table == regionsTable) {
|
|
989
|
-
;
|
|
990
|
-
query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions2"));
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
// Bubble up color and label
|
|
994
|
-
if (design.axes.color) {
|
|
995
|
-
query.selects.push({
|
|
996
|
-
type: "select",
|
|
997
|
-
expr: { type: "field", tableAlias: "regions", column: "color" },
|
|
998
|
-
alias: "color"
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
// Add label select if color axis
|
|
1002
|
-
if (design.axes.label) {
|
|
1003
|
-
query.selects.push({
|
|
1004
|
-
type: "select",
|
|
1005
|
-
expr: { type: "field", tableAlias: "regions", column: "label" },
|
|
1006
|
-
alias: "label"
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
return query;
|
|
1010
|
-
}
|
|
1011
|
-
if (design.regionMode === "direct") {
|
|
1012
|
-
/*
|
|
1013
|
-
E.g:
|
|
1014
|
-
select name, shape_simplified from
|
|
1015
|
-
admin_regions as regions
|
|
1016
|
-
where regions.level0 = 'eb3e12a2-de1e-49a9-8afd-966eb55d47eb'
|
|
1017
|
-
and regions.level = 2
|
|
1018
|
-
*/
|
|
1019
|
-
const query = {
|
|
1020
|
-
type: "query",
|
|
1021
|
-
selects: [
|
|
1022
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions", column: "_id" }, alias: "id" },
|
|
1023
|
-
{
|
|
1024
|
-
type: "select",
|
|
1025
|
-
expr: { type: "field", tableAlias: "regions", column: "shape_simplified" },
|
|
1026
|
-
alias: "the_geom_webmercator"
|
|
1027
|
-
},
|
|
1028
|
-
{ type: "select", expr: { type: "field", tableAlias: "regions", column: "name" }, alias: "name" }
|
|
1029
|
-
],
|
|
1030
|
-
from: { type: "table", table: regionsTable, alias: "regions" },
|
|
1031
|
-
where: {
|
|
1032
|
-
type: "op",
|
|
1033
|
-
op: "and",
|
|
1034
|
-
exprs: [
|
|
1035
|
-
// Level to display
|
|
1036
|
-
{
|
|
1037
|
-
type: "op",
|
|
1038
|
-
op: "=",
|
|
1039
|
-
exprs: [{ type: "field", tableAlias: "regions", column: "level" }, design.detailLevel]
|
|
1040
|
-
}
|
|
1041
|
-
]
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
// Add color select
|
|
1045
|
-
if (design.axes.color) {
|
|
1046
|
-
const colorExpr = axisBuilder.compileAxis({ axis: design.axes.color, tableAlias: "regions" });
|
|
1047
|
-
query.selects.push({ type: "select", expr: colorExpr, alias: "color" });
|
|
1048
|
-
}
|
|
1049
|
-
// Add label select if color axis
|
|
1050
|
-
if (design.axes.label) {
|
|
1051
|
-
const labelExpr = axisBuilder.compileAxis({ axis: design.axes.label, tableAlias: "regions" });
|
|
1052
|
-
query.selects.push({ type: "select", expr: labelExpr, alias: "label" });
|
|
1053
|
-
}
|
|
1054
|
-
// Scope overall
|
|
1055
|
-
if (design.scope) {
|
|
1056
|
-
;
|
|
1057
|
-
query.where.exprs.push({
|
|
1058
|
-
type: "op",
|
|
1059
|
-
op: "=",
|
|
1060
|
-
exprs: [
|
|
1061
|
-
{ type: "field", tableAlias: "regions", column: `level${design.scopeLevel || 0}` },
|
|
1062
|
-
{ type: "literal", value: design.scope }
|
|
1063
|
-
]
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
// Add filters on regions to outer query
|
|
1067
|
-
for (const filter of filters) {
|
|
1068
|
-
if (filter.table == regionsTable) {
|
|
1069
|
-
;
|
|
1070
|
-
query.where.exprs.push((0, expressions_1.injectTableAlias)(filter.jsonql, "regions"));
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
return query;
|
|
1074
|
-
}
|
|
1075
|
-
throw new Error(`Unsupported regionMode ${design.regionMode}`);
|
|
1076
|
-
}
|
|
1077
|
-
createCss(design, schema, filters) {
|
|
1078
|
-
let css = `\
|
|
1079
|
-
#layer0 {
|
|
1080
|
-
line-color: ${design.borderColor || "#000"};
|
|
1081
|
-
line-width: 1.5;
|
|
1082
|
-
line-opacity: 0.5;
|
|
1083
|
-
polygon-opacity: ` +
|
|
1084
|
-
design.fillOpacity * design.fillOpacity +
|
|
1085
|
-
`;
|
|
1086
|
-
polygon-fill: ` +
|
|
1087
|
-
(design.color || "transparent") +
|
|
1088
|
-
`;
|
|
1089
|
-
}
|
|
1090
|
-
\
|
|
1091
|
-
`;
|
|
1092
|
-
if (design.displayNames) {
|
|
1093
|
-
css += `\
|
|
1094
|
-
#layer0::labels {
|
|
1095
|
-
text-name: [name];
|
|
1096
|
-
text-face-name: 'Arial Regular';
|
|
1097
|
-
text-halo-radius: 2;
|
|
1098
|
-
text-halo-opacity: 0.5;
|
|
1099
|
-
text-halo-fill: #FFF;
|
|
1100
|
-
}\
|
|
1101
|
-
`;
|
|
1102
|
-
}
|
|
1103
|
-
// If color axes, add color conditions
|
|
1104
|
-
if (design.axes.color && design.axes.color.colorMap) {
|
|
1105
|
-
for (let item of design.axes.color.colorMap) {
|
|
1106
|
-
// If invisible
|
|
1107
|
-
if (lodash_1.default.includes(design.axes.color.excludedValues || [], item.value)) {
|
|
1108
|
-
css += `#layer0 [color=${JSON.stringify(item.value)}] { line-color: transparent; polygon-opacity: 0; polygon-fill: transparent; }\n`;
|
|
1109
|
-
if (design.displayNames) {
|
|
1110
|
-
css += `#layer0::labels [color=${JSON.stringify(item.value)}] { text-opacity: 0; text-halo-opacity: 0; }\n`;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
else {
|
|
1114
|
-
css += `#layer0 [color=${JSON.stringify(item.value)}] { polygon-fill: ${item.color}; }\n`;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
return css;
|
|
1119
|
-
}
|
|
1120
770
|
/**
|
|
1121
771
|
* Called when the interactivity grid is clicked.
|
|
1122
772
|
* arguments:
|
|
@@ -1320,7 +970,7 @@ class ChoroplethLayer extends Layer_1.default {
|
|
|
1320
970
|
// Get the legend to be optionally displayed on the map. Returns
|
|
1321
971
|
// a React element
|
|
1322
972
|
getLegend(options) {
|
|
1323
|
-
const { design, schema, name, dataSource, locale, filters } = options;
|
|
973
|
+
const { design, schema, name, dataSource, locale, filters, translate } = options;
|
|
1324
974
|
const _filters = filters.slice();
|
|
1325
975
|
if (design.filter != null) {
|
|
1326
976
|
const exprCompiler = new expressions_1.ExprCompiler(schema);
|
|
@@ -1333,16 +983,18 @@ class ChoroplethLayer extends Layer_1.default {
|
|
|
1333
983
|
const axisBuilder = new AxisBuilder_1.default({ schema });
|
|
1334
984
|
const regionsTable = design.regionsTable || "admin_regions";
|
|
1335
985
|
const axisTable = design.regionMode === "direct" ? regionsTable : design.table;
|
|
986
|
+
// Clean and translate axis
|
|
987
|
+
const axis = (0, MapUtils_1.translateAxis)(axisBuilder.cleanAxis({
|
|
988
|
+
axis: design.axes.color || null,
|
|
989
|
+
table: axisTable,
|
|
990
|
+
types: ["enum", "text", "boolean", "date"],
|
|
991
|
+
aggrNeed: design.regionMode == "indirect" ? "required" : "none"
|
|
992
|
+
}), translate);
|
|
1336
993
|
return react_1.default.createElement(LayerLegendComponent_1.default, {
|
|
1337
994
|
schema,
|
|
1338
|
-
name,
|
|
995
|
+
name: translate(name),
|
|
1339
996
|
filters: lodash_1.default.compact(_filters),
|
|
1340
|
-
axis:
|
|
1341
|
-
axis: design.axes.color || null,
|
|
1342
|
-
table: axisTable,
|
|
1343
|
-
types: ["enum", "text", "boolean", "date"],
|
|
1344
|
-
aggrNeed: design.regionMode == "indirect" ? "required" : "none"
|
|
1345
|
-
}) || undefined,
|
|
997
|
+
axis: axis || undefined,
|
|
1346
998
|
defaultColor: design.color || undefined,
|
|
1347
999
|
locale
|
|
1348
1000
|
});
|
|
@@ -1434,6 +1086,18 @@ class ChoroplethLayer extends Layer_1.default {
|
|
|
1434
1086
|
else {
|
|
1435
1087
|
delete draft.filter;
|
|
1436
1088
|
}
|
|
1089
|
+
// Clean hover over expressions only for indirect mode with a valid table
|
|
1090
|
+
if (design.table && design.regionMode === "indirect" && design.hoverOver && design.hoverOver.items) {
|
|
1091
|
+
for (let i = 0; i < design.hoverOver.items.length; i++) {
|
|
1092
|
+
const item = design.hoverOver.items[i];
|
|
1093
|
+
if (item.value) {
|
|
1094
|
+
draft.hoverOver.items[i].value = exprCleaner.cleanExpr(item.value || null, {
|
|
1095
|
+
table: design.table,
|
|
1096
|
+
aggrStatuses: ["individual", "literal", "aggregate"]
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1437
1101
|
if (design.detailLevel == null) {
|
|
1438
1102
|
draft.detailLevel = 0;
|
|
1439
1103
|
}
|
|
@@ -1506,6 +1170,9 @@ class ChoroplethLayer extends Layer_1.default {
|
|
|
1506
1170
|
/** Get strings to be translated */
|
|
1507
1171
|
getTranslatableStrings(design, schema) {
|
|
1508
1172
|
const strings = [];
|
|
1173
|
+
// Add strings from axis category labels and null labels
|
|
1174
|
+
strings.push(...(0, MapUtils_1.getTranslatableStringsFromAxis)(design.axes.color));
|
|
1175
|
+
strings.push(...(0, MapUtils_1.getTranslatableStringsFromAxis)(design.axes.label));
|
|
1509
1176
|
// Add strings from hoverOver items
|
|
1510
1177
|
if (design.hoverOver && design.hoverOver.items) {
|
|
1511
1178
|
for (const item of design.hoverOver.items) {
|
|
@@ -50,8 +50,11 @@ export default interface ChoroplethLayerDesign {
|
|
|
50
50
|
};
|
|
51
51
|
/** customizable filtering for popup. See PopupFilterJoins.md. Only when region mode is "indirect" */
|
|
52
52
|
popupFilterJoins: PopupFilterJoins;
|
|
53
|
-
/** Hover over items to display when hovering over a region. Only when region mode is "indirect"
|
|
54
|
-
|
|
53
|
+
/** Hover over items to display when hovering over a region. Only when region mode is "indirect".
|
|
54
|
+
* This is an aggregate hover over, but can contain individual items. If so, only the first row
|
|
55
|
+
* of the resulting query will be displayed.
|
|
56
|
+
*/
|
|
57
|
+
hoverOver?: {
|
|
55
58
|
items: HoverOverItem[];
|
|
56
59
|
};
|
|
57
60
|
/** minimum zoom level */
|
|
@@ -2,9 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Schema, DataSource, Expr } from "@mwater/expressions";
|
|
3
3
|
import ChoroplethLayerDesign from "./ChoroplethLayerDesign";
|
|
4
4
|
import { JsonQLFilter } from "../index";
|
|
5
|
-
import EditPopupComponent from "./EditPopupComponent";
|
|
6
5
|
import { Axis } from "../axes/Axis";
|
|
7
|
-
import ScopeAndDetailLevelComponent from "./ScopeAndDetailLevelComponent";
|
|
8
6
|
export default class ChoroplethLayerDesigner extends React.Component<{
|
|
9
7
|
schema: Schema;
|
|
10
8
|
dataSource: DataSource;
|
|
@@ -30,34 +28,14 @@ export default class ChoroplethLayerDesigner extends React.Component<{
|
|
|
30
28
|
renderTable(): React.JSX.Element | null;
|
|
31
29
|
renderRegionsTable(): React.JSX.Element;
|
|
32
30
|
renderAdminRegionExpr(): React.JSX.Element | null;
|
|
33
|
-
renderScopeAndDetailLevel(): React.
|
|
34
|
-
renderDisplayNames(): React.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, HTMLElement>;
|
|
44
|
-
renderBorderColor(): React.DetailedReactHTMLElement<{
|
|
45
|
-
className: string;
|
|
46
|
-
}, HTMLElement>;
|
|
47
|
-
renderFilter(): React.DetailedReactHTMLElement<{
|
|
48
|
-
className: string;
|
|
49
|
-
}, HTMLElement> | null;
|
|
50
|
-
renderPopup(): React.CElement<any, EditPopupComponent> | null;
|
|
51
|
-
renderHoverOver(): React.FunctionComponentElement<{
|
|
52
|
-
design: ChoroplethLayerDesign;
|
|
53
|
-
onDesignChange: (design: ChoroplethLayerDesign) => void;
|
|
54
|
-
schema: Schema;
|
|
55
|
-
dataSource: DataSource;
|
|
56
|
-
table: string;
|
|
57
|
-
idTable: string;
|
|
58
|
-
defaultPopupFilterJoins: {
|
|
59
|
-
[tableId: string]: Expr;
|
|
60
|
-
};
|
|
61
|
-
}> | null;
|
|
62
|
-
render(): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
31
|
+
renderScopeAndDetailLevel(): React.JSX.Element;
|
|
32
|
+
renderDisplayNames(): React.JSX.Element;
|
|
33
|
+
renderColor(): React.JSX.Element | null;
|
|
34
|
+
renderColorAxis(): React.JSX.Element | null | undefined;
|
|
35
|
+
renderFillOpacity(): React.JSX.Element;
|
|
36
|
+
renderBorderColor(): React.JSX.Element;
|
|
37
|
+
renderFilter(): React.JSX.Element | null;
|
|
38
|
+
renderPopup(): React.JSX.Element | null;
|
|
39
|
+
renderHoverOver(): React.JSX.Element | null;
|
|
40
|
+
render(): React.JSX.Element;
|
|
63
41
|
}
|