@mwater/visualization 5.1.0 → 5.3.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 (305) hide show
  1. package/lib/ColorComponent.d.ts +10 -11
  2. package/lib/ColorComponent.js +78 -29
  3. package/lib/ColorSchemeFactory.d.ts +13 -2
  4. package/lib/ColorSchemeFactory.js +7 -5
  5. package/lib/CustomColorsContext.d.ts +6 -0
  6. package/lib/CustomColorsContext.js +6 -0
  7. package/lib/FiltersDesignerComponent.d.ts +1 -4
  8. package/lib/FiltersDesignerComponent.js +2 -3
  9. package/lib/GlobalFilter.d.ts +13 -0
  10. package/lib/GlobalFilter.js +2 -0
  11. package/lib/LocaleContextInjector.d.ts +5 -11
  12. package/lib/LocaleContextInjector.js +4 -12
  13. package/lib/MWaterAddRelatedFormComponent.js +3 -3
  14. package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
  15. package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
  16. package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
  17. package/lib/MWaterCompleteTableSelectComponent.js +36 -36
  18. package/lib/MWaterContextComponent.d.ts +19 -9
  19. package/lib/MWaterContextComponent.js +38 -22
  20. package/lib/MWaterCustomTablesetListComponent.js +9 -3
  21. package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
  22. package/lib/MWaterGlobalFiltersComponent.js +4 -4
  23. package/lib/MWaterLoaderComponent.d.ts +15 -3
  24. package/lib/MWaterLoaderComponent.js +11 -2
  25. package/lib/MWaterTableSelectComponent.d.ts +1 -4
  26. package/lib/MWaterTableSelectComponent.js +10 -12
  27. package/lib/UIComponents.d.ts +2 -2
  28. package/lib/UIComponents.js +4 -12
  29. package/lib/axes/Axis.d.ts +20 -25
  30. package/lib/axes/AxisBuilder.d.ts +7 -4
  31. package/lib/axes/AxisBuilder.js +12 -8
  32. package/lib/axes/AxisComponent.d.ts +6 -9
  33. package/lib/axes/AxisComponent.js +1 -2
  34. package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
  35. package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
  36. package/lib/dashboards/DashboardComponent.d.ts +4 -17
  37. package/lib/dashboards/DashboardComponent.js +20 -67
  38. package/lib/dashboards/DashboardDesign.d.ts +5 -20
  39. package/lib/dashboards/DashboardUpgrader.js +36 -1
  40. package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
  41. package/lib/dashboards/DashboardViewComponent.js +112 -136
  42. package/lib/dashboards/FontStyleEditor.d.ts +8 -0
  43. package/lib/dashboards/FontStyleEditor.js +130 -0
  44. package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
  45. package/lib/dashboards/LayoutOptionsComponent.js +209 -39
  46. package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
  47. package/lib/dashboards/ServerDashboardDataSource.js +52 -33
  48. package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
  49. package/lib/dashboards/SettingsModalComponent.js +24 -38
  50. package/lib/dashboards/WidgetComponent.d.ts +3 -3
  51. package/lib/dashboards/WidgetComponent.js +3 -6
  52. package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
  53. package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
  54. package/lib/dashboards/layoutOptions.d.ts +83 -0
  55. package/lib/dashboards/layoutOptions.js +436 -10
  56. package/lib/datagrids/DatagridComponent.d.ts +2 -9
  57. package/lib/datagrids/DatagridDataSource.d.ts +3 -3
  58. package/lib/datagrids/DatagridDataSource.js +0 -14
  59. package/lib/datagrids/DatagridDesign.d.ts +7 -6
  60. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
  61. package/lib/datagrids/DatagridDesignerComponent.js +8 -6
  62. package/lib/datagrids/DatagridViewComponent.js +1 -1
  63. package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
  64. package/lib/datagrids/FindReplaceModalComponent.js +27 -13
  65. package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
  66. package/lib/datagrids/ServerDatagridDataSource.js +88 -36
  67. package/lib/demo.js +4 -4
  68. package/lib/index.css +5 -0
  69. package/lib/index.d.ts +2 -1
  70. package/lib/index.js +0 -1
  71. package/lib/layouts/LayoutManager.d.ts +33 -29
  72. package/lib/layouts/LayoutManager.js +2 -8
  73. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
  74. package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
  75. package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
  76. package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
  77. package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
  78. package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
  79. package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
  80. package/lib/mWaterLoader.d.ts +2 -0
  81. package/lib/mWaterLoader.js +2 -1
  82. package/lib/maps/AddLayerComponent.d.ts +6 -8
  83. package/lib/maps/AddLayerComponent.js +6 -6
  84. package/lib/maps/BingLayer.js +10 -20
  85. package/lib/maps/BufferLayer.js +5 -2
  86. package/lib/maps/ChoroplethLayer.js +2 -1
  87. package/lib/maps/ClusterLayer.js +3 -1
  88. package/lib/maps/DirectMapDataSource.d.ts +5 -2
  89. package/lib/maps/DirectMapDataSource.js +2 -1
  90. package/lib/maps/EditPopupComponent.js +2 -1
  91. package/lib/maps/GridLayer.js +5 -3
  92. package/lib/maps/GridLayerDesigner.js +0 -1
  93. package/lib/maps/LayerSwitcherComponent.js +1 -1
  94. package/lib/maps/MapComponent.d.ts +3 -11
  95. package/lib/maps/MapComponent.js +3 -3
  96. package/lib/maps/MapDesign.d.ts +2 -13
  97. package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
  98. package/lib/maps/MapFiltersDesignerComponent.js +4 -5
  99. package/lib/maps/MarkersLayer.js +30 -25
  100. package/lib/maps/RasterMapViewComponent.d.ts +3 -13
  101. package/lib/maps/RasterMapViewComponent.js +3 -3
  102. package/lib/maps/RegionSelectComponent.d.ts +2 -1
  103. package/lib/maps/ServerMapDataSource.d.ts +3 -4
  104. package/lib/maps/ServerMapDataSource.js +5 -5
  105. package/lib/maps/VectorMapViewComponent.js +2 -1
  106. package/lib/maps/mapSymbols.js +2 -0
  107. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  108. package/lib/maps/vectorMaps.d.ts +1 -0
  109. package/lib/maps/vectorMaps.js +70 -56
  110. package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
  111. package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
  112. package/lib/quickfilter/QuickfiltersComponent.js +3 -3
  113. package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
  114. package/lib/richtext/DropdownPaletteItem.js +82 -0
  115. package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
  116. package/lib/richtext/FontColorPaletteItem.js +32 -27
  117. package/lib/richtext/ItemsHtmlConverter.js +12 -3
  118. package/lib/richtext/RichTextComponent.d.ts +26 -52
  119. package/lib/richtext/RichTextComponent.js +166 -128
  120. package/lib/valueFormatter.js +6 -1
  121. package/lib/wellknown.d.ts +5 -0
  122. package/lib/wellknown.js +288 -0
  123. package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
  124. package/lib/widgets/DropdownWidgetComponent.js +48 -25
  125. package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
  126. package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
  127. package/lib/widgets/MapWidget.d.ts +4 -7
  128. package/lib/widgets/MapWidget.js +2 -1
  129. package/lib/widgets/MarkdownWidget.d.ts +2 -7
  130. package/lib/widgets/TOCWidget.d.ts +2 -9
  131. package/lib/widgets/TOCWidget.js +2 -1
  132. package/lib/widgets/Widget.d.ts +2 -0
  133. package/lib/widgets/WidgetDataSource.d.ts +3 -1
  134. package/lib/widgets/charts/Chart.d.ts +0 -1
  135. package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
  136. package/lib/widgets/charts/ChartViewComponent.js +11 -3
  137. package/lib/widgets/charts/ChartWidget.d.ts +1 -74
  138. package/lib/widgets/charts/ChartWidget.js +4 -183
  139. package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
  140. package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
  141. package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
  142. package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
  143. package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
  144. package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
  145. package/lib/widgets/charts/layered/LayeredChart.js +6 -7
  146. package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
  147. package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
  148. package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
  149. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
  150. package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
  151. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
  152. package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
  153. package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
  154. package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
  155. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
  156. package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
  157. package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
  158. package/lib/widgets/charts/pivot/PivotChart.js +47 -17
  159. package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
  160. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
  161. package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
  162. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
  163. package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
  164. package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
  165. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
  166. package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
  167. package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
  168. package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
  169. package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
  170. package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
  171. package/lib/widgets/charts/table/TableChart.js +8 -4
  172. package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
  173. package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
  174. package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
  175. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
  176. package/lib/widgets/text/TextComponent.d.ts +5 -12
  177. package/lib/widgets/text/TextComponent.js +19 -39
  178. package/lib/widgets/text/TextWidget.d.ts +2 -1
  179. package/lib/widgets/text/TextWidget.js +5 -1
  180. package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
  181. package/lib/widgets/text/TextWidgetComponent.js +76 -19
  182. package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
  183. package/lib/widgets/text/TextWidgetDesign.js +6 -0
  184. package/package.json +4 -4
  185. package/src/ColorComponent.tsx +177 -0
  186. package/src/ColorSchemeFactory.ts +12 -6
  187. package/src/CustomColorsContext.tsx +8 -0
  188. package/src/FiltersDesignerComponent.ts +3 -4
  189. package/src/GlobalFilter.ts +17 -0
  190. package/src/LocaleContextInjector.tsx +14 -13
  191. package/src/MWaterAddRelatedFormComponent.ts +3 -3
  192. package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
  193. package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
  194. package/src/MWaterContextComponent.tsx +42 -33
  195. package/src/MWaterCustomTablesetListComponent.tsx +21 -3
  196. package/src/MWaterGlobalFiltersComponent.ts +8 -8
  197. package/src/MWaterLoaderComponent.ts +14 -4
  198. package/src/MWaterTableSelectComponent.tsx +11 -12
  199. package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
  200. package/src/axes/Axis.ts +24 -25
  201. package/src/axes/AxisBuilder.ts +16 -13
  202. package/src/axes/AxisComponent.ts +3 -4
  203. package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
  204. package/src/dashboards/DashboardComponent.tsx +73 -147
  205. package/src/dashboards/DashboardDesign.ts +5 -25
  206. package/src/dashboards/DashboardUpgrader.ts +41 -1
  207. package/src/dashboards/DashboardViewComponent.tsx +313 -0
  208. package/src/dashboards/FontStyleEditor.tsx +166 -0
  209. package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
  210. package/src/dashboards/ServerDashboardDataSource.ts +52 -33
  211. package/src/dashboards/SettingsModalComponent.tsx +170 -0
  212. package/src/dashboards/WidgetComponent.tsx +6 -12
  213. package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
  214. package/src/dashboards/layoutOptions.tsx +581 -0
  215. package/src/datagrids/DatagridDataSource.ts +6 -12
  216. package/src/datagrids/DatagridDesign.ts +8 -3
  217. package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
  218. package/src/datagrids/DatagridViewComponent.ts +3 -3
  219. package/src/datagrids/ExprCellComponent.ts +0 -1
  220. package/src/datagrids/FindReplaceModalComponent.ts +39 -22
  221. package/src/datagrids/ServerDatagridDataSource.ts +107 -45
  222. package/src/demo.ts +4 -4
  223. package/src/index.css +5 -0
  224. package/src/index.ts +2 -1
  225. package/src/layouts/LayoutManager.ts +44 -42
  226. package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
  227. package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
  228. package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
  229. package/src/mWaterLoader.ts +4 -1
  230. package/src/maps/AddLayerComponent.ts +9 -9
  231. package/src/maps/BingLayer.ts +16 -26
  232. package/src/maps/BufferLayer.ts +5 -2
  233. package/src/maps/ChoroplethLayer.ts +2 -1
  234. package/src/maps/ClusterLayer.ts +3 -1
  235. package/src/maps/DirectMapDataSource.ts +12 -3
  236. package/src/maps/EditPopupComponent.ts +2 -1
  237. package/src/maps/GridLayer.ts +5 -3
  238. package/src/maps/GridLayerDesigner.tsx +0 -1
  239. package/src/maps/LayerSwitcherComponent.tsx +1 -1
  240. package/src/maps/MapComponent.ts +3 -3
  241. package/src/maps/MapDesign.ts +2 -17
  242. package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
  243. package/src/maps/MarkersLayer.ts +38 -41
  244. package/src/maps/RasterMapViewComponent.ts +3 -3
  245. package/src/maps/ServerMapDataSource.ts +8 -8
  246. package/src/maps/VectorMapViewComponent.tsx +2 -2
  247. package/src/maps/mapSymbols.ts +2 -0
  248. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  249. package/src/maps/vectorMaps.tsx +88 -74
  250. package/src/quickfilter/QuickfilterCompiler.ts +1 -1
  251. package/src/quickfilter/QuickfiltersComponent.ts +3 -3
  252. package/src/richtext/DropdownPaletteItem.tsx +144 -0
  253. package/src/richtext/FontColorPaletteItem.tsx +160 -0
  254. package/src/richtext/ItemsHtmlConverter.ts +15 -5
  255. package/src/richtext/RichTextComponent.tsx +274 -232
  256. package/src/valueFormatter.ts +5 -1
  257. package/src/wellknown.ts +286 -0
  258. package/src/widgets/DropdownWidgetComponent.tsx +75 -0
  259. package/src/widgets/MapWidget.ts +5 -2
  260. package/src/widgets/TOCWidget.ts +2 -1
  261. package/src/widgets/Widget.ts +3 -0
  262. package/src/widgets/WidgetDataSource.ts +3 -1
  263. package/src/widgets/charts/Chart.ts +1 -1
  264. package/src/widgets/charts/ChartViewComponent.ts +16 -3
  265. package/src/widgets/charts/ChartWidget.ts +3 -275
  266. package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
  267. package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
  268. package/src/widgets/charts/layered/LayeredChart.ts +4 -6
  269. package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
  270. package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
  271. package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
  272. package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
  273. package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
  274. package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
  275. package/src/widgets/charts/pivot/PivotChart.ts +56 -18
  276. package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
  277. package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
  278. package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
  279. package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
  280. package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
  281. package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
  282. package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
  283. package/src/widgets/charts/table/TableChart.ts +8 -4
  284. package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
  285. package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
  286. package/src/widgets/text/TextComponent.tsx +47 -49
  287. package/src/widgets/text/TextWidget.ts +8 -3
  288. package/src/widgets/text/TextWidgetComponent.tsx +249 -0
  289. package/src/widgets/text/TextWidgetDesign.ts +26 -2
  290. package/src/ColorComponent.ts +0 -117
  291. package/src/dashboards/DashboardViewComponent.ts +0 -304
  292. package/src/dashboards/SettingsModalComponent.ts +0 -169
  293. package/src/dashboards/layoutOptions.ts +0 -40
  294. package/src/layout-styles.css +0 -263
  295. package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
  296. package/src/layouts/grid/GridLayoutComponent.ts +0 -67
  297. package/src/layouts/grid/GridLayoutManager.ts +0 -185
  298. package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
  299. package/src/layouts/grid/PaletteItemComponent.ts +0 -28
  300. package/src/layouts/grid/README.md +0 -14
  301. package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
  302. package/src/richtext/FontColorPaletteItem.ts +0 -172
  303. package/src/richtext/FontSizePaletteItem.ts +0 -110
  304. package/src/widgets/DropdownWidgetComponent.ts +0 -78
  305. package/src/widgets/text/TextWidgetComponent.ts +0 -120
