@mwater/visualization 5.4.5 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.storybook/head.html +0 -1
  2. package/lib/MWaterContextComponent.js +1 -1
  3. package/lib/MWaterLoaderComponent.d.ts +2 -2
  4. package/lib/dashboards/DashboardComponent.js +2 -1
  5. package/lib/dashboards/LayoutOptionsComponent.js +18 -11
  6. package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
  7. package/lib/dashboards/ServerDashboardDataSource.js +29 -0
  8. package/lib/dashboards/layoutOptions.d.ts +5 -1
  9. package/lib/datagrids/DatagridComponent.js +1 -1
  10. package/lib/datagrids/ExprCellComponent.d.ts +1 -0
  11. package/lib/datagrids/ExprCellComponent.js +22 -20
  12. package/lib/maps/BufferLayer.d.ts +18 -0
  13. package/lib/maps/BufferLayer.js +24 -14
  14. package/lib/maps/ChoroplethLayer.d.ts +18 -0
  15. package/lib/maps/ChoroplethLayer.js +34 -25
  16. package/lib/maps/ChoroplethLayerDesign.d.ts +3 -2
  17. package/lib/maps/ChoroplethLayerDesigner.d.ts +11 -1
  18. package/lib/maps/DirectMapDataSource.js +17 -0
  19. package/lib/maps/EditHoverOver.d.ts +1 -1
  20. package/lib/maps/EditHoverOver.js +62 -33
  21. package/lib/maps/HoverContent.d.ts +10 -5
  22. package/lib/maps/HoverContent.js +6 -35
  23. package/lib/maps/Layer.d.ts +37 -0
  24. package/lib/maps/Layer.js +30 -4
  25. package/lib/maps/MWaterServerLayer.d.ts +2 -2
  26. package/lib/maps/MWaterServerLayer.js +6 -6
  27. package/lib/maps/MapLayerDataSource.d.ts +9 -0
  28. package/lib/maps/MapUtils.d.ts +19 -1
  29. package/lib/maps/MapUtils.js +71 -1
  30. package/lib/maps/MarkersLayer.d.ts +18 -0
  31. package/lib/maps/MarkersLayer.js +24 -24
  32. package/lib/maps/MarkersLayerDesignerComponent.d.ts +14 -1
  33. package/lib/maps/RasterMapViewComponent.js +1 -1
  34. package/lib/maps/ServerMapDataSource.d.ts +9 -0
  35. package/lib/maps/ServerMapDataSource.js +29 -0
  36. package/lib/maps/VectorMapViewComponent.js +6 -6
  37. package/lib/maps/maps.d.ts +4 -2
  38. package/lib/mwater_table_selection/FormsListComponent.d.ts +33 -0
  39. package/lib/mwater_table_selection/FormsListComponent.js +141 -0
  40. package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +47 -0
  41. package/lib/mwater_table_selection/IndicatorsListComponent.js +182 -0
  42. package/lib/mwater_table_selection/IssuesListComponent.d.ts +29 -0
  43. package/lib/mwater_table_selection/IssuesListComponent.js +123 -0
  44. package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.d.ts +20 -0
  45. package/lib/mwater_table_selection/MWaterAccountingSystemListComponent.js +157 -0
  46. package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.d.ts +17 -0
  47. package/lib/mwater_table_selection/MWaterAssetSystemsListComponent.js +79 -0
  48. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +37 -0
  49. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +275 -0
  50. package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.d.ts +17 -0
  51. package/lib/mwater_table_selection/MWaterCustomTablesetListComponent.js +94 -0
  52. package/lib/mwater_table_selection/MWaterMetricsTableListComponent.d.ts +17 -0
  53. package/lib/mwater_table_selection/MWaterMetricsTableListComponent.js +80 -0
  54. package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +32 -0
  55. package/lib/mwater_table_selection/MWaterTableSelectComponent.js +158 -0
  56. package/lib/widgets/charts/Chart.d.ts +11 -0
  57. package/lib/widgets/charts/Chart.js +15 -0
  58. package/lib/widgets/charts/ChartWidgetComponent.d.ts +1 -0
  59. package/lib/widgets/charts/ChartWidgetComponent.js +27 -1
  60. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +1 -1
  61. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +1 -1
  62. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +5 -12
  63. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +43 -57
  64. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +113 -110
  65. package/lib/widgets/charts/layered/LayeredChartUtils.d.ts +2 -1
  66. package/lib/widgets/charts/layered/LayeredChartUtils.js +0 -2
  67. package/lib/widgets/charts/pivot/PivotChart.d.ts +2 -0
  68. package/lib/widgets/charts/pivot/PivotChart.js +156 -0
  69. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -20
  70. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +31 -61
  71. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +4 -0
  72. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +4 -2
  73. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.d.ts +5 -44
  74. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +38 -63
  75. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +7 -68
  76. package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +58 -106
  77. package/lib/widgets/charts/table/TableChart.d.ts +2 -0
  78. package/lib/widgets/charts/table/TableChart.js +172 -1
  79. package/lib/widgets/charts/table/TableChartDesignerComponent.d.ts +7 -17
  80. package/lib/widgets/charts/table/TableChartDesignerComponent.js +79 -95
  81. package/lib/widgets/charts/table/TableChartViewComponent.d.ts +1 -7
  82. package/lib/widgets/charts/table/TableChartViewComponent.js +19 -27
  83. package/package.json +3 -8
  84. package/src/MWaterContextComponent.tsx +1 -1
  85. package/src/MWaterLoaderComponent.ts +1 -1
  86. package/src/dashboards/DashboardComponent.tsx +2 -1
  87. package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
  88. package/src/dashboards/ServerDashboardDataSource.ts +36 -1
  89. package/src/dashboards/layoutOptions.tsx +5 -1
  90. package/src/datagrids/DatagridComponent.tsx +1 -1
  91. package/src/datagrids/ExprCellComponent.tsx +23 -20
  92. package/src/maps/BufferLayer.ts +35 -20
  93. package/src/maps/ChoroplethLayer.ts +51 -33
  94. package/src/maps/ChoroplethLayerDesign.ts +3 -2
  95. package/src/maps/ChoroplethLayerDesigner.tsx +2 -2
  96. package/src/maps/DirectMapDataSource.ts +21 -1
  97. package/src/maps/EditHoverOver.tsx +91 -51
  98. package/src/maps/HoverContent.tsx +16 -47
  99. package/src/maps/Layer.ts +42 -4
  100. package/src/maps/MWaterServerLayer.ts +6 -6
  101. package/src/maps/MapLayerDataSource.ts +8 -0
  102. package/src/maps/MapUtils.ts +70 -3
  103. package/src/maps/MarkersLayer.ts +34 -24
  104. package/src/maps/RasterMapViewComponent.ts +1 -1
  105. package/src/maps/ServerMapDataSource.ts +35 -0
  106. package/src/maps/VectorMapViewComponent.tsx +6 -6
  107. package/src/maps/maps.ts +4 -2
  108. package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
  109. package/src/mwater_table_selection/IndicatorsListComponent.tsx +283 -0
  110. package/src/mwater_table_selection/IssuesListComponent.tsx +167 -0
  111. package/src/mwater_table_selection/MWaterAccountingSystemListComponent.tsx +225 -0
  112. package/src/{MWaterAssetSystemsListComponent.tsx → mwater_table_selection/MWaterAssetSystemsListComponent.tsx} +2 -2
  113. package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +377 -0
  114. package/src/{MWaterCustomTablesetListComponent.tsx → mwater_table_selection/MWaterCustomTablesetListComponent.tsx} +1 -1
  115. package/src/{MWaterMetricsTableListComponent.tsx → mwater_table_selection/MWaterMetricsTableListComponent.tsx} +1 -1
  116. package/src/{MWaterTableSelectComponent.tsx → mwater_table_selection/MWaterTableSelectComponent.tsx} +83 -86
  117. package/src/widgets/charts/Chart.ts +17 -0
  118. package/src/widgets/charts/ChartWidgetComponent.tsx +36 -1
  119. package/src/widgets/charts/layered/LayeredChartDesign.ts +1 -1
  120. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +23 -24
  121. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +260 -211
  122. package/src/widgets/charts/layered/LayeredChartUtils.ts +7 -7
  123. package/src/widgets/charts/pivot/PivotChart.ts +191 -0
  124. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +124 -129
  125. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +4 -2
  126. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +120 -149
  127. package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +178 -198
  128. package/src/widgets/charts/table/TableChart.ts +177 -1
  129. package/src/widgets/charts/table/TableChartDesignerComponent.tsx +422 -0
  130. package/src/widgets/charts/table/{TableChartViewComponent.ts → TableChartViewComponent.tsx} +65 -60
  131. package/src/MWaterCompleteTableSelectComponent.tsx +0 -975
  132. package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
