@mwater/visualization 5.4.4 → 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.
- package/.storybook/head.html +0 -1
- package/lib/MWaterContextComponent.js +1 -1
- package/lib/MWaterLoaderComponent.d.ts +2 -2
- package/lib/dashboards/DashboardComponent.js +2 -1
- package/lib/dashboards/LayoutOptionsComponent.js +18 -11
- package/lib/dashboards/ServerDashboardDataSource.d.ts +10 -1
- package/lib/dashboards/ServerDashboardDataSource.js +29 -0
- package/lib/dashboards/layoutOptions.d.ts +5 -1
- package/lib/datagrids/DatagridComponent.js +1 -1
- package/lib/datagrids/ExprCellComponent.d.ts +1 -0
- package/lib/datagrids/ExprCellComponent.js +22 -20
- package/lib/maps/BufferLayer.d.ts +18 -0
- package/lib/maps/BufferLayer.js +24 -14
- package/lib/maps/ChoroplethLayer.d.ts +18 -0
- package/lib/maps/ChoroplethLayer.js +34 -25
- package/lib/maps/ChoroplethLayerDesign.d.ts +3 -2
- package/lib/maps/ChoroplethLayerDesigner.d.ts +11 -1
- package/lib/maps/DirectMapDataSource.js +17 -0
- package/lib/maps/EditHoverOver.d.ts +1 -1
- package/lib/maps/EditHoverOver.js +62 -33
- package/lib/maps/HoverContent.d.ts +10 -5
- package/lib/maps/HoverContent.js +6 -35
- package/lib/maps/Layer.d.ts +37 -0
- package/lib/maps/Layer.js +30 -4
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +6 -6
- package/lib/maps/MapLayerDataSource.d.ts +9 -0
- package/lib/maps/MapUtils.d.ts +19 -1
- package/lib/maps/MapUtils.js +71 -1
- package/lib/maps/MarkersLayer.d.ts +18 -0
- package/lib/maps/MarkersLayer.js +24 -24
- package/lib/maps/MarkersLayerDesignerComponent.d.ts +14 -1
- package/lib/maps/RasterMapViewComponent.js +1 -1
- package/lib/maps/ServerMapDataSource.d.ts +9 -0
- package/lib/maps/ServerMapDataSource.js +29 -0
- package/lib/maps/VectorMapViewComponent.js +6 -6
- package/lib/maps/maps.d.ts +4 -2
- 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 +47 -0
- package/lib/mwater_table_selection/IndicatorsListComponent.js +182 -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/MWaterCompleteTableSelectComponent.d.ts +37 -0
- package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +275 -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 +158 -0
- package/lib/quickfilter/Quickfilter.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersDesignComponent.js +18 -10
- 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/package.json +3 -8
- package/src/MWaterContextComponent.tsx +1 -1
- package/src/MWaterLoaderComponent.ts +1 -1
- package/src/dashboards/DashboardComponent.tsx +2 -1
- package/src/dashboards/LayoutOptionsComponent.tsx +22 -10
- package/src/dashboards/ServerDashboardDataSource.ts +36 -1
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.tsx +1 -1
- package/src/datagrids/ExprCellComponent.tsx +23 -20
- package/src/maps/BufferLayer.ts +35 -20
- package/src/maps/ChoroplethLayer.ts +51 -33
- package/src/maps/ChoroplethLayerDesign.ts +3 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +2 -2
- package/src/maps/DirectMapDataSource.ts +21 -1
- package/src/maps/EditHoverOver.tsx +91 -51
- package/src/maps/HoverContent.tsx +16 -47
- package/src/maps/Layer.ts +42 -4
- package/src/maps/MWaterServerLayer.ts +6 -6
- package/src/maps/MapLayerDataSource.ts +8 -0
- package/src/maps/MapUtils.ts +70 -3
- package/src/maps/MarkersLayer.ts +34 -24
- package/src/maps/RasterMapViewComponent.ts +1 -1
- package/src/maps/ServerMapDataSource.ts +35 -0
- package/src/maps/VectorMapViewComponent.tsx +6 -6
- package/src/maps/maps.ts +4 -2
- package/src/mwater_table_selection/FormsListComponent.tsx +188 -0
- package/src/mwater_table_selection/IndicatorsListComponent.tsx +283 -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/MWaterCompleteTableSelectComponent.tsx +377 -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} +83 -86
- package/src/quickfilter/Quickfilter.ts +3 -0
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +19 -14
- 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/MWaterCompleteTableSelectComponent.tsx +0 -975
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +0 -441
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import _ from "lodash"
|
|
2
|
-
import React from "react"
|
|
3
|
-
const R = React.createElement
|
|
4
|
-
import uuid from "uuid"
|
|
5
|
-
import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
|
|
6
|
-
import AxisBuilder from "../../../axes/AxisBuilder"
|
|
7
|
-
import { ExprComponent } from "@mwater/expressions-ui"
|
|
8
|
-
import { FilterExprComponent } from "@mwater/expressions-ui"
|
|
9
|
-
import OrderingsComponent from "./OrderingsComponent"
|
|
10
|
-
import { TableSelectComponent } from "@mwater/expressions-ui"
|
|
11
|
-
import ReorderableListComponent from "@mwater/react-library/lib/reorderable/ReorderableListComponent"
|
|
12
|
-
import * as ui from "@mwater/react-library/lib/bootstrap"
|
|
13
|
-
import { getFormatOptions } from "../../../valueFormatter"
|
|
14
|
-
import { getDefaultFormat } from "../../../valueFormatter"
|
|
15
|
-
import { TableChartColumn, TableChartDesign } from "./TableChart"
|
|
16
|
-
import AxisComponent from "../../../axes/AxisComponent"
|
|
17
|
-
import { Axis } from "../../../axes/Axis"
|
|
18
|
-
|
|
19
|
-
import { LocaleContext } from "@mwater/expressions-ui"
|
|
20
|
-
|
|
21
|
-
export interface TableChartDesignerComponentProps {
|
|
22
|
-
design: TableChartDesign
|
|
23
|
-
schema: Schema
|
|
24
|
-
dataSource: DataSource
|
|
25
|
-
onDesignChange: (design: TableChartDesign) => void
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default class TableChartDesignerComponent extends React.Component<TableChartDesignerComponentProps> {
|
|
29
|
-
// Updates design with the specified changes
|
|
30
|
-
updateDesign(changes: Partial<TableChartDesign>) {
|
|
31
|
-
const design = _.extend({}, this.props.design, changes) as TableChartDesign
|
|
32
|
-
this.props.onDesignChange(design)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
handleTitleTextChange = (ev: any) => {
|
|
36
|
-
this.updateDesign({ titleText: ev.target.value })
|
|
37
|
-
}
|
|
38
|
-
handleTableChange = (table: any) => {
|
|
39
|
-
this.updateDesign({ table })
|
|
40
|
-
}
|
|
41
|
-
handleFilterChange = (filter: any) => {
|
|
42
|
-
this.updateDesign({ filter })
|
|
43
|
-
}
|
|
44
|
-
handleOrderingsChange = (orderings: any) => {
|
|
45
|
-
this.updateDesign({ orderings })
|
|
46
|
-
}
|
|
47
|
-
handleLimitChange = (limit: any) => {
|
|
48
|
-
this.updateDesign({ limit })
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
handleColumnChange = (index: any, column: any) => {
|
|
52
|
-
const columns = this.props.design.columns.slice()
|
|
53
|
-
columns[index] = column
|
|
54
|
-
this.updateDesign({ columns })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
handleRemoveColumn = (index: any) => {
|
|
58
|
-
const columns = this.props.design.columns.slice()
|
|
59
|
-
columns.splice(index, 1)
|
|
60
|
-
this.updateDesign({ columns })
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
handleAddColumn = () => {
|
|
64
|
-
const columns = this.props.design.columns.slice()
|
|
65
|
-
columns.push({ id: uuid() })
|
|
66
|
-
this.updateDesign({ columns })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
renderTable() {
|
|
70
|
-
return R(
|
|
71
|
-
"div",
|
|
72
|
-
{ className: "mb-3" },
|
|
73
|
-
R("label", { className: "text-muted" }, R("i", { className: "fa fa-database" }), " ", T`Data Source`),
|
|
74
|
-
": ",
|
|
75
|
-
R(TableSelectComponent, {
|
|
76
|
-
schema: this.props.schema,
|
|
77
|
-
value: this.props.design.table,
|
|
78
|
-
onChange: this.handleTableChange,
|
|
79
|
-
filter: this.props.design.filter,
|
|
80
|
-
onFilterChange: this.handleFilterChange
|
|
81
|
-
})
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
renderTitle() {
|
|
86
|
-
return R(
|
|
87
|
-
"div",
|
|
88
|
-
{ className: "mb-3" },
|
|
89
|
-
R("label", { className: "text-muted" }, T`Title`),
|
|
90
|
-
R("input", {
|
|
91
|
-
type: "text",
|
|
92
|
-
className: "form-control form-control-sm",
|
|
93
|
-
value: this.props.design.titleText,
|
|
94
|
-
onChange: this.handleTitleTextChange,
|
|
95
|
-
placeholder: T`Untitled`
|
|
96
|
-
})
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
renderColumn = (column: any, index: any, connectDragSource: any, connectDragPreview: any, connectDropTarget: any) => {
|
|
101
|
-
const style = {
|
|
102
|
-
borderTop: "solid 1px #EEE",
|
|
103
|
-
paddingTop: 10,
|
|
104
|
-
paddingBottom: 10
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return connectDragPreview(
|
|
108
|
-
connectDropTarget(
|
|
109
|
-
R(
|
|
110
|
-
"div",
|
|
111
|
-
{ key: index, style },
|
|
112
|
-
React.createElement(TableChartColumnDesignerComponent, {
|
|
113
|
-
design: this.props.design,
|
|
114
|
-
schema: this.props.schema,
|
|
115
|
-
dataSource: this.props.dataSource,
|
|
116
|
-
index,
|
|
117
|
-
onChange: this.handleColumnChange.bind(null, index),
|
|
118
|
-
onRemove: this.handleRemoveColumn.bind(null, index),
|
|
119
|
-
connectDragSource
|
|
120
|
-
})
|
|
121
|
-
)
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
handleReorder = (map: any) => {
|
|
127
|
-
return this.updateDesign({ columns: map })
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
renderColumns() {
|
|
131
|
-
if (!this.props.design.table) {
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return R(
|
|
136
|
-
"div",
|
|
137
|
-
null,
|
|
138
|
-
R(ReorderableListComponent, {
|
|
139
|
-
items: this.props.design.columns,
|
|
140
|
-
onReorder: this.handleReorder,
|
|
141
|
-
renderItem: this.renderColumn,
|
|
142
|
-
getItemId: (item: TableChartColumn) => item.id
|
|
143
|
-
}),
|
|
144
|
-
R(
|
|
145
|
-
"button",
|
|
146
|
-
{ className: "btn btn-secondary btn-sm", type: "button", onClick: this.handleAddColumn },
|
|
147
|
-
R("span", { className: "fas fa-plus" }),
|
|
148
|
-
" ", T`Add Column`
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
// return R 'div', className: "form-group",
|
|
153
|
-
// _.map(@props.design.columns, (column, i) => @renderColumn(i))
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
renderOrderings() {
|
|
157
|
-
// If no table, hide
|
|
158
|
-
if (!this.props.design.table) {
|
|
159
|
-
return null
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return R(
|
|
163
|
-
"div",
|
|
164
|
-
{ className: "mb-3" },
|
|
165
|
-
R("label", { className: "text-muted" }, R("span", { className: "fas fa-sort-amount-down" }), " ", T`Ordering`),
|
|
166
|
-
R(
|
|
167
|
-
"div",
|
|
168
|
-
{ style: { marginLeft: 8 } },
|
|
169
|
-
React.createElement(OrderingsComponent, {
|
|
170
|
-
schema: this.props.schema,
|
|
171
|
-
dataSource: this.props.dataSource,
|
|
172
|
-
orderings: this.props.design.orderings,
|
|
173
|
-
onOrderingsChange: this.handleOrderingsChange,
|
|
174
|
-
table: this.props.design.table
|
|
175
|
-
})
|
|
176
|
-
)
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
renderFilter() {
|
|
181
|
-
// If no table, hide
|
|
182
|
-
if (!this.props.design.table) {
|
|
183
|
-
return null
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return R(
|
|
187
|
-
"div",
|
|
188
|
-
{ className: "mb-3" },
|
|
189
|
-
R("label", { className: "text-muted" }, R("span", { className: "fas fa-filter" }), " ", T`Filters`),
|
|
190
|
-
R(
|
|
191
|
-
"div",
|
|
192
|
-
{ style: { marginLeft: 8 } },
|
|
193
|
-
React.createElement(FilterExprComponent, {
|
|
194
|
-
schema: this.props.schema,
|
|
195
|
-
dataSource: this.props.dataSource,
|
|
196
|
-
onChange: this.handleFilterChange,
|
|
197
|
-
table: this.props.design.table,
|
|
198
|
-
value: this.props.design.filter
|
|
199
|
-
})
|
|
200
|
-
)
|
|
201
|
-
)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
renderLimit() {
|
|
205
|
-
// If no table, hide
|
|
206
|
-
if (!this.props.design.table) {
|
|
207
|
-
return null
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return R(
|
|
211
|
-
"div",
|
|
212
|
-
{ className: "mb-3" },
|
|
213
|
-
R("label", { className: "text-muted" }, T`Maximum Number of Rows (up to 1000)`),
|
|
214
|
-
R(
|
|
215
|
-
"div",
|
|
216
|
-
{ style: { marginLeft: 8 } },
|
|
217
|
-
R(ui.NumberInput, {
|
|
218
|
-
value: this.props.design.limit,
|
|
219
|
-
onChange: this.handleLimitChange,
|
|
220
|
-
decimal: false,
|
|
221
|
-
placeholder: "1000"
|
|
222
|
-
})
|
|
223
|
-
)
|
|
224
|
-
)
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
render() {
|
|
228
|
-
return R(
|
|
229
|
-
"div",
|
|
230
|
-
null,
|
|
231
|
-
this.renderTable(),
|
|
232
|
-
this.renderColumns(),
|
|
233
|
-
this.props.design.table ? R("hr") : undefined,
|
|
234
|
-
this.renderOrderings(),
|
|
235
|
-
this.renderFilter(),
|
|
236
|
-
this.renderLimit(),
|
|
237
|
-
R("hr"),
|
|
238
|
-
this.renderTitle()
|
|
239
|
-
)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export interface TableChartColumnDesignerComponentProps {
|
|
244
|
-
design: TableChartDesign
|
|
245
|
-
schema: Schema
|
|
246
|
-
dataSource: DataSource
|
|
247
|
-
index: number
|
|
248
|
-
onChange: any
|
|
249
|
-
onRemove: any
|
|
250
|
-
connectDragSource: any
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
class TableChartColumnDesignerComponent extends React.Component<TableChartColumnDesignerComponentProps> {
|
|
254
|
-
static contextType = LocaleContext
|
|
255
|
-
|
|
256
|
-
// Updates column with the specified changes
|
|
257
|
-
updateColumn(changes: any) {
|
|
258
|
-
const column = _.extend({}, this.props.design.columns[this.props.index], changes)
|
|
259
|
-
return this.props.onChange(column)
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
updateTextAxis(changes: any) {
|
|
263
|
-
const textAxis = _.extend({}, this.props.design.columns[this.props.index].textAxis, changes)
|
|
264
|
-
return this.updateColumn({ textAxis })
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
handleExprChange = (expr: any) => {
|
|
268
|
-
return this.updateTextAxis({ expr })
|
|
269
|
-
}
|
|
270
|
-
handleHeaderTextChange = (ev: any) => {
|
|
271
|
-
return this.updateColumn({ headerText: ev.target.value })
|
|
272
|
-
}
|
|
273
|
-
handleAggrChange = (aggr: any) => {
|
|
274
|
-
return this.updateTextAxis({ aggr })
|
|
275
|
-
}
|
|
276
|
-
handleFormatChange = (ev: any) => {
|
|
277
|
-
return this.updateColumn({ format: ev.target.value })
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
renderRemove() {
|
|
281
|
-
if (this.props.design.columns.length > 1) {
|
|
282
|
-
return R(
|
|
283
|
-
"button",
|
|
284
|
-
{ className: "btn btn-sm btn-link float-end", type: "button", onClick: this.props.onRemove },
|
|
285
|
-
R("span", { className: "fas fa-times" })
|
|
286
|
-
)
|
|
287
|
-
}
|
|
288
|
-
return null
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
renderExpr() {
|
|
292
|
-
const column = this.props.design.columns[this.props.index]
|
|
293
|
-
|
|
294
|
-
const title = T`Value`
|
|
295
|
-
|
|
296
|
-
return R(
|
|
297
|
-
"div",
|
|
298
|
-
null,
|
|
299
|
-
R("label", { className: "text-muted" }, title),
|
|
300
|
-
": ",
|
|
301
|
-
React.createElement(ExprComponent, {
|
|
302
|
-
schema: this.props.schema,
|
|
303
|
-
dataSource: this.props.dataSource,
|
|
304
|
-
table: this.props.design.table,
|
|
305
|
-
value: column.textAxis ? column.textAxis.expr : null,
|
|
306
|
-
onChange: this.handleExprChange,
|
|
307
|
-
aggrStatuses: ["literal", "individual", "aggregate"]
|
|
308
|
-
})
|
|
309
|
-
)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
renderFormat() {
|
|
313
|
-
const column = this.props.design.columns[this.props.index]
|
|
314
|
-
|
|
315
|
-
// Get type
|
|
316
|
-
const exprUtils = new ExprUtils(this.props.schema)
|
|
317
|
-
const exprType = exprUtils.getExprType(column.textAxis?.expr ?? null)
|
|
318
|
-
if (!exprType) {
|
|
319
|
-
return null
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const formats = getFormatOptions(exprType)
|
|
323
|
-
if (!formats) {
|
|
324
|
-
return null
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return R(
|
|
328
|
-
"div",
|
|
329
|
-
{ className: "mb-3" },
|
|
330
|
-
R("label", { className: "text-muted" }, T`Format`),
|
|
331
|
-
": ",
|
|
332
|
-
R(
|
|
333
|
-
"select",
|
|
334
|
-
{
|
|
335
|
-
value: column.format != null ? column.format : getDefaultFormat(exprType),
|
|
336
|
-
className: "form-select",
|
|
337
|
-
style: { width: "auto", display: "inline-block" },
|
|
338
|
-
onChange: this.handleFormatChange
|
|
339
|
-
},
|
|
340
|
-
_.map(formats, (format) => R("option", { key: format.value, value: format.value }, format.label))
|
|
341
|
-
)
|
|
342
|
-
)
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
renderHeader() {
|
|
346
|
-
const column = this.props.design.columns[this.props.index]
|
|
347
|
-
|
|
348
|
-
const axisBuilder = new AxisBuilder({ schema: this.props.schema })
|
|
349
|
-
const placeholder = column.textAxis ? axisBuilder.summarizeAxis(column.textAxis ?? null, this.context): ""
|
|
350
|
-
|
|
351
|
-
return R(
|
|
352
|
-
"div",
|
|
353
|
-
null,
|
|
354
|
-
R("label", { className: "text-muted" }, T`Header`),
|
|
355
|
-
": ",
|
|
356
|
-
R("input", {
|
|
357
|
-
type: "text",
|
|
358
|
-
className: "form-control form-control-sm",
|
|
359
|
-
style: { display: "inline-block", width: "15em" },
|
|
360
|
-
value: column.headerText,
|
|
361
|
-
onChange: this.handleHeaderTextChange,
|
|
362
|
-
placeholder
|
|
363
|
-
})
|
|
364
|
-
)
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
renderSummarize() {
|
|
368
|
-
const column = this.props.design.columns[this.props.index]
|
|
369
|
-
const exprUtils = new ExprUtils(this.props.schema)
|
|
370
|
-
const exprType = exprUtils.getExprType(column.textAxis?.expr ?? null)
|
|
371
|
-
if (!exprType || exprType !== 'number') {
|
|
372
|
-
return null
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return R('div', null,
|
|
376
|
-
R(ui.Checkbox, {value: column.summarize, inline: true, onChange: (summarize) => this.updateColumn({ summarize, summaryType: column.summaryType ?? 'sum' })}, T`Summarize`),
|
|
377
|
-
column.summarize ?
|
|
378
|
-
R('div', null,
|
|
379
|
-
R("label", { className: "text-muted" }, T`Summary Type`),
|
|
380
|
-
": ",
|
|
381
|
-
R(ui.Select, {
|
|
382
|
-
inline: true,
|
|
383
|
-
value: column.summaryType,
|
|
384
|
-
onChange: (summaryType) => this.updateColumn({ summaryType }),
|
|
385
|
-
options: [{value: 'avg', label: T`Average`}, {value: 'sum', label: T`Sum`}, {value: 'min', label: T`Minimum`}, {value: 'max', label: T`Maximum`} ]
|
|
386
|
-
})
|
|
387
|
-
) : undefined
|
|
388
|
-
)
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
renderBackgroundColorAxis() {
|
|
392
|
-
const column = this.props.design.columns[this.props.index]
|
|
393
|
-
|
|
394
|
-
if(!column.textAxis) return null
|
|
395
|
-
|
|
396
|
-
return R(
|
|
397
|
-
ui.CollapsibleSection,
|
|
398
|
-
{
|
|
399
|
-
label: T`Background color by data`,
|
|
400
|
-
labelMuted: true
|
|
401
|
-
},
|
|
402
|
-
R(AxisComponent, {
|
|
403
|
-
schema: this.props.schema,
|
|
404
|
-
dataSource: this.props.dataSource,
|
|
405
|
-
table: this.props.design.table,
|
|
406
|
-
types: ["enum", "text", "boolean", "date"],
|
|
407
|
-
value: column.backgroundColorAxis,
|
|
408
|
-
onChange: (backgroundColorAxis: Axis | null) => this.updateColumn({ backgroundColorAxis }),
|
|
409
|
-
showColorMap: true,
|
|
410
|
-
aggrNeed: "optional"
|
|
411
|
-
})
|
|
412
|
-
|
|
413
|
-
)
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
render() {
|
|
417
|
-
const iconStyle = {
|
|
418
|
-
cursor: "move",
|
|
419
|
-
marginRight: 8,
|
|
420
|
-
opacity: 0.5,
|
|
421
|
-
fontSize: 12,
|
|
422
|
-
height: 20
|
|
423
|
-
}
|
|
424
|
-
return R(
|
|
425
|
-
"div",
|
|
426
|
-
null,
|
|
427
|
-
this.props.connectDragSource(R("i", { className: "fa fa-bars", style: iconStyle })),
|
|
428
|
-
this.renderRemove(),
|
|
429
|
-
R("label", null, T`Column ${this.props.index + 1}`),
|
|
430
|
-
R(
|
|
431
|
-
"div",
|
|
432
|
-
{ style: { marginLeft: 5 } },
|
|
433
|
-
this.renderExpr(),
|
|
434
|
-
this.renderFormat(),
|
|
435
|
-
this.renderHeader(),
|
|
436
|
-
this.renderSummarize(),
|
|
437
|
-
this.renderBackgroundColorAxis()
|
|
438
|
-
)
|
|
439
|
-
)
|
|
440
|
-
}
|
|
441
|
-
}
|