@@ -1,17 +1,9 @@
1
- import PropTypes from "prop-types"
2
1
  import React from "react"
3
2
  const R = React.createElement
4
3
  import Widget, { CreateViewElementOptions } from "./../Widget"
5
- import DropdownWidgetComponent from "./../DropdownWidgetComponent"
6
- import CsvBuilder from "./../../CsvBuilder"
7
- import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent"
8
- import ChartViewComponent from "./ChartViewComponent"
9
- import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent"
10
- import * as ui from "@mwater/react-library/lib/bootstrap"
11
4
  import { DataSource, Schema } from "@mwater/expressions"
12
- import { WidgetDataSource } from "../WidgetDataSource"
13
5
  import Chart from "./Chart"
14
- import { JsonQLFilter } from "../../JsonQLFilter"
6
+ import { ChartWidgetComponent } from "./ChartWidgetComponent"
15
7
 
16
8
  /** A widget which is a chart */
17
9
  export default class ChartWidget extends Widget {
@@ -48,7 +40,8 @@ export default class ChartWidget extends Widget {
48
40
  onDesignChange: options.onDesignChange,
49
41
  width: options.width,
50
42
  height: options.height,
51
- onRowClick: options.onRowClick
43
+ onRowClick: options.onRowClick,
44
+ refreshKey: options.refreshKey
52
45
  })
