@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,7 +1,5 @@
1
1
  import _ from "lodash"
2
2
  import React from "react"
3
- const R = React.createElement
4
-
5
3
  import Color from "color"
6
4
  import * as ui from "@mwater/react-library/lib/bootstrap"
7
5
  import classNames from "classnames"
@@ -61,77 +59,71 @@ export default class PivotChartLayoutComponent extends React.Component<PivotChar
61
59
  }
62
60
 
63
61
  renderRow(row: PivotChartLayoutRow, rowIndex: number) {
64
- return R(
65
- "tr",
66
- { key: rowIndex },
67
- _.map(row.cells, (cell, columnIndex) => {
68
- return R(LayoutCellComponent, {
69
- ref: this.recordCellComp.bind(null, rowIndex, columnIndex),
70
- key: columnIndex,
71
- layout: this.props.layout,
72
- rowIndex,
73
- columnIndex,
74
- onHover: this.props.editable ? () => this.setState({ hoverSection: cell.section ?? null }) : undefined,
75
- hoverSection: this.props.editable ? this.state.hoverSection : undefined,
76
- onEditSection: this.props.onEditSection ? this.props.onEditSection.bind(null, cell.section) : undefined,
77
- onSummarizeSegment: this.props.onSummarizeSegment
62
+ return <tr key={rowIndex}>
63
+ {_.map(row.cells, (cell, columnIndex) => {
64
+ return <LayoutCellComponent
65
+ ref={this.recordCellComp.bind(null, rowIndex, columnIndex)}
66
+ key={columnIndex}
67
+ layout={this.props.layout}
68
+ rowIndex={rowIndex}
69
+ columnIndex={columnIndex}
70
+ onHover={this.props.editable ? () => this.setState({ hoverSection: cell.section ?? null }) : undefined}
71
+ hoverSection={this.props.editable ? this.state.hoverSection : undefined}
72
+ onEditSection={this.props.onEditSection ? this.props.onEditSection.bind(null, cell.section) : undefined}
73
+ onSummarizeSegment={this.props.onSummarizeSegment
78
74
  ? this.props.onSummarizeSegment.bind(null, cell.section)
79
- : undefined
80
- })
81
- })
82
- )
75
+ : undefined}
76
+ />
77
+ })}
78
+ </tr>
83
79
  }
84
80
 
85
81
  renderHoverPlusIcon = (key: any, x: any, y: any, onClick: any) => {
86
82
  // Render a plus box
87
- return R(
88
- "div",
89
- {
90
- key,
91
- onClick,
92
- style: {
93
- position: "absolute",
94
- left: x - 7,
95
- top: y - 6,
96
- border: "solid 1px #337ab7",
97
- backgroundColor: "white",
98
- paddingLeft: 2,
99
- paddingRight: 2,
100
- paddingTop: 0,
101
- color: "#337ab7",
102
- fontSize: 9,
103
- cursor: "pointer",
104
- opacity: 0.8
105
- }
106
- },
107
- R(ui.Icon, { id: "fa-plus" })
108
- )
83
+ return <div
84
+ key={key}
85
+ onClick={onClick}
86
+ style={{
87
+ position: "absolute",
88
+ left: x - 7,
89
+ top: y - 6,
90
+ border: "solid 1px #337ab7",
91
+ backgroundColor: "white",
92
+ paddingLeft: 2,
93
+ paddingRight: 2,
94
+ paddingTop: 0,
95
+ color: "#337ab7",
96
+ fontSize: 9,
97
+ cursor: "pointer",
98
+ opacity: 0.8
99
+ }}
100
+ >
101
+ <ui.Icon id="fa-plus" />
102
+ </div>
109
103
  }
110
104
 
