@mwater/visualization 5.0.0 → 5.0.1

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 (48) hide show
  1. package/lib/MWaterContextComponent.js +1 -4
  2. package/lib/datagrids/DatagridComponent.d.ts +2 -0
  3. package/lib/datagrids/DatagridComponent.js +8 -2
  4. package/lib/datagrids/DatagridViewComponent.d.ts +2 -0
  5. package/lib/datagrids/DatagridViewComponent.js +3 -2
  6. package/lib/datagrids/LabeledExprGenerator.js +15 -0
  7. package/lib/dayjs.d.ts +2 -0
  8. package/lib/dayjs.js +9 -0
  9. package/lib/languages.js +5 -0
  10. package/lib/maps/DetailLevelSelectComponent.d.ts +1 -93
  11. package/lib/maps/Layer.js +7 -18
  12. package/lib/maps/MapComponent.js +1 -1
  13. package/lib/maps/RegionSelectComponent.d.ts +1 -33
  14. package/lib/maps/VectorMapViewComponent.js +21 -29
  15. package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -186
  16. package/lib/quickfilter/QuickfiltersDesignComponent.js +1 -1
  17. package/lib/quickfilter/TextLiteralComponent.d.ts +2 -186
  18. package/lib/quickfilter/TextLiteralComponent.js +3 -0
  19. package/lib/valueFormatter.js +52 -1
  20. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
  21. package/lib/widgets/charts/pivot/PivotChartLayout.d.ts +3 -2
  22. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +4 -1
  23. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +1 -1
  24. package/lib/widgets/charts/table/TableChart.js +15 -4
  25. package/lib/widgets/charts/table/TableChartViewComponent.d.ts +2 -1
  26. package/lib/widgets/charts/table/TableChartViewComponent.js +9 -4
  27. package/package.json +8 -8
  28. package/src/MWaterAddRelatedIndicatorComponent.ts +1 -1
  29. package/src/MWaterContextComponent.ts +1 -4
  30. package/src/datagrids/DatagridComponent.ts +15 -1
  31. package/src/datagrids/DatagridViewComponent.ts +6 -2
  32. package/src/datagrids/LabeledExprGenerator.ts +15 -0
  33. package/src/dayjs.ts +5 -0
  34. package/src/languages.ts +5 -0
  35. package/src/maps/Layer.ts +6 -16
  36. package/src/maps/MapComponent.ts +1 -1
  37. package/src/maps/RasterMapViewComponent.ts +0 -1
  38. package/src/maps/VectorMapViewComponent.tsx +23 -36
  39. package/src/quickfilter/QuickfiltersDesignComponent.tsx +1 -1
  40. package/src/quickfilter/TextLiteralComponent.ts +4 -0
  41. package/src/valueFormatter.ts +54 -1
  42. package/src/widgets/charts/pivot/PivotChartLayout.ts +3 -2
  43. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +2 -2
  44. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +7 -3
  45. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +1 -1
  46. package/src/widgets/charts/table/TableChart.ts +24 -14
  47. package/src/widgets/charts/table/TableChartViewComponent.ts +10 -5
  48. package/stories/dashboards.js +3 -3
