@mwater/visualization 5.1.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ColorComponent.d.ts +10 -11
- package/lib/ColorComponent.js +78 -29
- package/lib/ColorSchemeFactory.d.ts +13 -2
- package/lib/ColorSchemeFactory.js +7 -5
- package/lib/CustomColorsContext.d.ts +6 -0
- package/lib/CustomColorsContext.js +6 -0
- package/lib/FiltersDesignerComponent.d.ts +1 -4
- package/lib/FiltersDesignerComponent.js +2 -3
- package/lib/GlobalFilter.d.ts +13 -0
- package/lib/GlobalFilter.js +2 -0
- package/lib/LocaleContextInjector.d.ts +5 -11
- package/lib/LocaleContextInjector.js +4 -12
- package/lib/MWaterAddRelatedFormComponent.js +3 -3
- package/lib/MWaterAddRelatedIndicatorComponent.d.ts +1 -4
- package/lib/MWaterAddRelatedIndicatorComponent.js +6 -6
- package/lib/MWaterCompleteTableSelectComponent.d.ts +7 -25
- package/lib/MWaterCompleteTableSelectComponent.js +36 -36
- package/lib/MWaterContextComponent.d.ts +19 -9
- package/lib/MWaterContextComponent.js +38 -22
- package/lib/MWaterCustomTablesetListComponent.js +9 -3
- package/lib/MWaterGlobalFiltersComponent.d.ts +6 -5
- package/lib/MWaterGlobalFiltersComponent.js +4 -4
- package/lib/MWaterLoaderComponent.d.ts +15 -3
- package/lib/MWaterLoaderComponent.js +11 -2
- package/lib/MWaterTableSelectComponent.d.ts +1 -4
- package/lib/MWaterTableSelectComponent.js +10 -12
- package/lib/UIComponents.d.ts +2 -2
- package/lib/UIComponents.js +4 -12
- package/lib/axes/Axis.d.ts +20 -25
- package/lib/axes/AxisBuilder.d.ts +7 -4
- package/lib/axes/AxisBuilder.js +12 -8
- package/lib/axes/AxisComponent.d.ts +6 -9
- package/lib/axes/AxisComponent.js +1 -2
- package/lib/axes/ColorPaletteCollectionComponent.d.ts +5 -12
- package/lib/axes/ColorPaletteCollectionComponent.js +67 -36
- package/lib/dashboards/DashboardComponent.d.ts +4 -17
- package/lib/dashboards/DashboardComponent.js +20 -67
- package/lib/dashboards/DashboardDesign.d.ts +5 -20
- package/lib/dashboards/DashboardUpgrader.js +36 -1
- package/lib/dashboards/DashboardViewComponent.d.ts +5 -34
- package/lib/dashboards/DashboardViewComponent.js +112 -136
- package/lib/dashboards/FontStyleEditor.d.ts +8 -0
- package/lib/dashboards/FontStyleEditor.js +130 -0
- package/lib/dashboards/LayoutOptionsComponent.d.ts +0 -1
- package/lib/dashboards/LayoutOptionsComponent.js +209 -39
- package/lib/dashboards/ServerDashboardDataSource.d.ts +1 -2
- package/lib/dashboards/ServerDashboardDataSource.js +52 -33
- package/lib/dashboards/SettingsModalComponent.d.ts +4 -15
- package/lib/dashboards/SettingsModalComponent.js +24 -38
- package/lib/dashboards/WidgetComponent.d.ts +3 -3
- package/lib/dashboards/WidgetComponent.js +3 -6
- package/lib/dashboards/WidgetDataSourcePrioritizer.d.ts +20 -0
- package/lib/dashboards/WidgetDataSourcePrioritizer.js +72 -0
- package/lib/dashboards/layoutOptions.d.ts +83 -0
- package/lib/dashboards/layoutOptions.js +436 -10
- package/lib/datagrids/DatagridComponent.d.ts +2 -9
- package/lib/datagrids/DatagridDataSource.d.ts +3 -3
- package/lib/datagrids/DatagridDataSource.js +0 -14
- package/lib/datagrids/DatagridDesign.d.ts +7 -6
- package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -93
- package/lib/datagrids/DatagridDesignerComponent.js +8 -6
- package/lib/datagrids/DatagridViewComponent.js +1 -1
- package/lib/datagrids/FindReplaceModalComponent.d.ts +4 -20
- package/lib/datagrids/FindReplaceModalComponent.js +27 -13
- package/lib/datagrids/ServerDatagridDataSource.d.ts +8 -7
- package/lib/datagrids/ServerDatagridDataSource.js +88 -36
- package/lib/demo.js +4 -4
- package/lib/index.css +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +0 -1
- package/lib/layouts/LayoutManager.d.ts +33 -29
- package/lib/layouts/LayoutManager.js +2 -8
- package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +26 -56
- package/lib/layouts/blocks/BlocksDisplayComponent.js +122 -205
- package/lib/layouts/blocks/BlocksLayoutManager.d.ts +6 -22
- package/lib/layouts/blocks/BlocksLayoutManager.js +5 -14
- package/lib/layouts/blocks/HorizontalBlockComponent.d.ts +5 -4
- package/lib/layouts/blocks/HorizontalBlockComponent.js +5 -5
- package/lib/layouts/grid/GridLayoutManager.d.ts +2 -1
- package/lib/mWaterLoader.d.ts +2 -0
- package/lib/mWaterLoader.js +2 -1
- package/lib/maps/AddLayerComponent.d.ts +6 -8
- package/lib/maps/AddLayerComponent.js +6 -6
- package/lib/maps/BingLayer.js +10 -20
- package/lib/maps/BufferLayer.js +5 -2
- package/lib/maps/ChoroplethLayer.js +2 -1
- package/lib/maps/ClusterLayer.js +3 -1
- package/lib/maps/DirectMapDataSource.d.ts +5 -2
- package/lib/maps/DirectMapDataSource.js +2 -1
- package/lib/maps/EditPopupComponent.js +2 -1
- package/lib/maps/GridLayer.js +5 -3
- package/lib/maps/GridLayerDesigner.js +0 -1
- package/lib/maps/LayerSwitcherComponent.js +1 -1
- package/lib/maps/MapComponent.d.ts +3 -11
- package/lib/maps/MapComponent.js +3 -3
- package/lib/maps/MapDesign.d.ts +2 -13
- package/lib/maps/MapFiltersDesignerComponent.d.ts +0 -4
- package/lib/maps/MapFiltersDesignerComponent.js +4 -5
- package/lib/maps/MarkersLayer.js +30 -25
- package/lib/maps/RasterMapViewComponent.d.ts +3 -13
- package/lib/maps/RasterMapViewComponent.js +3 -3
- package/lib/maps/RegionSelectComponent.d.ts +2 -1
- package/lib/maps/ServerMapDataSource.d.ts +3 -4
- package/lib/maps/ServerMapDataSource.js +5 -5
- package/lib/maps/VectorMapViewComponent.js +2 -1
- package/lib/maps/mapSymbols.js +2 -0
- package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/lib/maps/vectorMaps.d.ts +1 -0
- package/lib/maps/vectorMaps.js +70 -56
- package/lib/quickfilter/QuickfilterCompiler.d.ts +1 -1
- package/lib/quickfilter/QuickfiltersComponent.d.ts +1 -4
- package/lib/quickfilter/QuickfiltersComponent.js +3 -3
- package/lib/richtext/DropdownPaletteItem.d.ts +32 -0
- package/lib/richtext/DropdownPaletteItem.js +82 -0
- package/lib/richtext/FontColorPaletteItem.d.ts +1 -5
- package/lib/richtext/FontColorPaletteItem.js +32 -27
- package/lib/richtext/ItemsHtmlConverter.js +12 -3
- package/lib/richtext/RichTextComponent.d.ts +26 -52
- package/lib/richtext/RichTextComponent.js +166 -128
- package/lib/valueFormatter.js +6 -1
- package/lib/wellknown.d.ts +5 -0
- package/lib/wellknown.js +288 -0
- package/lib/widgets/DropdownWidgetComponent.d.ts +8 -25
- package/lib/widgets/DropdownWidgetComponent.js +48 -25
- package/lib/widgets/IFrameWidgetComponent.d.ts +3 -11
- package/lib/widgets/ImageWidgetComponent.d.ts +8 -27
- package/lib/widgets/MapWidget.d.ts +4 -7
- package/lib/widgets/MapWidget.js +2 -1
- package/lib/widgets/MarkdownWidget.d.ts +2 -7
- package/lib/widgets/TOCWidget.d.ts +2 -9
- package/lib/widgets/TOCWidget.js +2 -1
- package/lib/widgets/Widget.d.ts +2 -0
- package/lib/widgets/WidgetDataSource.d.ts +3 -1
- package/lib/widgets/charts/Chart.d.ts +0 -1
- package/lib/widgets/charts/ChartViewComponent.d.ts +4 -0
- package/lib/widgets/charts/ChartViewComponent.js +11 -3
- package/lib/widgets/charts/ChartWidget.d.ts +1 -74
- package/lib/widgets/charts/ChartWidget.js +4 -183
- package/lib/widgets/charts/ChartWidgetComponent.d.ts +51 -0
- package/lib/widgets/charts/ChartWidgetComponent.js +167 -0
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/calendar/CalendarChartViewComponent.js +4 -4
- package/lib/widgets/charts/imagemosaic/ImagePopupComponent.d.ts +2 -7
- package/lib/widgets/charts/layered/LayeredChart.d.ts +5 -10
- package/lib/widgets/charts/layered/LayeredChart.js +6 -7
- package/lib/widgets/charts/layered/LayeredChartCompiler.d.ts +4 -2
- package/lib/widgets/charts/layered/LayeredChartCompiler.js +46 -32
- package/lib/widgets/charts/layered/LayeredChartDesign.d.ts +4 -0
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.d.ts +5 -31
- package/lib/widgets/charts/layered/LayeredChartDesignerComponent.js +21 -3
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.d.ts +1 -7
- package/lib/widgets/charts/layered/LayeredChartLayerDesignerComponent.js +2 -1
- package/lib/widgets/charts/layered/LayeredChartViewComponent.d.ts +1 -4
- package/lib/widgets/charts/layered/LayeredChartViewComponent.js +89 -38
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.d.ts +5 -105
- package/lib/widgets/charts/pivot/IntersectionDesignerComponent.js +122 -166
- package/lib/widgets/charts/pivot/PivotChart.d.ts +6 -0
- package/lib/widgets/charts/pivot/PivotChart.js +47 -17
- package/lib/widgets/charts/pivot/PivotChartDesign.d.ts +11 -0
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.d.ts +11 -7
- package/lib/widgets/charts/pivot/PivotChartDesignerComponent.js +1 -1
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartLayoutBuilder.js +20 -36
- package/lib/widgets/charts/pivot/PivotChartLayoutComponent.js +0 -1
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.d.ts +23 -2
- package/lib/widgets/charts/pivot/PivotChartQueryBuilder.js +215 -181
- package/lib/widgets/charts/pivot/PivotChartUtils.d.ts +2 -2
- package/lib/widgets/charts/pivot/PivotChartViewComponent.d.ts +9 -47
- package/lib/widgets/charts/pivot/PivotChartViewComponent.js +20 -60
- package/lib/widgets/charts/pivot/SegmentDesignerComponent.d.ts +55 -58
- package/lib/widgets/charts/table/TableChart.js +8 -4
- package/lib/widgets/charts/table/TableChartDesignerComponent.js +3 -3
- package/lib/widgets/charts/table/TableChartViewComponent.js +30 -16
- package/lib/widgets/text/ExprInsertModalComponent.d.ts +2 -13
- package/lib/widgets/text/ExprUpdateModalComponent.d.ts +2 -13
- package/lib/widgets/text/TextComponent.d.ts +5 -12
- package/lib/widgets/text/TextComponent.js +19 -39
- package/lib/widgets/text/TextWidget.d.ts +2 -1
- package/lib/widgets/text/TextWidget.js +5 -1
- package/lib/widgets/text/TextWidgetComponent.d.ts +15 -3
- package/lib/widgets/text/TextWidgetComponent.js +76 -19
- package/lib/widgets/text/TextWidgetDesign.d.ts +16 -2
- package/lib/widgets/text/TextWidgetDesign.js +6 -0
- package/package.json +4 -4
- package/src/ColorComponent.tsx +177 -0
- package/src/ColorSchemeFactory.ts +12 -6
- package/src/CustomColorsContext.tsx +8 -0
- package/src/FiltersDesignerComponent.ts +3 -4
- package/src/GlobalFilter.ts +17 -0
- package/src/LocaleContextInjector.tsx +14 -13
- package/src/MWaterAddRelatedFormComponent.ts +3 -3
- package/src/MWaterAddRelatedIndicatorComponent.ts +6 -6
- package/src/MWaterCompleteTableSelectComponent.tsx +36 -36
- package/src/MWaterContextComponent.tsx +42 -33
- package/src/MWaterCustomTablesetListComponent.tsx +21 -3
- package/src/MWaterGlobalFiltersComponent.ts +8 -8
- package/src/MWaterLoaderComponent.ts +14 -4
- package/src/MWaterTableSelectComponent.tsx +11 -12
- package/src/{UIComponents.ts → UIComponents.tsx} +7 -15
- package/src/axes/Axis.ts +24 -25
- package/src/axes/AxisBuilder.ts +16 -13
- package/src/axes/AxisComponent.ts +3 -4
- package/src/axes/{ColorPaletteCollectionComponent.ts → ColorPaletteCollectionComponent.tsx} +87 -61
- package/src/dashboards/DashboardComponent.tsx +73 -147
- package/src/dashboards/DashboardDesign.ts +5 -25
- package/src/dashboards/DashboardUpgrader.ts +41 -1
- package/src/dashboards/DashboardViewComponent.tsx +313 -0
- package/src/dashboards/FontStyleEditor.tsx +166 -0
- package/src/dashboards/LayoutOptionsComponent.tsx +377 -71
- package/src/dashboards/ServerDashboardDataSource.ts +52 -33
- package/src/dashboards/SettingsModalComponent.tsx +170 -0
- package/src/dashboards/WidgetComponent.tsx +6 -12
- package/src/dashboards/WidgetDataSourcePrioritizer.ts +82 -0
- package/src/dashboards/layoutOptions.tsx +581 -0
- package/src/datagrids/DatagridDataSource.ts +6 -12
- package/src/datagrids/DatagridDesign.ts +8 -3
- package/src/datagrids/DatagridDesignerComponent.tsx +22 -18
- package/src/datagrids/DatagridViewComponent.ts +3 -3
- package/src/datagrids/ExprCellComponent.ts +0 -1
- package/src/datagrids/FindReplaceModalComponent.ts +39 -22
- package/src/datagrids/ServerDatagridDataSource.ts +107 -45
- package/src/demo.ts +4 -4
- package/src/index.css +5 -0
- package/src/index.ts +2 -1
- package/src/layouts/LayoutManager.ts +44 -42
- package/src/layouts/blocks/BlocksDisplayComponent.tsx +498 -0
- package/src/layouts/blocks/BlocksLayoutManager.ts +6 -15
- package/src/layouts/blocks/HorizontalBlockComponent.ts +9 -8
- package/src/mWaterLoader.ts +4 -1
- package/src/maps/AddLayerComponent.ts +9 -9
- package/src/maps/BingLayer.ts +16 -26
- package/src/maps/BufferLayer.ts +5 -2
- package/src/maps/ChoroplethLayer.ts +2 -1
- package/src/maps/ClusterLayer.ts +3 -1
- package/src/maps/DirectMapDataSource.ts +12 -3
- package/src/maps/EditPopupComponent.ts +2 -1
- package/src/maps/GridLayer.ts +5 -3
- package/src/maps/GridLayerDesigner.tsx +0 -1
- package/src/maps/LayerSwitcherComponent.tsx +1 -1
- package/src/maps/MapComponent.ts +3 -3
- package/src/maps/MapDesign.ts +2 -17
- package/src/maps/{MapFiltersDesignerComponent.ts → MapFiltersDesignerComponent.tsx} +25 -25
- package/src/maps/MarkersLayer.ts +38 -41
- package/src/maps/RasterMapViewComponent.ts +3 -3
- package/src/maps/ServerMapDataSource.ts +8 -8
- package/src/maps/VectorMapViewComponent.tsx +2 -2
- package/src/maps/mapSymbols.ts +2 -0
- package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
- package/src/maps/vectorMaps.tsx +88 -74
- package/src/quickfilter/QuickfilterCompiler.ts +1 -1
- package/src/quickfilter/QuickfiltersComponent.ts +3 -3
- package/src/richtext/DropdownPaletteItem.tsx +144 -0
- package/src/richtext/FontColorPaletteItem.tsx +160 -0
- package/src/richtext/ItemsHtmlConverter.ts +15 -5
- package/src/richtext/RichTextComponent.tsx +274 -232
- package/src/valueFormatter.ts +5 -1
- package/src/wellknown.ts +286 -0
- package/src/widgets/DropdownWidgetComponent.tsx +75 -0
- package/src/widgets/MapWidget.ts +5 -2
- package/src/widgets/TOCWidget.ts +2 -1
- package/src/widgets/Widget.ts +3 -0
- package/src/widgets/WidgetDataSource.ts +3 -1
- package/src/widgets/charts/Chart.ts +1 -1
- package/src/widgets/charts/ChartViewComponent.ts +16 -3
- package/src/widgets/charts/ChartWidget.ts +3 -275
- package/src/widgets/charts/ChartWidgetComponent.tsx +281 -0
- package/src/widgets/charts/calendar/CalendarChartViewComponent.tsx +4 -4
- package/src/widgets/charts/layered/LayeredChart.ts +4 -6
- package/src/widgets/charts/layered/LayeredChartCompiler.ts +80 -63
- package/src/widgets/charts/layered/LayeredChartDesign.ts +7 -1
- package/src/widgets/charts/layered/LayeredChartDesignerComponent.tsx +43 -10
- package/src/widgets/charts/layered/LayeredChartLayerDesignerComponent.tsx +6 -6
- package/src/widgets/charts/layered/LayeredChartViewComponent.ts +140 -88
- package/src/widgets/charts/pivot/IntersectionDesignerComponent.tsx +305 -221
- package/src/widgets/charts/pivot/PivotChart.ts +56 -18
- package/src/widgets/charts/pivot/PivotChartDesign.ts +12 -0
- package/src/widgets/charts/pivot/PivotChartDesignerComponent.tsx +4 -3
- package/src/widgets/charts/pivot/PivotChartLayoutBuilder.ts +39 -76
- package/src/widgets/charts/pivot/PivotChartLayoutComponent.tsx +0 -1
- package/src/widgets/charts/pivot/PivotChartQueryBuilder.ts +230 -189
- package/src/widgets/charts/pivot/PivotChartUtils.ts +4 -4
- package/src/widgets/charts/pivot/{PivotChartViewComponent.ts → PivotChartViewComponent.tsx} +86 -89
- package/src/widgets/charts/table/TableChart.ts +8 -4
- package/src/widgets/charts/table/TableChartDesignerComponent.ts +4 -4
- package/src/widgets/charts/table/TableChartViewComponent.ts +32 -19
- package/src/widgets/text/TextComponent.tsx +47 -49
- package/src/widgets/text/TextWidget.ts +8 -3
- package/src/widgets/text/TextWidgetComponent.tsx +249 -0
- package/src/widgets/text/TextWidgetDesign.ts +26 -2
- package/src/ColorComponent.ts +0 -117
- package/src/dashboards/DashboardViewComponent.ts +0 -304
- package/src/dashboards/SettingsModalComponent.ts +0 -169
- package/src/dashboards/layoutOptions.ts +0 -40
- package/src/layout-styles.css +0 -263
- package/src/layouts/blocks/BlocksDisplayComponent.ts +0 -461
- package/src/layouts/grid/GridLayoutComponent.ts +0 -67
- package/src/layouts/grid/GridLayoutManager.ts +0 -185
- package/src/layouts/grid/LegoLayoutEngine.ts +0 -142
- package/src/layouts/grid/PaletteItemComponent.ts +0 -28
- package/src/layouts/grid/README.md +0 -14
- package/src/layouts/grid/WidgetContainerComponent.ts +0 -420
- package/src/richtext/FontColorPaletteItem.ts +0 -172
- package/src/richtext/FontSizePaletteItem.ts +0 -110
- package/src/widgets/DropdownWidgetComponent.ts +0 -78
- package/src/widgets/text/TextWidgetComponent.ts +0 -120
package/src/axes/Axis.ts
CHANGED
|
@@ -5,37 +5,19 @@ import { Expr } from "@mwater/expressions"
|
|
|
5
5
|
An axis is an expression with optional aggregation, transform and color mapping
|
|
6
6
|
In ggplot2 parlance, an "aesthetic"
|
|
7
7
|
|
|
8
|
-
It contains:
|
|
9
|
-
expr: expression
|
|
10
|
-
aggr: DEPRECATED: optional aggregation (e.g. sum)
|
|
11
|
-
xform: optional transformation to be applied. object with `type` field. See below
|
|
12
|
-
colorMap: optional array of color mappings. See below
|
|
13
|
-
excludedValues: Array of post-xform values to exclude when displaying.
|
|
14
|
-
format: optional d3-format format for numeric values. Default if null is ","
|
|
15
|
-
|
|
16
|
-
## Xforms
|
|
17
|
-
|
|
18
|
-
types:
|
|
19
|
-
|
|
20
|
-
|
|
21
8
|
*/
|
|
22
9
|
export interface Axis {
|
|
10
|
+
/** Expression to be displayed on axis */
|
|
23
11
|
expr: Expr
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
* `year`: year only e.g. `2015-01-01`. type date
|
|
28
|
-
* `yearmonth`: year and month only e.g. `2015-02-01`. type date
|
|
29
|
-
* `yearquarter`: year and quarter only e.g. `2015-01`. type enum
|
|
30
|
-
* `yearweek`: year and week (ISO) only e.g. `2015-31`. type enum
|
|
31
|
-
* `month`: month only e.g. `02`. type enum
|
|
32
|
-
* `week`: ISO week of year e.g. `01` for the first week that contains January 4th
|
|
33
|
-
* `ranges`: convert to ranges. type enum. `ranges` is array of { id (unique id), label (optional label), minValue (null for none), maxValue (null for none), minOpen (true for >, false for >=), maxOpen (true for <, false for <=) }
|
|
34
|
-
* `floor`: convert to floor. type enum
|
|
12
|
+
|
|
13
|
+
/** Optional transformation to be applied. If a date is used, for example, it's generally
|
|
14
|
+
* better to use a transform to convert to a year or month rather than creating an expression.
|
|
35
15
|
*/
|
|
36
16
|
xform?: AxisXform
|
|
37
17
|
|
|
18
|
+
/** optional array of color mappings */
|
|
38
19
|
colorMap?: ColorMap
|
|
20
|
+
|
|
39
21
|
/** optional array of category values which define the order in which categories should be rendered */
|
|
40
22
|
drawOrder?: any[]
|
|
41
23
|
|
|
@@ -45,12 +27,16 @@ export interface Axis {
|
|
|
45
27
|
/** optional string for null category */
|
|
46
28
|
nullLabel?: string
|
|
47
29
|
|
|
30
|
+
/** Array of post-xform values to exclude when displaying. */
|
|
48
31
|
excludedValues?: any[]
|
|
32
|
+
|
|
33
|
+
/** optional d3-format format for numeric values. Default if null is "," */
|
|
49
34
|
format?: string
|
|
50
35
|
|
|
51
|
-
/** @deprecated */
|
|
36
|
+
/** @deprecated optional aggregation (e.g. sum) */
|
|
52
37
|
aggr?: string
|
|
53
38
|
}
|
|
39
|
+
|
|
54
40
|
/**
|
|
55
41
|
* Color map
|
|
56
42
|
* Array of { value: post-transform value of expression, color: html color }
|
|
@@ -70,6 +56,19 @@ export interface AxisCategory {
|
|
|
70
56
|
}
|
|
71
57
|
|
|
72
58
|
export interface AxisXform {
|
|
59
|
+
/**
|
|
60
|
+
* Type of transformation
|
|
61
|
+
* `bin`: convert into bins. always has `numBins` integer and `min` and `max`. Can have `excludeUpper` and/or `excludeLower` to remove open bin on top or bottem. type enum
|
|
62
|
+
* `date`: convert to complete date e.g. `2015-02-08`. type date
|
|
63
|
+
* `year`: year only e.g. `2015-01-01`. type date
|
|
64
|
+
* `yearmonth`: year and month only e.g. `2015-02-01`. type date
|
|
65
|
+
* `yearquarter`: year and quarter only e.g. `2015-01`. type enum
|
|
66
|
+
* `yearweek`: year and week (ISO) only e.g. `2015-31`. type enum
|
|
67
|
+
* `month`: month only e.g. `02`. type enum
|
|
68
|
+
* `week`: ISO week of year e.g. `01` for the first week that contains January 4th
|
|
69
|
+
* `ranges`: convert to ranges. type enum. `ranges` is array of { id (unique id), label (optional label), minValue (null for none), maxValue (null for none), minOpen (true for >, false for >=), maxOpen (true for <, false for <=) }
|
|
70
|
+
* `floor`: convert to floor. type enum
|
|
71
|
+
*/
|
|
73
72
|
type: "bin" | "date" | "year" | "yearmonth" | "month" | "week" | "ranges" | "yearweek" | "yearquarter" | "floor"
|
|
74
73
|
numBins?: number
|
|
75
74
|
min?: number
|
package/src/axes/AxisBuilder.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { default as produce } from "immer"
|
|
|
12
12
|
import { formatValue } from "../valueFormatter"
|
|
13
13
|
import { Axis, AxisCategory } from "./Axis"
|
|
14
14
|
import { JsonQLExpr, JsonQLSelectQuery } from "@mwater/jsonql"
|
|
15
|
+
import dayjs from '../dayjs'
|
|
15
16
|
|
|
16
17
|
const xforms: { type: string; input: LiteralType; output: LiteralType }[] = [
|
|
17
18
|
{ type: "bin", input: "number", output: "enum" },
|
|
@@ -913,10 +914,9 @@ export default class AxisBuilder {
|
|
|
913
914
|
if (values.length === 0) {
|
|
914
915
|
return [noneCategory]
|
|
915
916
|
}
|
|
916
|
-
|
|
917
917
|
if (options.onlyValuesPresent) {
|
|
918
918
|
// Sort and take only present
|
|
919
|
-
categories = _.sortBy(_.uniq(values), item => item).map(value => ({ value, label:
|
|
919
|
+
categories = _.sortBy(_.uniq(values), item => item).map(value => ({ value, label: formatValue("date", value, axis.format)}))
|
|
920
920
|
|
|
921
921
|
if (hasNone) {
|
|
922
922
|
categories.push(noneCategory)
|
|
@@ -930,12 +930,12 @@ export default class AxisBuilder {
|
|
|
930
930
|
max = values.sort().slice(-1)[0]
|
|
931
931
|
|
|
932
932
|
// Use moment to get range
|
|
933
|
-
current =
|
|
934
|
-
end =
|
|
933
|
+
current = dayjs(min)
|
|
934
|
+
end = dayjs(max)
|
|
935
935
|
categories = []
|
|
936
936
|
while (!current.isAfter(end)) {
|
|
937
|
-
categories.push({ value: current.format("YYYY-MM-DD"), label: current.format("ll") })
|
|
938
|
-
current.add(1, "days")
|
|
937
|
+
categories.push({ value: current.format("YYYY-MM-DD"), label: current.format(axis.format ?? "ll") })
|
|
938
|
+
current = current.add(1, "days")
|
|
939
939
|
if (categories.length >= 1000) {
|
|
940
940
|
break
|
|
941
941
|
}
|
|
@@ -949,8 +949,10 @@ export default class AxisBuilder {
|
|
|
949
949
|
return []
|
|
950
950
|
}
|
|
951
951
|
|
|
952
|
-
|
|
953
|
-
|
|
952
|
+
/**
|
|
953
|
+
* Get type of axis output
|
|
954
|
+
*/
|
|
955
|
+
getAxisType(axis: Axis | null | undefined): LiteralType | null {
|
|
954
956
|
if (!axis) {
|
|
955
957
|
return null
|
|
956
958
|
}
|
|
@@ -971,19 +973,19 @@ export default class AxisBuilder {
|
|
|
971
973
|
}
|
|
972
974
|
|
|
973
975
|
// Determines if axis is aggregate
|
|
974
|
-
isAxisAggr(axis:
|
|
976
|
+
isAxisAggr(axis: Axis | null | undefined) {
|
|
975
977
|
// Legacy support of axis.aggr
|
|
976
978
|
return axis != null && (axis.aggr || this.exprUtils.getExprAggrStatus(axis.expr) === "aggregate")
|
|
977
979
|
}
|
|
978
980
|
|
|
979
981
|
// Determines if axis supports cumulative values (number, date or year-quarter)
|
|
980
|
-
doesAxisSupportCumulative(axis:
|
|
982
|
+
doesAxisSupportCumulative(axis: Axis) {
|
|
981
983
|
const axisType = this.getAxisType(axis)
|
|
982
984
|
return axisType == "date" || axisType == "number" || axis.xform?.type === "yearquarter"
|
|
983
985
|
}
|
|
984
986
|
|
|
985
987
|
// Converts a category to a string (uses label or override)
|
|
986
|
-
formatCategory(axis:
|
|
988
|
+
formatCategory(axis: Axis, category: any) {
|
|
987
989
|
const categoryLabel = axis.categoryLabels ? axis.categoryLabels[JSON.stringify(category.value)] : undefined
|
|
988
990
|
if (categoryLabel) {
|
|
989
991
|
return categoryLabel
|
|
@@ -1055,9 +1057,10 @@ export default class AxisBuilder {
|
|
|
1055
1057
|
_.map(value as string[], (v, i) => R("div", { key: i }, v))
|
|
1056
1058
|
)
|
|
1057
1059
|
case "date":
|
|
1058
|
-
|
|
1060
|
+
console.log(axis)
|
|
1061
|
+
return formatValue(type, value, axis.format)
|
|
1059
1062
|
case "datetime":
|
|
1060
|
-
return
|
|
1063
|
+
return formatValue(type, value, axis.format)
|
|
1061
1064
|
}
|
|
1062
1065
|
|
|
1063
1066
|
return "" + value
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
|
-
import PropTypes from "prop-types"
|
|
3
2
|
import React from "react"
|
|
4
3
|
const R = React.createElement
|
|
5
4
|
import uuid from "uuid"
|
|
6
5
|
import AsyncLoadComponent from "@mwater/react-library/lib/AsyncLoadComponent"
|
|
7
|
-
import { ExprComponent } from "@mwater/expressions-ui"
|
|
6
|
+
import { ExprComponent, LocaleContext } from "@mwater/expressions-ui"
|
|
8
7
|
import { AggrStatus, DataSource, ExprUtils, LiteralType, OpExpr, Schema } from "@mwater/expressions"
|
|
9
8
|
import AxisBuilder from "./AxisBuilder"
|
|
10
9
|
import update from "update-object"
|
|
@@ -29,7 +28,7 @@ export interface AxisComponentProps {
|
|
|
29
28
|
/** Optional types to limit to */
|
|
30
29
|
types?: LiteralType[]
|
|
31
30
|
aggrNeed: "none" | "optional" | "required"
|
|
32
|
-
value?: Axis
|
|
31
|
+
value?: Axis | null
|
|
33
32
|
onChange: (axis: Axis | null) => void
|
|
34
33
|
/** Makes this a required value */
|
|
35
34
|
required?: boolean
|
|
@@ -63,7 +62,7 @@ export default class AxisComponent extends AsyncLoadComponent<
|
|
|
63
62
|
autosetColors: true
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
static
|
|
65
|
+
static contextType = LocaleContext
|
|
67
66
|
|
|
68
67
|
constructor(props: any) {
|
|
69
68
|
super(props)
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import _ from "lodash"
|
|
2
|
-
import
|
|
3
|
-
import React from "react"
|
|
4
|
-
const R = React.createElement
|
|
2
|
+
import React, { useContext } from "react"
|
|
5
3
|
|
|
6
4
|
import ColorSchemeFactory from "../ColorSchemeFactory"
|
|
7
|
-
import { Axis, AxisCategory } from "./Axis"
|
|
5
|
+
import { Axis, AxisCategory, ColorMap } from "./Axis"
|
|
6
|
+
import { CustomColorsContext } from "../CustomColorsContext"
|
|
8
7
|
|
|
9
8
|
export interface ColorPaletteCollectionComponentProps {
|
|
10
|
-
onPaletteSelected: any
|
|
11
9
|
axis: Axis
|
|
12
10
|
categories: AxisCategory[]
|
|
13
|
-
|
|
11
|
+
onPaletteSelected: (colorMap: ColorMap) => void
|
|
12
|
+
onCancel: () => void
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
interface Palette {
|
|
16
|
+
type: string
|
|
17
|
+
reversed: boolean
|
|
18
|
+
/** Override colors if type is "custom" */
|
|
19
|
+
colors?: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function ColorPaletteCollectionComponent(props: ColorPaletteCollectionComponentProps) {
|
|
23
|
+
const palettes: Palette[] = [
|
|
18
24
|
{ type: "schemeSet1", reversed: false },
|
|
19
25
|
{ type: "schemeSet2", reversed: false },
|
|
20
26
|
{ type: "schemeSet3", reversed: false },
|
|
@@ -79,85 +85,105 @@ export default class ColorPaletteCollectionComponent extends React.Component<Col
|
|
|
79
85
|
{ type: "interpolateRdYlGn", reversed: true }
|
|
80
86
|
]
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
// Get custom colors
|
|
89
|
+
const customColorsContext = useContext(CustomColorsContext)
|
|
90
|
+
|
|
91
|
+
// Number of colors needed. Null doesn't count to length
|
|
92
|
+
const numColors = props.categories.filter((c) => c.value != null).length
|
|
93
|
+
|
|
94
|
+
if (customColorsContext && customColorsContext.customColors.filter((c) => c != null).length > 0) {
|
|
95
|
+
const filteredCustomColors = customColorsContext.customColors.filter((c) => c != null)
|
|
96
|
+
const customPalettes: Palette[] = []
|
|
97
|
+
for (let i = 0; i < filteredCustomColors.length; i += 6) {
|
|
98
|
+
const customPalette = filteredCustomColors.slice(i, i + 6)
|
|
99
|
+
customPalettes.push({ type: "custom", reversed: false, colors: customPalette })
|
|
100
|
+
}
|
|
101
|
+
palettes.unshift(...customPalettes)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function generatePaletteColors(palette: Palette, numColors: number) {
|
|
105
|
+
if (palette.type === "custom") {
|
|
106
|
+
return palette.colors!
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return ColorSchemeFactory.createColorScheme({
|
|
110
|
+
type: palette.type,
|
|
111
|
+
number: numColors,
|
|
112
|
+
reversed: palette.reversed
|
|
91
113
|
})
|
|
114
|
+
}
|
|
92
115
|
|
|
93
|
-
|
|
116
|
+
const onPaletteSelected = (index: number) => {
|
|
117
|
+
// Generate color map
|
|
118
|
+
const scheme = generatePaletteColors(palettes[index], Math.min(numColors, 6))
|
|
119
|
+
|
|
120
|
+
const colorMap = _.map(props.categories, (category, i) => ({
|
|
94
121
|
value: category.value,
|
|
95
122
|
color: category.value === null ? "#aaaaaa" : scheme[i % scheme.length]
|
|
96
123
|
}))
|
|
97
|
-
return
|
|
124
|
+
return props.onPaletteSelected(colorMap)
|
|
98
125
|
}
|
|
99
126
|
|
|
100
|
-
renderCancel = () => {
|
|
101
|
-
if (
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
127
|
+
const renderCancel = () => {
|
|
128
|
+
if (props.axis.colorMap) {
|
|
129
|
+
return (
|
|
130
|
+
<div>
|
|
131
|
+
<a className="link-plain" onClick={props.onCancel} key="cancel-customize">
|
|
132
|
+
Cancel
|
|
133
|
+
</a>
|
|
134
|
+
</div>
|
|
106
135
|
)
|
|
107
136
|
}
|
|
108
137
|
return null
|
|
109
138
|
}
|
|
110
139
|
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
index,
|
|
120
|
-
colorSet: ColorSchemeFactory.createColorScheme({
|
|
121
|
-
type: config.type,
|
|
122
|
-
number: Math.min(this.props.categories.length - 1, 6),
|
|
123
|
-
reversed: config.reversed
|
|
124
|
-
}),
|
|
125
|
-
onPaletteSelected: this.onPaletteSelected,
|
|
126
|
-
number: this.props.categories.length
|
|
127
|
-
})
|
|
128
|
-
}),
|
|
129
|
-
this.renderCancel()
|
|
140
|
+
function renderPalette(palette: Palette, index: number) {
|
|
141
|
+
return (
|
|
142
|
+
<ColorPaletteComponent
|
|
143
|
+
key={index}
|
|
144
|
+
index={index}
|
|
145
|
+
colorSet={generatePaletteColors(palette, 6)}
|
|
146
|
+
onPaletteSelected={onPaletteSelected}
|
|
147
|
+
/>
|
|
130
148
|
)
|
|
131
149
|
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div>
|
|
154
|
+
<p>Please select a color scheme</p>
|
|
155
|
+
{palettes.map((palette, index) => renderPalette(palette, index))}
|
|
156
|
+
{renderCancel()}
|
|
157
|
+
</div>
|
|
158
|
+
)
|
|
132
159
|
}
|
|
133
160
|
|
|
161
|
+
export default ColorPaletteCollectionComponent
|
|
162
|
+
|
|
134
163
|
interface ColorPaletteComponentProps {
|
|
135
164
|
index: number
|
|
136
|
-
colorSet:
|
|
137
|
-
onPaletteSelected:
|
|
138
|
-
number?: number
|
|
165
|
+
colorSet: string[]
|
|
166
|
+
onPaletteSelected: (index: number) => void
|
|
139
167
|
}
|
|
140
168
|
|
|
141
169
|
class ColorPaletteComponent extends React.Component<ColorPaletteComponentProps> {
|
|
142
|
-
static defaultProps = { number: 6 }
|
|
143
|
-
|
|
144
170
|
handleSelect = () => {
|
|
145
171
|
return this.props.onPaletteSelected(this.props.index)
|
|
146
172
|
}
|
|
147
173
|
|
|
148
174
|
render() {
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
return (
|
|
176
|
+
<div onClick={this.handleSelect} className="axis-palette">
|
|
177
|
+
{_.map(this.props.colorSet, (color, i) => {
|
|
178
|
+
const cellStyle: React.CSSProperties = {
|
|
179
|
+
display: "inline-block",
|
|
180
|
+
height: 20,
|
|
181
|
+
width: 20,
|
|
182
|
+
backgroundColor: color
|
|
183
|
+
}
|
|
184
|
+
return <div style={cellStyle} key={i}> </div>
|
|
185
|
+
})}
|
|
186
|
+
</div>
|
|
161
187
|
)
|
|
162
188
|
}
|
|
163
189
|
}
|