111
105
  renderHoverRemoveIcon = (key: any, x: any, y: any, onClick: any) => {
112
106
  // Render a plus box
113
- return R(
114
- "div",
115
- {
116
- key,
117
- onClick,
118
- style: {
119
- position: "absolute",
120
- left: x - 7,
121
- top: y - 6,
122
- border: "solid 1px #337ab7",
123
- backgroundColor: "white",
124
- paddingLeft: 3,
125
- paddingRight: 3,
126
- paddingTop: 0,
127
- color: "#337ab7",
128
- fontSize: 9,
129
- cursor: "pointer",
130
- opacity: 0.8
131
- }
132
- },
133
- R(ui.Icon, { id: "fa-remove" })
134
- )
107
+ return <div
108
+ key={key}
109
+ onClick={onClick}
110
+ style={{
111
+ position: "absolute",
112
+ left: x - 7,
113
+ top: y - 6,
114
+ border: "solid 1px #337ab7",
115
+ backgroundColor: "white",
116
+ paddingLeft: 3,
117
+ paddingRight: 3,
118
+ paddingTop: 0,
119
+ color: "#337ab7",
120
+ fontSize: 9,
121
+ cursor: "pointer",
122
+ opacity: 0.8
123
+ }}
124
+ >
125
+ <ui.Icon id="fa-remove" />
126
+ </div>
135
127
  }
136
128
 
137
129
  // Render floating hover controls
@@ -259,24 +251,20 @@ export default class PivotChartLayoutComponent extends React.Component<PivotChar
259
251
  )
260
252
  }
261
253
 
262
- return R("div", { key: "hover-controls" }, controls)
254
+ return <div key="hover-controls">{controls}</div>
263
255
  }
264
256
 
265
257
  render() {
266
- return R(
267
- "div",
268
- {
269
- style: { position: "relative" },
270
- onMouseLeave: () => this.setState({ hoverSection: null })
271
- },
272
- // Define CSS classes to keep HTML as small as possible
273
- // https://stackoverflow.com/a/19047221/876117
274
- // https://github.com/mWater/mwater-portal/issues/1183
275
- // cell borders not visible in firefox when you have a cell with position relative inside a table with collapsed borders
276
- R(
277
- "style",
278
- null,
279
- `\
258
+ return <div
259
+ style={{ position: "relative" }}
260
+ onMouseLeave={() => this.setState({ hoverSection: null })}
261
+ >
262
+ {/* Define CSS classes to keep HTML as small as possible
263
+ https://stackoverflow.com/a/19047221/876117
264
+ https://github.com/mWater/mwater-portal/issues/1183
265
+ cell borders not visible in firefox when you have a cell with position relative inside a table with collapsed borders */}
266
+ <style>
267
+ {`\
280
268
  .pivot-chart-table {
281
269
  width: 100%;
282
270
  border-spacing: 0;
@@ -304,42 +292,32 @@ vertical-align: top;
304
292
  .pivot-chart-table .br1 { border-right: solid 1px #f4f4f4 }
305
293
  .pivot-chart-table .br2 { border-right: solid 1px #ccc }
306
294
  .pivot-chart-table .br3 { border-right: solid 1px #888 }\
307
- `
308
- ),
309
- this.props.layout.tooManyRows
310
- ? R(
311
- "div",
312
- { className: "text-warning", style: { fontSize: 12 } },
313
- R("i", { className: "fa fa-exclamation-circle" }),
314
- T`Warning: Too many rows in table to display`
315
- )
316
- : undefined,
317
-
318
- this.props.layout.tooManyColumns
319
- ? R(
320
- "div",
321
- { className: "text-warning", style: { fontSize: 12 } },
322
- R("i", { className: "fa fa-exclamation-circle" }),
323
- T`Warning: Too many columns in table to display`
324
- )
325
- : undefined,
326
- R(
327
- "div",
328
- { style: { position: "relative" } },
329
- R(
330
- "table",
331
- { className: "pivot-chart-table" },
332
- R(
333
- "tbody",
334
- null,
335
- _.map(this.props.layout.rows, (row, rowIndex) => {
295
+ `}
296
+ </style>
297
+ {this.props.layout.tooManyRows ? (
298
+ <div className="text-warning" style={{ fontSize: 12 }}>
299
+ <i className="fa fa-exclamation-circle" />
300
+ {T`Warning: Too many rows in table to display`}
301
+ </div>
302
+ ) : undefined}
303
+
304
+ {this.props.layout.tooManyColumns ? (
305
+ <div className="text-warning" style={{ fontSize: 12 }}>
306
+ <i className="fa fa-exclamation-circle" />
307
+ {T`Warning: Too many columns in table to display`}
308
+ </div>
309
+ ) : undefined}
310
+ <div style={{ position: "relative" }}>
311
+ <table className="pivot-chart-table">
312
+ <tbody>
313
+ {_.map(this.props.layout.rows, (row, rowIndex) => {
336
314
  return this.renderRow(row, rowIndex)
337
- })
338
- )
339
- ),
340
- this.renderHoverControls()
341
- )
342
- )
315
+ })}
316
+ </tbody>
317
+ </table>
318
+ {this.renderHoverControls()}
319
+ </div>
320
+ </div>
343
321
  }