@@ -1,11 +1,8 @@
1
- import _ from "lodash"
2
- import PropTypes from "prop-types"
3
1
  import React from "react"
4
- const R = React.createElement
5
2
  import AxisComponent from "../../../axes/AxisComponent"
6
3
  import AxisBuilder from "../../../axes/AxisBuilder"
7
4
  import { FilterExprComponent } from "@mwater/expressions-ui"
8
- import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
5
+ import { DataSource, Schema, LiteralType, Expr } from "@mwater/expressions"
9
6
  import { ExprCompiler } from "@mwater/expressions"
10
7
  import ColorComponent from "../../../ColorComponent"
11
8
  import * as LayeredChartUtils from "./LayeredChartUtils"
@@ -15,61 +12,65 @@ import { TableSelectComponent } from "@mwater/expressions-ui"
15
12
  import * as ui from "@mwater/react-library/lib/bootstrap"
16
13
  import { Checkbox } from "@mwater/react-library/lib/bootstrap"
17
14
  import PopoverHelpComponent from "@mwater/react-library/lib/PopoverHelpComponent"
15
+ import { LayeredChartDesignLayer, LayeredChartDesign } from "./LayeredChartDesign"
16
+ import { Axis } from "../../../axes/Axis"
17
+ import { JsonQLFilter } from "@mwater/visualization"
18
18
 
