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