@mwater/visualization 5.3.2 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.d.ts +1 -1
- package/lib/ColorComponent.js +2 -2
- package/lib/CustomColorsContext.d.ts +0 -1
- package/lib/DateRangeComponent.js +10 -10
- package/lib/LocaleContextInjector.js +2 -2
- package/lib/MWaterAddRelatedFormComponent.js +8 -8
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +0 -1
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterAssetSystemsListComponent.d.ts +3 -3
- package/lib/MWaterAssetSystemsListComponent.js +4 -3
- package/lib/MWaterCompleteTableSelectComponent.d.ts +33 -34
- package/lib/MWaterCompleteTableSelectComponent.js +39 -38
- package/lib/MWaterCustomTablesetListComponent.d.ts +3 -3
- package/lib/MWaterCustomTablesetListComponent.js +5 -4
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +5 -5
- package/lib/MWaterLoaderComponent.js +1 -1
- package/lib/MWaterMetricsTableListComponent.d.ts +3 -3
- package/lib/MWaterMetricsTableListComponent.js +4 -3
- package/lib/MWaterResponsesFilterComponent.js +4 -4
- package/lib/MWaterTableSelectComponent.d.ts +1 -1
- package/lib/MWaterTableSelectComponent.js +5 -5
- package/lib/PopoverComponent.d.ts +4 -4
- package/lib/UIComponents.d.ts +5 -2
- package/lib/axes/AxisBuilder.js +42 -43
- package/lib/axes/AxisColorEditorComponent.d.ts +4 -4
- package/lib/axes/AxisColorEditorComponent.js +25 -60
- package/lib/axes/AxisComponent.d.ts +2 -3
- package/lib/axes/AxisComponent.js +20 -20
- package/lib/axes/BinsComponent.js +6 -6
- package/lib/axes/CategoryMapComponent.d.ts +2 -1
- package/lib/axes/CategoryMapComponent.js +7 -5
- package/lib/axes/ColorPaletteCollectionComponent.js +3 -3
- package/lib/axes/RangesComponent.js +12 -12
- package/lib/compressJson.js +1 -1
- package/lib/dashboards/DashboardComponent.d.ts +2 -0
- package/lib/dashboards/DashboardComponent.js +15 -8
- package/lib/dashboards/DashboardUtils.js +2 -3
- package/lib/dashboards/DashboardViewComponent.js +4 -4
- package/lib/dashboards/FontStyleEditor.js +8 -8
- package/lib/dashboards/LayoutOptionsComponent.js +101 -74
- package/lib/dashboards/SettingsModalComponent.d.ts +3 -4
- package/lib/dashboards/SettingsModalComponent.js +54 -40
- package/lib/dashboards/WidgetComponent.d.ts +0 -1
- package/lib/dashboards/WidgetComponent.js +1 -2
- package/lib/dashboards/layoutOptions.js +11 -7
- package/lib/datagrids/DatagridComponent.d.ts +1 -8
- package/lib/datagrids/DatagridComponent.js +14 -13
- package/lib/datagrids/DatagridDesignerComponent.js +18 -18
- package/lib/datagrids/DatagridQueryBuilder.d.ts +4 -4
- package/lib/datagrids/DatagridUtils.js +2 -2
- package/lib/datagrids/DatagridViewComponent.js +4 -4
- package/lib/datagrids/ExprCellComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.js +17 -17
- package/lib/datagrids/OrderBysDesignerComponent.js +2 -2
- package/lib/languages.js +2 -2
- package/lib/layouts/DecoratedBlockComponent.js +2 -2
- package/lib/layouts/blocks/BlocksDisplayComponent.js +13 -13
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +2 -1
- package/lib/layouts/blocks/ClipboardPaletteItemComponent.js +3 -3
- package/lib/layouts/blocks/HorizontalBlockComponent.js +3 -3
- package/lib/layouts/blocks/blockUtils.js +4 -5
- package/lib/mWaterLoader.js +1 -1
- package/lib/maps/AddLayerComponent.js +13 -13
- package/lib/maps/AdminScopeAndDetailLevelComponent.js +5 -5
- package/lib/maps/BaseLayerDesignerComponent.js +2 -2
- package/lib/maps/BufferLayer.js +7 -7
- package/lib/maps/BufferLayerDesignerComponent.js +8 -8
- package/lib/maps/ChoroplethLayer.js +6 -6
- package/lib/maps/ChoroplethLayerDesigner.js +16 -16
- package/lib/maps/ClusterLayer.js +3 -3
- package/lib/maps/ClusterLayerDesignerComponent.js +5 -5
- package/lib/maps/DetailLevelSelectComponent.d.ts +11 -1
- package/lib/maps/DetailLevelSelectComponent.js +3 -3
- package/lib/maps/DirectMapDataSource.js +1 -2
- package/lib/maps/EditHoverOver.js +7 -5
- package/lib/maps/EditPopupComponent.js +2 -2
- package/lib/maps/GridLayer.js +5 -5
- package/lib/maps/GridLayerDesigner.js +15 -15
- package/lib/maps/LayerSwitcherComponent.js +1 -2
- package/lib/maps/LeafletMapComponent.d.ts +1 -1
- package/lib/maps/LeafletMapComponent.js +1 -1
- package/lib/maps/LegendComponent.js +1 -1
- package/lib/maps/MWaterServerLayer.d.ts +0 -1
- package/lib/maps/MWaterServerLayer.js +1 -1
- package/lib/maps/MapComponent.js +8 -8
- package/lib/maps/MapControlComponent.js +1 -1
- package/lib/maps/MapDesignerComponent.js +16 -16
- package/lib/maps/MapFiltersDesignerComponent.js +2 -2
- package/lib/maps/MapLayerViewDesignerComponent.js +8 -8
- package/lib/maps/MapUtils.js +6 -7
- package/lib/maps/MapViewComponent.js +1 -2
- package/lib/maps/MarkerSymbolSelectComponent.js +3 -3
- package/lib/maps/MarkersLayer.js +6 -7
- package/lib/maps/MarkersLayerDesignerComponent.js +22 -22
- package/lib/maps/PopupFilterJoinsEditComponent.js +4 -4
- package/lib/maps/PopupFilterJoinsUtils.js +2 -3
- package/lib/maps/RasterMapViewComponent.d.ts +3 -3
- package/lib/maps/RasterMapViewComponent.js +4 -4
- package/lib/maps/RegionSelectComponent.d.ts +1 -3
- package/lib/maps/RegionSelectComponent.js +1 -2
- package/lib/maps/ScopeAndDetailLevelComponent.js +3 -3
- package/lib/maps/TileUrlLayer.d.ts +1 -1
- package/lib/maps/TileUrlLayer.js +3 -3
- package/lib/maps/VectorMapViewComponent.js +6 -7
- package/lib/maps/ZoomLevelsComponent.js +5 -5
- package/lib/maps/mapSymbols.d.ts +1 -1
- package/lib/maps/mapSymbols.js +51 -50
- package/lib/maps/mapboxUtils.js +2 -3
- package/lib/maps/maps.d.ts +0 -1
- package/lib/maps/vectorMaps.js +14 -15
- package/lib/memoizedDebounce.js +1 -2
- package/lib/quickfilter/DateExprComponent.d.ts +4 -0
- package/lib/quickfilter/DateExprComponent.js +17 -16
- package/lib/quickfilter/IdArrayQuickfilterComponent.js +1 -1
- package/lib/quickfilter/QuickfilterUtils.js +1 -2
- package/lib/quickfilter/QuickfiltersComponent.d.ts +23 -2
- package/lib/quickfilter/QuickfiltersComponent.js +2 -2
- package/lib/quickfilter/QuickfiltersDesignComponent.js +8 -8
- package/lib/quickfilter/TextLiteralComponent.d.ts +35 -2
- package/lib/quickfilter/TextLiteralComponent.js +6 -6
- package/lib/richtext/DropdownPaletteItem.js +1 -1
- package/lib/richtext/ExprItemsHtmlConverter.js +8 -10
- package/lib/richtext/FontColorPaletteItem.js +7 -7
- package/lib/richtext/ItemsHtmlConverter.js +0 -1
- package/lib/richtext/RichTextComponent.d.ts +1 -0
- package/lib/richtext/RichTextComponent.js +33 -29
- package/lib/valueFormatter.js +18 -19
- package/lib/wellknown.js +2 -3
- package/lib/widgets/IFrameWidgetComponent.d.ts +9 -1
- package/lib/widgets/IFrameWidgetComponent.js +3 -3
- package/lib/widgets/ImageUploaderComponent.js +5 -5
- package/lib/widgets/ImageWidget.js +2 -2
- package/lib/widgets/ImageWidgetComponent.d.ts +9 -1
- package/lib/widgets/ImageWidgetComponent.js +20 -20
- package/lib/widgets/ImagelistCarouselComponent.js +1 -1
- package/lib/widgets/MapWidget.js +2 -2
- package/lib/widgets/MarkdownWidget.d.ts +1 -1
- package/lib/widgets/MarkdownWidget.js +1 -1
- package/lib/widgets/TOCWidget.js +11 -12
- package/lib/widgets/WidgetScopesViewComponent.js +1 -1
- package/lib/widgets/charts/Chart.js +1 -1
- package/lib/widgets/charts/ChartViewComponent.js +9 -9
- package/lib/widgets/charts/ChartWidgetComponent.js +4 -4
- package/lib/widgets/charts/calendar/CalendarChart.js +4 -4
- package/lib/widgets/charts/calendar/CalendarChartDesignerComponent.js +7 -7
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +3 -3
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.d.ts +18 -5
- package/lib/widgets/charts/imagemosaic/ImageMosaicChart.js +3 -4
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.js +5 -5
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.d.ts +5 -19
- package/lib/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.js +66 -70
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.js +1 -1
- package/lib/widgets/charts/layered/LayeredChart.d.ts +1 -1
- package/lib/widgets/charts/layered/LayeredChart.js +9 -9
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +8 -8
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +15 -15
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +33 -33
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +16 -16
- package/lib/widgets/charts/layered/LayeredChartUtils.js +1 -2
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +4 -4
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +18 -17
- package/lib/widgets/charts/pivot/PivotChart.d.ts +1 -1
- package/lib/widgets/charts/pivot/PivotChart.js +12 -4
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +5 -5
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +10 -10
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +5 -5
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +1 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +5 -6
- package/lib/widgets/charts/pivot/PivotChartUtils.js +11 -12
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +9 -9
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +30 -30
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.js +28 -26
- package/lib/widgets/charts/table/OrderingsComponent.js +2 -2
- package/lib/widgets/charts/table/TableChart.js +3 -3
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +17 -17
- package/lib/widgets/charts/table/TableChartViewComponent.js +3 -3
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -3
- package/lib/widgets/text/ExprInsertModalComponent.js +2 -14
- package/lib/widgets/text/ExprItemEditorComponent.js +4 -4
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -3
- package/lib/widgets/text/ExprUpdateModalComponent.js +3 -15
- package/lib/widgets/text/TextComponent.js +3 -3
- package/lib/widgets/text/TextWidget.d.ts +1 -1
- package/lib/widgets/text/TextWidgetComponent.js +11 -11
- package/lib/widgets/text/TextWidgetDesign.d.ts +2 -1
- package/lib/widgets/text/TextWidgetDesign.js +1 -2
- package/package.json +3 -3
- package/src/ColorComponent.tsx +2 -2
- package/src/DateRangeComponent.ts +10 -10
- package/src/LocaleContextInjector.tsx +1 -1
- package/src/MWaterAddRelatedFormComponent.ts +7 -7
- package/src/MWaterAddRelatedIndicatorComponent.ts +5 -5
- package/src/MWaterAssetSystemsListComponent.tsx +3 -3
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -35
- package/src/MWaterCustomTablesetListComponent.tsx +4 -4
- package/src/MWaterGlobalFiltersComponent.ts +4 -4
- package/src/MWaterLoaderComponent.ts +1 -1
- package/src/MWaterMetricsTableListComponent.tsx +3 -3
- package/src/MWaterResponsesFilterComponent.ts +6 -6
- package/src/MWaterTableSelectComponent.tsx +6 -7
- package/src/axes/AxisBuilder.ts +42 -44
- package/src/axes/AxisColorEditorComponent.tsx +178 -0
- package/src/axes/AxisComponent.ts +20 -20
- package/src/axes/BinsComponent.tsx +6 -6
- package/src/axes/CategoryMapComponent.ts +10 -10
- package/src/axes/ColorPaletteCollectionComponent.tsx +3 -3
- package/src/axes/RangesComponent.ts +14 -14
- package/src/dashboards/DashboardComponent.tsx +21 -9
- package/src/dashboards/DashboardViewComponent.tsx +3 -3
- package/src/dashboards/FontStyleEditor.tsx +8 -8
- package/src/dashboards/LayoutOptionsComponent.tsx +74 -74
- package/src/dashboards/SettingsModalComponent.tsx +134 -107
- package/src/dashboards/layoutOptions.tsx +5 -1
- package/src/datagrids/DatagridComponent.ts +65 -62
- package/src/datagrids/DatagridDesignerComponent.tsx +17 -17
- package/src/datagrids/DatagridUtils.ts +2 -2
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +1 -1
- package/src/datagrids/FindReplaceModalComponent.ts +13 -13
- package/src/datagrids/OrderBysDesignerComponent.tsx +2 -2
- package/src/globals.d.ts +7 -1
- package/src/languages.ts +2 -2
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +13 -13
- package/src/layouts/blocks/BlocksLayoutManager.ts +3 -2
- package/src/layouts/blocks/ClipboardPaletteItemComponent.ts +3 -3
- package/src/maps/AddLayerComponent.ts +13 -13
- package/src/maps/AdminScopeAndDetailLevelComponent.ts +5 -5
- package/src/maps/BaseLayerDesignerComponent.ts +8 -8
- package/src/maps/BufferLayer.ts +5 -5
- package/src/maps/BufferLayerDesignerComponent.ts +8 -8
- package/src/maps/ChoroplethLayer.ts +3 -3
- package/src/maps/ChoroplethLayerDesigner.tsx +16 -16
- package/src/maps/ClusterLayer.ts +3 -3
- package/src/maps/ClusterLayerDesignerComponent.ts +5 -5
- package/src/maps/DetailLevelSelectComponent.ts +3 -3
- package/src/maps/EditHoverOver.tsx +5 -5
- package/src/maps/EditPopupComponent.ts +2 -2
- package/src/maps/GridLayer.ts +5 -5
- package/src/maps/GridLayerDesigner.tsx +15 -16
- package/src/maps/MWaterServerLayer.ts +1 -1
- package/src/maps/MapComponent.ts +6 -6
- package/src/maps/MapControlComponent.ts +1 -1
- package/src/maps/MapDesignerComponent.tsx +20 -20
- package/src/maps/MapFiltersDesignerComponent.tsx +3 -3
- package/src/maps/MapLayerViewDesignerComponent.ts +9 -9
- package/src/maps/MarkerSymbolSelectComponent.ts +4 -5
- package/src/maps/MarkersLayerDesignerComponent.ts +22 -22
- package/src/maps/PopupFilterJoinsEditComponent.ts +4 -4
- package/src/maps/RasterMapViewComponent.ts +2 -2
- package/src/maps/RegionSelectComponent.ts +1 -2
- package/src/maps/ScopeAndDetailLevelComponent.ts +3 -3
- package/src/maps/TileUrlLayer.tsx +3 -3
- package/src/maps/VectorMapViewComponent.tsx +5 -5
- package/src/maps/ZoomLevelsComponent.ts +6 -6
- package/src/maps/mapSymbols.ts +49 -49
- package/src/maps/vectorMaps.tsx +2 -2
- package/src/quickfilter/DateExprComponent.ts +19 -18
- package/src/quickfilter/IdArrayQuickfilterComponent.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +1 -1
- package/src/quickfilter/QuickfiltersDesignComponent.tsx +9 -9
- package/src/quickfilter/TextLiteralComponent.ts +4 -4
- package/src/richtext/DropdownPaletteItem.tsx +1 -1
- package/src/richtext/ExprItemsHtmlConverter.ts +8 -10
- package/src/richtext/ItemsHtmlConverter.ts +0 -1
- package/src/richtext/RichTextComponent.tsx +31 -31
- package/src/valueFormatter.ts +14 -14
- package/src/widgets/IFrameWidgetComponent.ts +3 -3
- package/src/widgets/ImageUploaderComponent.tsx +5 -5
- package/src/widgets/ImageWidget.ts +2 -2
- package/src/widgets/ImageWidgetComponent.ts +26 -26
- package/src/widgets/ImagelistCarouselComponent.ts +2 -2
- package/src/widgets/MapWidget.ts +1 -1
- package/src/widgets/MarkdownWidget.ts +1 -1
- package/src/widgets/TOCWidget.ts +13 -14
- package/src/widgets/WidgetScopesViewComponent.ts +1 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +4 -4
- package/src/widgets/charts/ChartWidgetComponent.tsx +3 -3
- package/src/widgets/charts/calendar/CalendarChart.ts +4 -4
- package/src/widgets/charts/calendar/CalendarChartDesignerComponent.ts +7 -7
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +2 -2
- package/src/widgets/charts/imagemosaic/ImageMosaicChart.ts +25 -8
- package/src/widgets/charts/imagemosaic/ImageMosaicChartDesignerComponent.ts +5 -5
- package/src/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.tsx +128 -0
- package/src/widgets/charts/layered/LayeredChart.ts +9 -9
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +45 -45
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +39 -39
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +18 -19
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +1 -1
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +22 -23
- package/src/widgets/charts/pivot/PivotChart.ts +15 -5
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +12 -12
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +5 -5
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +7 -8
- package/src/widgets/charts/pivot/PivotChartViewComponent.tsx +6 -6
- package/src/widgets/charts/pivot/SegmentDesignerComponent.tsx +30 -30
- package/src/widgets/charts/table/OrderingsComponent.tsx +2 -2
- package/src/widgets/charts/table/TableChart.ts +3 -3
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +16 -16
- package/src/widgets/charts/table/TableChartViewComponent.ts +2 -2
- package/src/widgets/text/{ExprInsertModalComponent.ts → ExprInsertModalComponent.tsx} +18 -20
- package/src/widgets/text/ExprItemEditorComponent.tsx +4 -4
- package/src/widgets/text/{ExprUpdateModalComponent.ts → ExprUpdateModalComponent.tsx} +18 -20
- package/src/widgets/text/TextComponent.tsx +2 -2
- package/src/widgets/text/TextWidgetComponent.tsx +10 -10
- package/src/widgets/text/TextWidgetDesign.ts +3 -1
- package/src/axes/AxisColorEditorComponent.ts +0 -210
- package/src/widgets/charts/imagemosaic/ImageMosaicChartViewComponent.ts +0 -117
package/src/axes/AxisBuilder.ts
CHANGED
|
@@ -187,27 +187,27 @@ export default class AxisBuilder {
|
|
|
187
187
|
// xform validation
|
|
188
188
|
if (options.axis.xform && options.axis.xform.type === "bin") {
|
|
189
189
|
if (!options.axis.xform.numBins) {
|
|
190
|
-
return
|
|
190
|
+
return T`Missing numBins`
|
|
191
191
|
}
|
|
192
192
|
if (options.axis.xform.min == null) {
|
|
193
|
-
return
|
|
193
|
+
return T`Missing min`
|
|
194
194
|
}
|
|
195
195
|
if (options.axis.xform.max == null) {
|
|
196
|
-
return
|
|
196
|
+
return T`Missing max`
|
|
197
197
|
}
|
|
198
198
|
if (options.axis.xform.max < options.axis.xform.min) {
|
|
199
|
-
return
|
|
199
|
+
return T`Max < min`
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
// xform validation
|
|
204
204
|
if (options.axis.xform && options.axis.xform.type === "ranges") {
|
|
205
205
|
if (!options.axis.xform.ranges || !_.isArray(options.axis.xform.ranges)) {
|
|
206
|
-
return
|
|
206
|
+
return T`Missing ranges`
|
|
207
207
|
}
|
|
208
208
|
for (let range of options.axis.xform.ranges) {
|
|
209
209
|
if (range.minValue != null && range.maxValue != null && range.minValue > range.maxValue) {
|
|
210
|
-
return
|
|
210
|
+
return T`Max < min`
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -397,8 +397,7 @@ export default class AxisBuilder {
|
|
|
397
397
|
// from (select expression as val, ntile(numBins + 2) over (order by expression asc) as ntilenum
|
|
398
398
|
// from the_table where exprssion is not null)
|
|
399
399
|
// where inner.ntilenum > 1 and inner.ntilenum < numBins + 2
|
|
400
|
-
// Inspired by: http://dba.stackexchange.com/questions/17086/fast-general-method-to-calculate-percentiles
|
|
401
|
-
// expr is mwater expression on table
|
|
400
|
+
// Inspired by: http://dba.stackexchange.com/questions/17086/fast-general-method-to-calculate-percentiles // expr is mwater expression on table
|
|
402
401
|
// filterExpr is optional filter on values to include
|
|
403
402
|
// Result can be null if no query could be computed
|
|
404
403
|
compileBinMinMax(expr: any, table: any, filterExpr: any, numBins: any) {
|
|
@@ -514,7 +513,7 @@ export default class AxisBuilder {
|
|
|
514
513
|
onlyValuesPresent?: boolean
|
|
515
514
|
} = {}): AxisCategory[] {
|
|
516
515
|
let categories: AxisCategory[], current, end, format, label, max, min, value, year
|
|
517
|
-
const noneCategory = { value: null, label: axis.nullLabel ||
|
|
516
|
+
const noneCategory = { value: null, label: axis.nullLabel || T`None` }
|
|
518
517
|
const hasNone = _.any(values || [], (v) => v == null)
|
|
519
518
|
|
|
520
519
|
// Handle ranges
|
|
@@ -533,7 +532,7 @@ export default class AxisBuilder {
|
|
|
533
532
|
|
|
534
533
|
if (range.maxValue != null) {
|
|
535
534
|
if (label) {
|
|
536
|
-
label +=
|
|
535
|
+
label += T` and `
|
|
537
536
|
}
|
|
538
537
|
if (range.maxOpen) {
|
|
539
538
|
label += `< ${range.maxValue}`
|
|
@@ -565,9 +564,9 @@ export default class AxisBuilder {
|
|
|
565
564
|
// Special case of single value (min and max within epsilon or 0.01% of each other since epsilon might be too small to add to a big number)
|
|
566
565
|
if (max - min <= epsilon || Math.abs((max - min) / (max + min)) < 0.0001) {
|
|
567
566
|
return [
|
|
568
|
-
{ value: 0, label: `< ${min}` },
|
|
569
|
-
{ value: 1, label: `= ${min}` },
|
|
570
|
-
{ value: axis.xform.numBins! + 1, label: `> ${min}` },
|
|
567
|
+
{ value: 0, label: T`< ${min}` },
|
|
568
|
+
{ value: 1, label: T`= ${min}` },
|
|
569
|
+
{ value: axis.xform.numBins! + 1, label: T`> ${min}` },
|
|
571
570
|
noneCategory
|
|
572
571
|
]
|
|
573
572
|
}
|
|
@@ -583,7 +582,7 @@ export default class AxisBuilder {
|
|
|
583
582
|
categories = []
|
|
584
583
|
|
|
585
584
|
if (!axis.xform.excludeLower) {
|
|
586
|
-
categories.push({ value: 0, label: `< ${format(min)}` })
|
|
585
|
+
categories.push({ value: 0, label: T`< ${format(min)}` })
|
|
587
586
|
}
|
|
588
587
|
|
|
589
588
|
for (let i = 1, end1 = numBins, asc = 1 <= end1; asc ? i <= end1 : i >= end1; asc ? i++ : i--) {
|
|
@@ -593,7 +592,7 @@ export default class AxisBuilder {
|
|
|
593
592
|
}
|
|
594
593
|
|
|
595
594
|
if (!axis.xform.excludeUpper) {
|
|
596
|
-
categories.push({ value: axis.xform.numBins! + 1, label: `> ${format(max)}` })
|
|
595
|
+
categories.push({ value: axis.xform.numBins! + 1, label: T`> ${format(max)}` })
|
|
597
596
|
}
|
|
598
597
|
|
|
599
598
|
categories.push(noneCategory)
|
|
@@ -627,18 +626,18 @@ export default class AxisBuilder {
|
|
|
627
626
|
|
|
628
627
|
if (axis.xform && axis.xform.type === "month") {
|
|
629
628
|
categories = [
|
|
630
|
-
{ value: "01", label:
|
|
631
|
-
{ value: "02", label:
|
|
632
|
-
{ value: "03", label:
|
|
633
|
-
{ value: "04", label:
|
|
634
|
-
{ value: "05", label:
|
|
635
|
-
{ value: "06", label:
|
|
636
|
-
{ value: "07", label:
|
|
637
|
-
{ value: "08", label:
|
|
638
|
-
{ value: "09", label:
|
|
639
|
-
{ value: "10", label:
|
|
640
|
-
{ value: "11", label:
|
|
641
|
-
{ value: "12", label:
|
|
629
|
+
{ value: "01", label: T`January` },
|
|
630
|
+
{ value: "02", label: T`February` },
|
|
631
|
+
{ value: "03", label: T`March` },
|
|
632
|
+
{ value: "04", label: T`April` },
|
|
633
|
+
{ value: "05", label: T`May` },
|
|
634
|
+
{ value: "06", label: T`June` },
|
|
635
|
+
{ value: "07", label: T`July` },
|
|
636
|
+
{ value: "08", label: T`August` },
|
|
637
|
+
{ value: "09", label: T`September` },
|
|
638
|
+
{ value: "10", label: T`October` },
|
|
639
|
+
{ value: "11", label: T`November` },
|
|
640
|
+
{ value: "12", label: T`December` }
|
|
642
641
|
]
|
|
643
642
|
|
|
644
643
|
// Add none if needed
|
|
@@ -722,7 +721,7 @@ export default class AxisBuilder {
|
|
|
722
721
|
|
|
723
722
|
if (options.onlyValuesPresent) {
|
|
724
723
|
// Sort and take only present
|
|
725
|
-
categories = _.sortBy(_.uniq(values), item => item).map(value => ({ value, label: moment(value, "YYYY-MM-DD").format(
|
|
724
|
+
categories = _.sortBy(_.uniq(values), item => item).map(value => ({ value, label: moment(value, "YYYY-MM-DD").format(T`MMM YYYY`) }))
|
|
726
725
|
|
|
727
726
|
if (hasNone) {
|
|
728
727
|
categories.push(noneCategory)
|
|
@@ -740,7 +739,7 @@ export default class AxisBuilder {
|
|
|
740
739
|
end = moment(max, "YYYY-MM-DD")
|
|
741
740
|
categories = []
|
|
742
741
|
while (!current.isAfter(end)) {
|
|
743
|
-
categories.push({ value: current.format("YYYY-MM-DD"), label: current.format(
|
|
742
|
+
categories.push({ value: current.format("YYYY-MM-DD"), label: current.format(T`MMM YYYY`) })
|
|
744
743
|
current.add(1, "months")
|
|
745
744
|
if (categories.length >= 1000) {
|
|
746
745
|
break
|
|
@@ -808,13 +807,13 @@ export default class AxisBuilder {
|
|
|
808
807
|
const year = value.substr(0, 4)
|
|
809
808
|
const quarter = value.substr(value.length - 1, 1)
|
|
810
809
|
if (quarter === "1") {
|
|
811
|
-
label = `${year} Jan-Mar`
|
|
810
|
+
label = `${year} ${T`Jan-Mar`}`
|
|
812
811
|
} else if (quarter === "2") {
|
|
813
|
-
label = `${year} Apr-Jun`
|
|
812
|
+
label = `${year} ${T`Apr-Jun`}`
|
|
814
813
|
} else if (quarter === "3") {
|
|
815
|
-
label = `${year} Jul-Sep`
|
|
814
|
+
label = `${year} ${T`Jul-Sep`}`
|
|
816
815
|
} else if (quarter === "4") {
|
|
817
|
-
label = `${year} Oct-Dec`
|
|
816
|
+
label = `${year} ${T`Oct-Dec`}`
|
|
818
817
|
} else {
|
|
819
818
|
label = ""
|
|
820
819
|
}
|
|
@@ -841,13 +840,13 @@ export default class AxisBuilder {
|
|
|
841
840
|
const quarter = current.format("Q")
|
|
842
841
|
year = current.format("YYYY")
|
|
843
842
|
if (quarter === "1") {
|
|
844
|
-
label = `${year} Jan-Mar`
|
|
843
|
+
label = `${year} ${T`Jan-Mar`}`
|
|
845
844
|
} else if (quarter === "2") {
|
|
846
|
-
label = `${year} Apr-Jun`
|
|
845
|
+
label = `${year} ${T`Apr-Jun`}`
|
|
847
846
|
} else if (quarter === "3") {
|
|
848
|
-
label = `${year} Jul-Sep`
|
|
847
|
+
label = `${year} ${T`Jul-Sep`}`
|
|
849
848
|
} else if (quarter === "4") {
|
|
850
|
-
label = `${year} Oct-Dec`
|
|
849
|
+
label = `${year} ${T`Oct-Dec`}`
|
|
851
850
|
} else {
|
|
852
851
|
label = ""
|
|
853
852
|
}
|
|
@@ -899,7 +898,7 @@ export default class AxisBuilder {
|
|
|
899
898
|
// Return unique values
|
|
900
899
|
categories = _.map(_.compact(_.uniq(values || [])).sort(), (v) => ({
|
|
901
900
|
value: v,
|
|
902
|
-
label: v ||
|
|
901
|
+
label: v || T`None`
|
|
903
902
|
}))
|
|
904
903
|
if (hasNone) {
|
|
905
904
|
categories.push(noneCategory)
|
|
@@ -908,7 +907,7 @@ export default class AxisBuilder {
|
|
|
908
907
|
return categories
|
|
909
908
|
case "boolean":
|
|
910
909
|
// Return unique values
|
|
911
|
-
return [{ value: true, label:
|
|
910
|
+
return [{ value: true, label: T`True` }, { value: false, label: T`False` }, noneCategory]
|
|
912
911
|
case "date":
|
|
913
912
|
values = _.compact(values || [])
|
|
914
913
|
if (values.length === 0) {
|
|
@@ -997,7 +996,7 @@ export default class AxisBuilder {
|
|
|
997
996
|
// Summarize axis as a string
|
|
998
997
|
summarizeAxis(axis: Axis, locale?: string) {
|
|
999
998
|
if (!axis) {
|
|
1000
|
-
return
|
|
999
|
+
return T`None`
|
|
1001
1000
|
}
|
|
1002
1001
|
|
|
1003
1002
|
return this.exprUtils.summarizeExpr(axis.expr, locale)
|
|
@@ -1007,7 +1006,7 @@ export default class AxisBuilder {
|
|
|
1007
1006
|
// Get a string (or React DOM actually) representation of an axis value
|
|
1008
1007
|
formatValue(axis: Axis, value: any, locale?: string, legacyPercentFormat?: any) {
|
|
1009
1008
|
if (value == null) {
|
|
1010
|
-
return axis?.nullLabel ||
|
|
1009
|
+
return axis?.nullLabel || T`None`
|
|
1011
1010
|
}
|
|
1012
1011
|
|
|
1013
1012
|
const type = this.getAxisType(axis)
|
|
@@ -1025,7 +1024,7 @@ export default class AxisBuilder {
|
|
|
1025
1024
|
if (category) {
|
|
1026
1025
|
return this.formatCategory(axis, category)
|
|
1027
1026
|
} else {
|
|
1028
|
-
return
|
|
1027
|
+
return T`???`
|
|
1029
1028
|
}
|
|
1030
1029
|
}).join(", ")
|
|
1031
1030
|
} else {
|
|
@@ -1033,7 +1032,7 @@ export default class AxisBuilder {
|
|
|
1033
1032
|
if (category) {
|
|
1034
1033
|
return this.formatCategory(axis, category)
|
|
1035
1034
|
} else {
|
|
1036
|
-
return
|
|
1035
|
+
return T`???`
|
|
1037
1036
|
}
|
|
1038
1037
|
}
|
|
1039
1038
|
}
|
|
@@ -1197,7 +1196,6 @@ export default class AxisBuilder {
|
|
|
1197
1196
|
exprs: [expr]
|
|
1198
1197
|
}
|
|
1199
1198
|
}
|
|
1200
|
-
|
|
1201
1199
|
if (xform.type === "yearmonth") {
|
|
1202
1200
|
expr = {
|
|
1203
1201
|
table,
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import _ from "lodash"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import CategoryMapComponent from "./CategoryMapComponent"
|
|
4
|
+
import ColorSchemeFactory from "../ColorSchemeFactory"
|
|
5
|
+
import ColorPaletteCollectionComponent from "./ColorPaletteCollectionComponent"
|
|
6
|
+
import AxisBuilder from "./AxisBuilder"
|
|
7
|
+
import produce from "immer"
|
|
8
|
+
import { Axis, AxisCategory, ColorMap } from "./Axis"
|
|
9
|
+
import { Schema } from "@mwater/expressions"
|
|
10
|
+
|
|
11
|
+
export interface AxisColorEditorComponentProps {
|
|
12
|
+
schema: Schema
|
|
13
|
+
axis: Axis
|
|
14
|
+
/** Called with new axis */
|
|
15
|
+
onChange: (axis: Axis) => void
|
|
16
|
+
|
|
17
|
+
/** Categories of the axis */
|
|
18
|
+
categories?: AxisCategory[]
|
|
19
|
+
|
|
20
|
+
/** is the color map reorderable */
|
|
21
|
+
reorderable?: boolean
|
|
22
|
+
|
|
23
|
+
defaultColor?: string
|
|
24
|
+
/** True to allow excluding of values via checkboxes */
|
|
25
|
+
allowExcludedValues?: boolean
|
|
26
|
+
/** True to start values expanded */
|
|
27
|
+
initiallyExpanded?: boolean
|
|
28
|
+
/** True to automatically set the colors if blank */
|
|
29
|
+
autosetColors?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface AxisColorEditorComponentState {
|
|
33
|
+
mode: "normal" | "palette"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Color editor for axis. Allows switching between editing individial colors (using CategoryMapComponent)
|
|
37
|
+
// and setting the colors from a palette (using ColorPaletteCollectionComponent)
|
|
38
|
+
export default class AxisColorEditorComponent extends React.Component<
|
|
39
|
+
AxisColorEditorComponentProps,
|
|
40
|
+
AxisColorEditorComponentState
|
|
41
|
+
> {
|
|
42
|
+
static defaultProps = {
|
|
43
|
+
reorderable: false,
|
|
44
|
+
autosetColors: true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
constructor(props: AxisColorEditorComponentProps) {
|
|
48
|
+
super(props)
|
|
49
|
+
|
|
50
|
+
this.state = {
|
|
51
|
+
mode: "normal"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
this.updateColorMap()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentDidUpdate() {
|
|
60
|
+
this.updateColorMap()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Update color map if categories no longer match
|
|
64
|
+
updateColorMap() {
|
|
65
|
+
const axisBuilder = new AxisBuilder({ schema: this.props.schema })
|
|
66
|
+
|
|
67
|
+
// If no categories, can't do anything
|
|
68
|
+
if (!this.props.categories) {
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// If no color map or color map values have changed
|
|
73
|
+
if (
|
|
74
|
+
!this.props.axis.colorMap ||
|
|
75
|
+
!_.isEqual(_.pluck(this.props.axis.colorMap, "value").sort(), _.pluck(this.props.categories, "value").sort())
|
|
76
|
+
) {
|
|
77
|
+
let colorMap
|
|
78
|
+
if (this.props.autosetColors) {
|
|
79
|
+
// Find categories that are not in the color map
|
|
80
|
+
const missingCategories = _.filter(this.props.categories, (category) => !(this.props.axis.colorMap || []).find(cm => cm.value === category.value))
|
|
81
|
+
if (missingCategories.length == 0) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
const missingColorMap = ColorSchemeFactory.createColorMapForCategories(
|
|
85
|
+
missingCategories,
|
|
86
|
+
axisBuilder.isCategorical(this.props.axis)
|
|
87
|
+
)
|
|
88
|
+
colorMap = (this.props.axis.colorMap || []).concat(missingColorMap)
|
|
89
|
+
} else {
|
|
90
|
+
// Keep existing
|
|
91
|
+
const existing = _.indexBy(this.props.axis.colorMap || [], "value")
|
|
92
|
+
colorMap = _.map(this.props.categories, (category) => ({
|
|
93
|
+
value: category.value,
|
|
94
|
+
color: existing[category.value] ? existing[category.value].color : null
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.handlePaletteChange(colorMap)
|
|
99
|
+
this.setState({ mode: "normal" })
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
handleSelectPalette = () => {
|
|
104
|
+
this.setState({ mode: "palette" })
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
handleResetPalette = () => {
|
|
108
|
+
// Completely reset
|
|
109
|
+
const colorMap = _.map(this.props.categories || [], (category) => ({
|
|
110
|
+
value: category.value,
|
|
111
|
+
color: null
|
|
112
|
+
}))
|
|
113
|
+
|
|
114
|
+
this.handlePaletteChange(colorMap)
|
|
115
|
+
this.setState({ mode: "normal" })
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
handlePaletteChange = (palette: ColorMap) => {
|
|
119
|
+
this.props.onChange(
|
|
120
|
+
produce(this.props.axis, (draft) => {
|
|
121
|
+
draft.colorMap = palette
|
|
122
|
+
draft.drawOrder = _.pluck(palette, "value")
|
|
123
|
+
})
|
|
124
|
+
)
|
|
125
|
+
this.setState({ mode: "normal" })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
handleCancelCustomize = () => {
|
|
129
|
+
this.setState({ mode: "normal" })
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
render() {
|
|
133
|
+
return (
|
|
134
|
+
<div>
|
|
135
|
+
{this.state.mode === "palette" && this.props.categories && (
|
|
136
|
+
<ColorPaletteCollectionComponent
|
|
137
|
+
onPaletteSelected={this.handlePaletteChange}
|
|
138
|
+
axis={this.props.axis}
|
|
139
|
+
categories={this.props.categories}
|
|
140
|
+
onCancel={this.handleCancelCustomize}
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
|
|
144
|
+
{this.state.mode === "normal" && (
|
|
145
|
+
<div>
|
|
146
|
+
<p>
|
|
147
|
+
<a className="link-plain" onClick={this.handleSelectPalette}>
|
|
148
|
+
{T`Change color scheme`}
|
|
149
|
+
</a>
|
|
150
|
+
{!this.props.autosetColors && (
|
|
151
|
+
<a className="btn btn-sm btn-link" onClick={this.handleResetPalette}>
|
|
152
|
+
{T`Reset colors`}
|
|
153
|
+
</a>
|
|
154
|
+
)}
|
|
155
|
+
</p>
|
|
156
|
+
|
|
157
|
+
{this.props.axis.colorMap && (
|
|
158
|
+
<div>
|
|
159
|
+
<div>
|
|
160
|
+
<CategoryMapComponent
|
|
161
|
+
schema={this.props.schema}
|
|
162
|
+
axis={this.props.axis}
|
|
163
|
+
onChange={this.props.onChange}
|
|
164
|
+
categories={this.props.categories}
|
|
165
|
+
reorderable={this.props.reorderable}
|
|
166
|
+
allowExcludedValues={this.props.allowExcludedValues}
|
|
167
|
+
showColorMap={true}
|
|
168
|
+
initiallyExpanded={this.props.initiallyExpanded}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
)}
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -106,7 +106,7 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// Get categories (value + label)
|
|
109
|
-
let categories = axisBuilder.getCategories(axis, values)
|
|
109
|
+
let categories = axisBuilder.getCategories(axis, values, { locale: this.context })
|
|
110
110
|
|
|
111
111
|
// Just "None" and so doesn't count
|
|
112
112
|
if (_.any(categories, (category) => category.value != null)) {
|
|
@@ -165,7 +165,7 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// Set expression and clear xform
|
|
168
|
-
|
|
168
|
+
this.props.onChange(this.cleanAxis(_.extend({}, _.omit(this.props.value || {}, ["drawOrder"]), { expr })))
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
handleFormatChange = (ev: any) => {
|
|
@@ -278,9 +278,9 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
278
278
|
R(ui.RadioToggleComponent, {
|
|
279
279
|
value: axis.xform ? axis.xform.type : null,
|
|
280
280
|
options: [
|
|
281
|
-
{ value: "bin", label:
|
|
282
|
-
{ value: "ranges", label:
|
|
283
|
-
{ value: "floor", label:
|
|
281
|
+
{ value: "bin", label: T`Equal Bins` },
|
|
282
|
+
{ value: "ranges", label: T`Custom Ranges` },
|
|
283
|
+
{ value: "floor", label: T`Whole Numbers` }
|
|
284
284
|
],
|
|
285
285
|
onChange: this.handleXformTypeChange
|
|
286
286
|
}),
|
|
@@ -296,13 +296,13 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
296
296
|
return R(ui.RadioToggleComponent, {
|
|
297
297
|
value: axis.xform ? axis.xform.type : null,
|
|
298
298
|
options: [
|
|
299
|
-
{ value: null, label:
|
|
300
|
-
{ value: "year", label:
|
|
301
|
-
{ value: "yearmonth", label:
|
|
302
|
-
{ value: "month", label:
|
|
303
|
-
{ value: "week", label:
|
|
304
|
-
{ value: "yearweek", label:
|
|
305
|
-
{ value: "yearquarter", label:
|
|
299
|
+
{ value: null, label: T`Exact Date` },
|
|
300
|
+
{ value: "year", label: T`Year` },
|
|
301
|
+
{ value: "yearmonth", label: T`Year/Month` },
|
|
302
|
+
{ value: "month", label: T`Month` },
|
|
303
|
+
{ value: "week", label: T`Week` },
|
|
304
|
+
{ value: "yearweek", label: T`Year/Week` },
|
|
305
|
+
{ value: "yearquarter", label: T`Year/Quarter` }
|
|
306
306
|
],
|
|
307
307
|
onChange: this.handleXformTypeChange
|
|
308
308
|
})
|
|
@@ -310,13 +310,13 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
310
310
|
return R(ui.RadioToggleComponent, {
|
|
311
311
|
value: axis.xform ? axis.xform.type : null,
|
|
312
312
|
options: [
|
|
313
|
-
{ value: "date", label:
|
|
314
|
-
{ value: "year", label:
|
|
315
|
-
{ value: "yearmonth", label:
|
|
316
|
-
{ value: "month", label:
|
|
317
|
-
{ value: "week", label:
|
|
318
|
-
{ value: "yearweek", label:
|
|
319
|
-
{ value: "yearquarter", label:
|
|
313
|
+
{ value: "date", label: T`Date` },
|
|
314
|
+
{ value: "year", label: T`Year` },
|
|
315
|
+
{ value: "yearmonth", label: T`Year/Month` },
|
|
316
|
+
{ value: "month", label: T`Month` },
|
|
317
|
+
{ value: "week", label: T`Week` },
|
|
318
|
+
{ value: "yearweek", label: T`Year/Week` },
|
|
319
|
+
{ value: "yearquarter", label: T`Year/Quarter` }
|
|
320
320
|
],
|
|
321
321
|
onChange: this.handleXformTypeChange
|
|
322
322
|
})
|
|
@@ -387,7 +387,7 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
387
387
|
return R(
|
|
388
388
|
"div",
|
|
389
389
|
{ className: "mb-3" },
|
|
390
|
-
R("label", { className: "text-muted" },
|
|
390
|
+
R("label", { className: "text-muted" }, T`Format`),
|
|
391
391
|
": ",
|
|
392
392
|
R(
|
|
393
393
|
"select",
|
|
@@ -102,7 +102,7 @@ export default class BinsComponent extends React.Component<BinsComponentProps, B
|
|
|
102
102
|
{ key: "vals" },
|
|
103
103
|
R(
|
|
104
104
|
LabeledInlineComponent,
|
|
105
|
-
{ key: "min", label:
|
|
105
|
+
{ key: "min", label: T`Min:` },
|
|
106
106
|
R(NumberInputComponent, {
|
|
107
107
|
small: true,
|
|
108
108
|
value: this.props.xform.min,
|
|
@@ -112,7 +112,7 @@ export default class BinsComponent extends React.Component<BinsComponentProps, B
|
|
|
112
112
|
" ",
|
|
113
113
|
R(
|
|
114
114
|
LabeledInlineComponent,
|
|
115
|
-
{ key: "max", label:
|
|
115
|
+
{ key: "max", label: T`Max:` },
|
|
116
116
|
R(NumberInputComponent, {
|
|
117
117
|
small: true,
|
|
118
118
|
value: this.props.xform.max,
|
|
@@ -122,7 +122,7 @@ export default class BinsComponent extends React.Component<BinsComponentProps, B
|
|
|
122
122
|
" ",
|
|
123
123
|
R(
|
|
124
124
|
LabeledInlineComponent,
|
|
125
|
-
{ key: "numBins", label:
|
|
125
|
+
{ key: "numBins", label: T`# of Bins:` },
|
|
126
126
|
R(NumberInputComponent, {
|
|
127
127
|
small: true,
|
|
128
128
|
value: this.props.xform.numBins,
|
|
@@ -134,7 +134,7 @@ export default class BinsComponent extends React.Component<BinsComponentProps, B
|
|
|
134
134
|
if (this.state.guessing) {
|
|
135
135
|
return R("i", { className: "fa fa-spinner fa-spin" })
|
|
136
136
|
} else if (this.props.xform.min == null || this.props.xform.max == null || !this.props.xform.numBins) {
|
|
137
|
-
return R("span", { className: "text-danger", style: { paddingLeft: 10 } },
|
|
137
|
+
return R("span", { className: "text-danger", style: { paddingLeft: 10 } }, T`Min and max are required`)
|
|
138
138
|
}
|
|
139
139
|
return null
|
|
140
140
|
})()
|
|
@@ -146,13 +146,13 @@ export default class BinsComponent extends React.Component<BinsComponentProps, B
|
|
|
146
146
|
inline
|
|
147
147
|
value={!this.props.xform.excludeLower}
|
|
148
148
|
onChange={(value) => this.props.onChange(update(this.props.xform, { excludeLower: { $set: !value } }))}
|
|
149
|
-
>{`Include < ${this.props.xform.min}`}</Checkbox>
|
|
149
|
+
>{T`Include < ${this.props.xform.min}`}</Checkbox>
|
|
150
150
|
<Checkbox
|
|
151
151
|
key="upper"
|
|
152
152
|
inline
|
|
153
153
|
value={!this.props.xform.excludeUpper}
|
|
154
154
|
onChange={(value) => this.props.onChange(update(this.props.xform, { excludeUpper: { $set: !value } }))}
|
|
155
|
-
>{`Include > ${this.props.xform.max}`}</Checkbox>
|
|
155
|
+
>{T`Include > ${this.props.xform.max}`}</Checkbox>
|
|
156
156
|
</div>
|
|
157
157
|
) : undefined
|
|
158
158
|
)
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
1
|
import _ from "lodash"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
|
-
import {
|
|
6
|
-
import AxisBuilder from "./AxisBuilder"
|
|
4
|
+
import { Schema } from "@mwater/expressions"
|
|
7
5
|
import update from "update-object"
|
|
8
6
|
import ColorComponent from "../ColorComponent"
|
|
9
|
-
import { ExprUtils } from "@mwater/expressions"
|
|
10
7
|
import ReorderableListComponent from "@mwater/react-library/lib/reorderable/ReorderableListComponent"
|
|
11
8
|
import { default as produce } from "immer"
|
|
12
9
|
import { Axis, AxisCategory } from "./Axis"
|
|
10
|
+
import { LocaleContext } from "@mwater/expressions-ui"
|
|
13
11
|
|
|
14
12
|
export interface CategoryMapComponentProps {
|
|
15
13
|
schema: Schema
|
|
@@ -34,7 +32,9 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
34
32
|
CategoryMapComponentProps,
|
|
35
33
|
CategoryMapComponentState
|
|
36
34
|
> {
|
|
37
|
-
|
|
35
|
+
static contextType = LocaleContext
|
|
36
|
+
|
|
37
|
+
constructor(props: CategoryMapComponentProps) {
|
|
38
38
|
super(props)
|
|
39
39
|
|
|
40
40
|
this.state = {
|
|
@@ -80,7 +80,7 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
handleNullLabelChange = (e: any) => {
|
|
83
|
-
const name = prompt(
|
|
83
|
+
const name = prompt(T`Enter label for none value`, this.props.axis.nullLabel || T`None`)
|
|
84
84
|
if (name) {
|
|
85
85
|
return this.props.onChange(update(this.props.axis, { nullLabel: { $set: name } }))
|
|
86
86
|
}
|
|
@@ -92,7 +92,7 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
92
92
|
label = this.props.axis.categoryLabels[JSON.stringify(category.value)] || label
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const name = prompt(
|
|
95
|
+
const name = prompt(T`Enter label or blank to reset`, label)
|
|
96
96
|
if (name != null) {
|
|
97
97
|
if (name) {
|
|
98
98
|
return this.props.onChange(
|
|
@@ -137,7 +137,7 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
137
137
|
"a",
|
|
138
138
|
{ className: "link-plain", onClick: this.handleNullLabelChange, style: { cursor: "pointer" } },
|
|
139
139
|
label,
|
|
140
|
-
R("span", { style: { fontSize: 12, marginLeft: 4 } },
|
|
140
|
+
R("span", { style: { fontSize: 12, marginLeft: 4 } }, T`(click to change label for none value)`)
|
|
141
141
|
)
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -246,7 +246,7 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
246
246
|
R(
|
|
247
247
|
"a",
|
|
248
248
|
{ className: "link-plain", onClick: this.handleToggle },
|
|
249
|
-
|
|
249
|
+
T`Show Values `,
|
|
250
250
|
R("i", { className: "fa fa-caret-down" })
|
|
251
251
|
)
|
|
252
252
|
)
|
|
@@ -257,7 +257,7 @@ export default class CategoryMapComponent extends React.Component<
|
|
|
257
257
|
R(
|
|
258
258
|
"a",
|
|
259
259
|
{ className: "link-plain", onClick: this.handleToggle },
|
|
260
|
-
|
|
260
|
+
T`Hide Values `,
|
|
261
261
|
R("i", { className: "fa fa-caret-up" })
|
|
262
262
|
)
|
|
263
263
|
)
|
|
@@ -114,7 +114,7 @@ function ColorPaletteCollectionComponent(props: ColorPaletteCollectionComponentP
|
|
|
114
114
|
|
|
115
115
|
const onPaletteSelected = (index: number) => {
|
|
116
116
|
// Generate color map
|
|
117
|
-
const scheme = generatePaletteColors(palettes[index],
|
|
117
|
+
const scheme = generatePaletteColors(palettes[index], numColors)
|
|
118
118
|
|
|
119
119
|
const colorMap = _.map(props.categories, (category, i) => ({
|
|
120
120
|
value: category.value,
|
|
@@ -128,7 +128,7 @@ function ColorPaletteCollectionComponent(props: ColorPaletteCollectionComponentP
|
|
|
128
128
|
return (
|
|
129
129
|
<div>
|
|
130
130
|
<a className="link-plain" onClick={props.onCancel} key="cancel-customize">
|
|
131
|
-
Cancel
|
|
131
|
+
{T`Cancel`}
|
|
132
132
|
</a>
|
|
133
133
|
</div>
|
|
134
134
|
)
|
|
@@ -150,7 +150,7 @@ function ColorPaletteCollectionComponent(props: ColorPaletteCollectionComponentP
|
|
|
150
150
|
|
|
151
151
|
return (
|
|
152
152
|
<div>
|
|
153
|
-
<p>Please select a color scheme</p>
|
|
153
|
+
<p>{T`Please select a color scheme`}</p>
|
|
154
154
|
{palettes.map((palette, index) => renderPalette(palette, index))}
|
|
155
155
|
{renderCancel()}
|
|
156
156
|
</div>
|