@mwater/visualization 5.2.0 → 5.3.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.
- 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/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 +5 -16
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +4 -6
- package/lib/MWaterContextComponent.js +4 -13
- package/lib/MWaterLoaderComponent.d.ts +5 -3
- package/lib/MWaterLoaderComponent.js +2 -1
- 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/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +3 -1
- package/lib/axes/AxisComponent.d.ts +2 -5
- 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 -12
- package/lib/dashboards/DashboardComponent.js +18 -38
- package/lib/dashboards/DashboardDesign.d.ts +3 -3
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +109 -132
- 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 +211 -42
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- 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/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.d.ts +7 -6
- package/lib/datagrids/ServerDatagridDataSource.js +87 -33
- package/lib/demo.js +3 -3
- package/lib/index.css +5 -0
- package/lib/index.d.ts +1 -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 -57
- 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/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 +2 -1
- package/lib/maps/ChoroplethLayer.js +2 -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/MapComponent.d.ts +1 -4
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +1 -4
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/ServerMapDataSource.d.ts +2 -3
- 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.js +61 -55
- 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 +1 -2
- package/lib/widgets/ImageWidgetComponent.d.ts +2 -3
- package/lib/widgets/MapWidget.d.ts +2 -0
- package/lib/widgets/MapWidget.js +2 -1
- 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 -62
- 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/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 +3 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -2
- 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 -112
- 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 +1 -1
- 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 -28
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- 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 +11 -11
- 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 +13 -1
- 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 +9 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- 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 +8 -17
- package/src/MWaterLoaderComponent.ts +6 -3
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/AxisBuilder.ts +7 -5
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +71 -107
- package/src/dashboards/DashboardDesign.ts +3 -3
- 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 +380 -75
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/ServerDatagridDataSource.ts +106 -43
- package/src/demo.ts +3 -3
- package/src/index.css +5 -0
- package/src/index.ts +1 -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 +2 -1
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +7 -7
- package/src/maps/VectorMapViewComponent.tsx +2 -1
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +79 -74
- 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 +13 -14
- 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 +22 -1
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -303
- 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,41 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
30
6
|
const react_1 = __importDefault(require("react"));
|
|
31
7
|
const R = react_1.default.createElement;
|
|
32
8
|
const Widget_1 = __importDefault(require("./../Widget"));
|
|
33
|
-
const
|
|
34
|
-
const CsvBuilder_1 = __importDefault(require("./../../CsvBuilder"));
|
|
35
|
-
const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
|
|
36
|
-
const ChartViewComponent_1 = __importDefault(require("./ChartViewComponent"));
|
|
37
|
-
const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
|
|
38
|
-
const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
|
|
9
|
+
const ChartWidgetComponent_1 = require("./ChartWidgetComponent");
|
|
39
10
|
/** A widget which is a chart */
|
|
40
11
|
class ChartWidget extends Widget_1.default {
|
|
41
12
|
chart;
|
|
@@ -57,7 +28,7 @@ class ChartWidget extends Widget_1.default {
|
|
|
57
28
|
// height: height in pixels on screen
|
|
58
29
|
// onRowClick: Called with (tableId, rowId) when item is clicked
|
|
59
30
|
createViewElement(options) {
|
|
60
|
-
return R(ChartWidgetComponent, {
|
|
31
|
+
return R(ChartWidgetComponent_1.ChartWidgetComponent, {
|
|
61
32
|
chart: this.chart,
|
|
62
33
|
design: options.design,
|
|
63
34
|
schema: options.schema,
|
|
@@ -69,7 +40,8 @@ class ChartWidget extends Widget_1.default {
|
|
|
69
40
|
onDesignChange: options.onDesignChange,
|
|
70
41
|
width: options.width,
|
|
71
42
|
height: options.height,
|
|
72
|
-
onRowClick: options.onRowClick
|
|
43
|
+
onRowClick: options.onRowClick,
|
|
44
|
+
refreshKey: options.refreshKey
|
|
73
45
|
});
|
|
74
46
|
}
|
|
75
47
|
// Get the data that the widget needs. This will be called on the server, typically.
|
|
@@ -95,154 +67,3 @@ class ChartWidget extends Widget_1.default {
|
|
|
95
67
|
}
|
|
96
68
|
}
|
|
97
69
|
exports.default = ChartWidget;
|
|
98
|
-
// Complete chart widget
|
|
99
|
-
class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
100
|
-
static contextTypes = { locale: prop_types_1.default.string };
|
|
101
|
-
constructor(props) {
|
|
102
|
-
super(props);
|
|
103
|
-
this.state = {
|
|
104
|
-
// Design that is being edited. Change is propagated on closing window
|
|
105
|
-
editDesign: null
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
// Saves a csv file to disk
|
|
109
|
-
handleSaveCsvFile = () => {
|
|
110
|
-
// Get the data
|
|
111
|
-
return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err, data) => {
|
|
112
|
-
if (err) {
|
|
113
|
-
return alert("Failed to get data: " + err.message);
|
|
114
|
-
}
|
|
115
|
-
// Create data table
|
|
116
|
-
const table = this.props.chart.createDataTable(this.props.design, this.props.schema, this.props.dataSource, data, this.context.locale);
|
|
117
|
-
if (!table) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
// Convert to csv
|
|
121
|
-
let csv = new CsvBuilder_1.default().build(table);
|
|
122
|
-
// Add BOM
|
|
123
|
-
csv = "\uFEFF" + csv;
|
|
124
|
-
// Make a blob and save
|
|
125
|
-
const blob = new Blob([csv], { type: "text/csv" });
|
|
126
|
-
// Require at use as causes server problems
|
|
127
|
-
const FileSaver = require("file-saver");
|
|
128
|
-
return FileSaver.saveAs(blob, "Exported Data.csv");
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
handleStartEditing = () => {
|
|
132
|
-
// Can't edit if already editing
|
|
133
|
-
if (this.state.editDesign) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
this.setState({ editDesign: this.props.design });
|
|
137
|
-
};
|
|
138
|
-
handleEndEditing = () => {
|
|
139
|
-
this.props.onDesignChange(this.state.editDesign);
|
|
140
|
-
this.setState({ editDesign: null });
|
|
141
|
-
};
|
|
142
|
-
handleCancelEditing = () => {
|
|
143
|
-
this.setState({ editDesign: null });
|
|
144
|
-
};
|
|
145
|
-
handleEditDesignChange = (design) => {
|
|
146
|
-
this.setState({ editDesign: design });
|
|
147
|
-
};
|
|
148
|
-
renderChart(design, onDesignChange, width, height) {
|
|
149
|
-
return R(ChartViewComponent_1.default, {
|
|
150
|
-
chart: this.props.chart,
|
|
151
|
-
design,
|
|
152
|
-
onDesignChange,
|
|
153
|
-
schema: this.props.schema,
|
|
154
|
-
dataSource: this.props.dataSource,
|
|
155
|
-
widgetDataSource: this.props.widgetDataSource,
|
|
156
|
-
scope: this.props.scope,
|
|
157
|
-
filters: this.props.filters,
|
|
158
|
-
width,
|
|
159
|
-
height,
|
|
160
|
-
onScopeChange: this.props.onScopeChange,
|
|
161
|
-
onRowClick: this.props.onRowClick
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
renderEditor() {
|
|
165
|
-
if (!this.state.editDesign) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
// Create editor
|
|
169
|
-
const editor = this.props.chart.createDesignerElement({
|
|
170
|
-
schema: this.props.schema,
|
|
171
|
-
filters: this.props.filters,
|
|
172
|
-
dataSource: this.props.dataSource,
|
|
173
|
-
design: this.state.editDesign,
|
|
174
|
-
onDesignChange: this.handleEditDesignChange
|
|
175
|
-
});
|
|
176
|
-
if (this.props.chart.hasDesignerPreview()) {
|
|
177
|
-
// Create chart (maxing out at half of width of screen)
|
|
178
|
-
const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width);
|
|
179
|
-
const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined;
|
|
180
|
-
const chart = this.renderChart(this.state.editDesign, (design) => this.setState({ editDesign: design }), chartWidth, chartHeight);
|
|
181
|
-
const content = R("div", { style: { height: "100%", width: "100%" } }, R("div", {
|
|
182
|
-
style: {
|
|
183
|
-
position: "absolute",
|
|
184
|
-
left: 0,
|
|
185
|
-
top: 0,
|
|
186
|
-
border: "solid 2px #EEE",
|
|
187
|
-
borderRadius: 8,
|
|
188
|
-
padding: 10,
|
|
189
|
-
width: chartWidth + 20,
|
|
190
|
-
height: chartHeight != null ? chartHeight + 20 : undefined,
|
|
191
|
-
overflow: "hidden"
|
|
192
|
-
}
|
|
193
|
-
}, chart), R("div", { style: { width: "100%", height: "100%", paddingLeft: chartWidth + 40 } }, R("div", {
|
|
194
|
-
style: {
|
|
195
|
-
width: "100%",
|
|
196
|
-
height: "100%",
|
|
197
|
-
overflowY: "auto",
|
|
198
|
-
paddingLeft: 20,
|
|
199
|
-
paddingRight: 20,
|
|
200
|
-
borderLeft: "solid 3px #AAA"
|
|
201
|
-
}
|
|
202
|
-
}, editor)));
|
|
203
|
-
return R(ModalWindowComponent_1.default, {
|
|
204
|
-
isOpen: true,
|
|
205
|
-
onRequestClose: this.handleEndEditing
|
|
206
|
-
}, content);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
return R(ActionCancelModalComponent_1.default, {
|
|
210
|
-
size: "large",
|
|
211
|
-
onCancel: this.handleCancelEditing,
|
|
212
|
-
onAction: this.handleEndEditing
|
|
213
|
-
}, editor);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// Render a link to start editing
|
|
217
|
-
renderEditLink() {
|
|
218
|
-
return R("div", { className: "mwater-visualization-widget-placeholder", onClick: this.handleStartEditing }, R(ui.Icon, { id: this.props.chart.getPlaceholderIcon() }));
|
|
219
|
-
}
|
|
220
|
-
render() {
|
|
221
|
-
const design = this.props.chart.cleanDesign(this.props.design, this.props.schema);
|
|
222
|
-
// Determine if valid design
|
|
223
|
-
const validDesign = !this.props.chart.validateDesign(design, this.props.schema);
|
|
224
|
-
// Determine if empty
|
|
225
|
-
const emptyDesign = this.props.chart.isEmpty(design);
|
|
226
|
-
// Create dropdown items
|
|
227
|
-
const dropdownItems = this.props.chart.createDropdownItems(design, this.props.schema, this.props.widgetDataSource, this.props.filters);
|
|
228
|
-
if (validDesign) {
|
|
229
|
-
dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile });
|
|
230
|
-
}
|
|
231
|
-
if (this.props.onDesignChange != null) {
|
|
232
|
-
dropdownItems.unshift({
|
|
233
|
-
label: this.props.chart.getEditLabel(),
|
|
234
|
-
icon: "pencil",
|
|
235
|
-
onClick: this.handleStartEditing
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
// Wrap in a simple widget
|
|
239
|
-
return R("div", {
|
|
240
|
-
onDoubleClick: this.props.onDesignChange != null ? this.handleStartEditing : undefined,
|
|
241
|
-
style: { position: "relative", width: this.props.width }
|
|
242
|
-
}, this.props.onDesignChange != null ? this.renderEditor() : undefined, react_1.default.createElement(DropdownWidgetComponent_1.default, {
|
|
243
|
-
width: this.props.width,
|
|
244
|
-
height: this.props.height,
|
|
245
|
-
dropdownItems
|
|
246
|
-
}, this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)), (emptyDesign || !validDesign) && this.props.onDesignChange != null ? this.renderEditLink() : undefined);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DataSource, Schema } from "@mwater/expressions";
|
|
3
|
+
import { WidgetDataSource } from "../WidgetDataSource";
|
|
4
|
+
import Chart from "./Chart";
|
|
5
|
+
import { JsonQLFilter } from "../../JsonQLFilter";
|
|
6
|
+
export interface ChartWidgetComponentProps {
|
|
7
|
+
/** schema to use */
|
|
8
|
+
schema: Schema;
|
|
9
|
+
/** data source to use */
|
|
10
|
+
dataSource: DataSource;
|
|
11
|
+
widgetDataSource: WidgetDataSource;
|
|
12
|
+
/** Chart object to use */
|
|
13
|
+
chart: Chart;
|
|
14
|
+
/** Design of chart */
|
|
15
|
+
design: any;
|
|
16
|
+
/** null/undefined for readonly */
|
|
17
|
+
onDesignChange?: any;
|
|
18
|
+
/** Width in pixels */
|
|
19
|
+
width: number;
|
|
20
|
+
/** Height, if a fixed height widget, or one that uses aspect ratio */
|
|
21
|
+
height?: number;
|
|
22
|
+
/** scope of the widget (when the widget self-selects a particular scope) */
|
|
23
|
+
scope?: any;
|
|
24
|
+
/** array of filters to apply. Each is { table: table id, jsonql: jsonql condition with {alias} for tableAlias. Use injectAlias to correct */
|
|
25
|
+
filters: JsonQLFilter[];
|
|
26
|
+
/** called with (scope) as a scope to apply to self and filter to apply to other widgets. See WidgetScoper for details */
|
|
27
|
+
onScopeChange?: any;
|
|
28
|
+
/** Called with (tableId, rowId) when item is clicked */
|
|
29
|
+
onRowClick?: any;
|
|
30
|
+
/** Connects move handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
31
|
+
connectMoveHandle?: any;
|
|
32
|
+
/** Connects resize handle for dragging (see WidgetContainerComponent) TODO REMOVE */
|
|
33
|
+
connectResizeHandle?: any;
|
|
34
|
+
/** A key that changes when the widget should be refreshed */
|
|
35
|
+
refreshKey?: any;
|
|
36
|
+
}
|
|
37
|
+
export declare class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, {
|
|
38
|
+
editDesign: any;
|
|
39
|
+
}> {
|
|
40
|
+
static contextType: React.Context<string>;
|
|
41
|
+
constructor(props: any);
|
|
42
|
+
handleSaveCsvFile: () => void | AbortController | undefined;
|
|
43
|
+
handleStartEditing: () => void;
|
|
44
|
+
handleEndEditing: () => void;
|
|
45
|
+
handleCancelEditing: () => void;
|
|
46
|
+
handleEditDesignChange: (design: any) => void;
|
|
47
|
+
renderChart(design: any, onDesignChange: any, width: any, height: any): React.JSX.Element;
|
|
48
|
+
renderEditor(): React.JSX.Element | null;
|
|
49
|
+
renderEditLink(message: string): React.JSX.Element;
|
|
50
|
+
render(): React.JSX.Element;
|
|
51
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ChartWidgetComponent = void 0;
|
|
30
|
+
const react_1 = __importDefault(require("react"));
|
|
31
|
+
const DropdownWidgetComponent_1 = __importDefault(require("../DropdownWidgetComponent"));
|
|
32
|
+
const CsvBuilder_1 = __importDefault(require("../../CsvBuilder"));
|
|
33
|
+
const ActionCancelModalComponent_1 = __importDefault(require("@mwater/react-library/lib/ActionCancelModalComponent"));
|
|
34
|
+
const ChartViewComponent_1 = __importDefault(require("./ChartViewComponent"));
|
|
35
|
+
const ModalWindowComponent_1 = __importDefault(require("@mwater/react-library/lib/ModalWindowComponent"));
|
|
36
|
+
const ui = __importStar(require("@mwater/react-library/lib/bootstrap"));
|
|
37
|
+
const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
|
|
38
|
+
const layoutOptions_1 = require("../../dashboards/layoutOptions");
|
|
39
|
+
// Complete chart widget
|
|
40
|
+
class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
41
|
+
static contextType = contexts_1.LocaleContext;
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
this.state = {
|
|
45
|
+
// Design that is being edited. Change is propagated on closing window
|
|
46
|
+
editDesign: null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Saves a csv file to disk
|
|
50
|
+
handleSaveCsvFile = () => {
|
|
51
|
+
// Get the data
|
|
52
|
+
return this.props.widgetDataSource.getData(this.props.design, this.props.filters, (err, data) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
return alert("Failed to get data: " + err.message);
|
|
55
|
+
}
|
|
56
|
+
// Create data table
|
|
57
|
+
const table = this.props.chart.createDataTable(this.props.design, this.props.schema, this.props.dataSource, data, this.context);
|
|
58
|
+
if (!table) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Convert to csv
|
|
62
|
+
let csv = new CsvBuilder_1.default().build(table);
|
|
63
|
+
// Add BOM
|
|
64
|
+
csv = "\uFEFF" + csv;
|
|
65
|
+
// Make a blob and save
|
|
66
|
+
const blob = new Blob([csv], { type: "text/csv" });
|
|
67
|
+
// Require at use as causes server problems
|
|
68
|
+
const FileSaver = require("file-saver");
|
|
69
|
+
return FileSaver.saveAs(blob, "Exported Data.csv");
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
handleStartEditing = () => {
|
|
73
|
+
// Can't edit if already editing
|
|
74
|
+
if (this.state.editDesign) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.setState({ editDesign: this.props.design });
|
|
78
|
+
};
|
|
79
|
+
handleEndEditing = () => {
|
|
80
|
+
this.props.onDesignChange(this.state.editDesign);
|
|
81
|
+
this.setState({ editDesign: null });
|
|
82
|
+
};
|
|
83
|
+
handleCancelEditing = () => {
|
|
84
|
+
this.setState({ editDesign: null });
|
|
85
|
+
};
|
|
86
|
+
handleEditDesignChange = (design) => {
|
|
87
|
+
this.setState({ editDesign: design });
|
|
88
|
+
};
|
|
89
|
+
renderChart(design, onDesignChange, width, height) {
|
|
90
|
+
return react_1.default.createElement(ChartViewComponent_1.default, { chart: this.props.chart, design: design, onDesignChange: onDesignChange, schema: this.props.schema, dataSource: this.props.dataSource, widgetDataSource: this.props.widgetDataSource, scope: this.props.scope, filters: this.props.filters, width: width, height: height, onScopeChange: this.props.onScopeChange, onRowClick: this.props.onRowClick, refreshKey: this.props.refreshKey });
|
|
91
|
+
}
|
|
92
|
+
renderEditor() {
|
|
93
|
+
if (!this.state.editDesign) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
// Create editor
|
|
97
|
+
const editor = this.props.chart.createDesignerElement({
|
|
98
|
+
schema: this.props.schema,
|
|
99
|
+
filters: this.props.filters,
|
|
100
|
+
dataSource: this.props.dataSource,
|
|
101
|
+
design: this.state.editDesign,
|
|
102
|
+
onDesignChange: this.handleEditDesignChange
|
|
103
|
+
});
|
|
104
|
+
if (this.props.chart.hasDesignerPreview()) {
|
|
105
|
+
// Create chart (maxing out at half of width of screen)
|
|
106
|
+
const chartWidth = Math.min(document.body.clientWidth / 2, this.props.width);
|
|
107
|
+
const chartHeight = this.props.height != null ? this.props.height * (chartWidth / this.props.width) : undefined;
|
|
108
|
+
let chart = this.renderChart(this.state.editDesign, (design) => this.setState({ editDesign: design }), chartWidth, chartHeight);
|
|
109
|
+
const content = (react_1.default.createElement("div", { style: { height: "100%", width: "100%" } },
|
|
110
|
+
react_1.default.createElement(layoutOptions_1.BlocksLayoutOptionsContext.Consumer, null, blocksLayoutOptions => (react_1.default.createElement("style", { dangerouslySetInnerHTML: { __html: (0, layoutOptions_1.createDashboardStyles)("#chart-editor", blocksLayoutOptions || (0, layoutOptions_1.getDefaultLayoutOptions)()) } }))),
|
|
111
|
+
react_1.default.createElement("div", { style: {
|
|
112
|
+
position: "absolute",
|
|
113
|
+
left: 0,
|
|
114
|
+
top: 0,
|
|
115
|
+
border: "solid 2px #EEE",
|
|
116
|
+
borderRadius: 8,
|
|
117
|
+
padding: 10,
|
|
118
|
+
width: chartWidth + 20,
|
|
119
|
+
height: chartHeight != null ? chartHeight + 20 : undefined,
|
|
120
|
+
overflow: "hidden"
|
|
121
|
+
}, id: "chart-editor" }, chart),
|
|
122
|
+
react_1.default.createElement("div", { style: { width: "100%", height: "100%", paddingLeft: chartWidth + 40 } },
|
|
123
|
+
react_1.default.createElement("div", { style: {
|
|
124
|
+
width: "100%",
|
|
125
|
+
height: "100%",
|
|
126
|
+
overflowY: "auto",
|
|
127
|
+
paddingLeft: 20,
|
|
128
|
+
paddingRight: 20,
|
|
129
|
+
borderLeft: "solid 3px #AAA"
|
|
130
|
+
} }, editor))));
|
|
131
|
+
return (react_1.default.createElement(ModalWindowComponent_1.default, { isOpen: true, onRequestClose: this.handleEndEditing }, content));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return (react_1.default.createElement(ActionCancelModalComponent_1.default, { size: "large", onCancel: this.handleCancelEditing, onAction: this.handleEndEditing }, editor));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Render a link to start editing
|
|
138
|
+
renderEditLink(message) {
|
|
139
|
+
return (react_1.default.createElement("div", { className: "mwater-visualization-widget-placeholder", onClick: this.handleStartEditing },
|
|
140
|
+
react_1.default.createElement(ui.Icon, { id: this.props.chart.getPlaceholderIcon() }),
|
|
141
|
+
react_1.default.createElement("div", { className: "mwater-visualization-widget-placeholder-message" }, message)));
|
|
142
|
+
}
|
|
143
|
+
render() {
|
|
144
|
+
const design = this.props.chart.cleanDesign(this.props.design, this.props.schema);
|
|
145
|
+
// Determine if valid design
|
|
146
|
+
const designError = this.props.chart.validateDesign(design, this.props.schema);
|
|
147
|
+
// Determine if empty
|
|
148
|
+
const emptyDesign = this.props.chart.isEmpty(design);
|
|
149
|
+
// Create dropdown items
|
|
150
|
+
const dropdownItems = this.props.chart.createDropdownItems(design, this.props.schema, this.props.widgetDataSource, this.props.filters);
|
|
151
|
+
if (!designError) {
|
|
152
|
+
dropdownItems.push({ label: "Export Data", icon: "save-file", onClick: this.handleSaveCsvFile });
|
|
153
|
+
}
|
|
154
|
+
if (this.props.onDesignChange != null) {
|
|
155
|
+
dropdownItems.unshift({
|
|
156
|
+
label: this.props.chart.getEditLabel(),
|
|
157
|
+
onClick: this.handleStartEditing
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Wrap in a simple widget
|
|
161
|
+
return (react_1.default.createElement("div", { onDoubleClick: this.props.onDesignChange != null ? this.handleStartEditing : undefined, style: { position: "relative", width: this.props.width } },
|
|
162
|
+
this.props.onDesignChange != null ? this.renderEditor() : undefined,
|
|
163
|
+
react_1.default.createElement(DropdownWidgetComponent_1.default, { width: this.props.width, height: this.props.height, dropdownItems: dropdownItems }, this.renderChart(design, this.props.onDesignChange, this.props.width, this.props.height)),
|
|
164
|
+
(emptyDesign || designError) && this.props.onDesignChange != null ? this.renderEditLink(designError || "") : undefined));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.ChartWidgetComponent = ChartWidgetComponent;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import PropTypes from "prop-types";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import AxisBuilder from "../../../axes/AxisBuilder";
|
|
4
3
|
import { Schema } from "@mwater/expressions";
|
|
@@ -30,9 +29,7 @@ export default class CalendarChartViewComponent extends React.Component<Calendar
|
|
|
30
29
|
monthsStrokeWidth: number;
|
|
31
30
|
highlightCellFillColor: string;
|
|
32
31
|
};
|
|
33
|
-
static
|
|
34
|
-
locale: PropTypes.Requireable<string>;
|
|
35
|
-
};
|
|
32
|
+
static contextType: React.Context<string>;
|
|
36
33
|
axisBuilder: AxisBuilder;
|
|
37
34
|
reloading: boolean;
|
|
38
35
|
chart_container: any;
|
|
@@ -27,13 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const jquery_1 = __importDefault(require("jquery"));
|
|
30
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
31
30
|
const lodash_1 = __importDefault(require("lodash"));
|
|
32
31
|
const react_1 = __importDefault(require("react"));
|
|
33
32
|
const R = react_1.default.createElement;
|
|
34
33
|
const moment_1 = __importDefault(require("moment"));
|
|
35
34
|
const AxisBuilder_1 = __importDefault(require("../../../axes/AxisBuilder"));
|
|
36
35
|
const d3 = __importStar(require("d3"));
|
|
36
|
+
const contexts_1 = require("@mwater/expressions-ui/lib/contexts");
|
|
37
37
|
// Require d3-tip to use it
|
|
38
38
|
const d3_tip_1 = __importDefault(require("d3-tip"));
|
|
39
39
|
// creates a d3 calendar visualization
|
|
@@ -43,7 +43,7 @@ class CalendarChartViewComponent extends react_1.default.Component {
|
|
|
43
43
|
monthsStrokeWidth: 1,
|
|
44
44
|
highlightCellFillColor: "#000000"
|
|
45
45
|
};
|
|
46
|
-
static
|
|
46
|
+
static contextType = contexts_1.LocaleContext;
|
|
47
47
|
axisBuilder;
|
|
48
48
|
reloading;
|
|
49
49
|
chart_container;
|
|
@@ -91,9 +91,9 @@ class CalendarChartViewComponent extends react_1.default.Component {
|
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
const scopeData = {
|
|
94
|
-
name: this.axisBuilder.summarizeAxis(this.props.design.dateAxis, this.context
|
|
94
|
+
name: this.axisBuilder.summarizeAxis(this.props.design.dateAxis, this.context) +
|
|
95
95
|
" is " +
|
|
96
|
-
this.axisBuilder.formatValue(this.props.design.dateAxis, data, this.context
|
|
96
|
+
this.axisBuilder.formatValue(this.props.design.dateAxis, data, this.context),
|
|
97
97
|
filter: {
|
|
98
98
|
jsonql: this.axisBuilder.createValueFilter(this.props.design.dateAxis, data),
|
|
99
99
|
table: this.props.design.table
|
|
@@ -4,23 +4,18 @@ import { DataSource, Schema } from "@mwater/expressions";
|
|
|
4
4
|
import { LayeredChartDesign } from "./LayeredChartDesign";
|
|
5
5
|
import { WidgetDataSource } from "../../WidgetDataSource";
|
|
6
6
|
import { JsonQLFilter } from "../../..";
|
|
7
|
+
import LayeredChartViewComponent from "./LayeredChartViewComponent";
|
|
8
|
+
import LayeredChartDesignerComponent from "./LayeredChartDesignerComponent";
|
|
7
9
|
export default class LayeredChart extends Chart {
|
|
8
10
|
cleanDesign(design: LayeredChartDesign, schema: Schema): LayeredChartDesign;
|
|
9
11
|
validateDesign(design: LayeredChartDesign, schema: Schema): string | null | undefined;
|
|
10
12
|
isEmpty(design: any): boolean;
|
|
11
|
-
createDesignerElement(options: any): React.
|
|
12
|
-
schema: any;
|
|
13
|
-
dataSource: any;
|
|
14
|
-
design: LayeredChartDesign;
|
|
15
|
-
filters: any;
|
|
16
|
-
onDesignChange: (design: any) => any;
|
|
17
|
-
}>;
|
|
13
|
+
createDesignerElement(options: any): React.CElement<import("./LayeredChartDesignerComponent").LayeredChartDesignerComponentProps, LayeredChartDesignerComponent>;
|
|
18
14
|
getData(design: any, schema: Schema, dataSource: DataSource, filters: JsonQLFilter[], callback: any): void;
|
|
19
|
-
createViewElement(options: ChartCreateViewElementOptions): React.
|
|
15
|
+
createViewElement(options: ChartCreateViewElementOptions): React.CElement<any, LayeredChartViewComponent>;
|
|
20
16
|
createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): {
|
|
21
17
|
label: string;
|
|
22
|
-
|
|
23
|
-
onClick: () => void;
|
|
18
|
+
onClick: () => void | AbortController | undefined;
|
|
24
19
|
}[];
|
|
25
20
|
createDataTable(design: LayeredChartDesign, schema: Schema, dataSource: DataSource, data: any, locale: string): any[][];
|
|
26
21
|
getFilterableTables(design: LayeredChartDesign, schema: Schema): string[];
|
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const lodash_1 = __importDefault(require("lodash"));
|
|
30
30
|
const react_1 = __importDefault(require("react"));
|
|
31
|
-
const R = react_1.default.createElement;
|
|
32
31
|
const async_1 = __importDefault(require("async"));
|
|
33
32
|
const immer_1 = __importDefault(require("immer"));
|
|
34
33
|
const immer_2 = require("immer");
|
|
@@ -39,6 +38,8 @@ const AxisBuilder_1 = __importDefault(require("../../../axes/AxisBuilder"));
|
|
|
39
38
|
const LayeredChartSvgFileSaver_1 = __importDefault(require("./LayeredChartSvgFileSaver"));
|
|
40
39
|
const LayeredChartUtils = __importStar(require("./LayeredChartUtils"));
|
|
41
40
|
const TextWidget_1 = __importDefault(require("../../text/TextWidget"));
|
|
41
|
+
const LayeredChartViewComponent_1 = __importDefault(require("./LayeredChartViewComponent"));
|
|
42
|
+
const LayeredChartDesignerComponent_1 = __importDefault(require("./LayeredChartDesignerComponent"));
|
|
42
43
|
// See LayeredChart Design.md for the design
|
|
43
44
|
class LayeredChart extends Chart_1.default {
|
|
44
45
|
cleanDesign(design, schema) {
|
|
@@ -151,7 +152,6 @@ class LayeredChart extends Chart_1.default {
|
|
|
151
152
|
// filters: array of filters
|
|
152
153
|
createDesignerElement(options) {
|
|
153
154
|
// Require here to prevent server require problems
|
|
154
|
-
const LayeredChartDesignerComponent = require("./LayeredChartDesignerComponent").default;
|
|
155
155
|
const props = {
|
|
156
156
|
schema: options.schema,
|
|
157
157
|
dataSource: options.dataSource,
|
|
@@ -163,7 +163,7 @@ class LayeredChart extends Chart_1.default {
|
|
|
163
163
|
return options.onDesignChange(design);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
return react_1.default.createElement(
|
|
166
|
+
return react_1.default.createElement(LayeredChartDesignerComponent_1.default, props);
|
|
167
167
|
}
|
|
168
168
|
// Get data for the chart asynchronously
|
|
169
169
|
// design: design of the chart
|
|
@@ -212,7 +212,6 @@ class LayeredChart extends Chart_1.default {
|
|
|
212
212
|
// scope: current scope of the view element
|
|
213
213
|
// onScopeChange: called when scope changes with new scope
|
|
214
214
|
createViewElement(options) {
|
|
215
|
-
const LayeredChartViewComponent = require("./LayeredChartViewComponent").default;
|
|
216
215
|
// Create chart
|
|
217
216
|
const props = {
|
|
218
217
|
schema: options.schema,
|
|
@@ -225,7 +224,7 @@ class LayeredChart extends Chart_1.default {
|
|
|
225
224
|
scope: options.scope,
|
|
226
225
|
onScopeChange: options.onScopeChange
|
|
227
226
|
};
|
|
228
|
-
return react_1.default.createElement(
|
|
227
|
+
return react_1.default.createElement(LayeredChartViewComponent_1.default, props);
|
|
229
228
|
}
|
|
230
229
|
createDropdownItems(design, schema, widgetDataSource, filters) {
|
|
231
230
|
// TODO validate design before allowing save
|
|
@@ -245,8 +244,8 @@ class LayeredChart extends Chart_1.default {
|
|
|
245
244
|
return [];
|
|
246
245
|
}
|
|
247
246
|
return [
|
|
248
|
-
{ label: "Save as SVG",
|
|
249
|
-
{ label: "Save as PNG",
|
|
247
|
+
{ label: "Save as SVG", onClick: save.bind(null, "svg") },
|
|
248
|
+
{ label: "Save as PNG", onClick: save.bind(null, "png") }
|
|
250
249
|
];
|
|
251
250
|
}
|
|
252
251
|
createDataTable(design, schema, dataSource, data, locale) {
|
|
@@ -17,6 +17,8 @@ interface C3Data {
|
|
|
17
17
|
columns: PrimitiveArray[];
|
|
18
18
|
xAxisType?: "category" | "indexed" | "log" | "timeseries";
|
|
19
19
|
xAxisTickFit?: boolean;
|
|
20
|
+
/** Whether to allow multiline x axis tick labels (default true) */
|
|
21
|
+
xAxisTickMultiline?: boolean;
|
|
20
22
|
xs?: {
|
|
21
23
|
[key: string]: string;
|
|
22
24
|
};
|
|
@@ -35,8 +37,8 @@ interface C3Data {
|
|
|
35
37
|
titleText?: string;
|
|
36
38
|
legendHide?: boolean;
|
|
37
39
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
* Set custom data name.
|
|
41
|
+
*/
|
|
40
42
|
names?: {
|
|
41
43
|
[key: string]: string;
|
|
42
44
|
};
|