53
46
  }
54
47
 
@@ -78,268 +71,3 @@ export default class ChartWidget extends Widget {
78
71
  return this.chart.isAutoHeight()
79
72
  }
80
73
  }
81
-
82
- interface ChartWidgetComponentProps {
83
- /** schema to use */
84
- schema: Schema
85
- /** data source to use */
86
- dataSource: DataSource
87
- widgetDataSource: WidgetDataSource
88
- /** Chart object to use */
89
- chart: Chart
90
- /** Design of chart */
91
- design: any
92
- /** null/undefined for readonly */
93
- onDesignChange?: any
94
-
95
- /** Width in pixels */
96
- width: number
97
-
98
- /** Height, if a fixed height widget, or one that uses aspect ratio */
99
- height?: number
100
-
101
- /** scope of the widget (when the widget self-selects a particular scope) */
102
- scope?: any
103
-
104
- /** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
105
- filters: JsonQLFilter[]
106
-
107
- /** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
108
- onScopeChange?: any
109
- /** Called with (tableId, rowId) when item is clicked */
110
- onRowClick?: any
111
- /** Connects move handle for dragging (see WidgetContainerComponent) TODO REMOVE */
112
- connectMoveHandle?: any
113
- /** Connects resize handle for dragging (see WidgetContainerComponent) TODO REMOVE */
114
- connectResizeHandle?: any
115
- }
116
-
117
- // Complete chart widget
118
- class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, { editDesign: any }> {
119
- static contextTypes = { locale: PropTypes.string }
120
-
121
- constructor(props: any) {
122
- super(props)
123
-
124
- this.state = {
125
- // Design that is being edited. Change is propagated on closing window
126
- editDesign: null
127
- }
128
- }
129
-
130
- // Saves a csv file to disk
131
- handleSaveCsvFile = () => {
132
- // Get the data
133
- return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err: any, data: any) => {
134
- if (err) {
135
- return alert("Failed to get data: " + err.message)
136
- }
137
-
138
- // Create data table
139
- const table = this.props.chart.createDataTable(
140
- this.props.design,
141
- this.props.schema,
142
- this.props.dataSource,
143
- data,
144
- this.context.locale
145
- )
146
- if (!table) {
147
- return
148
- }
149
-
150
- // Convert to csv
151
- let csv = new CsvBuilder().build(table)
152
-
153
- // Add BOM
154
- csv = "\uFEFF" + csv
155
-
156
- // Make a blob and save
157
- const blob = new Blob([csv], { type: "text/csv" })
158
-
159
- // Require at use as causes server problems
160
- const FileSaver = require("file-saver")
161
- return FileSaver.saveAs(blob, "Exported Data.csv")
162
- })
163
- }
164
-
165
- handleStartEditing = () => {
166
- // Can't edit if already editing
167
- if (this.state.editDesign) {
168
- return
169
- }
170
- this.setState({ editDesign: this.props.design })
171
- }
172
-
173
- handleEndEditing = () => {
174
- this.props.onDesignChange(this.state.editDesign)
175
- this.setState({ editDesign: null })
176
- }
177
-
178
- handleCancelEditing = () => {
179
- this.setState({ editDesign: null })
180
- }
181
-
182
- handleEditDesignChange = (design: any) => {
183
- this.setState({ editDesign: design })
184
- }
185
-
186
- renderChart(design: any, onDesignChange: any, width: any, height: any) {
187
- return R(ChartViewComponent, {
188
- chart: this.props.chart,
189
- design,
190
- onDesignChange,
191
- schema: this.props.schema,
192
- dataSource: this.props.dataSource,
193
- widgetDataSource: this.props.widgetDataSource,
194
- scope: this.props.scope,
195
- filters: this.props.filters,
196
- width,
197
- height,
198
- onScopeChange: this.props.onScopeChange,
199
- onRowClick: this.props.onRowClick
200
- })
201
- }
202
-
203
- renderEditor() {
204
- if (!this.state.editDesign) {
205
- return null
206
- }
207
-
208
- // Create editor
209
- const editor = this.props.chart.createDesignerElement({
210
- schema: this.props.schema,
211
- filters: this.props.filters,
212
- dataSource: this.props.dataSource,
213
- design: this.state.editDesign,
214
- onDesignChange: this.handleEditDesignChange
215
- })
216
-
217
- if (this.props.chart.hasDesignerPreview()) {
218
- // Create chart (maxing out at half of width of screen)
219
- const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width)
220
- const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined
221
- const chart = this.renderChart(
222
- this.state.editDesign,
223
- (design: any) => this.setState({ editDesign: design }),
224
- chartWidth,
225
- chartHeight
226
- )
227
-
228
- const content = R(
229
- "div",
230
- { style: { height: "100%", width: "100%" } },
231
- R(
232
- "div",
233
- {
234
- style: {
235
- position: "absolute",
236
- left: 0,
237
- top: 0,
238
- border: "solid 2px #EEE",
239
- borderRadius: 8,
240
- padding: 10,
241
- width: chartWidth + 20,
242
- height: chartHeight != null ? chartHeight + 20 : undefined,
243
- overflow: "hidden"
244
- }
245
- },
246
- chart
247
- ),
248
- R(
249
- "div",
250
- { style: { width: "100%", height: "100%", paddingLeft: chartWidth + 40 } },
251
- R(
252
- "div",
253
- {
254
- style: {
255
- width: "100%",
256
- height: "100%",
257
- overflowY: "auto",
258
- paddingLeft: 20,
259
- paddingRight: 20,
260
- borderLeft: "solid 3px #AAA"
261
- }
262
- },
263
- editor
264
- )
265
- )
266
- )
267
-
268
- return R(
269
- ModalWindowComponent,
270
- {
271
- isOpen: true,
272
- onRequestClose: this.handleEndEditing
273
- },
274
- content
275
- )
276
- } else {
277
- return R(
278
- ActionCancelModalComponent,
279
- {
280
- size: "large",
281
- onCancel: this.handleCancelEditing,
282
- onAction: this.handleEndEditing
283
- },
284
- editor
285
- )
286
- }
287
- }
288
-
289
- // Render a link to start editing
290
- renderEditLink() {
291
- return R(
292
- "div",
293
- { className: "mwater-visualization-widget-placeholder", onClick: this.handleStartEditing },
294
- R(ui.Icon, { id: this.props.chart.getPlaceholderIcon() })
295
- )
296
- }
297
-
298
- render() {
299
- const design = this.props.chart.cleanDesign(this.props.design, this.props.schema)
300
-
301
- // Determine if valid design
302
- const validDesign = !this.props.chart.validateDesign(design, this.props.schema)
303
-
304
- // Determine if empty
305
- const emptyDesign = this.props.chart.isEmpty(design)
306
-
307
- // Create dropdown items
308
- const dropdownItems = this.props.chart.createDropdownItems(
309
- design,
310
- this.props.schema,
311
- this.props.widgetDataSource,
312
- this.props.filters
313
- )
314
- if (validDesign) {
315
- dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile })
316
- }
317
- if (this.props.onDesignChange != null) {
318
- dropdownItems.unshift({
319
- label: this.props.chart.getEditLabel(),
320
- icon: "pencil",
321
- onClick: this.handleStartEditing
322
- })
323
- }
324
-
325
- // Wrap in a simple widget
326
- return R(
327
- "div",
328
- {
329
- onDoubleClick: this.props.onDesignChange != null ? this.handleStartEditing : undefined,
330
- style: { position: "relative", width: this.props.width }
331
- },
332
- this.props.onDesignChange != null ? this.renderEditor() : undefined,
333
- React.createElement(
334
- DropdownWidgetComponent,
335
- {
336
- width: this.props.width,
337
- height: this.props.height,
338
- dropdownItems
339
- },
340
- this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)
341
- ),
342
- (emptyDesign || !validDesign) && this.props.onDesignChange != null ? this.renderEditLink() : undefined
343
- )
344
- }
345
- }
@@ -0,0 +1,281 @@
1
+ import React from "react"
2
+ import DropdownWidgetComponent from "../DropdownWidgetComponent"
3
+ import CsvBuilder from "../../CsvBuilder"
4
+ import ActionCancelModalComponent from "@mwater/react-library/lib/ActionCancelModalComponent"
5
+ import ChartViewComponent from "./ChartViewComponent"
6
+ import ModalWindowComponent from "@mwater/react-library/lib/ModalWindowComponent"
7
+ import * as ui from "@mwater/react-library/lib/bootstrap"
8
+ import { DataSource, Schema } from "@mwater/expressions"
9
+ import { WidgetDataSource } from "../WidgetDataSource"
10
+ import Chart from "./Chart"
11
+ import { JsonQLFilter } from "../../JsonQLFilter"
12
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
13
+ import { BlocksLayoutOptionsContext, createDashboardStyles, DashboardStyleWrapper, getDefaultLayoutOptions } from "../../dashboards/layoutOptions"
14
+
15
+ export interface ChartWidgetComponentProps {
16
+ /** schema to use */
17
+ schema: Schema
18
+ /** data source to use */
19
+ dataSource: DataSource
20
+ widgetDataSource: WidgetDataSource
21
+ /** Chart object to use */
22
+ chart: Chart
23
+ /** Design of chart */
24
+ design: any
25
+ /** null/undefined for readonly */
26
+ onDesignChange?: any
27
+
28
+ /** Width in pixels */
29
+ width: number
30
+
31
+ /** Height, if a fixed height widget, or one that uses aspect ratio */
32
+ height?: number
33
+
34
+ /** scope of the widget (when the widget self-selects a particular scope) */
35
+ scope?: any
36
+
37
+ /** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
38
+ filters: JsonQLFilter[]
39
+
40
+ /** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
41
+ onScopeChange?: any
42
+ /** Called with (tableId, rowId) when item is clicked */
43
+ onRowClick?: any
44
+ /** Connects move handle for dragging (see WidgetContainerComponent) TODO REMOVE */
45
+ connectMoveHandle?: any
46
+ /** Connects resize handle for dragging (see WidgetContainerComponent) TODO REMOVE */
47
+ connectResizeHandle?: any
48
+
49
+ /** A key that changes when the widget should be refreshed */
50
+ refreshKey?: any
51
+ }
52
+
53
+ // Complete chart widget
54
+ export class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, { editDesign: any }> {
55
+ static contextType = LocaleContext
56
+
57
+ constructor(props: any) {
58
+ super(props)
59
+
60
+ this.state = {
61
+ // Design that is being edited. Change is propagated on closing window
62
+ editDesign: null
63
+ }
64
+ }
65
+
66
+ // Saves a csv file to disk
67
+ handleSaveCsvFile = () => {
68
+ // Get the data
69
+ return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err: any, data: any) => {
70
+ if (err) {
71
+ return alert("Failed to get data: " + err.message)
72
+ }
73
+
74
+ // Create data table
75
+ const table = this.props.chart.createDataTable(
76
+ this.props.design,
77
+ this.props.schema,
78
+ this.props.dataSource,
79
+ data,
80
+ this.context
81
+ )
82
+ if (!table) {
83
+ return
84
+ }
85
+
86
+ // Convert to csv
87
+ let csv = new CsvBuilder().build(table)
88
+
89
+ // Add BOM
90
+ csv = "\uFEFF" + csv
91
+
92
+ // Make a blob and save
93
+ const blob = new Blob([csv], { type: "text/csv" })
94
+
95
+ // Require at use as causes server problems
96
+ const FileSaver = require("file-saver")
97
+ return FileSaver.saveAs(blob, "Exported Data.csv")
98
+ })
99
+ }
100
+
101
+ handleStartEditing = () => {
102
+ // Can't edit if already editing
103
+ if (this.state.editDesign) {
104
+ return
105
+ }
106
+ this.setState({ editDesign: this.props.design })
107
+ }
108
+
109
+ handleEndEditing = () => {
110
+ this.props.onDesignChange(this.state.editDesign)
111
+ this.setState({ editDesign: null })
112
+ }
113
+
114
+ handleCancelEditing = () => {
115
+ this.setState({ editDesign: null })
116
+ }
117
+
118
+ handleEditDesignChange = (design: any) => {
119
+ this.setState({ editDesign: design })
120
+ }
121
+
122
+ renderChart(design: any, onDesignChange: any, width: any, height: any) {
123
+ return <ChartViewComponent
124
+ chart={this.props.chart}
125
+ design={design}
126
+ onDesignChange={onDesignChange}
127
+ schema={this.props.schema}
128
+ dataSource={this.props.dataSource}
129
+ widgetDataSource={this.props.widgetDataSource}
130
+ scope={this.props.scope}
131
+ filters={this.props.filters}
132
+ width={width}
133
+ height={height}
134
+ onScopeChange={this.props.onScopeChange}
135
+ onRowClick={this.props.onRowClick}
136
+ refreshKey={this.props.refreshKey}
137
+ />
138
+ }
139
+
140
+ renderEditor() {
141
+ if (!this.state.editDesign) {
142
+ return null
143
+ }
144
+
145
+ // Create editor
146
+ const editor = this.props.chart.createDesignerElement({
147
+ schema: this.props.schema,
148
+ filters: this.props.filters,
149
+ dataSource: this.props.dataSource,
150
+ design: this.state.editDesign,
151
+ onDesignChange: this.handleEditDesignChange
152
+ })
153
+
154
+ if (this.props.chart.hasDesignerPreview()) {
155
+ // Create chart (maxing out at half of width of screen)
156
+ const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width)
157
+ const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined
158
+ let chart = this.renderChart(
159
+ this.state.editDesign,
160
+ (design: any) => this.setState({ editDesign: design }),
161
+ chartWidth,
162
+ chartHeight
163
+ )
164
+
165
+ const content = (
166
+ <div style={{ height: "100%", width: "100%" }}>
167
+ <BlocksLayoutOptionsContext.Consumer>
168
+ {blocksLayoutOptions => (
169
+ <style dangerouslySetInnerHTML={{ __html: createDashboardStyles("#chart-editor", blocksLayoutOptions || getDefaultLayoutOptions()) }} />
170
+ )}
171
+ </BlocksLayoutOptionsContext.Consumer>
172
+
173
+ <div
174
+ style={{
175
+ position: "absolute",
176
+ left: 0,
177
+ top: 0,
178
+ border: "solid 2px #EEE",
179
+ borderRadius: 8,
180
+ padding: 10,
181
+ width: chartWidth + 20,
182
+ height: chartHeight != null ? chartHeight + 20 : undefined,
183
+ overflow: "hidden"
184
+ }}
185
+ id="chart-editor"
186
+ >
187
+ {chart}
188
+ </div>
189
+ <div style={{ width: "100%", height: "100%", paddingLeft: chartWidth + 40 }}>
190
+ <div
191
+ style={{
192
+ width: "100%",
193
+ height: "100%",
194
+ overflowY: "auto",
195
+ paddingLeft: 20,
196
+ paddingRight: 20,
197
+ borderLeft: "solid 3px #AAA"
198
+ }}
199
+ >
200
+ {editor}
201
+ </div>
202
+ </div>
203
+ </div>
204
+ )
205
+
206
+ return (
207
+ <ModalWindowComponent
208
+ isOpen={true}
209
+ onRequestClose={this.handleEndEditing}
210
+ >
211
+ {content}
212
+ </ModalWindowComponent>
213
+ )
214
+ } else {
215
+ return (
216
+ <ActionCancelModalComponent
217
+ size="large"
218
+ onCancel={this.handleCancelEditing}
219
+ onAction={this.handleEndEditing}
220
+ >
221
+ {editor}
222
+ </ActionCancelModalComponent>
223
+ )
224
+ }
225
+ }
226
+
227
+ // Render a link to start editing
228
+ renderEditLink(message: string) {
229
+ return (
230
+ <div className="mwater-visualization-widget-placeholder" onClick={this.handleStartEditing}>
231
+ <ui.Icon id={this.props.chart.getPlaceholderIcon()} />
232
+ <div className="mwater-visualization-widget-placeholder-message">{message}</div>
233
+ </div>
234
+ )
235
+ }
236
+
237
+ render() {
238
+ const design = this.props.chart.cleanDesign(this.props.design, this.props.schema)
239
+
240
+ // Determine if valid design
241
+ const designError = this.props.chart.validateDesign(design, this.props.schema)
242
+
243
+ // Determine if empty
244
+ const emptyDesign = this.props.chart.isEmpty(design)
245
+
246
+ // Create dropdown items
247
+ const dropdownItems = this.props.chart.createDropdownItems(
248
+ design,
249
+ this.props.schema,
250
+ this.props.widgetDataSource,
251
+ this.props.filters
252
+ )
253
+ if (!designError) {
254
+ dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile })
255
+ }
256
+ if (this.props.onDesignChange != null) {
257
+ dropdownItems.unshift({
258
+ label: this.props.chart.getEditLabel(),
259
+ onClick: this.handleStartEditing
260
+ })
261
+ }
262
+
263
+ // Wrap in a simple widget
264
+ return (
265
+ <div
266
+ onDoubleClick={this.props.onDesignChange != null ? this.handleStartEditing : undefined}
267
+ style={{ position: "relative", width: this.props.width }}
268
+ >
269
+ {this.props.onDesignChange != null ? this.renderEditor() : undefined}
270
+ <DropdownWidgetComponent
271
+ width={this.props.width}
272
+ height={this.props.height}
273
+ dropdownItems={dropdownItems}
274
+ >
275
+ {this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)}
276
+ </DropdownWidgetComponent>
277
+ {(emptyDesign || designError) && this.props.onDesignChange != null ? this.renderEditLink(designError || "") : undefined}
278
+ </div>
279
+ )
280
+ }
281
+ }
@@ -1,5 +1,4 @@
1
1
  import $ from "jquery"