344
322
  }
345
323
 
@@ -387,17 +365,13 @@ class LayoutCellComponent extends React.Component<LayoutCellComponentProps> {
387
365
  return null
388
366
  }
389
367
 
390
- return R(
391
- "span",
392
- { style: { fontSize: "90%" } },
393
- R("a", { className: "link-plain", onClick: this.props.onEditSection }, T`Edit`),
394
- cell.summarize
395
- ? [
396
- R("span", { className: "text-muted" }, ` / `),
397
- R("a", { className: "link-plain", onClick: this.props.onSummarizeSegment }, T`Summarize`)
398
- ]
399
- : undefined
400
- )
368
+ return <span style={{ fontSize: "90%" }}>
369
+ <a className="link-plain" onClick={this.props.onEditSection}>{T`Edit`}</a>
370
+ {cell.summarize ? [
371
+ <span className="text-muted"> / </span>,
372
+ <a className="link-plain" onClick={this.props.onSummarizeSegment}>{T`Summarize`}</a>
373
+ ] : undefined}
374
+ </span>
401
375
  }
402
376
 
403
377
  render() {
@@ -452,12 +426,13 @@ class LayoutCellComponent extends React.Component<LayoutCellComponentProps> {
452
426
  textColor = lightness < 0.5 ? "rgb(204,204,204)" : undefined
453
427
  }
454
428
 
455
- const style = {
456
- backgroundColor,
429
+ const style: React.CSSProperties = {
430
+ backgroundColor: backgroundColor || undefined,
457
431
  textAlign: cell.align,
458
432
  cursor: isHover && !cell.unconfigured ? "pointer" : undefined,
459
- color: textColor
433
+ color: textColor || undefined
460
434
  }
435
+
461
436
  const classes = classNames({
462
437
  cell: true,
463
438
  // List out borders in compact way to keep HTML smaller
@@ -476,32 +451,28 @@ class LayoutCellComponent extends React.Component<LayoutCellComponentProps> {
476
451
  })
477
452
 
478
453
  // Style that should not affect popup menu
479
- const innerStyle = {
454
+ const innerStyle: React.CSSProperties = {
480
455
  fontWeight: cell.bold ? "bold" : undefined,
481
456
  fontStyle: cell.italic ? "italic" : undefined,
482
457
  marginLeft: cell.indent ? cell.indent * 5 : undefined
483
458
  }
484
459
 
485
- return R(
486
- "td",
487
- {
488
- ref: (c) => {
489
- this.tdComponent = c
490
- },
491
- onMouseEnter: this.props.onHover,
492
- onClick: this.handleClick,
493
- className: classes,
494
- style,
495
- colSpan: cell.columnSpan || null,
496
- rowSpan: cell.rowSpan || null
497
- },
498
- R(
499
- "span",
500
- { style: innerStyle },
501
- cell.unconfigured && this.props.onEditSection
460
+ return <td
461
+ ref={(c) => {
462
+ this.tdComponent = c
463
+ }}
464
+ onMouseEnter={this.props.onHover}
465
+ onClick={this.handleClick}
466
+ className={classes}
467
+ style={style}
468
+ colSpan={cell.columnSpan || undefined}
469
+ rowSpan={cell.rowSpan || undefined}
470
+ >
471
+ <span style={innerStyle}>
472
+ {cell.unconfigured && this.props.onEditSection
502
473
  ? this.renderUnconfigured(cell)
503
- : cell.text || "\u00A0\u00A0\u00A0"
504
- )
505
- )
474
+ : cell.text || "\u00A0\u00A0\u00A0"}
475
+ </span>
476
+ </td>
506
477
  }
507
478
  }