@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.
- package/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- 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 {
|
|
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
|
|
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
|
|
115
|
+
this.axisBuilder.summarizeAxis(this.props.design.dateAxis!, this.context) +
|
|
116
116
|
" is " +
|
|
117
|
-
this.axisBuilder.formatValue(this.props.design.dateAxis!, data, this.context
|
|
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",
|
|
277
|
-
{ label: "Save as 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
|
|