@mwater/visualization 5.4.5 → 5.6.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.
- package/lib/MWaterContextComponent.d.ts +1 -1
- package/lib/MWaterContextComponent.js +1 -1
- package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
- package/lib/MWaterGlobalFiltersComponent.js +11 -20
- package/lib/MWaterLoaderComponent.d.ts +5 -14
- package/lib/MWaterLoaderComponent.js +2 -11
- package/lib/UndoStack.d.ts +2 -1
- package/lib/UndoStack.js +12 -6
- package/lib/dashboards/DashboardComponent.js +7 -5
- package/lib/dashboards/DashboardDesign.d.ts +1 -1
- package/lib/dashboards/LayoutOptionsComponent.js +18 -11
- package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
- package/lib/dashboards/ServerDashboardDataSource.js +29 -10
- package/lib/dashboards/SettingsModalComponent.js +1 -1
- package/lib/dashboards/layoutOptions.d.ts +5 -1
- package/lib/datagrids/DatagridComponent.js +23 -3
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
- package/lib/datagrids/DatagridDesignerComponent.js +108 -120
- package/lib/datagrids/DatagridViewComponent.js +3 -2
- package/lib/datagrids/ExprCellComponent.d.ts +1 -0
- package/lib/datagrids/ExprCellComponent.js +22 -20
- 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 +18 -0
- package/lib/maps/BufferLayer.js +36 -14
- package/lib/maps/BufferLayerDesign.d.ts +1 -1
- package/lib/maps/BufferLayerDesignerComponent.js +2 -2
- package/lib/maps/ChoroplethLayer.d.ts +18 -0
- package/lib/maps/ChoroplethLayer.js +46 -25
- package/lib/maps/ChoroplethLayerDesign.d.ts +7 -3
- package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -22
- package/lib/maps/ChoroplethLayerDesigner.js +58 -89
- package/lib/maps/DirectMapDataSource.js +17 -10
- package/lib/maps/EditHoverOver.d.ts +4 -3
- package/lib/maps/EditHoverOver.js +64 -35
- package/lib/maps/HoverContent.d.ts +10 -5
- package/lib/maps/HoverContent.js +7 -36
- package/lib/maps/Layer.d.ts +37 -0
- package/lib/maps/Layer.js +30 -4
- package/lib/maps/LeafletMapComponent.js +10 -19
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +6 -6
- package/lib/maps/MapComponent.js +0 -1
- package/lib/maps/MapLayerDataSource.d.ts +9 -0
- package/lib/maps/MapUtils.d.ts +19 -1
- package/lib/maps/MapUtils.js +80 -1
- package/lib/maps/MarkersLayer.d.ts +18 -0
- package/lib/maps/MarkersLayer.js +42 -26
- package/lib/maps/MarkersLayerDesign.d.ts +1 -1
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +12 -28
- package/lib/maps/MarkersLayerDesignerComponent.js +81 -111
- package/lib/maps/RasterMapViewComponent.js +1 -1
- package/lib/maps/ServerMapDataSource.d.ts +9 -0
- package/lib/maps/ServerMapDataSource.js +29 -10
- package/lib/maps/VectorMapViewComponent.js +7 -15
- package/lib/maps/maps.d.ts +4 -2
- 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 +1 -0
- package/lib/maps/vectorMaps.js +20 -36
- package/lib/mwater_table_selection/FormsListComponent.d.ts +33 -0
- package/lib/mwater_table_selection/FormsListComponent.js +141 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +49 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.js +251 -0
- package/lib/mwater_table_selection/IssuesListComponent.d.ts +29 -0
- package/lib/mwater_table_selection/IssuesListComponent.js +123 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.d.ts +20 -0
- package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.js +157 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.js +79 -0
- 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 +63 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +461 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.js +94 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.d.ts +17 -0
- package/lib/mwater_table_selection/MWaterMetricsTableListComponent.js +80 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +32 -0
- package/lib/mwater_table_selection/MWaterTableSelectComponent.js +163 -0
- 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 +4 -2
- package/lib/widgets/charts/Chart.d.ts +11 -0
- package/lib/widgets/charts/Chart.js +15 -0
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +1 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +27 -1
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +5 -12
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +43 -57
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +113 -110
- package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +2 -1
- package/lib/widgets/charts/layered/LayeredChartUtils.js +0 -2
- package/lib/widgets/charts/pivot/PivotChart.d.ts +2 -0
- package/lib/widgets/charts/pivot/PivotChart.js +156 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -20
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +31 -61
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +4 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +4 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +5 -44
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +38 -63
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +7 -68
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +58 -106
- package/lib/widgets/charts/table/TableChart.d.ts +2 -0
- package/lib/widgets/charts/table/TableChart.js +172 -1
- package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +7 -17
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +79 -95
- package/lib/widgets/charts/table/TableChartViewComponent.d.ts +1 -7
- package/lib/widgets/charts/table/TableChartViewComponent.js +19 -27
- 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 +4 -10
- package/src/MWaterContextComponent.tsx +2 -2
- package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
- package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +18 -19
- package/src/UndoStack.ts +14 -6
- package/src/dashboards/DashboardComponent.tsx +7 -5
- package/src/dashboards/DashboardDesign.ts +1 -1
- package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
- package/src/dashboards/ServerDashboardDataSource.ts +36 -13
- package/src/dashboards/SettingsModalComponent.tsx +1 -1
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.tsx +31 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
- package/src/datagrids/DatagridViewComponent.tsx +3 -2
- package/src/datagrids/ExprCellComponent.tsx +23 -20
- 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 +48 -20
- package/src/maps/BufferLayerDesign.ts +1 -1
- package/src/maps/BufferLayerDesignerComponent.tsx +2 -1
- package/src/maps/ChoroplethLayer.ts +70 -39
- package/src/maps/ChoroplethLayerDesign.ts +6 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +171 -167
- package/src/maps/DirectMapDataSource.ts +21 -13
- package/src/maps/EditHoverOver.tsx +98 -54
- package/src/maps/HoverContent.tsx +17 -48
- package/src/maps/Layer.ts +42 -4
- package/src/maps/LeafletMapComponent.tsx +10 -19
- package/src/maps/MWaterServerLayer.ts +6 -6
- package/src/maps/MapComponent.ts +0 -1
- package/src/maps/MapLayerDataSource.ts +8 -0
- package/src/maps/MapUtils.ts +82 -3
- package/src/maps/MarkersLayer.ts +54 -27
- package/src/maps/MarkersLayerDesign.ts +1 -1
- package/src/maps/MarkersLayerDesignerComponent.tsx +360 -0
- package/src/maps/RasterMapViewComponent.ts +1 -1
- package/src/maps/ServerMapDataSource.ts +35 -12
- package/src/maps/VectorMapViewComponent.tsx +8 -19
- package/src/maps/maps.ts +4 -2
- 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 +20 -44
- package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +411 -0
- package/src/mwater_table_selection/IssuesListComponent.tsx +167 -0
- package/src/mwater_table_selection/MWaterAccountingSystemListComponent.tsx +225 -0
- package/src/{MWaterAssetSystemsListComponent.tsx → mwater_table_selection/MWaterAssetSystemsListComponent.tsx} +2 -2
- package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
- package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +713 -0
- package/src/{MWaterCustomTablesetListComponent.tsx → mwater_table_selection/MWaterCustomTablesetListComponent.tsx} +1 -1
- package/src/{MWaterMetricsTableListComponent.tsx → mwater_table_selection/MWaterMetricsTableListComponent.tsx} +1 -1
- package/src/{MWaterTableSelectComponent.tsx → mwater_table_selection/MWaterTableSelectComponent.tsx} +91 -90
- 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 +9 -1
- package/src/widgets/charts/Chart.ts +17 -0
- package/src/widgets/charts/ChartWidgetComponent.tsx +36 -1
- package/src/widgets/charts/layered/LayeredChartDesign.ts +1 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +23 -24
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +260 -211
- package/src/widgets/charts/layered/LayeredChartUtils.ts +7 -7
- package/src/widgets/charts/pivot/PivotChart.ts +191 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +124 -129
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +4 -2
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +120 -149
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +178 -198
- package/src/widgets/charts/table/TableChart.ts +177 -1
- package/src/widgets/charts/table/TableChartDesignerComponent.tsx +422 -0
- package/src/widgets/charts/table/{TableChartViewComponent.ts → TableChartViewComponent.tsx} +65 -60
- 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 -4
- package/.storybook/webpack.config.js +0 -15
- package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
- package/src/maps/BingLayer.ts +0 -146
- package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
- package/src/quickfilter/TextLiteralComponent.ts +0 -165
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
- 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
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// TODO: This file was created by bulk-decaffeinate.
|
|
2
|
-
// Sanity-check the conversion and remove this comment.
|
|
3
1
|
// Misc utils for layered charts
|
|
4
2
|
|
|
3
|
+
import { LiteralType } from "@mwater/expressions"
|
|
4
|
+
|
|
5
5
|
// Get possible types for axis of a layer
|
|
6
|
-
export function getAxisTypes(design: any, layer: any, axis: any) {
|
|
6
|
+
export function getAxisTypes(design: any, layer: any, axis: any): LiteralType[] | null {
|
|
7
7
|
// If categorical
|
|
8
8
|
const layerType = layer.type || design.type
|
|
9
9
|
|
|
10
10
|
switch (axis) {
|
|
11
11
|
case "x":
|
|
12
12
|
if (layerType === "bar") {
|
|
13
|
-
return ["enum", "enumset", "text", "date", "boolean"]
|
|
13
|
+
return ["enum", "enumset", "text", "date", "boolean"] as LiteralType[]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// More broad
|
|
17
|
-
return ["enum", "text", "number", "boolean", "date"]
|
|
17
|
+
return ["enum", "text", "number", "boolean", "date"] as LiteralType[]
|
|
18
18
|
case "color":
|
|
19
|
-
return ["enum", "text", "date", "boolean"]
|
|
19
|
+
return ["enum", "text", "date", "boolean"] as LiteralType[]
|
|
20
20
|
case "y":
|
|
21
|
-
return ["number"]
|
|
21
|
+
return ["number"] as LiteralType[]
|
|
22
22
|
}
|
|
23
23
|
return null
|
|
24
24
|
}
|
|
@@ -495,4 +495,195 @@ export default class PivotChart extends Chart {
|
|
|
495
495
|
}
|
|
496
496
|
})
|
|
497
497
|
}
|
|
498
|
+
|
|
499
|
+
// Override to indicate this chart supports XLSX export
|
|
500
|
+
supportsXlsxExport(): boolean {
|
|
501
|
+
return true
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Creates a SheetJS workbook for the pivot chart data
|
|
505
|
+
createXlsxWorkbook(design: PivotChartDesign, schema: Schema, dataSource: DataSource, data: any, locale: string): any {
|
|
506
|
+
// Import XLSX here to ensure it's available
|
|
507
|
+
const XLSX = require("xlsx-js-style")
|
|
508
|
+
const Color = require("color")
|
|
509
|
+
|
|
510
|
+
// Create a new workbook
|
|
511
|
+
const workbook = XLSX.utils.book_new()
|
|
512
|
+
|
|
513
|
+
// Build layout using the layout builder
|
|
514
|
+
const layoutBuilder = new PivotChartLayoutBuilder({ schema })
|
|
515
|
+
const layout = layoutBuilder.buildLayout(design, data, locale)
|
|
516
|
+
|
|
517
|
+
// Create a 2D array for the worksheet data
|
|
518
|
+
const wsData: any[][] = []
|
|
519
|
+
|
|
520
|
+
// Process each row in the layout
|
|
521
|
+
layout.rows.forEach(layoutRow => {
|
|
522
|
+
const rowData: any[] = []
|
|
523
|
+
|
|
524
|
+
// Process each cell in the row
|
|
525
|
+
layoutRow.cells.forEach(cell => {
|
|
526
|
+
// For skipped cells, still add an empty placeholder
|
|
527
|
+
if (cell.skip) {
|
|
528
|
+
rowData.push({ v: "", s: {} })
|
|
529
|
+
return
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// Create cell value and style
|
|
533
|
+
const cellObj: any = {
|
|
534
|
+
v: cell.text === null || cell.text === undefined ? "" : cell.text,
|
|
535
|
+
s: {}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Apply alignment based on cell type and subtype
|
|
539
|
+
if (cell.align === "right") {
|
|
540
|
+
cellObj.s.alignment = { horizontal: "right" }
|
|
541
|
+
} else if (cell.align === "center") {
|
|
542
|
+
cellObj.s.alignment = { horizontal: "center" }
|
|
543
|
+
} else {
|
|
544
|
+
cellObj.s.alignment = { horizontal: "left" }
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Apply styles based on cell properties
|
|
548
|
+
if (cell.bold) {
|
|
549
|
+
cellObj.s.font = { ...cellObj.s.font, bold: true }
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (cell.italic) {
|
|
553
|
+
cellObj.s.font = { ...cellObj.s.font, italic: true }
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// Apply background color if present
|
|
557
|
+
if (cell.backgroundColor) {
|
|
558
|
+
try {
|
|
559
|
+
const color = Color(cell.backgroundColor)
|
|
560
|
+
const hex = color.hex().substring(1) // Remove #
|
|
561
|
+
|
|
562
|
+
cellObj.s.fill = {
|
|
563
|
+
patternType: "solid",
|
|
564
|
+
fgColor: { rgb: hex },
|
|
565
|
+
bgColor: { rgb: hex }
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Adjust text color based on background lightness
|
|
569
|
+
const lightness = color.luminosity()
|
|
570
|
+
cellObj.s.font = {
|
|
571
|
+
...cellObj.s.font,
|
|
572
|
+
color: { rgb: lightness < 0.3 ? "FFFFFF" : "000000" }
|
|
573
|
+
}
|
|
574
|
+
} catch (e) {
|
|
575
|
+
// Silently ignore color errors
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Apply borders
|
|
580
|
+
const borders: any = {}
|
|
581
|
+
if (cell.borderTop) {
|
|
582
|
+
const style = cell.borderTop === 1 ? "thin" : cell.borderTop === 2 ? "medium" : "thick"
|
|
583
|
+
borders.top = { style }
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (cell.borderBottom) {
|
|
587
|
+
const style = cell.borderBottom === 1 ? "thin" : cell.borderBottom === 2 ? "medium" : "thick"
|
|
588
|
+
borders.bottom = { style }
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if (cell.borderLeft) {
|
|
592
|
+
const style = cell.borderLeft === 1 ? "thin" : cell.borderLeft === 2 ? "medium" : "thick"
|
|
593
|
+
borders.left = { style }
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (cell.borderRight) {
|
|
597
|
+
const style = cell.borderRight === 1 ? "thin" : cell.borderRight === 2 ? "medium" : "thick"
|
|
598
|
+
borders.right = { style }
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (Object.keys(borders).length > 0) {
|
|
602
|
+
cellObj.s.border = borders
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
rowData.push(cellObj)
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
wsData.push(rowData)
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
// Create a worksheet from the data
|
|
612
|
+
const worksheet = XLSX.utils.aoa_to_sheet(wsData)
|
|
613
|
+
|
|
614
|
+
// Process merged cells
|
|
615
|
+
const merges: { s: { r: number, c: number }, e: { r: number, c: number } }[] = []
|
|
616
|
+
|
|
617
|
+
// Track current row and column position
|
|
618
|
+
let rowOffset = 0
|
|
619
|
+
|
|
620
|
+
// Traverse layout again to collect merge info
|
|
621
|
+
layout.rows.forEach((layoutRow, rowIndex) => {
|
|
622
|
+
let colOffset = 0
|
|
623
|
+
|
|
624
|
+
layoutRow.cells.forEach((cell, colIndex) => {
|
|
625
|
+
// Skip cells that are part of spans (already handled)
|
|
626
|
+
if (cell.skip) {
|
|
627
|
+
colOffset++
|
|
628
|
+
return
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Handle row spans
|
|
632
|
+
if (cell.rowSpan && cell.rowSpan > 1) {
|
|
633
|
+
merges.push({
|
|
634
|
+
s: { r: rowOffset, c: colOffset },
|
|
635
|
+
e: { r: rowOffset + cell.rowSpan - 1, c: colOffset }
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// Handle column spans
|
|
640
|
+
if (cell.columnSpan && cell.columnSpan > 1) {
|
|
641
|
+
merges.push({
|
|
642
|
+
s: { r: rowOffset, c: colOffset },
|
|
643
|
+
e: { r: rowOffset, c: colOffset + cell.columnSpan - 1 }
|
|
644
|
+
})
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
colOffset++
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
rowOffset++
|
|
651
|
+
})
|
|
652
|
+
|
|
653
|
+
// Apply merges to worksheet
|
|
654
|
+
if (merges.length > 0) {
|
|
655
|
+
worksheet["!merges"] = merges
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Set column widths based on content
|
|
659
|
+
const colWidths = []
|
|
660
|
+
if (wsData.length > 0) {
|
|
661
|
+
for (let colIndex = 0; colIndex < wsData[0].length; colIndex++) {
|
|
662
|
+
// Start with reasonable default width
|
|
663
|
+
let maxWidth = 10
|
|
664
|
+
|
|
665
|
+
// Check all rows for this column
|
|
666
|
+
for (let rowIndex = 0; rowIndex < wsData.length; rowIndex++) {
|
|
667
|
+
const cell = wsData[rowIndex][colIndex]
|
|
668
|
+
if (cell && cell.v) {
|
|
669
|
+
maxWidth = Math.max(maxWidth, String(cell.v).length)
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// Add some padding and cap at 50 characters
|
|
674
|
+
colWidths.push(Math.min(maxWidth + 2, 50))
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
worksheet['!cols'] = colWidths.map(width => ({ wch: width }))
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Add the worksheet to the workbook
|
|
681
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, "Pivot Table")
|
|
682
|
+
|
|
683
|
+
// Convert workbook to blob
|
|
684
|
+
const workbookBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' })
|
|
685
|
+
const blob = new Blob([workbookBuffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" })
|
|
686
|
+
|
|
687
|
+
return blob
|
|
688
|
+
}
|
|
498
689
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
2
|
import PropTypes from "prop-types"
|
|
3
3
|
import React from "react"
|
|
4
|
-
const R = React.createElement
|
|
5
4
|
import uuid from "uuid"
|
|
6
5
|
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
7
6
|
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
@@ -78,18 +77,20 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
renderTable() {
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
return (
|
|
81
|
+
<div className="mb-3">
|
|
82
|
+
<label className="text-muted">
|
|
83
|
+
<i className="fa fa-database" /> {T`Data Source`}
|
|
84
|
+
</label>
|
|
85
|
+
: {" "}
|
|
86
|
+
<TableSelectComponent
|
|
87
|
+
schema={this.props.schema}
|
|
88
|
+
value={this.props.design.table}
|
|
89
|
+
onChange={this.handleTableChange}
|
|
90
|
+
filter={this.props.design.filter}
|
|
91
|
+
onFilterChange={this.handleFilterChange}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
93
94
|
)
|
|
94
95
|
}
|
|
95
96
|
|
|
@@ -99,21 +100,21 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
99
100
|
return null
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
103
|
+
return (
|
|
104
|
+
<div className="mb-3">
|
|
105
|
+
<label className="text-muted">
|
|
106
|
+
<span className="fas fa-filter" /> {T`Filters`}
|
|
107
|
+
</label>
|
|
108
|
+
<div style={{ marginLeft: 8 }}>
|
|
109
|
+
<FilterExprComponent
|
|
110
|
+
schema={this.props.schema}
|
|
111
|
+
dataSource={this.props.dataSource}
|
|
112
|
+
onChange={this.handleFilterChange}
|
|
113
|
+
table={this.props.design.table}
|
|
114
|
+
value={this.props.design.filter}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
117
118
|
)
|
|
118
119
|
}
|
|
119
120
|
|
|
@@ -123,41 +124,41 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
123
124
|
return null
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
return
|
|
127
|
-
ui.FormGroup
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
label: T`Striping`
|
|
131
|
-
},
|
|
132
|
-
<ui.Radio
|
|
133
|
-
key="none"
|
|
134
|
-
inline
|
|
135
|
-
radioValue={null}
|
|
136
|
-
value={this.props.design.striping || null}
|
|
137
|
-
onChange={(value) => this.updateDesign({ striping: value })}
|
|
127
|
+
return (
|
|
128
|
+
<ui.FormGroup
|
|
129
|
+
labelMuted={true}
|
|
130
|
+
label={T`Striping`}
|
|
138
131
|
>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
132
|
+
<ui.Radio
|
|
133
|
+
key="none"
|
|
134
|
+
inline
|
|
135
|
+
radioValue={null}
|
|
136
|
+
value={this.props.design.striping || null}
|
|
137
|
+
onChange={(value) => this.updateDesign({ striping: value })}
|
|
138
|
+
>
|
|
139
|
+
{T`None`}
|
|
140
|
+
</ui.Radio>
|
|
141
|
+
|
|
142
|
+
<ui.Radio
|
|
143
|
+
key="columns"
|
|
144
|
+
inline
|
|
145
|
+
radioValue={"columns"}
|
|
146
|
+
value={this.props.design.striping}
|
|
147
|
+
onChange={(value) => this.updateDesign({ striping: value })}
|
|
148
|
+
>
|
|
149
|
+
{T`Columns`}
|
|
150
|
+
</ui.Radio>
|
|
151
|
+
|
|
152
|
+
<ui.Radio
|
|
153
|
+
key="rows"
|
|
154
|
+
inline
|
|
155
|
+
value={this.props.design.striping}
|
|
156
|
+
radioValue={"rows"}
|
|
157
|
+
onChange={(value) => this.updateDesign({ striping: value })}
|
|
158
|
+
>
|
|
159
|
+
{T`Rows`}
|
|
160
|
+
</ui.Radio>
|
|
161
|
+
</ui.FormGroup>
|
|
161
162
|
)
|
|
162
163
|
}
|
|
163
164
|
|
|
@@ -165,77 +166,71 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
165
166
|
renderSetup() {
|
|
166
167
|
const intersectionId = `${this.props.design.rows[0].id}:${this.props.design.columns[0].id}`
|
|
167
168
|
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
value: this.props.design.intersections[intersectionId].valueAxis,
|
|
223
|
-
onChange: this.handleIntersectionValueAxisChange,
|
|
224
|
-
showFormat: true,
|
|
225
|
-
filters: this.props.filters
|
|
226
|
-
})
|
|
227
|
-
)
|
|
169
|
+
return (
|
|
170
|
+
<div>
|
|
171
|
+
<ui.FormGroup
|
|
172
|
+
labelMuted={true}
|
|
173
|
+
label={T`Columns`}
|
|
174
|
+
help={T`Field to optionally make columns out of`}
|
|
175
|
+
>
|
|
176
|
+
<AxisComponent
|
|
177
|
+
schema={this.props.schema}
|
|
178
|
+
dataSource={this.props.dataSource}
|
|
179
|
+
table={this.props.design.table}
|
|
180
|
+
types={["enum", "enumset", "text", "boolean", "date"]}
|
|
181
|
+
aggrNeed="none"
|
|
182
|
+
value={this.props.design.columns[0].valueAxis}
|
|
183
|
+
onChange={this.handleColumnChange}
|
|
184
|
+
filters={this.props.filters}
|
|
185
|
+
/>
|
|
186
|
+
</ui.FormGroup>
|
|
187
|
+
|
|
188
|
+
<ui.FormGroup
|
|
189
|
+
labelMuted={true}
|
|
190
|
+
label={T`Rows`}
|
|
191
|
+
help={T`Field to optionally make rows out of`}
|
|
192
|
+
>
|
|
193
|
+
<AxisComponent
|
|
194
|
+
schema={this.props.schema}
|
|
195
|
+
dataSource={this.props.dataSource}
|
|
196
|
+
table={this.props.design.table}
|
|
197
|
+
types={["enum", "enumset", "text", "boolean", "date"]}
|
|
198
|
+
aggrNeed="none"
|
|
199
|
+
value={this.props.design.rows[0].valueAxis}
|
|
200
|
+
onChange={this.handleRowChange}
|
|
201
|
+
filters={this.props.filters}
|
|
202
|
+
/>
|
|
203
|
+
</ui.FormGroup>
|
|
204
|
+
|
|
205
|
+
<ui.FormGroup
|
|
206
|
+
labelMuted={true}
|
|
207
|
+
label={T`Value`}
|
|
208
|
+
help={T`Field show in cells`}
|
|
209
|
+
>
|
|
210
|
+
<AxisComponent
|
|
211
|
+
schema={this.props.schema}
|
|
212
|
+
dataSource={this.props.dataSource}
|
|
213
|
+
table={this.props.design.table}
|
|
214
|
+
types={["enum", "text", "boolean", "date", "number"]}
|
|
215
|
+
aggrNeed="required"
|
|
216
|
+
value={this.props.design.intersections[intersectionId].valueAxis}
|
|
217
|
+
onChange={this.handleIntersectionValueAxisChange}
|
|
218
|
+
showFormat={true}
|
|
219
|
+
filters={this.props.filters}
|
|
220
|
+
/>
|
|
221
|
+
</ui.FormGroup>
|
|
222
|
+
</div>
|
|
228
223
|
)
|
|
229
224
|
}
|
|
230
225
|
|
|
231
226
|
render() {
|
|
232
|
-
return
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
227
|
+
return (
|
|
228
|
+
<div>
|
|
229
|
+
{this.renderTable()}
|
|
230
|
+
{this.state.isNew && this.props.design.table ? this.renderSetup() : undefined}
|
|
231
|
+
{this.renderFilter()}
|
|
232
|
+
{this.renderStriping()}
|
|
233
|
+
</div>
|
|
239
234
|
)
|
|
240
235
|
}
|
|
241
236
|
}
|
|
@@ -12,8 +12,10 @@ const maxColumns = 50
|
|
|
12
12
|
|
|
13
13
|
export type PivotChartData = { [intersectionId: string]: any[] }
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Builds pivot table layout from the design and data
|
|
17
|
+
* See PivotChartDesign.ts for more details
|
|
18
|
+
*/
|
|
17
19
|
export default class PivotChartLayoutBuilder {
|
|
18
20
|
schema: Schema
|
|
19
21
|
exprUtils: ExprUtils
|