@@ -217,7 +217,7 @@ export default class TableChart extends Chart {
217
217
  const totalColumns: string[] = []
218
218
 
219
219
  // For each column
220
- for (let colNum = 0 ; colNum < design.columns.length ; colNum++) {
220
+ for (let colNum = 0; colNum < design.columns.length; colNum++) {
221
221
  column = design.columns[colNum]
222
222
 
223
223
  const exprType = exprUtils.getExprType(column.textAxis?.expr ?? null)
@@ -242,7 +242,7 @@ export default class TableChart extends Chart {
242
242
  alias: `c${colNum}`
243
243
  })
244
244
 
245
- if(exprType === 'number' && column.summarize) {
245
+ if (exprType === 'number' && column.summarize) {
246
246
  totalColumns.push(`c${colNum}`)
247
247
  }
248
248
 
@@ -275,9 +275,9 @@ export default class TableChart extends Chart {
275
275
  }
276
276
  }
277
277
 
278
- for (let colNum = 0 ; colNum < design.columns.length ; colNum++) {
278
+ for (let colNum = 0; colNum < design.columns.length; colNum++) {
279
279
  column = design.columns[colNum]
280
- if(!column.backgroundColorAxis) continue
280
+ if (!column.backgroundColorAxis) continue
281
281
 
282
282
  query.selects.push({
283
283
  type: "select",
@@ -320,27 +320,37 @@ export default class TableChart extends Chart {
320
320
  const summaryQuery: JsonQLSelectQuery = {
321
321
  type: "query",
322
322
  selects: design.columns.map((c: any, i) => {
323
- if(totalColumns.includes(`c${i}`))
323
+ if (totalColumns.includes(`c${i}`))
324
324
  return { type: "select", expr: { type: "op", op: c.summaryType ?? 'sum', exprs: [{ type: "field", tableAlias: "t", column: `c${i}` }] }, alias: `c${i}` }
325
- else
326
- return { type: 'select', expr: {type: 'literal', value: null} , alias: `c${i}` }
325
+ else
326
+ return { type: 'select', expr: { type: 'literal', value: null }, alias: `c${i}` }
327
327
  }),
328
328
  from: { type: "subquery", query, alias: "t" },
329
329
  }
330
-
331
- return dataSource.performQuery(query, (error: any, data: any) => {
332
- if(totalColumns.length > 0)
330
+ // Query for the data in question.
331
+ dataSource.performQuery(query, (error: any, data: any) => {
332
+ if (error) {
333
+ callback(error)
334
+ }
335
+ else if (totalColumns.length > 0) {
336
+ // Query for the summaries
333
337
  dataSource.performQuery(summaryQuery, (error: any, summary: any) => {
334
- callback(error, { main: data, summary: summary[0] })
338
+ if (error) {
339
+ callback(error)
340
+ }
341
+ else {
342
+ callback(error, { main: data, summary: summary[0] })
343
+ }
335
344
  })
336
- else
337
- callback(error, { main: data})
345
+ }
346
+ else
347
+ callback(error, { main: data })
338
348
  })
339
349
  }
340
350
 
341
351
  // Create a view element for the chart
342
352
  // Options include:
343
- // schema: schema to use
353
+ // p schema: schema to use
344
354
  // dataSource: dataSource to use
345
355
  // design: design of the chart
346
356
  // data: results from queries
@@ -8,12 +8,12 @@ import AxisBuilder from "../../../axes/AxisBuilder"
8
8
  import { DataSource, ExprUtils, Schema } from "@mwater/expressions"
9
9
  import { formatValue } from "../../../valueFormatter"
10
10
  import { Image } from "@mwater/forms/lib/RotationAwareImageComponent"
11
- import { TableChartColumn } from "./TableChart"
11
+ import { TableChartColumn, TableChartDesign } from "./TableChart"
12
12
  import Color from "color"
13
13
 
14
14
  export interface TableChartViewComponentProps {
15
15
  /** Design of chart */
16
- design: any
16
+ design: TableChartDesign
17
17
  /** Data that the table has requested */
18
18
  data: any
19
19
  /** Schema to use */
@@ -249,7 +249,12 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
249
249
  } else {
250
250
  // Parse if should be JSON
251
251
  if (["image", "imagelist", "geometry", "text[]"].includes(exprType || "") && _.isString(value)) {
252
- value = JSON.parse(value)
252
+ try {
253
+ value = JSON.parse(value)
254
+ } catch (e) {
255
+ // Ignore as can happen when re-arranging columns
256
+ value = null
257
+ }
253
258
  }
254
259
 
255
260
  if (column.backgroundColorAxis && row[`bc${columnIndex}`] != null) {
@@ -272,10 +277,10 @@ class TableContentsComponent extends React.Component<TableContentsComponentProps
272
277
  node = exprUtils.stringifyExprLiteral(column.textAxis?.expr, value, this.context.locale)
273
278
  break
274
279
  case "date":
275
- node = moment(value, "YYYY-MM-DD").format("ll")
280
+ node = formatValue(exprType, value, column.format)
276
281
  break
277
282
  case "datetime":
278
- node = moment(value, moment.ISO_8601).format("lll")
283
+ node = formatValue(exprType, value, column.format)
279
284
  break
280
285
  case "image":
281
286
  node = this.renderImage(value.id)
@@ -155,9 +155,9 @@ class DashboardPopupTest extends React.Component {
155
155
  }
156
156
 
157
157
 
158
- const ModalWindowComponent = require('react-library/lib/ModalWindowComponent');
159
- const ui = require('react-library/lib/bootstrap');
160
- const update = require('react-library/lib/update');
158
+ const ModalWindowComponent = require("@mwater/react-library/lib/ModalWindowComponent");
159
+ const ui = require("@mwater/react-library/lib/bootstrap");
160
+ const update = require("@mwater/react-library/lib/update");
161
161
 
162
162
  class DashboardPopupComponent extends React.Component {
163
163
  static initClass() {