19
19
  export interface LayeredChartLayerDesignerComponentProps {
20
- design: any
20
+ design: LayeredChartDesign
21
21
  schema: Schema
22
22
  dataSource: DataSource
23
23
  index: number
24
- onChange: any
25
- onRemove: any
26
- filters?: any
24
+ onChange: (layer: LayeredChartDesignLayer) => void
25
+ onRemove: () => void
26
+ filters?: JsonQLFilter[]
27
27
  }
28
28
 
29
29
  export default class LayeredChartLayerDesignerComponent extends React.Component<LayeredChartLayerDesignerComponentProps> {
30
- isLayerPolar(layer: any) {
30
+ isLayerPolar(layer: LayeredChartDesignLayer) {
31
31
  return ["pie", "donut"].includes(layer.type || this.props.design.type)
32
32
  }
33
33
 
34
- doesLayerNeedGrouping(layer: any) {
34
+ doesLayerNeedGrouping(layer: LayeredChartDesignLayer) {
35
35
  return !["scatter"].includes(layer.type || this.props.design.type)
36
36
  }
37
37
 
38
38
  // Determine if x-axis required
39
- isXAxisRequired(layer: any) {
39
+ isXAxisRequired(layer: LayeredChartDesignLayer) {
40
40
  return !this.isLayerPolar(layer)
41
41
  }
42
42
 
43
- getAxisTypes(layer: any, axisKey: any) {
44
- return LayeredChartUtils.getAxisTypes(this.props.design, layer, axisKey)
43
+ getAxisTypes(layer: LayeredChartDesignLayer, axisKey: any): LiteralType[] | undefined {
44
+ const types = LayeredChartUtils.getAxisTypes(this.props.design, layer, axisKey)
45
+ return types ?? undefined
45
46
  }
46
47
 
47
48
  getAxisLabel(icon: any, label: any) {
48
- return R("span", null, R("span", { className: "glyphicon glyphicon-" + icon }), " " + label)
49
+ return <span><i className={`fas fa-${icon}`}/> {label}</span>
49
50
  }
50
51
 
51
52
  // Determine icon/label for color axis
52
- getXAxisLabel(layer: any) {
53
+ getXAxisLabel(layer: LayeredChartDesignLayer) {
53
54
  if (this.props.design.transpose) {
54
- return this.getAxisLabel("resize-vertical", T`Vertical Axis`)
55
+ return this.getAxisLabel("arrows-v", T`Vertical Axis`)
55
56
  } else {
56
- return this.getAxisLabel("resize-horizontal", T`Horizontal Axis`)
57
+ return this.getAxisLabel("arrows-h", T`Horizontal Axis`)
57
58
  }
58
59
  }
59
60
 
60
61
  // Determine icon/label for color axis
61
- getYAxisLabel(layer: any) {
62
+ getYAxisLabel(layer: LayeredChartDesignLayer) {
62
63
  if (this.isLayerPolar(layer)) {
63
64
  return this.getAxisLabel("repeat", T`Angle Axis`)
64
65
  } else if (this.props.design.transpose) {
65
- return this.getAxisLabel("resize-horizontal", T`Horizontal Axis`)
66
+ return this.getAxisLabel("arrows-h", T`Horizontal Axis`)
66
67
  } else {
67
- return this.getAxisLabel("resize-vertical", T`Vertical Axis`)
68
+ return this.getAxisLabel("arrows-v", T`Vertical Axis`)
68
69
  }
69
70
  }
70
71
 
71
72
  // Determine icon/label for color axis
72
- getColorAxisLabel(layer: any) {
73
+ getColorAxisLabel(layer: LayeredChartDesignLayer) {
73
74
  if (this.isLayerPolar(layer)) {
74
75
  return this.getAxisLabel("text-color", T`Label Axis`)
75
76
  } else {
@@ -78,25 +79,30 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
78
79
  }
79
80
 
80
81
  // Updates layer with the specified changes
81
- updateLayer(changes: any) {
82
- const layer = _.extend({}, this.props.design.layers[this.props.index], changes)
82
+ updateLayer(changes: Partial<LayeredChartDesignLayer>) {
83
+ const layer = { ...this.props.design.layers[this.props.index], ...changes }
83
84
  return this.props.onChange(layer)
84
85
  }
85
86
 
86
87
  // Update axes with specified changes
87
- updateAxes(changes: any) {
88
- const axes = _.extend({}, this.props.design.layers[this.props.index].axes, changes)
88
+ updateAxes(changes: Partial<LayeredChartDesignLayer["axes"]>) {
89
+ const axes = { ...this.props.design.layers[this.props.index].axes, ...changes }
89
90
  return this.updateLayer({ axes })
90
91
  }
91
92
 
92
93
  handleNameChange = (ev: any) => {
93
94
  return this.updateLayer({ name: ev.target.value })
94
95
  }
95
- handleTableChange = (table: any) => {
96
+
97
+ handleLayerTypeChange = (type: LayeredChartDesignLayer["type"]) => {
98
+ this.updateLayer({ type: type === this.props.design.type ? undefined : type })
99
+ }
100
+
101
+ handleTableChange = (table: string) => {
96
102
  return this.updateLayer({ table })
97
103
  }
98
104
 
99
- handleXAxisChange = (axis: any) => {
105
+ handleXAxisChange = (axis: Axis) => {
100
106
  const layer = this.props.design.layers[this.props.index]
101
107
  const axesChanges: any = { x: axis }
102
108
 
@@ -108,12 +114,11 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
108
114
  return this.updateAxes(axesChanges)
109
115
  }
110
116
 
111
- handleXColorMapChange = (xColorMap: any) => {
112
- const layer = this.props.design.layers[this.props.index]
117
+ handleXColorMapChange = (xColorMap: boolean) => {
113
118
  return this.updateLayer({ xColorMap })
114
119
  }
115
120
 
116
- handleColorAxisChange = (axis: any) => {
121
+ handleColorAxisChange = (axis: Axis) => {
117
122
  const layer = this.props.design.layers[this.props.index]
118
123
  const axesChanges: any = { color: axis }
119
124
 
@@ -125,64 +130,117 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
125
130
  return this.updateAxes(axesChanges)
126
131
  }
127
132
 
128
- handleYAxisChange = (axis: any) => {
133
+ handleYAxisChange = (axis: Axis) => {
129
134
  return this.updateAxes({ y: axis })
130
135
  }
131
- handleFilterChange = (filter: any) => {
136
+ handleFilterChange = (filter: Expr) => {
132
137
  return this.updateLayer({ filter })
133
138
  }
134
- handleColorChange = (color: any) => {
139
+ handleColorChange = (color: string) => {
135
140
  return this.updateLayer({ color })
136
141
  }
137
- handleCumulativeChange = (value: any) => {
142
+ handleCumulativeChange = (value: boolean) => {
138
143
  return this.updateLayer({ cumulative: value })
139
144
  }
140
- handleTrendlineChange = (value: any) => {
145
+ handleTrendlineChange = (value: boolean) => {
141
146
  return this.updateLayer({ trendline: value ? "linear" : undefined })
142
147
  }
143
- handleStackedChange = (value: any) => {
148
+ handleStackedChange = (value: boolean) => {
144
149
  return this.updateLayer({ stacked: value })
145
150
  }
146
151
 
147
152
  renderName() {
148
153
  const layer = this.props.design.layers[this.props.index]
149
-
150
- // R 'div', className: "form-group",
151
- // R 'label', className: "text-muted", "Series Name"
152
154
  const placeholder = this.props.design.layers.length === 1 ? T`Value` : T`Series ${this.props.index + 1}`
153
- return R("input", {
154
- type: "text",
155
- className: "form-control form-control-sm",
156
- value: layer.name,
157
- onChange: this.handleNameChange,
158
- placeholder
159
- })
155
+ return <input
156
+ type="text"
157
+ className="form-control form-control-sm"
158
+ value={layer.name}
159
+ onChange={this.handleNameChange}
160
+ placeholder={placeholder}
161
+ />
160
162
  }
161
163
 
162
164
  renderRemove() {
163
165
  if (this.props.design.layers.length > 1) {
164
- return R(
165
- "button",
166
- { className: "btn btn-sm btn-link float-end", type: "button", onClick: this.props.onRemove },
167
- R("span", { className: "fas fa-times" })
166
+ return (
167
+ <button className="btn btn-sm btn-link float-end" type="button" onClick={this.props.onRemove}>
168
+ <span className="fas fa-times"/>
169
+ </button>
168
170
  )
169
171
  }
170
- return null
172
+ return undefined
171
173
  }
172
174
 
173
175
  renderTable() {
174
176
  const layer = this.props.design.layers[this.props.index]
175
177
 
176
- return R(
177
- uiComponents.SectionComponent,
178
- { icon: "fa-database", label: T`Data Source` },
179
- R(TableSelectComponent, {
180
- schema: this.props.schema,
181
- value: layer.table,
182
- onChange: this.handleTableChange,
183
- filter: layer.filter,
184
- onFilterChange: this.handleFilterChange
185
- })
178
+ return (
179
+ <uiComponents.SectionComponent icon="fa-database" label={T`Data Source`}>
180
+ <TableSelectComponent
181
+ schema={this.props.schema}
182
+ value={layer.table}
183
+ onChange={this.handleTableChange}
184
+ filter={layer.filter}
185
+ onFilterChange={this.handleFilterChange}
186
+ />
187
+ </uiComponents.SectionComponent>
188
+ )
189
+ }
190
+
191
+ renderLayerTypeSelector() {
192
+ const layer = this.props.design.layers[this.props.index]
193
+ const { design, index } = this.props
194
+
195
+ if (index === 0) {
196
+ return null
197
+ }
198
+
199
+ const mainType = design.type
200
+ const isMainPolar = ["pie", "donut"].includes(mainType)
201
+
202
+ const compatibleTypes: { value: LayeredChartDesignLayer["type"]; label: string; name?: string }[] = isMainPolar
203
+ ? [
204
+ { value: "pie", label: T`Pie` },
205
+ { value: "donut", label: T`Donut` }
206
+ ]
207
+ : [
208
+ { value: "bar", label: T`Bar` },
209
+ { value: "line", label: T`Line` },
210
+ { value: "spline", label: T`Smoothed Line` },
211
+ { value: "area", label: T`Area` }
212
+ ]
213
+
214
+ // Add the main type as the first option if it's not already there (e.g. if main is scatter)
215
+ if (!compatibleTypes.some((t) => t.value === mainType)) {
216
+ compatibleTypes.unshift({ value: mainType as any, label: T(mainType) })
217
+ }
218
+
219
+ // Assign names for OptionListComponent
220
+ compatibleTypes.forEach((t) => (t.name = t.label))
221
+
222
+ const currentType = layer.type || mainType
223
+ const currentTypeLabel = compatibleTypes.find((t) => t.value === currentType)?.label || T(currentType)
224
+
225
+ return (
226
+ <div className="mb-3">
227
+ <label className="text-muted">{T`Layer Chart Type`}</label>
228
+ <uiComponents.ToggleEditComponent
229
+ label={currentTypeLabel}
230
+ editor={(onClose: any) => (
231
+ <uiComponents.OptionListComponent
232
+ hint={T`Select a Chart Type`}
233
+ items={compatibleTypes.map((ct) => ({
234
+ name: ct.name || "",
235
+ onClick: () => {
236
+ onClose() // Close editor first
237
+ return this.handleLayerTypeChange(ct.value)
238
+ }
239
+ }))}
240
+ />
241
+ )}
242
+ />
243
+ </div>
186
244
  )
187
245
  }
188
246
 
@@ -193,122 +251,119 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
193
251
  renderXAxis() {
194
252
  const layer = this.props.design.layers[this.props.index]
195
253
  if (!layer.table) {
196
- return
254
+ return undefined
197
255
  }
198
256
 
199
257
  if (!this.isXAxisRequired(layer)) {
200
- return
258
+ return undefined
201
259
  }
202
260
 
203
261
  const title = this.getXAxisLabel(layer)
204
262
 
205
- const filters = _.clone(this.props.filters) || []
263
+ const filters = this.props.filters ? this.props.filters.slice() : []
206
264
  if (layer.filter != null) {
207
265
  const exprCompiler = new ExprCompiler(this.props.schema)
208
266
  const jsonql = exprCompiler.compileExpr({ expr: layer.filter, tableAlias: "{alias}" })
209
267
 
210
268
  if (jsonql) {
211
- filters.push({ table: layer.filter.table, jsonql })
269
+ filters.push({ table: (layer.filter as any).table, jsonql })
212
270
  }
213
271
  }
214
272
 
215
273
  const categoricalX = new LayeredChartCompiler({ schema: this.props.schema }).isCategoricalX(this.props.design)
216
274
 
217
275
  return [
218
- R(
219
- uiComponents.SectionComponent,
220
- { label: title },
221
- R(AxisComponent, {
222
- schema: this.props.schema,
223
- dataSource: this.props.dataSource,
224
- table: layer.table,
225
- types: this.getAxisTypes(layer, "x"),
226
- aggrNeed: "none",
227
- required: true,
228
- value: layer.axes.x,
229
- onChange: this.handleXAxisChange,
230
- filters,
231
- // Only show x color map if no color axis and is categorical and enabled
232
- showColorMap: layer.xColorMap && categoricalX && !layer.axes.color,
233
- autosetColors: false,
234
- // Categorical X can exclude values
235
- allowExcludedValues: categoricalX
236
- })
237
- ),
238
- categoricalX ? R(ui.Checkbox, {
239
- value: layer.xAxisOnlyValuesPresent,
240
- onChange: this.handlexAxisOnlyValuesPresentChange
241
- },
242
- T`Only show values actually present `,
243
- R(PopoverHelpComponent, { placement: 'bottom' }, T`Limits values to those that are present in the data, as opposed to all choices or all dates within range`)
244
- ) : null,
245
- <br/>
246
- ]
276
+ <uiComponents.SectionComponent key="axis" label={title}>
277
+ <AxisComponent
278
+ schema={this.props.schema}
279
+ dataSource={this.props.dataSource}
280
+ table={layer.table}
281
+ types={this.getAxisTypes(layer, "x")}
282
+ aggrNeed="none"
283
+ required={true}
284
+ value={layer.axes.x}
285
+ onChange={this.handleXAxisChange}
286
+ filters={filters}
287
+ showColorMap={layer.xColorMap && categoricalX && !layer.axes.color}
288
+ autosetColors={false}
289
+ allowExcludedValues={categoricalX}
290
+ />
291
+ </uiComponents.SectionComponent>,
292
+ categoricalX ? (
293
+ <ui.Checkbox
294
+ key="checkbox"
295
+ value={layer.xAxisOnlyValuesPresent}
296
+ onChange={this.handlexAxisOnlyValuesPresentChange}
297
+ >
298
+ {T`Only show values actually present `}
299
+ <PopoverHelpComponent placement="bottom">
300
+ {T`Limits values to those that are present in the data, as opposed to all choices or all dates within range`}
301
+ </PopoverHelpComponent>
302
+ </ui.Checkbox>
303
+ ) : undefined,
304
+ <br key="br"/>
305
+ ] as React.ReactNode[]
247
306
  }
248
307
 
249
308
  renderColorAxis() {
250
309
  const layer = this.props.design.layers[this.props.index]
251
310
  if (!layer.table) {
252
- return
311
+ return undefined
253
312
  }
254
313
 
255
314
  const title = this.getColorAxisLabel(layer)
256
315
 
257
- return R(
258
- "div",
259
- { className: "mb-3" },
260
- R("label", { className: "text-muted" }, title),
261
- R(
262
- "div",
263
- { style: { marginLeft: 10 } },
264
- R(AxisComponent, {
265
- schema: this.props.schema,
266
- dataSource: this.props.dataSource,
267
- table: layer.table,
268
- types: this.getAxisTypes(layer, "color"),
269
- aggrNeed: "none",
270
- required: this.isLayerPolar(layer),
271
- showColorMap: true,
272
- value: layer.axes.color,
273
- onChange: this.handleColorAxisChange,
274
- allowExcludedValues: true,
275
- filters: this.props.filters
276
- })
277
- )
316
+ return (
317
+ <div className="mb-3">
318
+ <label className="text-muted">{title}</label>
319
+ <div style={{ marginLeft: 10 }}>
320
+ <AxisComponent
321
+ schema={this.props.schema}
322
+ dataSource={this.props.dataSource}
323
+ table={layer.table}
324
+ types={this.getAxisTypes(layer, "color")}
325
+ aggrNeed="none"
326
+ required={this.isLayerPolar(layer)}
327
+ showColorMap={true}
328
+ value={layer.axes.color}
329
+ onChange={this.handleColorAxisChange}
330
+ allowExcludedValues={true}
331
+ filters={this.props.filters}
332
+ />
333
+ </div>
334
+ </div>
278
335
  )
279
336
  }
280
337
 
281
338
  renderYAxis() {
282
339
  const layer = this.props.design.layers[this.props.index]
283
340
  if (!layer.table) {
284
- return
341
+ return undefined
285
342
  }
286
343
 
287
344
  const title = this.getYAxisLabel(layer)
288
345
 
289
- return R(
290
- "div",
291
- { className: "mb-3" },
292
- R("label", { className: "text-muted" }, title),
293
- R(
294
- "div",
295
- { style: { marginLeft: 10 } },
296
- R(AxisComponent, {
297
- schema: this.props.schema,
298
- dataSource: this.props.dataSource,
299
- table: layer.table,
300
- types: this.getAxisTypes(layer, "y"),
301
- aggrNeed: this.doesLayerNeedGrouping(layer) ? "required" : "none",
302
- value: layer.axes.y,
303
- required: true,
304
- filters: this.props.filters,
305
- showFormat: true,
306
- onChange: this.handleYAxisChange
307
- }),
308
- this.renderCumulative(),
309
- this.renderStacked(),
310
- this.renderTrendline()
311
- )
346
+ return (
347
+ <div className="mb-3">
348
+ <label className="text-muted">{title}</label>
349
+ <div style={{ marginLeft: 10 }}>
350
+ <AxisComponent
351
+ schema={this.props.schema}
352
+ dataSource={this.props.dataSource}
353
+ table={layer.table}
354
+ types={this.getAxisTypes(layer, "y")}
355
+ aggrNeed={this.doesLayerNeedGrouping(layer) ? "required" : "none"}
356
+ value={layer.axes.y}
357
+ required={true}
358
+ filters={this.props.filters}
359
+ showFormat={true}
360
+ onChange={this.handleYAxisChange}
361
+ />
362
+ {this.renderCumulative()}
363
+ {this.renderStacked()}
364
+ {this.renderTrendline()}
365
+ </div>
366
+ </div>
312
367
  )
313
368
  }
314
369
 
@@ -321,12 +376,12 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
321
376
  return
322
377
  }
323
378
 
324
- return R(
325
- "div",
326
- { key: "cumulative" },
327
- <Checkbox inline value={layer.cumulative} onChange={this.handleCumulativeChange}>
328
- {T`Cumulative`}
329
- </Checkbox>
379
+ return (
380
+ <div key="cumulative">
381
+ <Checkbox inline value={layer.cumulative} onChange={this.handleCumulativeChange}>
382
+ {T`Cumulative`}
383
+ </Checkbox>
384
+ </div>
330
385
  )
331
386
  }
332
387
 
@@ -339,12 +394,12 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
339
394
  return
340
395
  }
341
396
 
342
- return R(
343
- "div",
344
- { key: "trendline" },
345
- <Checkbox value={layer.trendline === "linear"} onChange={this.handleTrendlineChange}>
346
- {T`Show linear trendline`}
347
- </Checkbox>
397
+ return (
398
+ <div key="trendline">
399
+ <Checkbox value={layer.trendline === "linear"} onChange={this.handleTrendlineChange}>
400
+ {T`Show linear trendline`}
401
+ </Checkbox>
402
+ </div>
348
403
  )
349
404
  }
350
405
 
@@ -355,16 +410,16 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
355
410
  if (layer.axes.color && this.props.design.layers.length > 1) {
356
411
  const stacked = layer.stacked != null ? layer.stacked : true
357
412
 
358
- return R(
359
- "div",
360
- { key: "stacked" },
361
- <Checkbox value={stacked} onChange={this.handleStackedChange}>
362
- {T`Stacked`}
363
- </Checkbox>
413
+ return (
414
+ <div key="stacked">
415
+ <Checkbox value={stacked} onChange={this.handleStackedChange}>
416
+ {T`Stacked`}
417
+ </Checkbox>
418
+ </div>
364
419
  )
365
420
  }
366
421
 
367
- return null
422
+ return undefined
368
423
  }
369
424
 
370
425
  renderColor() {
@@ -372,24 +427,23 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
372
427
 
373
428
  // If not table do nothing
374
429
  if (!layer.table) {
375
- return
430
+ return undefined
376
431
  }
377
432
 
378
433
  const categoricalX = new LayeredChartCompiler({ schema: this.props.schema }).isCategoricalX(this.props.design)
379
434
 
380
- return R(
381
- "div",
382
- { className: "mb-3" },
383
- R("label", { className: "text-muted" }, layer.axes.color ? T`Default Color` : T`Color`),
384
- R(
385
- "div",
386
- { style: { marginLeft: 8 } },
387
- R(ColorComponent, { color: layer.color, onChange: this.handleColorChange }),
388
- // Allow toggling of colors
389
- layer.axes.x && categoricalX && !layer.axes.color
390
- ? R(ui.Checkbox, { value: layer.xColorMap, onChange: this.handleXColorMapChange }, T`Set Individual Colors`)
391
- : undefined
392
- )
435
+ return (
436
+ <div className="mb-3">
437
+ <label className="text-muted">{layer.axes.color ? T`Default Color` : T`Color`}</label>
438
+ <div style={{ marginLeft: 8 }}>
439
+ <ColorComponent color={layer.color} onChange={this.handleColorChange}/>
440
+ {layer.axes.x && categoricalX && !layer.axes.color ? (
441
+ <ui.Checkbox value={layer.xColorMap} onChange={this.handleXColorMapChange}>
442
+ {T`Set Individual Colors`}
443
+ </ui.Checkbox>
444
+ ) : undefined}
445
+ </div>
446
+ </div>
393
447
  )
394
448
  }
395
449
 
@@ -397,51 +451,46 @@ export default class LayeredChartLayerDesignerComponent extends React.Component<
397
451
  const layer = this.props.design.layers[this.props.index]
398
452
 
399
453
  // If no table, hide
400
- if (!layer.table) { return null
454
+ if (!layer.table) {
455
+ return undefined
401
456
  }
402
457
 
403
- return R(
404
- "div",
405
- { className: "mb-3" },
406
- R("label", { className: "text-muted" }, R("span", { className: "fas fa-filter" }), " ", T`Filters`),
407
- R(
408
- "div",
409
- { style: { marginLeft: 8 } },
410
- R(FilterExprComponent, {
411
- schema: this.props.schema,
412
- dataSource: this.props.dataSource,
413
- onChange: this.handleFilterChange,
414
- table: layer.table,
415
- value: layer.filter
416
- })
417
- )
458
+ return (
459
+ <div className="mb-3">
460
+ <label className="text-muted">
461
+ <span className="fas fa-filter"/> {T`Filters`}
462
+ </label>
463
+ <div style={{ marginLeft: 8 }}>
464
+ <FilterExprComponent
465
+ schema={this.props.schema}
466
+ dataSource={this.props.dataSource}
467
+ onChange={this.handleFilterChange}
468
+ table={layer.table}
469
+ value={layer.filter}
470
+ />
471
+ </div>
472
+ </div>
418
473
  )
419
474
  }
420
475
 
421
476
  render() {
422
477
  const layer = this.props.design.layers[this.props.index]
423
- return R(
424
- "div",
425
- null,
426
- this.props.index > 0 ? R("hr") : undefined,
427
- this.renderRemove(),
428
- this.renderTable(),
429
- // Color axis first for pie
430
- this.isLayerPolar(layer) ? this.renderColorAxis() : undefined,
431
- this.renderXAxis(),
432
- layer.axes.x || layer.axes.color ? this.renderYAxis() : undefined,
433
- layer.axes.x && layer.axes.y && !this.isLayerPolar(layer) ? this.renderColorAxis() : undefined,
434
- // No default color for polar
435
- (() => {
436
- if (!this.isLayerPolar(layer)) {
437
- if (layer.axes.y) {
438
- return this.renderColor()
439
- }
440
- }
441
- return null
442
- })(),
443
- layer.axes.y ? this.renderFilter() : undefined,
444
- layer.axes.y ? this.renderName() : undefined
478
+ return (
479
+ <div>
480
+ {this.props.index > 0 ? <hr/> : undefined}
481
+ {this.renderRemove()}
482
+ {this.renderTable()}
483
+ {this.renderLayerTypeSelector()}
484
+ {/* Color axis first for pie */}
485
+ {this.isLayerPolar(layer) ? this.renderColorAxis() : undefined}
486
+ {this.renderXAxis()}
487
+ {layer.axes.x || layer.axes.color ? this.renderYAxis() : undefined}
488
+ {layer.axes.x && layer.axes.y && !this.isLayerPolar(layer) ? this.renderColorAxis() : undefined}
489
+ {/* No default color for polar */}
490
+ {!this.isLayerPolar(layer) && layer.axes.y ? this.renderColor() : undefined}
491
+ {layer.axes.y ? this.renderFilter() : undefined}
492
+ {layer.axes.y ? this.renderName() : undefined}
493
+ </div>
445
494
  )
446
495
  }
447
496
  }