2
- import PropTypes from "prop-types"
3
2
  import _ from "lodash"
4
3
  import React from "react"
5
4
  const R = React.createElement
@@ -7,6 +6,7 @@ import moment from "moment"
7
6
  import AxisBuilder from "../../../axes/AxisBuilder"
8
7
  import { Schema } from "@mwater/expressions"
9
8
  import * as d3 from "d3"
9
+ import { LocaleContext } from "@mwater/expressions-ui/lib/contexts"
10
10
 
11
11
  // Require d3-tip to use it
12
12
  import { default as d3Tip } from "d3-tip"
@@ -46,7 +46,7 @@ export default class CalendarChartViewComponent extends React.Component<Calendar
46
46
  highlightCellFillColor: "#000000"
47
47
  }
48
48
 
49
- static contextTypes = { locale: PropTypes.string }
49
+ static contextType = LocaleContext
50
50
  axisBuilder: AxisBuilder
51
51
  reloading: boolean
52
52
  chart_container: any
@@ -112,9 +112,9 @@ export default class CalendarChartViewComponent extends React.Component<Calendar
112
112
 
113
113
  const scopeData: WidgetScope = {
114
114
  name:
115
- this.axisBuilder.summarizeAxis(this.props.design.dateAxis!, this.context.locale) +
115
+ this.axisBuilder.summarizeAxis(this.props.design.dateAxis!, this.context) +
116
116
  " is " +
117
- this.axisBuilder.formatValue(this.props.design.dateAxis!, data, this.context.locale),
117
+ this.axisBuilder.formatValue(this.props.design.dateAxis!, data, this.context),
118
118
  filter: {
119
119
  jsonql: this.axisBuilder.createValueFilter(this.props.design.dateAxis!, data),
120
120
  table: this.props.design.table
@@ -1,6 +1,5 @@
1
1
  import _ from "lodash"
2
2
  import React from "react"
3
- const R = React.createElement
4
3
  import async from "async"
5
4
  import { default as produce } from "immer"
6
5
  import { original } from "immer"
@@ -15,6 +14,8 @@ import { LayeredChartDesign } from "./LayeredChartDesign"
15
14
  import { WidgetDataSource } from "../../WidgetDataSource"
16
15
  import { JsonQLFilter } from "../../.."
17
16
  import { JsonQLQuery } from "@mwater/jsonql"
17
+ import LayeredChartViewComponent from "./LayeredChartViewComponent"
18
+ import LayeredChartDesignerComponent from "./LayeredChartDesignerComponent"
18
19
 
19
20
  // See LayeredChart Design.md for the design
20
21
  export default class LayeredChart extends Chart {
@@ -160,7 +161,6 @@ export default class LayeredChart extends Chart {
160
161
  // filters: array of filters
161
162
  createDesignerElement(options: any) {
162
163
  // Require here to prevent server require problems
163
- const LayeredChartDesignerComponent = require("./LayeredChartDesignerComponent").default
164
164
  const props = {
165
165
  schema: options.schema,
166
166
  dataSource: options.dataSource,
@@ -234,8 +234,6 @@ export default class LayeredChart extends Chart {
234
234
  // scope: current scope of the view element
235
235
  // onScopeChange: called when scope changes with new scope
236
236
  createViewElement(options: ChartCreateViewElementOptions) {
237
- const LayeredChartViewComponent = require("./LayeredChartViewComponent").default
238
-
239
237
  // Create chart
240
238
  const props = {
241
239
  schema: options.schema,
@@ -273,8 +271,8 @@ export default class LayeredChart extends Chart {
273
271
  }
274
272
 
275
273
  return [
276
- { label: "Save as SVG", icon: "picture", onClick: save.bind(null, "svg") },
277
- { label: "Save as PNG", icon: "camera", onClick: save.bind(null, "png") }
274
+ { label: "Save as SVG", onClick: save.bind(null, "svg") },
275
+ { label: "Save as PNG", onClick: save.bind(null, "png") }
278
276
  ]
279
277
  }
280
278