@mwater/visualization 5.2.0 → 5.3.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/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +5 -16
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +4 -6
- package/lib/MWaterContextComponent.js +4 -13
- package/lib/MWaterLoaderComponent.d.ts +5 -3
- package/lib/MWaterLoaderComponent.js +2 -1
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +3 -1
- package/lib/axes/AxisComponent.d.ts +2 -5
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -12
- package/lib/dashboards/DashboardComponent.js +18 -38
- package/lib/dashboards/DashboardDesign.d.ts +3 -3
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +109 -132
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +211 -42
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.js +87 -33
- package/lib/demo.js +3 -3
- package/lib/index.css +5 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -57
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +2 -1
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/MapComponent.d.ts +1 -4
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +1 -4
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/ServerMapDataSource.d.ts +2 -3
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.js +61 -55
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +1 -2
- package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
- package/lib/widgets/MapWidget.d.ts +2 -0
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -62
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +3 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -112
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +1 -1
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -28
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +11 -11
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +13 -1
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +8 -17
- package/src/MWaterLoaderComponent.ts +6 -3
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/AxisBuilder.ts +7 -5
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +71 -107
- package/src/dashboards/DashboardDesign.ts +3 -3
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +379 -75
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/ServerDatagridDataSource.ts +106 -43
- package/src/demo.ts +3 -3
- package/src/index.css +5 -0
- package/src/index.ts +1 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +2 -1
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/VectorMapViewComponent.tsx +2 -1
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +79 -74
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +13 -14
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +22 -1
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -303
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
2
|
import React from "react"
|
|
3
|
-
const R = React.createElement
|
|
4
|
-
import async from "async"
|
|
5
3
|
import uuid from "uuid"
|
|
6
4
|
import { default as produce } from "immer"
|
|
7
5
|
import { original } from "immer"
|
|
@@ -36,9 +34,12 @@ export default class PivotChart extends Chart {
|
|
|
36
34
|
draft.rows = design.rows || []
|
|
37
35
|
draft.columns = design.columns || []
|
|
38
36
|
draft.intersections = design.intersections || {}
|
|
39
|
-
draft.header = design.header || { style: "
|
|
37
|
+
draft.header = design.header || { style: "header", items: [] }
|
|
40
38
|
draft.footer = design.footer || { style: "footer", items: [] }
|
|
41
39
|
|
|
40
|
+
// Fix style of header
|
|
41
|
+
draft.header.style = "header"
|
|
42
|
+
|
|
42
43
|
if (design.table) {
|
|
43
44
|
// Add default row and column
|
|
44
45
|
let intersectionId, segment
|
|
@@ -93,10 +94,12 @@ export default class PivotChart extends Chart {
|
|
|
93
94
|
// Clean all intersections
|
|
94
95
|
for (intersectionId in draft.intersections) {
|
|
95
96
|
const intersection = draft.intersections[intersectionId]
|
|
97
|
+
const intersectionTable = intersection.tableOverride || design.table
|
|
98
|
+
|
|
96
99
|
if (intersection.valueAxis) {
|
|
97
100
|
intersection.valueAxis = axisBuilder.cleanAxis({
|
|
98
101
|
axis: intersection.valueAxis ? original(intersection.valueAxis) : null,
|
|
99
|
-
table:
|
|
102
|
+
table: intersectionTable,
|
|
100
103
|
aggrNeed: "required",
|
|
101
104
|
types: ["enum", "text", "boolean", "date", "number"]
|
|
102
105
|
})
|
|
@@ -105,7 +108,7 @@ export default class PivotChart extends Chart {
|
|
|
105
108
|
if (intersection.backgroundColorAxis) {
|
|
106
109
|
intersection.backgroundColorAxis = axisBuilder.cleanAxis({
|
|
107
110
|
axis: intersection.backgroundColorAxis ? original(intersection.backgroundColorAxis) : null,
|
|
108
|
-
table:
|
|
111
|
+
table: intersectionTable,
|
|
109
112
|
aggrNeed: "required",
|
|
110
113
|
types: ["enum", "text", "boolean", "date"]
|
|
111
114
|
})
|
|
@@ -117,7 +120,7 @@ export default class PivotChart extends Chart {
|
|
|
117
120
|
|
|
118
121
|
for (const colorCondition of intersection.backgroundColorConditions || []) {
|
|
119
122
|
colorCondition.condition = exprCleaner.cleanExpr(colorCondition.condition ? original(colorCondition.condition)! : null, {
|
|
120
|
-
table:
|
|
123
|
+
table: intersectionTable,
|
|
121
124
|
types: ["boolean"],
|
|
122
125
|
aggrStatuses: ["aggregate", "literal"]
|
|
123
126
|
})
|
|
@@ -125,10 +128,44 @@ export default class PivotChart extends Chart {
|
|
|
125
128
|
|
|
126
129
|
if (intersection.filter) {
|
|
127
130
|
intersection.filter = exprCleaner.cleanExpr(intersection.filter ? original(intersection.filter)! : null, {
|
|
128
|
-
table:
|
|
131
|
+
table: intersectionTable,
|
|
129
132
|
types: ["boolean"]
|
|
130
133
|
})
|
|
131
134
|
}
|
|
135
|
+
|
|
136
|
+
if (intersection.tableOverride) {
|
|
137
|
+
const allSegments = PivotChartUtils.getAllSegments(design.rows).concat(PivotChartUtils.getAllSegments(design.columns))
|
|
138
|
+
|
|
139
|
+
// Clean segment value axis overrides
|
|
140
|
+
intersection.segmentValueAxisOverrides = intersection.segmentValueAxisOverrides || {}
|
|
141
|
+
for (const segmentId of Object.keys(intersection.segmentValueAxisOverrides)) {
|
|
142
|
+
// Find segment
|
|
143
|
+
const segment = allSegments.find((s: PivotChartSegment) => s.id === segmentId)
|
|
144
|
+
if (!segment || !segment.valueAxis) {
|
|
145
|
+
delete intersection.segmentValueAxisOverrides[segmentId]
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Get type of the segment
|
|
150
|
+
const segmentValueAxisType = axisBuilder.getAxisType(segment.valueAxis!)!
|
|
151
|
+
|
|
152
|
+
intersection.segmentValueAxisOverrides[segmentId] = axisBuilder.cleanAxis({
|
|
153
|
+
axis: intersection.segmentValueAxisOverrides[segmentId] ? original(intersection.segmentValueAxisOverrides[segmentId]) : null,
|
|
154
|
+
table: intersectionTable,
|
|
155
|
+
aggrNeed: "none",
|
|
156
|
+
types: [segmentValueAxisType]
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Determine all required segment overrides
|
|
161
|
+
const intersectingSegmentIds = intersectionId.split(/[,:]/).filter(id => id !== "")
|
|
162
|
+
const intersectingSegments = allSegments.filter(segment => intersectingSegmentIds.includes(segment.id) && segment.valueAxis)
|
|
163
|
+
|
|
164
|
+
intersection.segmentValueAxisOverridesComplete = intersectingSegments.every(segment => intersection.segmentValueAxisOverrides![segment.id])
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
delete intersection.segmentValueAxisOverridesComplete
|
|
168
|
+
}
|
|
132
169
|
}
|
|
133
170
|
|
|
134
171
|
// Get all intersection ids
|
|
@@ -201,6 +238,12 @@ export default class PivotChart extends Chart {
|
|
|
201
238
|
if (intersection.valueAxis) {
|
|
202
239
|
error = error || axisBuilder.validateAxis({ axis: intersection.valueAxis })
|
|
203
240
|
}
|
|
241
|
+
|
|
242
|
+
if (intersection.segmentValueAxisOverrides) {
|
|
243
|
+
for (const segmentId of Object.keys(intersection.segmentValueAxisOverrides)) {
|
|
244
|
+
error = error || axisBuilder.validateAxis({ axis: intersection.segmentValueAxisOverrides[segmentId] })
|
|
245
|
+
}
|
|
246
|
+
}
|
|
204
247
|
}
|
|
205
248
|
|
|
206
249
|
return error
|
|
@@ -314,17 +357,12 @@ export default class PivotChart extends Chart {
|
|
|
314
357
|
}
|
|
315
358
|
}
|
|
316
359
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
// data: results from queries
|
|
324
|
-
// width, height: size of the chart view
|
|
325
|
-
// scope: current scope of the view element
|
|
326
|
-
// onScopeChange: called when scope changes with new scope
|
|
327
|
-
// filters: array of filters
|
|
360
|
+
/**
|
|
361
|
+
* Create a view element for the chart
|
|
362
|
+
*
|
|
363
|
+
* @param options - Options for the view element
|
|
364
|
+
* @returns - React element
|
|
365
|
+
*/
|
|
328
366
|
createViewElement(options: ChartCreateViewElementOptions) {
|
|
329
367
|
const PivotChartViewComponent = require("./PivotChartViewComponent").default
|
|
330
368
|
|
|
@@ -112,4 +112,16 @@ export interface PivotChartIntersection {
|
|
|
112
112
|
|
|
113
113
|
/** true if italic */
|
|
114
114
|
italic?: boolean
|
|
115
|
+
|
|
116
|
+
/** Overrides table */
|
|
117
|
+
tableOverride?: string
|
|
118
|
+
|
|
119
|
+
/** If table is overridden, each related segment needs to have its valueAxis overridden */
|
|
120
|
+
segmentValueAxisOverrides?: { [id: string]: Axis | null }
|
|
121
|
+
|
|
122
|
+
/** Set true when overrides are all present. If false and tableOverride is not null, then intersection cannot be rendered.
|
|
123
|
+
* This is set by cleanDesign. If some are missing, the design is still valid, but the intersection will not be queried
|
|
124
|
+
* and the intersection will be shaded red in design mode.
|
|
125
|
+
*/
|
|
126
|
+
segmentValueAxisOverridesComplete?: boolean
|
|
115
127
|
}
|
|
@@ -8,6 +8,7 @@ import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
|
8
8
|
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
9
9
|
import AxisComponent from "../../../axes/AxisComponent"
|
|
10
10
|
import { DataSource, Schema } from "@mwater/expressions"
|
|
11
|
+
import { PivotChartIntersection } from "./PivotChartDesign"
|
|
11
12
|
|
|
12
13
|
export interface PivotChartDesignerComponentProps {
|
|
13
14
|
design: any
|
|
@@ -45,10 +46,10 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
45
46
|
const row = { id: uuid(), label: "" }
|
|
46
47
|
const column = { id: uuid(), label: "" }
|
|
47
48
|
|
|
48
|
-
const intersections = {}
|
|
49
|
+
const intersections: { [key: string]: PivotChartIntersection } = {}
|
|
49
50
|
intersections[`${row.id}:${column.id}`] = { valueAxis: { expr: { type: "op", op: "count", table, exprs: [] } } }
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
this.updateDesign({
|
|
52
53
|
table,
|
|
53
54
|
rows: [row],
|
|
54
55
|
columns: [column],
|
|
@@ -71,7 +72,7 @@ export default class PivotChartDesignerComponent extends React.Component<
|
|
|
71
72
|
handleIntersectionValueAxisChange = (valueAxis: any) => {
|
|
72
73
|
const intersectionId = `${this.props.design.rows[0].id}:${this.props.design.columns[0].id}`
|
|
73
74
|
|
|
74
|
-
const intersections = {}
|
|
75
|
+
const intersections: { [key: string]: PivotChartIntersection } = {}
|
|
75
76
|
intersections[intersectionId] = { valueAxis }
|
|
76
77
|
return this.updateDesign({ intersections })
|
|
77
78
|
}
|
|
@@ -118,7 +118,7 @@ export default class PivotChartLayoutBuilder {
|
|
|
118
118
|
for (let row of rows) {
|
|
119
119
|
// Emit special row header for any segments that have changed and have both axis and label
|
|
120
120
|
const needsSpecialRowHeader = []
|
|
121
|
-
for (let depth = 0; depth < rowsDepth; depth++) {
|
|
121
|
+
for (let depth = 0; depth < rowsDepth; depth++) {
|
|
122
122
|
if (
|
|
123
123
|
row[depth] &&
|
|
124
124
|
rowSegments[depth] !== row[depth].segment &&
|
|
@@ -210,7 +210,7 @@ export default class PivotChartLayoutBuilder {
|
|
|
210
210
|
|
|
211
211
|
// Set up section top/left/bottom/right info
|
|
212
212
|
for (let columnIndex = 0; columnIndex < layout.rows[0].cells.length; columnIndex++) {
|
|
213
|
-
for (let rowIndex = 0; rowIndex < layout.rows.length; rowIndex++) {
|
|
213
|
+
for (let rowIndex = 0; rowIndex < layout.rows.length; rowIndex++) {
|
|
214
214
|
cell = layout.rows[rowIndex].cells[columnIndex]
|
|
215
215
|
|
|
216
216
|
cell.sectionTop =
|
|
@@ -349,10 +349,10 @@ export default class PivotChartLayoutBuilder {
|
|
|
349
349
|
// from getRowsOrColumns
|
|
350
350
|
// dataIndexed is created above. See there for format
|
|
351
351
|
buildIntersectionCell(
|
|
352
|
-
design: PivotChartDesign,
|
|
353
|
-
dataIndexed: any,
|
|
354
|
-
locale: string,
|
|
355
|
-
row: { segment: PivotChartSegment, label: string, value: any }[],
|
|
352
|
+
design: PivotChartDesign,
|
|
353
|
+
dataIndexed: any,
|
|
354
|
+
locale: string,
|
|
355
|
+
row: { segment: PivotChartSegment, label: string, value: any }[],
|
|
356
356
|
column: { segment: PivotChartSegment, label: string, value: any }[]) {
|
|
357
357
|
|
|
358
358
|
// Get intersection id
|
|
@@ -420,7 +420,12 @@ export default class PivotChartLayoutBuilder {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
if (!backgroundColor && intersection.backgroundColor && !intersection.backgroundColorAxis) {
|
|
423
|
-
;({ backgroundColor } = intersection)
|
|
423
|
+
; ({ backgroundColor } = intersection)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Override to light red if segment value axis overrides are incomplete
|
|
427
|
+
if (intersection.tableOverride && !intersection.segmentValueAxisOverridesComplete) {
|
|
428
|
+
backgroundColor = "#FFCDCD"
|
|
424
429
|
}
|
|
425
430
|
|
|
426
431
|
if (backgroundColor) {
|
|
@@ -433,29 +438,20 @@ export default class PivotChartLayoutBuilder {
|
|
|
433
438
|
|
|
434
439
|
// Determine summarize value for unconfigured cells
|
|
435
440
|
setupSummarize(design: any, layout: any) {
|
|
436
|
-
|
|
437
|
-
(
|
|
438
|
-
const
|
|
439
|
-
for (
|
|
440
|
-
let rowIndex = 0, end = layout.rows.length, asc = 0 <= end;
|
|
441
|
-
asc ? rowIndex < end : rowIndex > end;
|
|
442
|
-
asc ? rowIndex++ : rowIndex--
|
|
443
|
-
) {
|
|
444
|
-
const cell = layout.rows[rowIndex].cells[columnIndex]
|
|
441
|
+
for (let columnIndex = 0; columnIndex < layout.rows[0].cells.length; columnIndex++) {
|
|
442
|
+
for (let rowIndex = 0; rowIndex < layout.rows.length; rowIndex++) {
|
|
443
|
+
const cell = layout.rows[rowIndex].cells[columnIndex]
|
|
445
444
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
445
|
+
if (cell.unconfigured && cell.type === "row") {
|
|
446
|
+
cell.summarize = PivotChartUtils.canSummarizeSegment(design.rows, cell.section)
|
|
447
|
+
}
|
|
449
448
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
} else {
|
|
453
|
-
result.push(undefined)
|
|
454
|
-
}
|
|
449
|
+
if (cell.unconfigured && cell.type === "column") {
|
|
450
|
+
cell.summarize = PivotChartUtils.canSummarizeSegment(design.columns, cell.section)
|
|
455
451
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
}
|
|
459
455
|
}
|
|
460
456
|
|
|
461
457
|
// Determine borders, mutating cells
|
|
@@ -463,7 +459,6 @@ export default class PivotChartLayoutBuilder {
|
|
|
463
459
|
// Set up borders for row and column cells
|
|
464
460
|
let cell, columnIndex, rowIndex
|
|
465
461
|
let asc, end
|
|
466
|
-
let asc2, end2
|
|
467
462
|
const borderTops: any = [] // Array of border top information for intersections. index is layout row number
|
|
468
463
|
const borderBottoms: any = [] // Array of border bottom information for intersections. index is layout row number
|
|
469
464
|
const borderLefts: any = [] // Array of border left information for intersections. index is layout column number
|
|
@@ -584,17 +579,8 @@ export default class PivotChartLayoutBuilder {
|
|
|
584
579
|
}
|
|
585
580
|
|
|
586
581
|
// Propagate borders across row cells and down column cells so that heavier border win
|
|
587
|
-
for (
|
|
588
|
-
|
|
589
|
-
asc2 ? columnIndex < end2 : columnIndex > end2;
|
|
590
|
-
asc2 ? columnIndex++ : columnIndex--
|
|
591
|
-
) {
|
|
592
|
-
var asc3, end3
|
|
593
|
-
for (
|
|
594
|
-
rowIndex = 1, end3 = layout.rows.length, asc3 = 1 <= end3;
|
|
595
|
-
asc3 ? rowIndex < end3 : rowIndex > end3;
|
|
596
|
-
asc3 ? rowIndex++ : rowIndex--
|
|
597
|
-
) {
|
|
582
|
+
for (let columnIndex = 1; columnIndex < layout.rows[0].cells.length; columnIndex++) {
|
|
583
|
+
for (let rowIndex = 1; rowIndex < layout.rows.length; rowIndex++) {
|
|
598
584
|
cell = layout.rows[rowIndex].cells[columnIndex]
|
|
599
585
|
|
|
600
586
|
if (cell.type === "row") {
|
|
@@ -610,41 +596,19 @@ export default class PivotChartLayoutBuilder {
|
|
|
610
596
|
}
|
|
611
597
|
|
|
612
598
|
// Setup borders of intersections
|
|
613
|
-
|
|
614
|
-
let
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const result1 = []
|
|
625
|
-
for (
|
|
626
|
-
rowIndex = 0, end5 = layout.rows.length, asc5 = 0 <= end5;
|
|
627
|
-
asc5 ? rowIndex < end5 : rowIndex > end5;
|
|
628
|
-
asc5 ? rowIndex++ : rowIndex--
|
|
629
|
-
) {
|
|
630
|
-
cell = layout.rows[rowIndex].cells[columnIndex]
|
|
631
|
-
|
|
632
|
-
if (cell.type === "intersection") {
|
|
633
|
-
cell.borderLeft = borderLefts[columnIndex]
|
|
634
|
-
cell.borderRight = borderRights[columnIndex]
|
|
635
|
-
|
|
636
|
-
cell.borderTop = borderTops[rowIndex]
|
|
637
|
-
result1.push((cell.borderBottom = borderBottoms[rowIndex]))
|
|
638
|
-
} else {
|
|
639
|
-
result1.push(undefined)
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
return result1
|
|
643
|
-
})()
|
|
644
|
-
)
|
|
599
|
+
for (let columnIndex = 0; columnIndex < layout.rows[0].cells.length; columnIndex++) {
|
|
600
|
+
for (let rowIndex = 0; rowIndex < layout.rows.length; rowIndex++) {
|
|
601
|
+
cell = layout.rows[rowIndex].cells[columnIndex]
|
|
602
|
+
|
|
603
|
+
if (cell.type === "intersection") {
|
|
604
|
+
cell.borderLeft = borderLefts[columnIndex]
|
|
605
|
+
cell.borderRight = borderRights[columnIndex]
|
|
606
|
+
|
|
607
|
+
cell.borderTop = borderTops[rowIndex]
|
|
608
|
+
cell.borderBottom = borderBottoms[rowIndex]
|
|
609
|
+
}
|
|
645
610
|
}
|
|
646
|
-
|
|
647
|
-
})()
|
|
611
|
+
}
|
|
648
612
|
}
|
|
649
613
|
|
|
650
614
|
// Get rows or columns in format of array of
|
|
@@ -652,8 +616,7 @@ export default class PivotChartLayoutBuilder {
|
|
|
652
616
|
// For segments with no children, there will be an array of single value array entries (array of array)
|
|
653
617
|
// data is lookup of query results by intersection id
|
|
654
618
|
// parentSegments are ancestry of current segment, starting with root
|
|
655
|
-
getRowsOrColumns(isRow: boolean, segment: PivotChartSegment, data: { [intersectionId: string]: any[] }, locale: string, parentSegments: PivotChartSegment[] = [], parentValues: any[] = []):
|
|
656
|
-
{ segment: PivotChartSegment, label: string, value: any }[][] {
|
|
619
|
+
getRowsOrColumns(isRow: boolean, segment: PivotChartSegment, data: { [intersectionId: string]: any[] }, locale: string, parentSegments: PivotChartSegment[] = [], parentValues: any[] = []): { segment: PivotChartSegment, label: string, value: any }[][] {
|
|
657
620
|
// If no axis, categories are just null
|
|
658
621
|
let categories, value
|
|
659
622
|
if (!segment.valueAxis) {
|
|
@@ -710,7 +673,7 @@ export default class PivotChartLayoutBuilder {
|
|
|
710
673
|
|
|
711
674
|
// Get categories, mapping label
|
|
712
675
|
categories = _.map(this.axisBuilder.getCategories(segment.valueAxis, allValues, { locale, onlyValuesPresent: segment.valueAxisOnlyValuesPresent }), (category) => {
|
|
713
|
-
return { value: category.value, label: this.axisBuilder.formatCategory(segment.valueAxis
|
|
676
|
+
return { value: category.value, label: this.axisBuilder.formatCategory(segment.valueAxis!, category) }
|
|
714
677
|
})
|
|
715
678
|
|
|
716
679
|
// Filter excluded values
|