@mwater/visualization 5.4.1 → 5.4.2
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.js +2 -1
- package/lib/IdSelection.d.ts +16 -0
- package/lib/IdSelection.js +59 -0
- package/lib/MWaterAddRelatedIndicatorComponent.js +2 -2
- package/lib/MWaterCompleteTableSelectComponent.d.ts +3 -8
- package/lib/MWaterCompleteTableSelectComponent.js +36 -42
- package/lib/MWaterLoaderComponent.d.ts +11 -10
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterResponsesFilterComponent.js +1 -1
- package/lib/MWaterTableSelectComponent.d.ts +0 -1
- package/lib/MWaterTableSelectComponent.js +4 -6
- package/lib/autotranslate.d.ts +20 -0
- package/lib/autotranslate.js +122 -0
- package/lib/axes/AxisBuilder.js +3 -3
- package/lib/axes/AxisColorEditorComponent.js +4 -0
- package/lib/axes/AxisComponent.d.ts +8 -12
- package/lib/axes/AxisComponent.js +32 -80
- package/lib/axes/CategoryMapComponent.js +4 -4
- package/lib/axes/RangesComponent.js +2 -2
- package/lib/dashboards/DashboardComponent.d.ts +6 -0
- package/lib/dashboards/DashboardComponent.js +44 -12
- package/lib/dashboards/DashboardDesign.d.ts +11 -2
- package/lib/dashboards/DashboardUtils.d.ts +5 -0
- package/lib/dashboards/DashboardUtils.js +30 -0
- package/lib/dashboards/DashboardViewComponent.d.ts +2 -0
- package/lib/dashboards/DashboardViewComponent.js +16 -3
- package/lib/dashboards/ServerDashboardDataSource.js +2 -1
- package/lib/dashboards/SettingsModalComponent.d.ts +1 -1
- package/lib/dashboards/SettingsModalComponent.js +256 -19
- package/lib/dashboards/WidgetComponent.d.ts +6 -3
- package/lib/dashboards/WidgetComponent.js +3 -1
- package/lib/datagrids/CellEditor.d.ts +19 -0
- package/lib/datagrids/CellEditor.js +223 -0
- package/lib/datagrids/DatagridComponent.d.ts +18 -87
- package/lib/datagrids/DatagridComponent.js +304 -222
- package/lib/datagrids/DatagridViewComponent.d.ts +15 -53
- package/lib/datagrids/DatagridViewComponent.js +256 -257
- package/lib/datagrids/DirectDatagridDataSource.js +2 -3
- package/lib/datagrids/ExprCellComponent.d.ts +8 -15
- package/lib/datagrids/ExprCellComponent.js +11 -15
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -6
- package/lib/datagrids/FindReplaceModalComponent.js +38 -75
- package/lib/index.css +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/layouts/blocks/HorizontalBlockComponent.js +2 -2
- package/lib/mWaterLoader.d.ts +1 -1
- package/lib/maps/BufferLayer.d.ts +7 -5
- package/lib/maps/BufferLayer.js +69 -48
- package/lib/maps/BufferLayerDesign.d.ts +21 -14
- package/lib/maps/BufferLayerDesignerComponent.d.ts +16 -31
- package/lib/maps/BufferLayerDesignerComponent.js +68 -102
- package/lib/maps/ChoroplethLayer.d.ts +5 -4
- package/lib/maps/ChoroplethLayer.js +32 -9
- package/lib/maps/ChoroplethLayerDesign.d.ts +6 -2
- package/lib/maps/ChoroplethLayerDesigner.js +4 -2
- package/lib/maps/ClusterLayer.d.ts +3 -4
- package/lib/maps/ClusterLayer.js +2 -1
- package/lib/maps/DetailLevelSelectComponent.js +1 -1
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +5 -3
- package/lib/maps/GridLayer.d.ts +3 -4
- package/lib/maps/GridLayer.js +2 -1
- package/lib/maps/GridLayerDesigner.js +5 -3
- package/lib/maps/HoverContent.d.ts +11 -3
- package/lib/maps/HoverContent.js +25 -9
- package/lib/maps/Layer.d.ts +24 -3
- package/lib/maps/Layer.js +5 -1
- package/lib/maps/LayerFactory.js +0 -8
- package/lib/maps/LayerLegendComponent.js +0 -1
- package/lib/maps/LayerSwitcherComponent.d.ts +1 -0
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/LeafletMapComponent.js +3 -1
- package/lib/maps/LegendComponent.d.ts +1 -0
- package/lib/maps/LegendComponent.js +9 -1
- package/lib/maps/MWaterServerLayer.d.ts +2 -2
- package/lib/maps/MWaterServerLayer.js +2 -2
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -0
- package/lib/maps/MapDesignerComponent.d.ts +4 -3
- package/lib/maps/MapDesignerComponent.js +68 -74
- package/lib/maps/MapLayerViewDesignerComponent.js +2 -2
- package/lib/maps/MapUtils.d.ts +4 -0
- package/lib/maps/MapUtils.js +19 -0
- package/lib/maps/MapViewComponent.d.ts +8 -3
- package/lib/maps/MarkersLayer.d.ts +5 -4
- package/lib/maps/MarkersLayer.js +33 -7
- package/lib/maps/MarkersLayerDesign.d.ts +19 -16
- package/lib/maps/PopupFilterJoinsUtils.d.ts +6 -3
- package/lib/maps/PopupFilterJoinsUtils.js +0 -6
- package/lib/maps/RasterMapViewComponent.d.ts +3 -31
- package/lib/maps/RasterMapViewComponent.js +7 -2
- package/lib/maps/ServerMapDataSource.js +2 -1
- package/lib/maps/SwitchableTileUrlLayer.d.ts +3 -3
- package/lib/maps/SwitchableTileUrlLayer.js +2 -1
- package/lib/maps/TileUrlLayer.d.ts +4 -5
- package/lib/maps/TileUrlLayer.js +2 -1
- package/lib/maps/VectorMapViewComponent.d.ts +5 -37
- package/lib/maps/VectorMapViewComponent.js +19 -8
- package/lib/maps/maps.d.ts +3 -0
- package/lib/quickfilter/QuickfiltersComponent.d.ts +2 -0
- package/lib/quickfilter/QuickfiltersComponent.js +9 -7
- package/lib/quickfilter/QuickfiltersDesignComponent.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersDesignComponent.js +19 -35
- package/lib/richtext/ExprItemsHtmlConverter.d.ts +5 -2
- package/lib/richtext/ExprItemsHtmlConverter.js +4 -4
- package/lib/richtext/ExprItemsTranslator.d.ts +5 -0
- package/lib/richtext/ExprItemsTranslator.js +149 -0
- package/lib/richtext/ItemsHtmlConverter.d.ts +1 -1
- package/lib/richtext/ItemsHtmlConverter.js +31 -15
- package/lib/wellknown.js +12 -9
- package/lib/widgets/IFrameWidget.d.ts +4 -4
- package/lib/widgets/ImageWidget.d.ts +7 -4
- package/lib/widgets/ImageWidget.js +9 -1
- package/lib/widgets/ImageWidgetComponent.d.ts +1 -0
- package/lib/widgets/ImageWidgetComponent.js +1 -1
- package/lib/widgets/MapWidget.d.ts +5 -48
- package/lib/widgets/MapWidget.js +26 -63
- package/lib/widgets/MarkdownWidget.d.ts +3 -0
- package/lib/widgets/MarkdownWidget.js +3 -0
- package/lib/widgets/TOCWidget.d.ts +15 -27
- package/lib/widgets/TOCWidget.js +107 -183
- package/lib/widgets/Widget.d.ts +18 -7
- package/lib/widgets/Widget.js +4 -0
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.d.ts +10 -1
- package/lib/widgets/charts/Chart.js +22 -11
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +6 -3
- package/lib/widgets/charts/ChartWidget.d.ts +2 -0
- package/lib/widgets/charts/ChartWidget.js +9 -1
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +2 -2
- package/lib/widgets/charts/calendar/CalendarChart.d.ts +1 -0
- package/lib/widgets/charts/calendar/CalendarChart.js +26 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -1
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +1 -0
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +8 -0
- package/lib/widgets/charts/layered/LayeredChart.d.ts +2 -0
- package/lib/widgets/charts/layered/LayeredChart.js +63 -3
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +1 -1
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +2 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +8 -3
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -0
- package/lib/widgets/charts/pivot/PivotChart.js +63 -0
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +1 -1
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +7 -4
- package/lib/widgets/charts/table/OrderingsComponent.js +1 -1
- package/lib/widgets/charts/table/TableChart.d.ts +1 -0
- package/lib/widgets/charts/table/TableChart.js +15 -0
- package/lib/widgets/text/TextComponent.d.ts +11 -4
- package/lib/widgets/text/TextComponent.js +11 -8
- package/lib/widgets/text/TextWidget.d.ts +6 -3
- package/lib/widgets/text/TextWidget.js +7 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +4 -0
- package/lib/widgets/text/TextWidgetComponent.js +7 -1
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -4
- package/lib/widgets/text/TextWidgetDesign.js +1 -1
- package/package.json +7 -8
- package/src/ColorComponent.tsx +1 -2
- package/src/IdSelection.ts +62 -0
- package/src/MWaterAddRelatedIndicatorComponent.ts +3 -2
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -46
- package/src/MWaterLoaderComponent.ts +28 -26
- package/src/MWaterResponsesFilterComponent.ts +5 -2
- package/src/MWaterTableSelectComponent.tsx +5 -9
- package/src/autotranslate.ts +141 -0
- package/src/axes/AxisBuilder.ts +3 -3
- package/src/axes/AxisColorEditorComponent.tsx +5 -0
- package/src/axes/{AxisComponent.ts → AxisComponent.tsx} +106 -106
- package/src/axes/CategoryMapComponent.ts +4 -4
- package/src/axes/RangesComponent.ts +3 -2
- package/src/dashboards/DashboardComponent.tsx +79 -14
- package/src/dashboards/DashboardDesign.ts +9 -2
- package/src/dashboards/DashboardUtils.ts +39 -0
- package/src/dashboards/DashboardViewComponent.tsx +22 -3
- package/src/dashboards/ServerDashboardDataSource.ts +2 -1
- package/src/dashboards/SettingsModalComponent.tsx +450 -35
- package/src/dashboards/WidgetComponent.tsx +12 -6
- package/src/datagrids/CellEditor.tsx +354 -0
- package/src/datagrids/DatagridComponent.tsx +646 -0
- package/src/datagrids/DatagridViewComponent.tsx +539 -0
- package/src/datagrids/DirectDatagridDataSource.ts +2 -3
- package/src/datagrids/{ExprCellComponent.ts → ExprCellComponent.tsx} +28 -23
- package/src/datagrids/{FindReplaceModalComponent.ts → FindReplaceModalComponent.tsx} +109 -122
- package/src/index.css +1 -1
- package/src/index.ts +0 -1
- package/src/layouts/blocks/HorizontalBlockComponent.ts +2 -2
- package/src/mWaterLoader.ts +1 -1
- package/src/maps/BufferLayer.ts +83 -60
- package/src/maps/BufferLayerDesign.ts +20 -14
- package/src/maps/BufferLayerDesignerComponent.tsx +309 -0
- package/src/maps/ChoroplethLayer.ts +40 -19
- package/src/maps/ChoroplethLayerDesign.ts +4 -2
- package/src/maps/ChoroplethLayerDesigner.tsx +4 -2
- package/src/maps/ClusterLayer.ts +4 -10
- package/src/maps/DetailLevelSelectComponent.ts +1 -1
- package/src/maps/DirectMapDataSource.ts +2 -1
- package/src/maps/EditPopupComponent.ts +7 -3
- package/src/maps/GridLayer.ts +4 -10
- package/src/maps/GridLayerDesigner.tsx +5 -3
- package/src/maps/HoverContent.tsx +40 -16
- package/src/maps/Layer.ts +28 -10
- package/src/maps/LayerFactory.ts +0 -8
- package/src/maps/LayerLegendComponent.ts +2 -4
- package/src/maps/LayerSwitcherComponent.tsx +6 -2
- package/src/maps/LeafletMapComponent.tsx +3 -1
- package/src/maps/LegendComponent.tsx +10 -1
- package/src/maps/MWaterServerLayer.ts +3 -3
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +3 -0
- package/src/maps/MapDesignerComponent.tsx +165 -162
- package/src/maps/MapLayerViewDesignerComponent.ts +2 -2
- package/src/maps/MapUtils.ts +24 -0
- package/src/maps/MapViewComponent.tsx +11 -3
- package/src/maps/MarkersLayer.ts +44 -18
- package/src/maps/MarkersLayerDesign.ts +19 -16
- package/src/maps/PopupFilterJoinsUtils.ts +6 -2
- package/src/maps/RasterMapViewComponent.ts +9 -45
- package/src/maps/ServerMapDataSource.ts +2 -2
- package/src/maps/SwitchableTileUrlLayer.tsx +4 -10
- package/src/maps/TileUrlLayer.tsx +4 -10
- package/src/maps/VectorMapViewComponent.tsx +28 -55
- package/src/maps/maps.ts +3 -0
- package/src/quickfilter/QuickfiltersComponent.ts +13 -7
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +56 -74
- package/src/richtext/ExprItemsHtmlConverter.ts +9 -5
- package/src/richtext/ExprItemsTranslator.ts +176 -0
- package/src/richtext/ItemsHtmlConverter.ts +33 -18
- package/src/wellknown.ts +33 -30
- package/src/widgets/ImageWidget.ts +10 -1
- package/src/widgets/ImageWidgetComponent.ts +3 -2
- package/src/widgets/{MapWidget.ts → MapWidget.tsx} +90 -101
- package/src/widgets/MarkdownWidget.ts +3 -0
- package/src/widgets/TOCWidget.tsx +281 -0
- package/src/widgets/Widget.ts +25 -5
- package/src/widgets/WidgetScopesViewComponent.ts +2 -1
- package/src/widgets/charts/Chart.ts +31 -12
- package/src/widgets/charts/ChartViewComponent.ts +13 -3
- package/src/widgets/charts/ChartWidget.ts +11 -1
- package/src/widgets/charts/ChartWidgetComponent.tsx +9 -1
- package/src/widgets/charts/calendar/CalendarChart.ts +29 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +3 -1
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +9 -0
- package/src/widgets/charts/layered/LayeredChart.ts +71 -3
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +2 -2
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +4 -2
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +10 -4
- package/src/widgets/charts/pivot/PivotChart.ts +73 -0
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +1 -1
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +6 -4
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -1
- package/src/widgets/charts/table/TableChart.ts +17 -0
- package/src/widgets/text/TextComponent.tsx +22 -12
- package/src/widgets/text/TextWidget.ts +9 -2
- package/src/widgets/text/TextWidgetComponent.tsx +16 -1
- package/src/widgets/text/TextWidgetDesign.ts +4 -7
- package/test/IdSelectionTests.ts +54 -0
- package/test/LayeredChartCompilerTests.ts +0 -2
- package/test/richtext/ExprItemsTranslatorTests.ts +144 -0
- package/test/wellknownTests.ts +144 -0
- package/src/datagrids/DatagridComponent.ts +0 -478
- package/src/datagrids/DatagridViewComponent.ts +0 -464
- package/src/datagrids/EditExprCellComponent.tsx +0 -305
- package/src/datagrids/README.md +0 -3
- package/src/maps/BufferLayerDesignerComponent.ts +0 -311
- package/src/widgets/TOCWidget.ts +0 -326
- package/test/LegoLayoutEngineTests.ts +0 -69
|
@@ -8,7 +8,7 @@ export interface ChartCreateViewElementOptions {
|
|
|
8
8
|
schema: Schema;
|
|
9
9
|
/** data source to use. Only used when designing, for display uses data **/
|
|
10
10
|
dataSource: DataSource;
|
|
11
|
-
/** Chart design
|
|
11
|
+
/** Chart design. Should already be translated. */
|
|
12
12
|
design: any;
|
|
13
13
|
/** called with new design. null/undefined for readonly **/
|
|
14
14
|
onDesignChange?: {
|
|
@@ -28,6 +28,8 @@ export interface ChartCreateViewElementOptions {
|
|
|
28
28
|
height?: number;
|
|
29
29
|
/** Called with (tableId, rowId) when item is clicked **/
|
|
30
30
|
onRowClick?: (tableId: string, rowId: any) => void;
|
|
31
|
+
/** Locale to use for display */
|
|
32
|
+
locale: string;
|
|
31
33
|
}
|
|
32
34
|
export default class Chart {
|
|
33
35
|
cleanDesign(design: any, schema: Schema): void;
|
|
@@ -45,6 +47,9 @@ export default class Chart {
|
|
|
45
47
|
onDesignChange: (design: any) => void;
|
|
46
48
|
}): ReactNode;
|
|
47
49
|
getData(design: any, schema: Schema, dataSource: DataSource, filters: any, callback: any): void;
|
|
50
|
+
/** Create a view element for the chart.
|
|
51
|
+
* Chart design should already be translated. This is handled by ChartViewComponent.
|
|
52
|
+
*/
|
|
48
53
|
createViewElement(options: ChartCreateViewElementOptions): ReactNode;
|
|
49
54
|
createDropdownItems(design: any, schema: Schema, widgetDataSource: WidgetDataSource, filters: any): {
|
|
50
55
|
label: ReactNode;
|
|
@@ -53,4 +58,8 @@ export default class Chart {
|
|
|
53
58
|
createDataTable(design: any, schema: Schema, dataSource: DataSource, data: any, locale: any): any[][];
|
|
54
59
|
getFilterableTables(design: any, schema: Schema): string[];
|
|
55
60
|
getPlaceholderIcon(): string;
|
|
61
|
+
/** Get a list of translatable strings in the design. No need to override in subclasses. Design should already be cleaned. */
|
|
62
|
+
getTranslatableStrings(design: any, schema: Schema): string[];
|
|
63
|
+
/** Translates the design. Override in subclasses. Design is already cleaned. */
|
|
64
|
+
translateDesign(design: any, translate: (input: string) => string): any;
|
|
56
65
|
}
|
|
@@ -44,17 +44,9 @@ class Chart {
|
|
|
44
44
|
getData(design, schema, dataSource, filters, callback) {
|
|
45
45
|
throw new Error("Not implemented");
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// dataSource: dataSource to use
|
|
51
|
-
// design: design of the chart
|
|
52
|
-
// onDesignChange: when design changes
|
|
53
|
-
// data: results from queries
|
|
54
|
-
// width, height: size of the chart view
|
|
55
|
-
// scope: current scope of the view element
|
|
56
|
-
// onScopeChange: called when scope changes with new scope
|
|
57
|
-
// onRowClick: Called with (tableId, rowId) when item is clicked
|
|
47
|
+
/** Create a view element for the chart.
|
|
48
|
+
* Chart design should already be translated. This is handled by ChartViewComponent.
|
|
49
|
+
*/
|
|
58
50
|
createViewElement(options) {
|
|
59
51
|
throw new Error("Not implemented");
|
|
60
52
|
}
|
|
@@ -79,5 +71,24 @@ class Chart {
|
|
|
79
71
|
getPlaceholderIcon() {
|
|
80
72
|
return "";
|
|
81
73
|
}
|
|
74
|
+
/** Get a list of translatable strings in the design. No need to override in subclasses. Design should already be cleaned. */
|
|
75
|
+
getTranslatableStrings(design, schema) {
|
|
76
|
+
const strings = new Set();
|
|
77
|
+
// Create collector function that just saves strings and returns them unchanged
|
|
78
|
+
const collectStrings = (str) => {
|
|
79
|
+
// Only collect non-empty strings
|
|
80
|
+
if (str) {
|
|
81
|
+
strings.add(str);
|
|
82
|
+
}
|
|
83
|
+
return str;
|
|
84
|
+
};
|
|
85
|
+
// Use existing translation function but with collector
|
|
86
|
+
this.translateDesign(design, collectStrings);
|
|
87
|
+
return Array.from(strings);
|
|
88
|
+
}
|
|
89
|
+
/** Translates the design. Override in subclasses. Design is already cleaned. */
|
|
90
|
+
translateDesign(design, translate) {
|
|
91
|
+
return design;
|
|
92
|
+
}
|
|
82
93
|
}
|
|
83
94
|
exports.default = Chart;
|
|
@@ -26,6 +26,10 @@ export interface ChartViewComponentProps {
|
|
|
26
26
|
onRowClick?: (tableId: string, rowId: any) => void;
|
|
27
27
|
/** A key that changes when the widget should be refreshed */
|
|
28
28
|
refreshKey?: any;
|
|
29
|
+
/** Locale to use for display */
|
|
30
|
+
locale: string;
|
|
31
|
+
/** Translate function to use for display */
|
|
32
|
+
translate: (input: string) => string;
|
|
29
33
|
}
|
|
30
34
|
interface ChartViewComponentState {
|
|
31
35
|
cacheExpiry?: any;
|
|
@@ -108,11 +108,13 @@ class ChartViewComponent extends react_1.default.Component {
|
|
|
108
108
|
if (this.state.dataError) {
|
|
109
109
|
return this.renderError();
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
// Translate design if needed
|
|
112
|
+
const translatedDesign = this.props.onDesignChange || !this.props.translate || !this.state.validDesign ? this.state.validDesign : this.props.chart.translateDesign(this.state.validDesign, this.props.translate);
|
|
113
|
+
return R("div", { style }, translatedDesign
|
|
112
114
|
? this.props.chart.createViewElement({
|
|
113
115
|
schema: this.props.schema,
|
|
114
116
|
dataSource: this.props.dataSource,
|
|
115
|
-
design:
|
|
117
|
+
design: translatedDesign,
|
|
116
118
|
onDesignChange: this.props.onDesignChange,
|
|
117
119
|
data: this.state.data,
|
|
118
120
|
scope: this.props.scope,
|
|
@@ -120,7 +122,8 @@ class ChartViewComponent extends react_1.default.Component {
|
|
|
120
122
|
width: this.props.width,
|
|
121
123
|
height: this.props.height,
|
|
122
124
|
onRowClick: this.props.onRowClick,
|
|
123
|
-
filters: this.props.filters
|
|
125
|
+
filters: this.props.filters,
|
|
126
|
+
locale: this.props.locale,
|
|
124
127
|
})
|
|
125
128
|
: undefined, this.state.dataLoading ? this.renderSpinner() : undefined);
|
|
126
129
|
}
|
|
@@ -11,4 +11,6 @@ export default class ChartWidget extends Widget {
|
|
|
11
11
|
getData(design: any, schema: Schema, dataSource: DataSource, filters: any, callback: any): void;
|
|
12
12
|
getFilterableTables(design: any, schema: Schema): string[];
|
|
13
13
|
isAutoHeight(): boolean;
|
|
14
|
+
/** Get a list of translatable strings in the design */
|
|
15
|
+
getTranslatableStrings(design: any, schema: Schema): string[];
|
|
14
16
|
}
|
|
@@ -41,7 +41,9 @@ class ChartWidget extends Widget_1.default {
|
|
|
41
41
|
width: options.width,
|
|
42
42
|
height: options.height,
|
|
43
43
|
onRowClick: options.onRowClick,
|
|
44
|
-
refreshKey: options.refreshKey
|
|
44
|
+
refreshKey: options.refreshKey,
|
|
45
|
+
locale: options.locale,
|
|
46
|
+
translate: options.translate
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
// Get the data that the widget needs. This will be called on the server, typically.
|
|
@@ -65,5 +67,11 @@ class ChartWidget extends Widget_1.default {
|
|
|
65
67
|
isAutoHeight() {
|
|
66
68
|
return this.chart.isAutoHeight();
|
|
67
69
|
}
|
|
70
|
+
/** Get a list of translatable strings in the design */
|
|
71
|
+
getTranslatableStrings(design, schema) {
|
|
72
|
+
// Clean design first
|
|
73
|
+
const cleanDesign = this.chart.cleanDesign(design, schema);
|
|
74
|
+
return this.chart.getTranslatableStrings(cleanDesign, schema);
|
|
75
|
+
}
|
|
68
76
|
}
|
|
69
77
|
exports.default = ChartWidget;
|
|
@@ -33,6 +33,10 @@ export interface ChartWidgetComponentProps {
|
|
|
33
33
|
connectResizeHandle?: any;
|
|
34
34
|
/** A key that changes when the widget should be refreshed */
|
|
35
35
|
refreshKey?: any;
|
|
36
|
+
/** Locale to use for display */
|
|
37
|
+
locale: string;
|
|
38
|
+
/** Translate function to use for display */
|
|
39
|
+
translate: (input: string) => string;
|
|
36
40
|
}
|
|
37
41
|
export declare class ChartWidgetComponent extends React.PureComponent<ChartWidgetComponentProps, {
|
|
38
42
|
editDesign: any;
|
|
@@ -87,7 +87,7 @@ class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
|
87
87
|
this.setState({ editDesign: design });
|
|
88
88
|
};
|
|
89
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 });
|
|
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, locale: this.props.locale, translate: this.props.translate });
|
|
91
91
|
}
|
|
92
92
|
renderEditor() {
|
|
93
93
|
if (!this.state.editDesign) {
|
|
@@ -149,7 +149,7 @@ class ChartWidgetComponent extends react_1.default.PureComponent {
|
|
|
149
149
|
// Create dropdown items
|
|
150
150
|
const dropdownItems = this.props.chart.createDropdownItems(design, this.props.schema, this.props.widgetDataSource, this.props.filters);
|
|
151
151
|
if (!designError) {
|
|
152
|
-
dropdownItems.push({ label: T `Export Data`,
|
|
152
|
+
dropdownItems.push({ label: T `Export Data`, onClick: this.handleSaveCsvFile });
|
|
153
153
|
}
|
|
154
154
|
if (this.props.onDesignChange != null) {
|
|
155
155
|
dropdownItems.unshift({
|
|
@@ -36,4 +36,5 @@ export default class CalendarChart extends Chart {
|
|
|
36
36
|
createDataTable(design: any, schema: Schema, dataSource: DataSource, data: any): string[][];
|
|
37
37
|
getFilterableTables(design: any, schema: Schema): any[];
|
|
38
38
|
getPlaceholderIcon(): string;
|
|
39
|
+
translateDesign(design: CalendarChartDesign, translate: (input: string) => string): CalendarChartDesign;
|
|
39
40
|
}
|
|
@@ -171,5 +171,31 @@ class CalendarChart extends Chart_1.default {
|
|
|
171
171
|
getPlaceholderIcon() {
|
|
172
172
|
return "fa-calendar";
|
|
173
173
|
}
|
|
174
|
+
translateDesign(design, translate) {
|
|
175
|
+
return (0, immer_1.default)(design, draft => {
|
|
176
|
+
// Translate title text
|
|
177
|
+
if (draft.titleText) {
|
|
178
|
+
draft.titleText = translate(draft.titleText);
|
|
179
|
+
}
|
|
180
|
+
// Translate axis category labels
|
|
181
|
+
if (draft.dateAxis?.categoryLabels) {
|
|
182
|
+
for (const key in draft.dateAxis.categoryLabels) {
|
|
183
|
+
draft.dateAxis.categoryLabels[key] = translate(draft.dateAxis.categoryLabels[key]);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (draft.valueAxis?.categoryLabels) {
|
|
187
|
+
for (const key in draft.valueAxis.categoryLabels) {
|
|
188
|
+
draft.valueAxis.categoryLabels[key] = translate(draft.valueAxis.categoryLabels[key]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Translate null labels
|
|
192
|
+
if (draft.dateAxis?.nullLabel) {
|
|
193
|
+
draft.dateAxis.nullLabel = translate(draft.dateAxis.nullLabel);
|
|
194
|
+
}
|
|
195
|
+
if (draft.valueAxis?.nullLabel) {
|
|
196
|
+
draft.valueAxis.nullLabel = translate(draft.valueAxis.nullLabel);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
174
200
|
}
|
|
175
201
|
exports.default = CalendarChart;
|
|
@@ -92,7 +92,9 @@ class CalendarChartViewComponent extends react_1.default.Component {
|
|
|
92
92
|
}
|
|
93
93
|
const scopeData = {
|
|
94
94
|
name: this.axisBuilder.summarizeAxis(this.props.design.dateAxis, this.context) +
|
|
95
|
-
|
|
95
|
+
" " +
|
|
96
|
+
T `is` +
|
|
97
|
+
" " +
|
|
96
98
|
this.axisBuilder.formatValue(this.props.design.dateAxis, data, this.context),
|
|
97
99
|
filter: {
|
|
98
100
|
jsonql: this.axisBuilder.createValueFilter(this.props.design.dateAxis, data),
|
|
@@ -31,4 +31,5 @@ export default class ImageMosaicChart extends Chart {
|
|
|
31
31
|
createDataTable(design: any, schema: Schema, dataSource: DataSource, data: any): never[];
|
|
32
32
|
getFilterableTables(design: any, schema: Schema): any[];
|
|
33
33
|
getPlaceholderIcon(): string;
|
|
34
|
+
translateDesign(design: ImageMosaicChartDesign, translate: (input: string) => string): ImageMosaicChartDesign;
|
|
34
35
|
}
|
|
@@ -178,5 +178,13 @@ class ImageMosaicChart extends Chart_1.default {
|
|
|
178
178
|
getPlaceholderIcon() {
|
|
179
179
|
return "fa-th";
|
|
180
180
|
}
|
|
181
|
+
translateDesign(design, translate) {
|
|
182
|
+
return (0, immer_1.default)(design, draft => {
|
|
183
|
+
// Translate title text
|
|
184
|
+
if (draft.titleText) {
|
|
185
|
+
draft.titleText = translate(draft.titleText);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
181
189
|
}
|
|
182
190
|
exports.default = ImageMosaicChart;
|
|
@@ -20,4 +20,6 @@ export default class LayeredChart extends Chart {
|
|
|
20
20
|
createDataTable(design: LayeredChartDesign, schema: Schema, dataSource: DataSource, data: any, locale: string): any[][];
|
|
21
21
|
getFilterableTables(design: LayeredChartDesign, schema: Schema): string[];
|
|
22
22
|
getPlaceholderIcon(): string;
|
|
23
|
+
/** Translates the design */
|
|
24
|
+
translateDesign(design: LayeredChartDesign, translate: (input: string) => string): LayeredChartDesign;
|
|
23
25
|
}
|
|
@@ -40,7 +40,7 @@ const LayeredChartUtils = __importStar(require("./LayeredChartUtils"));
|
|
|
40
40
|
const TextWidget_1 = __importDefault(require("../../text/TextWidget"));
|
|
41
41
|
const LayeredChartViewComponent_1 = __importDefault(require("./LayeredChartViewComponent"));
|
|
42
42
|
const LayeredChartDesignerComponent_1 = __importDefault(require("./LayeredChartDesignerComponent"));
|
|
43
|
-
|
|
43
|
+
const ExprItemsTranslator_1 = require("../../../richtext/ExprItemsTranslator");
|
|
44
44
|
class LayeredChart extends Chart_1.default {
|
|
45
45
|
cleanDesign(design, schema) {
|
|
46
46
|
const exprCleaner = new expressions_1.ExprCleaner(schema);
|
|
@@ -126,7 +126,7 @@ class LayeredChart extends Chart_1.default {
|
|
|
126
126
|
if (!layer.axes.y) {
|
|
127
127
|
return T `Missing Y Axis`;
|
|
128
128
|
}
|
|
129
|
-
if (!layer.axes.x && compiler.isXAxisRequired(design
|
|
129
|
+
if (!layer.axes.x && compiler.isXAxisRequired(design)) {
|
|
130
130
|
return T `Missing X Axis`;
|
|
131
131
|
}
|
|
132
132
|
if (!layer.axes.color && compiler.isColorAxisRequired(design, layerId)) {
|
|
@@ -222,7 +222,8 @@ class LayeredChart extends Chart_1.default {
|
|
|
222
222
|
width: options.width,
|
|
223
223
|
height: options.height,
|
|
224
224
|
scope: options.scope,
|
|
225
|
-
onScopeChange: options.onScopeChange
|
|
225
|
+
onScopeChange: options.onScopeChange,
|
|
226
|
+
locale: options.locale,
|
|
226
227
|
};
|
|
227
228
|
return react_1.default.createElement(LayeredChartViewComponent_1.default, props);
|
|
228
229
|
}
|
|
@@ -319,5 +320,64 @@ class LayeredChart extends Chart_1.default {
|
|
|
319
320
|
getPlaceholderIcon() {
|
|
320
321
|
return "fa-bar-chart";
|
|
321
322
|
}
|
|
323
|
+
/** Translates the design */
|
|
324
|
+
translateDesign(design, translate) {
|
|
325
|
+
return (0, immer_1.default)(design, draft => {
|
|
326
|
+
// Translate axis labels
|
|
327
|
+
if (draft.xAxisLabelText) {
|
|
328
|
+
draft.xAxisLabelText = translate(draft.xAxisLabelText);
|
|
329
|
+
}
|
|
330
|
+
if (draft.yAxisLabelText) {
|
|
331
|
+
draft.yAxisLabelText = translate(draft.yAxisLabelText);
|
|
332
|
+
}
|
|
333
|
+
// Translate layer names
|
|
334
|
+
for (const layer of draft.layers) {
|
|
335
|
+
if (layer.name) {
|
|
336
|
+
layer.name = translate(layer.name);
|
|
337
|
+
}
|
|
338
|
+
// Translate axis category labels
|
|
339
|
+
if (layer.axes.x?.categoryLabels) {
|
|
340
|
+
for (const key in layer.axes.x.categoryLabels) {
|
|
341
|
+
layer.axes.x.categoryLabels[key] = translate(layer.axes.x.categoryLabels[key]);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (layer.axes.y?.categoryLabels) {
|
|
345
|
+
for (const key in layer.axes.y.categoryLabels) {
|
|
346
|
+
layer.axes.y.categoryLabels[key] = translate(layer.axes.y.categoryLabels[key]);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (layer.axes.color?.categoryLabels) {
|
|
350
|
+
for (const key in layer.axes.color.categoryLabels) {
|
|
351
|
+
layer.axes.color.categoryLabels[key] = translate(layer.axes.color.categoryLabels[key]);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Translate null labels
|
|
355
|
+
if (layer.axes.x?.nullLabel) {
|
|
356
|
+
layer.axes.x.nullLabel = translate(layer.axes.x.nullLabel);
|
|
357
|
+
}
|
|
358
|
+
if (layer.axes.y?.nullLabel) {
|
|
359
|
+
layer.axes.y.nullLabel = translate(layer.axes.y.nullLabel);
|
|
360
|
+
}
|
|
361
|
+
if (layer.axes.color?.nullLabel) {
|
|
362
|
+
layer.axes.color.nullLabel = translate(layer.axes.color.nullLabel);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// Translate y thresholds
|
|
366
|
+
if (draft.yThresholds) {
|
|
367
|
+
for (const threshold of draft.yThresholds) {
|
|
368
|
+
if (threshold.label) {
|
|
369
|
+
threshold.label = translate(threshold.label);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// Translate header and footer using ExprItemsTranslator
|
|
374
|
+
if (draft.header) {
|
|
375
|
+
draft.header.items = (0, ExprItemsTranslator_1.translateHtmlItems)(draft.header.items || [], translate);
|
|
376
|
+
}
|
|
377
|
+
if (draft.footer) {
|
|
378
|
+
draft.footer.items = (0, ExprItemsTranslator_1.translateHtmlItems)(draft.footer.items || [], translate);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
322
382
|
}
|
|
323
383
|
exports.default = LayeredChart;
|
|
@@ -91,7 +91,7 @@ export default class LayeredChartCompiler {
|
|
|
91
91
|
}): ChartOptions;
|
|
92
92
|
isCategoricalX(design: LayeredChartDesign): boolean;
|
|
93
93
|
compileData(design: LayeredChartDesign, data: C3ChartData, locale?: string): C3Data;
|
|
94
|
-
compileDataPolar(design: LayeredChartDesign, data: C3ChartData, locale
|
|
94
|
+
compileDataPolar(design: LayeredChartDesign, data: C3ChartData, locale?: string): C3Data;
|
|
95
95
|
compileDataNonCategorical(design: LayeredChartDesign, data: C3ChartData, locale?: string): C3Data;
|
|
96
96
|
fixStringYValues(rows?: any): any;
|
|
97
97
|
flattenRowData(rows: any): any[];
|
|
@@ -558,7 +558,7 @@ class LayeredChartCompiler {
|
|
|
558
558
|
const trendlineSeries = seriesY + ":trendline";
|
|
559
559
|
columns.push([trendlineSeries].concat(calculateLinearRegression(yValues, xValues)));
|
|
560
560
|
types[trendlineSeries] = billboard_js_1.line ? (0, billboard_js_1.line)() : "line";
|
|
561
|
-
names[trendlineSeries] = names[seriesY] + T `
|
|
561
|
+
names[trendlineSeries] = names[seriesY] + " " + T `Trendline`;
|
|
562
562
|
xs[trendlineSeries] = seriesX;
|
|
563
563
|
colors[trendlineSeries] = layer.color || defaultColors[layerIndex];
|
|
564
564
|
legendHide.push(trendlineSeries); // Hide in legend
|
|
@@ -195,7 +195,7 @@ class LayeredChartDesignerComponent extends react_1.default.Component {
|
|
|
195
195
|
return R("div", null, lodash_1.default.map(this.props.design.layers, (layer, i) => this.renderLayer(i)),
|
|
196
196
|
// Only add if last has table
|
|
197
197
|
this.props.design.layers.length > 0 && lodash_1.default.last(this.props.design.layers).table
|
|
198
|
-
? R("button", { className: "btn btn-link", type: "button", onClick: this.handleAddLayer }, R("span", { className: "fas fa-plus" }), T `
|
|
198
|
+
? R("button", { className: "btn btn-link", type: "button", onClick: this.handleAddLayer }, R("span", { className: "fas fa-plus" }), " ", T `Add Another Series`)
|
|
199
199
|
: undefined);
|
|
200
200
|
}
|
|
201
201
|
renderOptions() {
|
|
@@ -306,7 +306,7 @@ class ThresholdsComponent extends react_1.default.Component {
|
|
|
306
306
|
onRemove: this.handleRemove.bind(null, index),
|
|
307
307
|
showHighlightColor: this.props.showHighlightColor
|
|
308
308
|
});
|
|
309
|
-
}), R("button", { type: "button", className: "btn btn-sm btn-link", onClick: this.handleAdd }, R("i", { className: "fa fa-plus" }), T `
|
|
309
|
+
}), R("button", { type: "button", className: "btn btn-sm btn-link", onClick: this.handleAdd }, R("i", { className: "fa fa-plus" }), " ", T `Add Y Threshold`));
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
class ThresholdComponent extends react_1.default.Component {
|
|
@@ -93,7 +93,8 @@ class LayeredChartViewComponent extends react_1.default.Component {
|
|
|
93
93
|
schema: this.props.schema,
|
|
94
94
|
dataSource: this.props.dataSource,
|
|
95
95
|
exprValues: this.props.data.header || {},
|
|
96
|
-
width: this.props.width
|
|
96
|
+
width: this.props.width,
|
|
97
|
+
locale: this.context
|
|
97
98
|
}));
|
|
98
99
|
}
|
|
99
100
|
renderFooter() {
|
|
@@ -109,7 +110,8 @@ class LayeredChartViewComponent extends react_1.default.Component {
|
|
|
109
110
|
schema: this.props.schema,
|
|
110
111
|
dataSource: this.props.dataSource,
|
|
111
112
|
exprValues: this.props.data.footer || {},
|
|
112
|
-
width: this.props.width
|
|
113
|
+
width: this.props.width,
|
|
114
|
+
locale: this.context
|
|
113
115
|
}));
|
|
114
116
|
}
|
|
115
117
|
render() {
|
|
@@ -147,6 +149,9 @@ class C3ChartComponent extends react_1.default.Component {
|
|
|
147
149
|
if (this.chart) {
|
|
148
150
|
this.chart.destroy();
|
|
149
151
|
}
|
|
152
|
+
if (!this.chartDiv) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
150
155
|
const compiler = new LayeredChartCompiler_1.default({ schema: props.schema });
|
|
151
156
|
const chartOptions = compiler.createChartOptions({
|
|
152
157
|
design: this.props.design,
|
|
@@ -450,7 +455,7 @@ class C3ChartComponent extends react_1.default.Component {
|
|
|
450
455
|
// css += ".c3-title { font-size: #{scale * 14}px; }\n"
|
|
451
456
|
return R("div", {
|
|
452
457
|
ref: c => {
|
|
453
|
-
|
|
458
|
+
this.chartDiv = c;
|
|
454
459
|
}
|
|
455
460
|
});
|
|
456
461
|
}
|
|
@@ -39,4 +39,5 @@ export default class PivotChart extends Chart {
|
|
|
39
39
|
createDataTable(design: PivotChartDesign, schema: Schema, dataSource: DataSource, data: any, locale: string): (string | undefined)[][];
|
|
40
40
|
getFilterableTables(design: PivotChartDesign, schema: Schema): string[];
|
|
41
41
|
getPlaceholderIcon(): string;
|
|
42
|
+
translateDesign(design: PivotChartDesign, translate: (input: string) => string): PivotChartDesign;
|
|
42
43
|
}
|
|
@@ -39,6 +39,7 @@ const TextWidget_1 = __importDefault(require("../../text/TextWidget"));
|
|
|
39
39
|
const PivotChartUtils = __importStar(require("./PivotChartUtils"));
|
|
40
40
|
const PivotChartQueryBuilder_1 = __importDefault(require("./PivotChartQueryBuilder"));
|
|
41
41
|
const PivotChartLayoutBuilder_1 = __importDefault(require("./PivotChartLayoutBuilder"));
|
|
42
|
+
const ExprItemsTranslator_1 = require("../../../richtext/ExprItemsTranslator");
|
|
42
43
|
// Store true as a weakly cached value if a design is already clean
|
|
43
44
|
const cleanDesignCache = new expressions_1.WeakCache();
|
|
44
45
|
class PivotChart extends Chart_1.default {
|
|
@@ -377,5 +378,67 @@ class PivotChart extends Chart_1.default {
|
|
|
377
378
|
getPlaceholderIcon() {
|
|
378
379
|
return "fa-magic";
|
|
379
380
|
}
|
|
381
|
+
translateDesign(design, translate) {
|
|
382
|
+
return (0, immer_1.default)(design, draft => {
|
|
383
|
+
// Helper function to translate a segment and its children
|
|
384
|
+
const translateSegment = (segment) => {
|
|
385
|
+
// Translate segment label
|
|
386
|
+
if (segment.label) {
|
|
387
|
+
segment.label = translate(segment.label);
|
|
388
|
+
}
|
|
389
|
+
// Translate value axis labels
|
|
390
|
+
if (segment.valueAxis?.categoryLabels) {
|
|
391
|
+
for (const key in segment.valueAxis.categoryLabels) {
|
|
392
|
+
segment.valueAxis.categoryLabels[key] = translate(segment.valueAxis.categoryLabels[key]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// Translate null label
|
|
396
|
+
if (segment.valueAxis?.nullLabel) {
|
|
397
|
+
segment.valueAxis.nullLabel = translate(segment.valueAxis.nullLabel);
|
|
398
|
+
}
|
|
399
|
+
// Recursively translate children
|
|
400
|
+
if (segment.children) {
|
|
401
|
+
segment.children.forEach(translateSegment);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
// Translate all row segments
|
|
405
|
+
draft.rows.forEach(translateSegment);
|
|
406
|
+
// Translate all column segments
|
|
407
|
+
draft.columns.forEach(translateSegment);
|
|
408
|
+
// Translate all intersections
|
|
409
|
+
for (const intersection of Object.values(draft.intersections)) {
|
|
410
|
+
// Translate value axis labels
|
|
411
|
+
if (intersection.valueAxis?.categoryLabels) {
|
|
412
|
+
for (const key in intersection.valueAxis.categoryLabels) {
|
|
413
|
+
intersection.valueAxis.categoryLabels[key] = translate(intersection.valueAxis.categoryLabels[key]);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
// Translate null label
|
|
417
|
+
if (intersection.valueAxis?.nullLabel) {
|
|
418
|
+
intersection.valueAxis.nullLabel = translate(intersection.valueAxis.nullLabel);
|
|
419
|
+
}
|
|
420
|
+
// Translate segment value axis override labels
|
|
421
|
+
if (intersection.segmentValueAxisOverrides) {
|
|
422
|
+
for (const axis of Object.values(intersection.segmentValueAxisOverrides)) {
|
|
423
|
+
if (axis?.categoryLabels) {
|
|
424
|
+
for (const key in axis.categoryLabels) {
|
|
425
|
+
axis.categoryLabels[key] = translate(axis.categoryLabels[key]);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (axis?.nullLabel) {
|
|
429
|
+
axis.nullLabel = translate(axis.nullLabel);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
// Translate header and footer using ExprItemsTranslator
|
|
435
|
+
if (draft.header?.items) {
|
|
436
|
+
draft.header.items = (0, ExprItemsTranslator_1.translateHtmlItems)(draft.header.items, translate);
|
|
437
|
+
}
|
|
438
|
+
if (draft.footer?.items) {
|
|
439
|
+
draft.footer.items = (0, ExprItemsTranslator_1.translateHtmlItems)(draft.footer.items, translate);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
380
443
|
}
|
|
381
444
|
exports.default = PivotChart;
|
|
@@ -252,7 +252,7 @@ class LayoutCellComponent extends react_1.default.Component {
|
|
|
252
252
|
}
|
|
253
253
|
return R("span", { style: { fontSize: "90%" } }, R("a", { className: "link-plain", onClick: this.props.onEditSection }, T `Edit`), cell.summarize
|
|
254
254
|
? [
|
|
255
|
-
R("span", { className: "text-muted" },
|
|
255
|
+
R("span", { className: "text-muted" }, ` / `),
|
|
256
256
|
R("a", { className: "link-plain", onClick: this.props.onSummarizeSegment }, T `Summarize`)
|
|
257
257
|
]
|
|
258
258
|
: undefined);
|
|
@@ -83,9 +83,12 @@ class SegmentDesignerComponent extends react_1.default.Component {
|
|
|
83
83
|
label: T `Type`
|
|
84
84
|
}, react_1.default.createElement(ui.Radio, { key: "single", value: this.state.mode, radioValue: "single", onChange: this.handleMode },
|
|
85
85
|
T `Single ${this.props.segmentType}`,
|
|
86
|
-
react_1.default.createElement("span", { className: "text-muted" },
|
|
86
|
+
react_1.default.createElement("span", { className: "text-muted" },
|
|
87
|
+
` - `,
|
|
88
|
+
T `used for summary ${this.props.segmentType}s and empty ${this.props.segmentType}s`)), react_1.default.createElement(ui.Radio, { key: "multiple", value: this.state.mode, radioValue: "multiple", onChange: this.handleMode },
|
|
87
89
|
T `Multiple ${this.props.segmentType}s`,
|
|
88
|
-
|
|
90
|
+
" - ",
|
|
91
|
+
react_1.default.createElement("span", { className: "text-muted" }, T `disaggregate data by a field`)));
|
|
89
92
|
}
|
|
90
93
|
renderLabel() {
|
|
91
94
|
return R(ui.FormGroup, {
|
|
@@ -132,7 +135,7 @@ class SegmentDesignerComponent extends react_1.default.Component {
|
|
|
132
135
|
renderFilter() {
|
|
133
136
|
return R(ui.FormGroup, {
|
|
134
137
|
labelMuted: true,
|
|
135
|
-
label: [R(ui.Icon, { id: "glyphicon-filter" }), T `
|
|
138
|
+
label: [R(ui.Icon, { id: "glyphicon-filter" }), " ", T `Filters`],
|
|
136
139
|
hint: T `Filters all data associated with this ${this.props.segmentType}`
|
|
137
140
|
}, R(expressions_ui_2.FilterExprComponent, {
|
|
138
141
|
schema: this.props.schema,
|
|
@@ -180,7 +183,7 @@ class SegmentDesignerComponent extends react_1.default.Component {
|
|
|
180
183
|
renderOrderExpr() {
|
|
181
184
|
return R(ui.FormGroup, {
|
|
182
185
|
labelMuted: true,
|
|
183
|
-
label: [R(ui.Icon, { id: "fa-sort-amount-asc" }), T `
|
|
186
|
+
label: [R(ui.Icon, { id: "fa-sort-amount-asc" }), " ", T `Sort`],
|
|
184
187
|
hint: T `Sorts the display of this ${this.props.segmentType}`
|
|
185
188
|
}, R(expressions_ui_1.ExprComponent, {
|
|
186
189
|
schema: this.props.schema,
|
|
@@ -37,7 +37,7 @@ class OrderingsComponent extends react_1.default.Component {
|
|
|
37
37
|
onOrderingChange: this.handleOrderingChange.bind(null, i),
|
|
38
38
|
onOrderingRemove: this.handleOrderingRemove.bind(null, i)
|
|
39
39
|
});
|
|
40
|
-
}), R("button", { type: "button", className: "btn btn-sm btn-secondary", onClick: this.handleAdd, key: "add" }, R("span", { className: "fas fa-plus" }), T `
|
|
40
|
+
}), R("button", { type: "button", className: "btn btn-sm btn-secondary", onClick: this.handleAdd, key: "add" }, R("span", { className: "fas fa-plus" }), " ", T `Add Ordering`));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
exports.default = OrderingsComponent;
|
|
@@ -54,4 +54,5 @@ export default class TableChart extends Chart {
|
|
|
54
54
|
createDataTable(design: any, schema: Schema, dataSource: DataSource, data: any, locale: any): any[][];
|
|
55
55
|
getFilterableTables(design: any, schema: Schema): any[];
|
|
56
56
|
getPlaceholderIcon(): string;
|
|
57
|
+
translateDesign(design: TableChartDesign, translate: (input: string) => string): TableChartDesign;
|
|
57
58
|
}
|
|
@@ -321,5 +321,20 @@ class TableChart extends Chart_1.default {
|
|
|
321
321
|
getPlaceholderIcon() {
|
|
322
322
|
return "fa-table";
|
|
323
323
|
}
|
|
324
|
+
translateDesign(design, translate) {
|
|
325
|
+
return (0, immer_1.default)(design, draft => {
|
|
326
|
+
// Translate title text
|
|
327
|
+
if (draft.titleText) {
|
|
328
|
+
draft.titleText = translate(draft.titleText);
|
|
329
|
+
}
|
|
330
|
+
// Translate column headers and axis labels
|
|
331
|
+
for (const column of draft.columns) {
|
|
332
|
+
// Translate header text
|
|
333
|
+
if (column.headerText) {
|
|
334
|
+
column.headerText = translate(column.headerText);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
324
339
|
}
|
|
325
340
|
exports.default = TableChart;
|
|
@@ -2,11 +2,12 @@ import React from "react";
|
|
|
2
2
|
import RichTextComponent from "../../richtext/RichTextComponent";
|
|
3
3
|
import ExprInsertModalComponent from "./ExprInsertModalComponent";
|
|
4
4
|
import ExprUpdateModalComponent from "./ExprUpdateModalComponent";
|
|
5
|
-
import ExprItemsHtmlConverter from "../../richtext/ExprItemsHtmlConverter";
|
|
5
|
+
import ExprItemsHtmlConverter, { HtmlItemExpr, HtmlItemOrExpr } from "../../richtext/ExprItemsHtmlConverter";
|
|
6
6
|
import { TextWidgetDesign } from "./TextWidgetDesign";
|
|
7
7
|
import { DataSource, Schema } from "@mwater/expressions";
|
|
8
8
|
export interface TextComponentProps {
|
|
9
9
|
design: TextWidgetDesign;
|
|
10
|
+
/** Called when design changes. If not set, will be in display mode, otherwise in edit mode */
|
|
10
11
|
onDesignChange?: (design: TextWidgetDesign) => void;
|
|
11
12
|
schema: Schema;
|
|
12
13
|
dataSource: DataSource;
|
|
@@ -22,17 +23,23 @@ export interface TextComponentProps {
|
|
|
22
23
|
namedStrings?: {
|
|
23
24
|
[key: string]: string;
|
|
24
25
|
};
|
|
26
|
+
/** Locale to use for display */
|
|
27
|
+
locale: string;
|
|
25
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Text component which is provided with the data it needs, rather than loading it.
|
|
31
|
+
* Used by TextWidgetComponent and also by other components that embed text fields
|
|
32
|
+
*/
|
|
26
33
|
export default class TextComponent extends React.Component<TextComponentProps> {
|
|
27
34
|
static contextType: React.Context<string>;
|
|
28
35
|
exprInsertModal: ExprInsertModalComponent | null;
|
|
29
36
|
exprUpdateModal: ExprUpdateModalComponent | null;
|
|
30
37
|
editor: RichTextComponent | null;
|
|
31
38
|
createItemsHtmlConverter(): ExprItemsHtmlConverter;
|
|
32
|
-
handleItemsChange: (items:
|
|
33
|
-
handleInsertExpr: (item:
|
|
39
|
+
handleItemsChange: (items: HtmlItemOrExpr[]) => void;
|
|
40
|
+
handleInsertExpr: (item: HtmlItemExpr) => void;
|
|
34
41
|
replaceItem(item: any): void;
|
|
35
|
-
handleItemClick: (item:
|
|
42
|
+
handleItemClick: (item: HtmlItemExpr) => void;
|
|
36
43
|
handleAddExpr: (ev: React.MouseEvent<HTMLDivElement>) => void;
|
|
37
44
|
renderExtraPaletteButtons(): React.JSX.Element;
|
|
38
45
|
renderModals(): React.JSX.Element[];
|