macrigiuseppe closed pull request #6555: Forecasting URL: https://github.com/apache/incubator-superset/pull/6555
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/.gitignore b/.gitignore index 2ace393240..128ded479c 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,10 @@ celerybeat.pid geckodriver.log ghostdriver.log testCSV.csv + +# docker +Dockerfile +docker-compose.yml +docker-entrypoint.sh +docker-init.sh +data diff --git a/README.md b/README.md index b0f3ca5007..ceb6312b19 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,19 @@ power analytic dashboards and applications.* Installation & Configuration ---------------------------- -[See in the documentation](https://superset.incubator.apache.org/installation.html) - +For __Docker installation__ use the following steps + +``` +$ git clone https://github.com/apache/incubator-superset/ +$ cd incubator-superset +$ cp contrib/docker/* . +$ cp contrib/docker/superset_config.py superset/ +$ docker-compose up -d +$ docker-compose exec superset bash +$ bash docker-init.sh +``` + +For the rest of the documentation please follow the official link here: [See in the documentation](https://superset.incubator.apache.org/installation.html) Resources ------------- diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile index a59a3edd43..b63fd1b9f9 100644 --- a/contrib/docker/Dockerfile +++ b/contrib/docker/Dockerfile @@ -54,6 +54,8 @@ RUN cd superset/assets \ && rm -rf node_modules \ && yarn cache clean +# Copy flask env +COPY .flaskenv ./.flaskenv COPY contrib/docker/docker-init.sh . COPY contrib/docker/docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/contrib/docker/docker-compose.yml b/contrib/docker/docker-compose.yml index 49119055fb..bcf979e10a 100644 --- a/contrib/docker/docker-compose.yml +++ b/contrib/docker/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - 6379:6379 volumes: - - redis:/data + - ./data/redis:/data postgres: image: postgres:10 restart: unless-stopped @@ -17,11 +17,11 @@ services: ports: - 5432:5432 volumes: - - postgres:/var/lib/postgresql/data + - ./data/postgres:/var/lib/postgresql/data superset: build: - context: ../../ - dockerfile: contrib/docker/Dockerfile + context: ./ + dockerfile: Dockerfile restart: unless-stopped environment: POSTGRES_DB: superset @@ -34,6 +34,8 @@ services: # If using production, comment development volume below #SUPERSET_ENV: production SUPERSET_ENV: development + FLASK_APP: "superset:app" + SUPERSET_LOAD_EXAMPLES: "yes" ports: - 8088:8088 depends_on: @@ -43,9 +45,4 @@ services: # this is needed to communicate with the postgres and redis services - ./superset_config.py:/home/superset/superset/superset_config.py # this is needed for development, remove with SUPERSET_ENV=production - - ../../superset:/home/superset/superset -volumes: - postgres: - external: false - redis: - external: false + - ./superset:/home/superset/superset diff --git a/requirements.txt b/requirements.txt index fedd2b177e..373fa37180 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,7 @@ click==6.7 colorama==0.3.9 contextlib2==0.5.5 croniter==0.3.26 -cryptography==1.9 +cryptography==2.4.2 defusedxml==0.5.0 # via python3-openid docutils==0.14 # via botocore et-xmlfile==1.0.1 # via openpyxl diff --git a/superset/assets/backendSync.json b/superset/assets/backendSync.json index 711496dcd3..3f69e3167f 100644 --- a/superset/assets/backendSync.json +++ b/superset/assets/backendSync.json @@ -1,5 +1,23 @@ { "controls": { + "metrics": { + "type": "MetricsControl", + "multi": true, + "label": "Metrics", + "validators": [ + null + ], + "description": "One or many metrics to display" + }, + "metric": { + "type": "MetricsControl", + "multi": false, + "label": "Metric", + "validators": [ + null + ], + "description": "One or many metrics to display" + }, "datasource": { "type": "DatasourceControl", "label": "Datasource", @@ -12,21 +30,12 @@ "default": "table", "description": "The type of visualization to display" }, - "metrics": { - "type": "SelectControl", - "multi": true, - "label": "Metrics", - "validators": [ - null - ], - "valueKey": "metric_name", - "description": "One or many metrics to display" - }, "percent_metrics": { - "type": "SelectControl", + "type": "MetricsControl", "multi": true, "label": "Percentage Metrics", - "valueKey": "metric_name", + "validators": [], + "default": [], "description": "Metrics for which percentage of total are to be displayed" }, "y_axis_bounds": { @@ -58,30 +67,86 @@ }, "renderTrigger": true }, - "metric": { + "target_color_picker": { + "label": "Target Color", + "description": "Color of the target location", + "type": "ColorPickerControl", + "default": { + "r": 0, + "g": 122, + "b": 135, + "a": 1 + }, + "renderTrigger": true + }, + "legend_position": { + "label": "Legend Position", + "description": "Choose the position of the legend", "type": "SelectControl", - "label": "Metric", "clearable": false, - "description": "Choose the metric", - "validators": [ - null + "default": "tr", + "choices": [ + [ + null, + "None" + ], + [ + "tl", + "Top left" + ], + [ + "tr", + "Top right" + ], + [ + "bl", + "Bottom left" + ], + [ + "br", + "Bottom right" + ] ], - "valueKey": "metric_name" + "renderTrigger": true + }, + "fill_color_picker": { + "label": "Fill Color", + "description": " Set the opacity to 0 if you do not want to override the color specified in the GeoJSON", + "type": "ColorPickerControl", + "default": { + "r": 0, + "g": 122, + "b": 135, + "a": 1 + }, + "renderTrigger": true + }, + "stroke_color_picker": { + "label": "Stroke Color", + "description": " Set the opacity to 0 if you do not want to override the color specified in the GeoJSON", + "type": "ColorPickerControl", + "default": { + "r": 0, + "g": 122, + "b": 135, + "a": 1 + }, + "renderTrigger": true }, "metric_2": { - "type": "SelectControl", + "type": "MetricsControl", + "multi": false, "label": "Right Axis Metric", - "default": null, "validators": [ null ], - "clearable": true, "description": "Choose a metric for right axis", - "valueKey": "metric_name" + "clearable": true }, "stacked_style": { "type": "SelectControl", "label": "Stacked Style", + "renderTrigger": true, "choices": [ [ "stack", @@ -150,69 +215,10 @@ "linear_color_scheme": { "type": "ColorSchemeControl", "label": "Linear Color Scheme", - "choices": [ - [ - "fire", - "fire" - ], - [ - "blue_white_yellow", - "blue/white/yellow" - ], - [ - "white_black", - "white/black" - ], - [ - "black_white", - "black/white" - ], - [ - "dark_blue", - "light/dark blue" - ], - [ - "pink_grey", - "pink/white/grey" - ] - ], "default": "blue_white_yellow", "clearable": false, "description": "", "renderTrigger": true, - "schemes": { - "blue_white_yellow": [ - "#00d1c1", - "white", - "#ffb400" - ], - "fire": [ - "white", - "yellow", - "red", - "black" - ], - "white_black": [ - "white", - "black" - ], - "black_white": [ - "black", - "white" - ], - "dark_blue": [ - "#EBF5F8", - "#6BB1CC", - "#357E9B", - "#1B4150", - "#092935" - ], - "pink_grey": [ - "#E70B81", - "#FAFAFA", - "#666666" - ] - }, "isLinear": true }, "normalize_across": { @@ -237,7 +243,8 @@ }, "horizon_color_scale": { "type": "SelectControl", - "label": "Horizon Color Scale", + "renderTrigger": true, + "label": "Value Domain", "choices": [ [ "series", @@ -253,7 +260,7 @@ ] ], "default": "series", - "description": "Defines how the colors are attributed." + "description": "series: Treat each series independently; overall: All series use the same scale; change: Show changes compared to the first data point in each series" }, "canvas_image_rendering": { "type": "SelectControl", @@ -275,6 +282,7 @@ "xscale_interval": { "type": "SelectControl", "label": "XScale Interval", + "renderTrigger": true, "choices": [ [ 1, @@ -478,6 +486,7 @@ ] ], "default": "1", + "clearable": false, "description": "Number of steps to take between ticks when displaying the X scale" }, "yscale_interval": { @@ -685,7 +694,9 @@ "50" ] ], - "default": null, + "default": "1", + "clearable": false, + "renderTrigger": true, "description": "Number of steps to take between ticks when displaying the Y scale" }, "include_time": { @@ -694,6 +705,13 @@ "description": "Whether to include the time granularity as defined in the time section", "default": false }, + "autozoom": { + "type": "CheckboxControl", + "label": "Auto Zoom", + "default": true, + "renderTrigger": true, + "description": "When checked, the map will zoom to your data after each query" + }, "show_perc": { "type": "CheckboxControl", "label": "Show percentage", @@ -733,6 +751,7 @@ "type": "CheckboxControl", "label": "Sort Bars", "default": false, + "renderTrigger": true, "description": "Sort bars by x labels." }, "combine_metric": { @@ -753,7 +772,7 @@ "label": "Reduce X ticks", "renderTrigger": true, "default": false, - "description": "Reduces the number of X-axis ticks to be rendered. If true, the x-axis won't overflow and labels may be missing. If false, a minimum width will be applied to columns and the width may overflow into a horizontal scroll." + "description": "Reduces the number of X-axis ticks to be rendered. If true, the x-axis will not overflow and labels may be missing. If false, a minimum width will be applied to columns and the width may overflow into an horizontal scroll." }, "include_series": { "type": "CheckboxControl", @@ -763,8 +782,10 @@ "description": "Include series name as an axis" }, "secondary_metric": { - "type": "SelectControl", + "type": "MetricsControl", + "multi": false, "label": "Color Metric", + "validators": [], "default": null, "description": "A metric to use for color" }, @@ -801,14 +822,26 @@ "Italy", "Italy" ], + [ + "Japan", + "Japan" + ], [ "Morocco", "Morocco" ], + [ + "Myanmar", + "Myanmar" + ], [ "Netherlands", "Netherlands" ], + [ + "Portugal", + "Portugal" + ], [ "Russia", "Russia" @@ -821,6 +854,14 @@ "Spain", "Spain" ], + [ + "Thailand", + "Thailand" + ], + [ + "Timorleste", + "Timorleste" + ], [ "Uk", "Uk" @@ -832,6 +873,10 @@ [ "Usa", "Usa" + ], + [ + "Zambia", + "Zambia" ] ], "description": "The name of the country that Superset should display" @@ -926,7 +971,32 @@ "multi": true, "label": "Columns", "default": [], - "description": "Columns to display" + "description": "Columns to display", + "valueKey": "column_name" + }, + "spatial": { + "type": "SpatialControl", + "label": "Longitude & Latitude", + "validators": [ + null + ], + "description": "Point to your spatial columns" + }, + "start_spatial": { + "type": "SpatialControl", + "label": "Start Longitude & Latitude", + "validators": [ + null + ], + "description": "Point to your spatial columns" + }, + "end_spatial": { + "type": "SpatialControl", + "label": "End Longitude & Latitude", + "validators": [ + null + ], + "description": "Point to your spatial columns" }, "longitude": { "type": "SelectControl", @@ -946,6 +1016,83 @@ ], "description": "Select the latitude column" }, + "filter_nulls": { + "type": "CheckboxControl", + "label": "Ignore null locations", + "default": true, + "description": "Whether to ignore locations that are null" + }, + "geojson": { + "type": "SelectControl", + "label": "GeoJson Column", + "validators": [ + null + ], + "description": "Select the geojson column" + }, + "point_radius_scale": { + "type": "SelectControl", + "freeForm": true, + "label": "Point Radius Scale", + "validators": [ + null + ], + "default": null, + "choices": [ + [ + 0, + "0" + ], + [ + 100, + "100" + ], + [ + 200, + "200" + ], + [ + 300, + "300" + ], + [ + 500, + "500" + ] + ] + }, + "stroke_width": { + "type": "SelectControl", + "freeForm": true, + "label": "Stroke Width", + "validators": [ + null + ], + "default": null, + "renderTrigger": true, + "choices": [ + [ + 1, + "1" + ], + [ + 2, + "2" + ], + [ + 3, + "3" + ], + [ + 4, + "4" + ], + [ + 5, + "5" + ] + ] + }, "all_columns_x": { "type": "SelectControl", "label": "X", @@ -977,6 +1124,7 @@ }, "bottom_margin": { "type": "SelectControl", + "clearable": false, "freeForm": true, "label": "Bottom Margin", "choices": [ @@ -1013,9 +1161,36 @@ "renderTrigger": true, "description": "Bottom margin, in pixels, allowing for more room for axis labels" }, + "x_ticks_layout": { + "type": "SelectControl", + "label": "X Tick Layout", + "choices": [ + [ + "auto", + "auto" + ], + [ + "flat", + "flat" + ], + [ + "45°", + "45°" + ], + [ + "staggered", + "staggered" + ] + ], + "default": "auto", + "clearable": false, + "renderTrigger": true, + "description": "The way the ticks are laid out on the X-axis" + }, "left_margin": { "type": "SelectControl", "freeForm": true, + "clearable": false, "label": "Left Margin", "choices": [ [ @@ -1058,56 +1233,68 @@ "default": "one day", "choices": [ [ - "all", + null, "all" ], [ - "5 seconds", + "PT5S", "5 seconds" ], [ - "30 seconds", + "PT30S", "30 seconds" ], [ - "1 minute", + "PT1M", "1 minute" ], [ - "5 minutes", + "PT5M", "5 minutes" ], [ - "1 hour", + "PT30M", + "30 minutes" + ], + [ + "PT1H", "1 hour" ], [ - "6 hour", + "PT6H", "6 hour" ], [ - "1 day", + "P1D", "1 day" ], [ - "7 days", + "P7D", "7 days" ], [ - "week", + "P1W", "week" ], [ "week_starting_sunday", - "week_starting_sunday" + "week starting Sunday" ], [ "week_ending_saturday", - "week_ending_saturday" + "week ending Saturday" ], [ - "month", + "P1M", "month" + ], + [ + "P3M", + "quarter" + ], + [ + "P1Y", + "year" ] ], "description": "The time granularity for the visualization. Note that you can type and use simple natural language as in `10 seconds`, `1 day` or `56 weeks`" @@ -1170,6 +1357,7 @@ }, "link_length": { "type": "SelectControl", + "renderTrigger": true, "freeForm": true, "label": "Link Length", "default": "200", @@ -1211,6 +1399,7 @@ }, "charge": { "type": "SelectControl", + "renderTrigger": true, "freeForm": true, "label": "Charge", "default": "-500", @@ -1268,12 +1457,13 @@ "time_grain_sqla": { "type": "SelectControl", "label": "Time Grain", + "default": "P1D", "description": "The time granularity for the visualization. This applies a date transformation to alter your time column and defines a new time granularity. The options here are defined on a per database engine basis in the Superset source code." }, "resample_rule": { "type": "SelectControl", "freeForm": true, - "label": "Resample Rule", + "label": "Rule", "default": null, "choices": [ [ @@ -1310,7 +1500,7 @@ "resample_how": { "type": "SelectControl", "freeForm": true, - "label": "Resample How", + "label": "How", "default": null, "choices": [ [ @@ -1335,7 +1525,7 @@ "resample_fillmethod": { "type": "SelectControl", "freeForm": true, - "label": "Resample Fill Method", + "label": "Fill Method", "default": null, "choices": [ [ @@ -1353,17 +1543,11 @@ ], "description": "Pandas resample fill method" }, - "since": { - "type": "DateFilterControl", - "freeForm": true, - "label": "Since", - "default": "7 days ago" - }, - "until": { + "time_range": { "type": "DateFilterControl", "freeForm": true, - "label": "Until", - "default": "now" + "label": "Time range", + "default": "Last week" }, "max_bubble_size": { "type": "SelectControl", @@ -1429,6 +1613,7 @@ "treemap_ratio": { "type": "TextControl", "label": "Ratio", + "renderTrigger": true, "isFloat": true, "default": 1.618033988749895, "description": "Target aspect ratio for treemap tiles." @@ -1440,29 +1625,37 @@ "renderTrigger": true, "default": ".3s", "choices": [ + [ + ".1s", + ".1s (12345.432 => 10k)" + ], [ ".3s", - ".3s | 12.3k" + ".3s (12345.432 => 12.3k)" + ], + [ + ",.1%", + ",.1% (12345.432 => 1,234,543.2%)" ], [ ".3%", - ".3% | 1234543.210%" + ".3% (12345.432 => 1234543.200%)" ], [ ".4r", - ".4r | 12350" + ".4r (12345.432 => 12350)" ], [ - ".3f", - ".3f | 12345.432" + ",.3f", + ",.3f (12345.432 => 12,345.432)" ], [ "+,", - "+, | +12,345.4321" + "+, (12345.432 => +12,345.432)" ], [ "$,.2f", - "$,.2f | $12,345.43" + "$,.2f (12345.432 => $12,345.43)" ] ], "description": "D3 format syntax: https://github.com/d3/d3-format" @@ -1474,7 +1667,7 @@ "validators": [ null ], - "default": null, + "default": 10000, "choices": [ [ 10, @@ -1551,11 +1744,10 @@ "500" ] ], - "default": 50, - "description": "Limits the number of time series that get displayed" + "description": "Limits the number of time series that get displayed. A sub query (or an extra phase where sub queries are not supported) is applied to limit the number of time series that get fetched and displayed. This feature is useful when grouping by high cardinality dimension(s)." }, "timeseries_limit_metric": { - "type": "SelectControl", + "type": "MetricsControl", "label": "Sort By", "default": null, "description": "Metric used to define the top series" @@ -1598,6 +1790,7 @@ "type": "TextControl", "label": "Multiplier", "isFloat": true, + "renderTrigger": true, "default": 1, "description": "Factor to multiply the metric by" }, @@ -1607,19 +1800,63 @@ "isInt": true, "description": "Defines the size of the rolling window function, relative to the time granularity selected" }, - "grid_size": { + "cell_size": { "type": "TextControl", - "label": "Grid Size", - "renderTrigger": true, - "default": 20, "isInt": true, - "description": "Defines the grid size in pixels" + "default": 10, + "validators": [ + null + ], + "renderTrigger": true, + "label": "Cell Size", + "description": "The size of the square cell, in pixels" }, - "min_periods": { + "cell_padding": { "type": "TextControl", - "label": "Min Periods", "isInt": true, - "description": "The minimum number of rolling periods required to show a value. For instance if you do a cumulative sum on 7 days you may want your \"Min Period\" to be 7, so that all data points shown are the total of 7 periods. This will hide the \"ramp up\" taking place over the first 7 periods" + "validators": [ + null + ], + "renderTrigger": true, + "default": 2, + "label": "Cell Padding", + "description": "The distance between cells, in pixels" + }, + "cell_radius": { + "type": "TextControl", + "isInt": true, + "validators": [ + null + ], + "renderTrigger": true, + "default": 0, + "label": "Cell Radius", + "description": "The pixel radius" + }, + "steps": { + "type": "TextControl", + "isInt": true, + "validators": [ + null + ], + "renderTrigger": true, + "default": 10, + "label": "Color Steps", + "description": "The number color \"steps\"" + }, + "grid_size": { + "type": "TextControl", + "label": "Grid Size", + "renderTrigger": true, + "default": 20, + "isInt": true, + "description": "Defines the grid size in pixels" + }, + "min_periods": { + "type": "TextControl", + "label": "Min Periods", + "isInt": true, + "description": "The minimum number of rolling periods required to show a value. For instance if you do a cumulative sum on 7 days you may want your \"Min Period\" to be 7, so that all data points shown are the total of 7 periods. This will hide the \"ramp up\" taking place over the first 7 periods" }, "series": { "type": "SelectControl", @@ -1637,33 +1874,34 @@ "description": "This defines the element to be plotted on the chart" }, "x": { - "type": "SelectControl", + "type": "MetricsControl", + "multi": false, "label": "X Axis", - "description": "Metric assigned to the [X] axis", - "default": null, "validators": [ null ], - "valueKey": "metric_name" + "default": null, + "description": "Metric assigned to the [X] axis" }, "y": { - "type": "SelectControl", + "type": "MetricsControl", + "multi": false, "label": "Y Axis", - "default": null, "validators": [ null ], - "description": "Metric assigned to the [Y] axis", - "valueKey": "metric_name" + "default": null, + "description": "Metric assigned to the [Y] axis" }, "size": { - "type": "SelectControl", + "type": "MetricsControl", + "multi": false, "label": "Bubble Size", - "default": null, "validators": [ null ], - "valueKey": "metric_name" + "default": null, + "description": "One or many metrics to display" }, "url": { "type": "TextControl", @@ -1699,6 +1937,7 @@ "freeForm": true, "label": "Table Timestamp Format", "default": "%Y-%m-%d %H:%M:%S", + "renderTrigger": true, "validators": [ null ], @@ -1708,6 +1947,10 @@ "smart_date", "Adaptative formating" ], + [ + "%d/%m/%Y", + "%d/%m/%Y | 14/01/2019" + ], [ "%m/%d/%Y", "%m/%d/%Y | 01/14/2019" @@ -1720,6 +1963,10 @@ "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S | 2019-01-14 01:32:10" ], + [ + "%d-%m-%Y %H:%M:%S", + "%Y-%m-%d %H:%M:%S | 14-01-2019 01:32:10" + ], [ "%H:%M:%S", "%H:%M:%S | 01:32:10" @@ -1729,6 +1976,7 @@ }, "series_height": { "type": "SelectControl", + "renderTrigger": true, "freeForm": true, "label": "Series Height", "default": "25", @@ -1771,6 +2019,7 @@ "page_length": { "type": "SelectControl", "freeForm": true, + "renderTrigger": true, "label": "Page Length", "default": 0, "choices": [ @@ -1820,29 +2069,37 @@ "renderTrigger": true, "default": ".3s", "choices": [ + [ + ".1s", + ".1s (12345.432 => 10k)" + ], [ ".3s", - ".3s | 12.3k" + ".3s (12345.432 => 12.3k)" + ], + [ + ",.1%", + ",.1% (12345.432 => 1,234,543.2%)" ], [ ".3%", - ".3% | 1234543.210%" + ".3% (12345.432 => 1234543.200%)" ], [ ".4r", - ".4r | 12350" + ".4r (12345.432 => 12350)" ], [ - ".3f", - ".3f | 12345.432" + ",.3f", + ",.3f (12345.432 => 12,345.432)" ], [ "+,", - "+, | +12,345.4321" + "+, (12345.432 => +12,345.432)" ], [ "$,.2f", - "$,.2f | $12,345.43" + "$,.2f (12345.432 => $12,345.43)" ] ], "description": "D3 format syntax: https://github.com/d3/d3-format" @@ -1858,6 +2115,10 @@ "smart_date", "Adaptative formating" ], + [ + "%d/%m/%Y", + "%d/%m/%Y | 14/01/2019" + ], [ "%m/%d/%Y", "%m/%d/%Y | 01/14/2019" @@ -1870,6 +2131,10 @@ "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S | 2019-01-14 01:32:10" ], + [ + "%d-%m-%Y %H:%M:%S", + "%Y-%m-%d %H:%M:%S | 14-01-2019 01:32:10" + ], [ "%H:%M:%S", "%H:%M:%S | 01:32:10" @@ -1884,29 +2149,37 @@ "renderTrigger": true, "default": ".3s", "choices": [ + [ + ".1s", + ".1s (12345.432 => 10k)" + ], [ ".3s", - ".3s | 12.3k" + ".3s (12345.432 => 12.3k)" + ], + [ + ",.1%", + ",.1% (12345.432 => 1,234,543.2%)" ], [ ".3%", - ".3% | 1234543.210%" + ".3% (12345.432 => 1234543.200%)" ], [ ".4r", - ".4r | 12350" + ".4r (12345.432 => 12350)" ], [ - ".3f", - ".3f | 12345.432" + ",.3f", + ",.3f (12345.432 => 12,345.432)" ], [ "+,", - "+, | +12,345.4321" + "+, (12345.432 => +12,345.432)" ], [ "$,.2f", - "$,.2f | $12,345.43" + "$,.2f (12345.432 => $12,345.43)" ] ], "description": "D3 format syntax: https://github.com/d3/d3-format" @@ -1917,29 +2190,37 @@ "label": "Right Axis Format", "default": ".3s", "choices": [ + [ + ".1s", + ".1s (12345.432 => 10k)" + ], [ ".3s", - ".3s | 12.3k" + ".3s (12345.432 => 12.3k)" + ], + [ + ",.1%", + ",.1% (12345.432 => 1,234,543.2%)" ], [ ".3%", - ".3% | 1234543.210%" + ".3% (12345.432 => 1234543.200%)" ], [ ".4r", - ".4r | 12350" + ".4r (12345.432 => 12350)" ], [ - ".3f", - ".3f | 12345.432" + ",.3f", + ",.3f (12345.432 => 12,345.432)" ], [ "+,", - "+, | +12,345.4321" + "+, (12345.432 => +12,345.432)" ], [ "$,.2f", - "$,.2f | $12,345.43" + "$,.2f (12345.432 => $12,345.43)" ] ], "description": "D3 format syntax: https://github.com/d3/d3-format" @@ -1955,6 +2236,10 @@ "smart_date", "Adaptative formating" ], + [ + "%d/%m/%Y", + "%d/%m/%Y | 14/01/2019" + ], [ "%m/%d/%Y", "%m/%d/%Y | 01/14/2019" @@ -1967,6 +2252,10 @@ "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S | 2019-01-14 01:32:10" ], + [ + "%d-%m-%Y %H:%M:%S", + "%Y-%m-%d %H:%M:%S | 14-01-2019 01:32:10" + ], [ "%H:%M:%S", "%H:%M:%S | 01:32:10" @@ -2011,7 +2300,8 @@ "square" ] ], - "default": "random", + "renderTrigger": true, + "default": "flat", "description": "Rotation to apply to words in the cloud" }, "line_interpolation": { @@ -2051,6 +2341,7 @@ "type": "SelectControl", "label": "Label Type", "default": "key", + "renderTrigger": true, "choices": [ [ "key", @@ -2102,10 +2393,6 @@ "max", "max" ], - [ - "median", - "median" - ], [ "stdev", "stdev" @@ -2118,10 +2405,69 @@ "default": "sum", "description": "Aggregate function to apply when pivoting and computing the total rows and columns" }, + "js_agg_function": { + "type": "SelectControl", + "label": "Dynamic Aggregation Function", + "description": "The function to use when aggregating points into groups", + "default": "sum", + "clearable": false, + "renderTrigger": true, + "choices": [ + [ + "sum", + "sum" + ], + [ + "min", + "min" + ], + [ + "max", + "max" + ], + [ + "mean", + "mean" + ], + [ + "median", + "median" + ], + [ + "count", + "count" + ], + [ + "variance", + "variance" + ], + [ + "deviation", + "deviation" + ], + [ + "p1", + "p1" + ], + [ + "p5", + "p5" + ], + [ + "p95", + "p95" + ], + [ + "p99", + "p99" + ] + ] + }, "size_from": { "type": "TextControl", "isInt": true, "label": "Font Size From", + "renderTrigger": true, "default": "20", "description": "Font size for the smallest value in the list" }, @@ -2129,6 +2475,7 @@ "type": "TextControl", "isInt": true, "label": "Font Size To", + "renderTrigger": true, "default": "150", "description": "Font size for the biggest value in the list" }, @@ -2147,16 +2494,31 @@ "description": "Whether to make the grid 3D" }, "show_brush": { - "type": "CheckboxControl", - "label": "Range Filter", + "type": "SelectControl", + "label": "Show Range Filter", "renderTrigger": true, - "default": false, + "clearable": false, + "default": "auto", + "choices": [ + [ + "yes", + "Yes" + ], + [ + "no", + "No" + ], + [ + "auto", + "Auto" + ] + ], "description": "Whether to display the time range interactive selector" }, "date_filter": { "type": "CheckboxControl", "label": "Date Filter", - "default": false, + "default": true, "description": "Whether to include a time filter" }, "show_sqla_time_granularity": { @@ -2187,6 +2549,7 @@ "type": "CheckboxControl", "label": "Data Table", "default": false, + "renderTrigger": true, "description": "Whether to display the interactive data table" }, "include_search": { @@ -2198,9 +2561,10 @@ }, "table_filter": { "type": "CheckboxControl", - "label": "Table Filter", + "label": "Emit Filter Events", + "renderTrigger": true, "default": false, - "description": "Whether to apply filter when table cell is clicked" + "description": "Whether to apply filter when items are clicked" }, "align_pn": { "type": "CheckboxControl", @@ -2230,6 +2594,63 @@ "default": true, "description": "Whether to display the legend (toggles)" }, + "send_time_range": { + "type": "CheckboxControl", + "label": "Propagate", + "renderTrigger": true, + "default": false, + "description": "Send range filter events to other charts" + }, + "toggle_polygons": { + "type": "CheckboxControl", + "label": "Multiple filtering", + "renderTrigger": true, + "default": true, + "description": "Allow sending multiple polygons as a filter event" + }, + "num_buckets": { + "type": "SelectControl", + "multi": false, + "freeForm": true, + "label": "Number of buckets to group data", + "default": 5, + "choices": [ + [ + 2, + "2" + ], + [ + 3, + "3" + ], + [ + 5, + "5" + ], + [ + 10, + "10" + ] + ], + "description": "How many buckets should the data be grouped in.", + "renderTrigger": true + }, + "break_points": { + "type": "SelectControl", + "multi": true, + "freeForm": true, + "label": "Bucket break points", + "choices": [], + "description": "List of n+1 values for bucketing metric into n buckets.", + "renderTrigger": true + }, + "show_labels": { + "type": "CheckboxControl", + "label": "Show Labels", + "renderTrigger": true, + "default": true, + "description": "Whether to display the labels. Note that the label only displays when the the 5% threshold." + }, "show_values": { "type": "CheckboxControl", "label": "Show Values", @@ -2237,18 +2658,39 @@ "default": false, "description": "Whether to display the numerical values within the cells" }, + "show_metric_name": { + "type": "CheckboxControl", + "label": "Show Metric Names", + "renderTrigger": true, + "default": true, + "description": "Whether to display the metric name as a title" + }, + "show_trend_line": { + "type": "CheckboxControl", + "label": "Show Trend Line", + "renderTrigger": true, + "default": true, + "description": "Whether to display the trend line" + }, + "start_y_axis_at_zero": { + "type": "CheckboxControl", + "label": "Start y-axis at 0", + "renderTrigger": true, + "default": true, + "description": "Start y-axis at zero. Uncheck to start y-axis at minimum value in the data." + }, "x_axis_showminmax": { "type": "CheckboxControl", "label": "X bounds", "renderTrigger": true, - "default": true, + "default": false, "description": "Whether to display the min and max values of the X-axis" }, "y_axis_showminmax": { "type": "CheckboxControl", "label": "Y bounds", "renderTrigger": true, - "default": true, + "default": false, "description": "Whether to display the min and max values of the Y-axis" }, "rich_tooltip": { @@ -2299,38 +2741,62 @@ "default": false, "description": "Compute the contribution to the total" }, - "num_period_compare": { - "type": "TextControl", - "label": "Period Ratio", - "default": "", - "isInt": true, - "description": "[integer] Number of period to compare against, this is relative to the granularity selected" - }, - "period_ratio_type": { + "time_compare": { "type": "SelectControl", - "label": "Period Ratio Type", - "default": "growth", + "multi": true, + "freeForm": true, + "label": "Time Shift", "choices": [ [ - "factor", - "factor" + "1 day", + "1 day" ], [ - "growth", - "growth" + "1 week", + "1 week" ], [ - "value", - "value" + "28 days", + "28 days" + ], + [ + "30 days", + "30 days" + ], + [ + "52 weeks", + "52 weeks" + ], + [ + "1 year", + "1 year" ] ], - "description": "`factor` means (new/previous), `growth` is ((new/previous) - 1), `value` is (new-previous)" + "description": "Overlay one or more timeseries from a relative time period. Expects relative time deltas in natural language (example: 24 hours, 7 days, 56 weeks, 365 days)" }, - "time_compare": { - "type": "TextControl", - "label": "Time Shift", - "default": null, - "description": "Overlay a timeseries from a relative time period. Expects relative time delta in natural language (example: 24 hours, 7 days, 56 weeks, 365 days)" + "comparison_type": { + "type": "SelectControl", + "label": "Calculation type", + "default": "values", + "choices": [ + [ + "values", + "Actual Values" + ], + [ + "absolute", + "Absolute difference" + ], + [ + "percentage", + "Percentage change" + ], + [ + "ratio", + "Ratio" + ] + ], + "description": "How to display time shifts: as individual lines; as the absolute difference between the main time series and each time shift; as the percentage change; or as the ratio between series and time shifts." }, "subheader": { "type": "TextControl", @@ -2347,6 +2813,7 @@ "mapbox_style": { "type": "SelectControl", "label": "Map Style", + "clearable": false, "renderTrigger": true, "choices": [ [ @@ -2374,7 +2841,7 @@ "Outdoors" ] ], - "default": "mapbox://styles/mapbox/streets-v9", + "default": "mapbox://styles/mapbox/light-v9", "description": "Base layer map style" }, "clustering_radius": { @@ -2425,6 +2892,10 @@ "point_radius_fixed": { "type": "FixedOrMetricControl", "label": "Point Size", + "default": { + "type": "fix", + "value": 1000 + }, "description": "Fixed point radius" }, "point_radius": { @@ -2493,10 +2964,20 @@ "isFloat": true, "description": "Opacity of all clusters, points, and labels. Between 0 and 1." }, + "opacity": { + "type": "SliderControl", + "label": "Opacity", + "default": 80, + "step": 1, + "min": 0, + "max": 100, + "renderTrigger": true, + "description": "Opacity, expects values between 0 and 100" + }, "viewport": { "type": "ViewportControl", "label": "Viewport", - "renderTrigger": true, + "renderTrigger": false, "description": "Parameters related to the view and perspective on the map", "default": { "longitude": 6.85236157047845, @@ -2504,31 +2985,38 @@ "zoom": 1, "bearing": 0, "pitch": 0 - } + }, + "dontRefreshOnChange": true }, "viewport_zoom": { "type": "TextControl", "label": "Zoom", + "renderTrigger": true, "isFloat": true, "default": 11, "description": "Zoom level of the map", - "places": 8 + "places": 8, + "dontRefreshOnChange": true }, "viewport_latitude": { "type": "TextControl", "label": "Default latitude", + "renderTrigger": true, "default": 37.772123, "isFloat": true, "description": "Latitude of default viewport", - "places": 8 + "places": 8, + "dontRefreshOnChange": true }, "viewport_longitude": { "type": "TextControl", "label": "Default longitude", + "renderTrigger": true, "default": -122.405293, "isFloat": true, "description": "Longitude of default viewport", - "places": 8 + "places": 8, + "dontRefreshOnChange": true }, "render_while_dragging": { "type": "CheckboxControl", @@ -2621,13 +3109,24 @@ "label": "", "default": [], "description": "Annotation Layers", - "renderTrigger": true + "renderTrigger": true, + "tabOverride": "data" + }, + "adhoc_filters": { + "type": "AdhocFilterControl", + "label": "Filters", + "default": null, + "description": "", + "provideFormDataToProps": true + }, + "filters": { + "type": "FilterPanel" }, "slice_id": { "type": "HiddenControl", - "label": "Slice ID", + "label": "Chart ID", "hidden": true, - "description": "The id of the active slice" + "description": "The id of the active chart" }, "cache_timeout": { "type": "HiddenControl", @@ -2635,6 +3134,12 @@ "hidden": true, "description": "The number of seconds before expiring the cache" }, + "url_params": { + "type": "HiddenControl", + "label": "URL Parameters", + "hidden": true, + "description": "Extra parameters for use in jinja templated queries" + }, "order_by_entity": { "type": "CheckboxControl", "label": "Order by entity id", @@ -2695,178 +3200,7 @@ "label": "Color Scheme", "default": "bnbColors", "renderTrigger": true, - "choices": [ - [ - "bnbColors", - "bnbColors" - ], - [ - "d3Category10", - "d3Category10" - ], - [ - "d3Category20", - "d3Category20" - ], - [ - "d3Category20b", - "d3Category20b" - ], - [ - "d3Category20c", - "d3Category20c" - ], - [ - "googleCategory10c", - "googleCategory10c" - ], - [ - "googleCategory20c", - "googleCategory20c" - ], - [ - "lyftColors", - "lyftColors" - ] - ], - "description": "The color scheme for rendering chart", - "schemes": { - "bnbColors": [ - "#ff5a5f", - "#7b0051", - "#007A87", - "#00d1c1", - "#8ce071", - "#ffb400", - "#b4a76c", - "#ff8083", - "#cc0086", - "#00a1b3", - "#00ffeb", - "#bbedab", - "#ffd266", - "#cbc29a", - "#ff3339", - "#ff1ab1", - "#005c66", - "#00b3a5", - "#55d12e", - "#b37e00", - "#988b4e" - ], - "d3Category10": [ - "#1f77b4", - "#ff7f0e", - "#2ca02c", - "#d62728", - "#9467bd", - "#8c564b", - "#e377c2", - "#7f7f7f", - "#bcbd22", - "#17becf" - ], - "d3Category20": [ - "#1f77b4", - "#aec7e8", - "#ff7f0e", - "#ffbb78", - "#2ca02c", - "#98df8a", - "#d62728", - "#ff9896", - "#9467bd", - "#c5b0d5", - "#8c564b", - "#c49c94", - "#e377c2", - "#f7b6d2", - "#7f7f7f", - "#c7c7c7", - "#bcbd22", - "#dbdb8d", - "#17becf", - "#9edae5" - ], - "d3Category20b": [ - "#393b79", - "#5254a3", - "#6b6ecf", - "#9c9ede", - "#637939", - "#8ca252", - "#b5cf6b", - "#cedb9c", - "#8c6d31", - "#bd9e39", - "#e7ba52", - "#e7cb94", - "#843c39", - "#ad494a", - "#d6616b", - "#e7969c", - "#7b4173", - "#a55194", - "#ce6dbd", - "#de9ed6" - ], - "d3Category20c": [ - "#3182bd", - "#6baed6", - "#9ecae1", - "#c6dbef", - "#e6550d", - "#fd8d3c", - "#fdae6b", - "#fdd0a2", - "#31a354", - "#74c476", - "#a1d99b", - "#c7e9c0", - "#756bb1", - "#9e9ac8", - "#bcbddc", - "#dadaeb", - "#636363", - "#969696", - "#bdbdbd", - "#d9d9d9" - ], - "googleCategory10c": [ - "#3366cc", - "#dc3912", - "#ff9900", - "#109618", - "#990099", - "#0099c6", - "#dd4477", - "#66aa00", - "#b82e2e", - "#316395" - ], - "googleCategory20c": [ - "#3366cc", - "#dc3912", - "#ff9900", - "#109618", - "#990099", - "#0099c6", - "#dd4477", - "#66aa00", - "#b82e2e", - "#316395", - "#994499", - "#22aa99", - "#aaaa11", - "#6633cc", - "#e67300", - "#8b0707", - "#651067", - "#329262", - "#5574a6", - "#3b3eac" - ] - } + "description": "The color scheme for rendering chart" }, "significance_level": { "type": "TextControl", @@ -2894,6 +3228,13 @@ ], "controlName": "TimeSeriesColumnControl" }, + "rose_area_proportion": { + "type": "CheckboxControl", + "label": "Use Area Proportions", + "description": "Check if the Rose Chart should use segment area instead of segment radius for proportioning", + "default": false, + "renderTrigger": true + }, "time_series_option": { "type": "SelectControl", "label": "Options", @@ -2960,12 +3301,414 @@ "default": "5", "description": "The maximum number of subdivisions of each group; lower values are pruned first" }, + "min_radius": { + "type": "TextControl", + "label": "Minimum Radius", + "isFloat": true, + "validators": [ + null + ], + "renderTrigger": true, + "default": 2, + "description": "Minimum radius size of the circle, in pixels. As the zoom level changes, this insures that the circle respects this minimum radius." + }, + "max_radius": { + "type": "TextControl", + "label": "Maximum Radius", + "isFloat": true, + "validators": [ + null + ], + "renderTrigger": true, + "default": 250, + "description": "Maxium radius size of the circle, in pixels. As the zoom level changes, this insures that the circle respects this maximum radius." + }, "partition_threshold": { "type": "TextControl", "label": "Partition Threshold", "isFloat": true, "default": "0.05", "description": "Partitions whose height to parent height proportions are below this value are pruned" + }, + "line_column": { + "type": "SelectControl", + "label": "Lines column", + "default": null, + "description": "The database columns that contains lines information", + "validators": [ + null + ] + }, + "line_type": { + "type": "SelectControl", + "label": "Lines encoding", + "clearable": false, + "default": "json", + "description": "The encoding format of the lines", + "choices": [ + [ + "polyline", + "Polyline" + ], + [ + "json", + "JSON" + ], + [ + "geohash", + "geohash (square)" + ] + ] + }, + "line_width": { + "type": "TextControl", + "label": "Line width", + "renderTrigger": true, + "isInt": true, + "default": 10, + "description": "The width of the lines" + }, + "line_charts": { + "type": "SelectAsyncControl", + "multi": true, + "label": "Line charts", + "validators": [ + null + ], + "default": [], + "description": "Pick a set of line charts to layer on top of one another", + "dataEndpoint": "/sliceasync/api/read?_flt_0_viz_type=line&_flt_7_viz_type=line_multi", + "placeholder": "Select charts", + "onAsyncErrorMessage": "Error while fetching charts" + }, + "line_charts_2": { + "type": "SelectAsyncControl", + "multi": true, + "label": "Right Axis chart(s)", + "validators": [], + "default": [], + "description": "Choose one or more charts for right axis", + "dataEndpoint": "/sliceasync/api/read?_flt_0_viz_type=line&_flt_7_viz_type=line_multi", + "placeholder": "Select charts", + "onAsyncErrorMessage": "Error while fetching charts" + }, + "prefix_metric_with_slice_name": { + "type": "CheckboxControl", + "label": "Prefix metric name with slice name", + "default": false, + "renderTrigger": true + }, + "reverse_long_lat": { + "type": "CheckboxControl", + "label": "Reverse Lat & Long", + "default": false + }, + "deck_slices": { + "type": "SelectAsyncControl", + "multi": true, + "label": "deck.gl charts", + "validators": [ + null + ], + "default": [], + "description": "Pick a set of deck.gl charts to layer on top of one another", + "dataEndpoint": "/sliceasync/api/read?_flt_0_viz_type=deck_&_flt_7_viz_type=deck_multi", + "placeholder": "Select charts", + "onAsyncErrorMessage": "Error while fetching charts" + }, + "js_data_mutator": { + "type": "TextAreaControl", + "language": "javascript", + "label": "Javascript data interceptor", + "description": "Define a javascript function that receives the data array used in the visualization and is expected to return a modified version of that array. This can be used to alter properties of the data, filter, or enrich the array.", + "height": 100, + "default": "", + "aboveEditorSection": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": "Define a javascript function that receives the data array used in the visualization and is expected to return a modified version of that array. This can be used to alter properties of the data, filter, or enrich the array." + }, + "_owner": null, + "_store": {} + }, + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + "For more information about objects are in context in the scope of this function, refer to the", + { + "type": "a", + "key": null, + "ref": null, + "props": { + "href": "https://github.com/apache/incubator-superset/blob/master/superset/assets/src/modules/sandbox.js", + "children": [ + " source code of Superset's sandboxed parser", + "." + ] + }, + "_owner": null, + "_store": {} + }, + "." + ] + }, + "_owner": null, + "_store": {} + } + }, + "_owner": null, + "_store": {} + }, + null + ] + }, + "_owner": null, + "_store": {} + } + }, + "js_data": { + "type": "TextAreaControl", + "language": "javascript", + "label": "Javascript data mutator", + "description": "Define a function that receives intercepts the data objects and can mutate it", + "height": 100, + "default": "", + "aboveEditorSection": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": "Define a function that receives intercepts the data objects and can mutate it" + }, + "_owner": null, + "_store": {} + }, + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + "For more information about objects are in context in the scope of this function, refer to the", + { + "type": "a", + "key": null, + "ref": null, + "props": { + "href": "https://github.com/apache/incubator-superset/blob/master/superset/assets/src/modules/sandbox.js", + "children": [ + " source code of Superset's sandboxed parser", + "." + ] + }, + "_owner": null, + "_store": {} + }, + "." + ] + }, + "_owner": null, + "_store": {} + } + }, + "_owner": null, + "_store": {} + }, + null + ] + }, + "_owner": null, + "_store": {} + } + }, + "js_tooltip": { + "type": "TextAreaControl", + "language": "javascript", + "label": "Javascript tooltip generator", + "description": "Define a function that receives the input and outputs the content for a tooltip", + "height": 100, + "default": "", + "aboveEditorSection": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": "Define a function that receives the input and outputs the content for a tooltip" + }, + "_owner": null, + "_store": {} + }, + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + "For more information about objects are in context in the scope of this function, refer to the", + { + "type": "a", + "key": null, + "ref": null, + "props": { + "href": "https://github.com/apache/incubator-superset/blob/master/superset/assets/src/modules/sandbox.js", + "children": [ + " source code of Superset's sandboxed parser", + "." + ] + }, + "_owner": null, + "_store": {} + }, + "." + ] + }, + "_owner": null, + "_store": {} + } + }, + "_owner": null, + "_store": {} + }, + null + ] + }, + "_owner": null, + "_store": {} + } + }, + "js_onclick_href": { + "type": "TextAreaControl", + "language": "javascript", + "label": "Javascript onClick href", + "description": "Define a function that returns a URL to navigate to when user clicks", + "height": 100, + "default": "", + "aboveEditorSection": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": "Define a function that returns a URL to navigate to when user clicks" + }, + "_owner": null, + "_store": {} + }, + { + "type": "p", + "key": null, + "ref": null, + "props": { + "children": { + "type": "div", + "key": null, + "ref": null, + "props": { + "children": [ + "For more information about objects are in context in the scope of this function, refer to the", + { + "type": "a", + "key": null, + "ref": null, + "props": { + "href": "https://github.com/apache/incubator-superset/blob/master/superset/assets/src/modules/sandbox.js", + "children": [ + " source code of Superset's sandboxed parser", + "." + ] + }, + "_owner": null, + "_store": {} + }, + "." + ] + }, + "_owner": null, + "_store": {} + } + }, + "_owner": null, + "_store": {} + }, + null + ] + }, + "_owner": null, + "_store": {} + } + }, + "js_columns": { + "type": "SelectControl", + "multi": true, + "label": "Extra data for JS", + "default": [], + "includeTime": false, + "description": "List of extra columns made available in Javascript functions", + "valueKey": "column_name" + }, + "stroked": { + "type": "CheckboxControl", + "label": "Stroked", + "renderTrigger": true, + "description": "Whether to display the stroke", + "default": false + }, + "filled": { + "type": "CheckboxControl", + "label": "Filled", + "renderTrigger": true, + "description": "Whether to fill the objects", + "default": true + }, + "normalized": { + "type": "CheckboxControl", + "label": "Normalized", + "renderTrigger": true, + "description": "Whether to normalize the histogram", + "default": false } } -} +} \ No newline at end of file diff --git a/superset/assets/docs b/superset/assets/docs deleted file mode 120000 index 9321704203..0000000000 --- a/superset/assets/docs +++ /dev/null @@ -1 +0,0 @@ -../../docs/_build/html/ \ No newline at end of file diff --git a/superset/assets/src/chart/chartAction.js b/superset/assets/src/chart/chartAction.js index 6c6ddab2fb..c6e61ca20a 100644 --- a/superset/assets/src/chart/chartAction.js +++ b/superset/assets/src/chart/chartAction.js @@ -10,6 +10,17 @@ import { Logger, LOG_ACTIONS_LOAD_CHART } from '../logger'; import getClientErrorObject from '../utils/getClientErrorObject'; import { allowCrossDomain } from '../utils/hostNamesConfig'; +// Forecasting +import { mutator as forecastingMutator } from '../forecasting/client'; + +const ACTION_PLUGINS = { + CHART_UPDATE_SUCCEEDED: [ + { + mutator: forecastingMutator, + }, + ], +}; + export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED'; export function chartUpdateStarted(queryController, latestQueryFormData, key) { return { type: CHART_UPDATE_STARTED, queryController, latestQueryFormData, key }; @@ -17,7 +28,17 @@ export function chartUpdateStarted(queryController, latestQueryFormData, key) { export const CHART_UPDATE_SUCCEEDED = 'CHART_UPDATE_SUCCEEDED'; export function chartUpdateSucceeded(queryResponse, key) { - return { type: CHART_UPDATE_SUCCEEDED, queryResponse, key }; + return function (dispatch) { + + // We are chaining all mutators for this particular action + const responsePormise = ACTION_PLUGINS.CHART_UPDATE_SUCCEEDED + .reduce((finalPromise, plugin) => finalPromise.then(plugin.mutator), + Promise.resolve(queryResponse)); + + responsePormise.then((data) => { + dispatch({ type: CHART_UPDATE_SUCCEEDED, queryResponse: data, key }); + }); + }; } export const CHART_UPDATE_STOPPED = 'CHART_UPDATE_STOPPED'; @@ -40,6 +61,7 @@ export function chartRenderingFailed(error, key, stackTrace) { return { type: CHART_RENDERING_FAILED, error, key, stackTrace }; } +// TODO: this is where we receive data export const CHART_RENDERING_SUCCEEDED = 'CHART_RENDERING_SUCCEEDED'; export function chartRenderingSucceeded(key) { return { type: CHART_RENDERING_SUCCEEDED, key }; @@ -139,6 +161,7 @@ export function addChart(chart, key) { return { type: ADD_CHART, chart, key }; } +// TODO: this is where we run queries export const RUN_QUERY = 'RUN_QUERY'; export function runQuery(formData, force = false, timeout = 60, key) { return (dispatch) => { @@ -180,6 +203,7 @@ export function runQuery(formData, force = false, timeout = 60, key) { has_extra_filters: formData.extra_filters && formData.extra_filters.length > 0, viz_type: formData.viz_type, }); + // TODO: this is where we update data return dispatch(chartUpdateSucceeded(json, key)); }) .catch((response) => { diff --git a/superset/assets/src/explore/controlPanels/Line.js b/superset/assets/src/explore/controlPanels/Line.js index cbb2341a72..c40c773c8b 100644 --- a/superset/assets/src/explore/controlPanels/Line.js +++ b/superset/assets/src/explore/controlPanels/Line.js @@ -1,6 +1,7 @@ import { t } from '@superset-ui/translation'; import { NVD3TimeSeries, annotations } from './sections'; import { D3_TIME_FORMAT_OPTIONS } from '../controls'; +import forecastingSection from '../../forecasting/sections'; export default { requiresTime: true, @@ -36,6 +37,7 @@ export default { }, NVD3TimeSeries[1], annotations, + forecastingSection, ], controlOverrides: { x_axis_format: { diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx index d34fc3653c..d23bae2fdd 100644 --- a/superset/assets/src/explore/controls.jsx +++ b/superset/assets/src/explore/controls.jsx @@ -52,6 +52,8 @@ import { defaultViewport } from '../modules/geo'; import ColumnOption from '../components/ColumnOption'; import OptionDescription from '../components/OptionDescription'; +import forecastingControls from '../forecasting/controls'; + const categoricalSchemeRegistry = getCategoricalSchemeRegistry(); const sequentialSchemeRegistry = getSequentialSchemeRegistry(); @@ -2281,5 +2283,8 @@ export const controls = { description: t('Whether to normalize the histogram'), default: false, }, + + ...forecastingControls, + }; export default controls; diff --git a/superset/assets/src/forecasting/client.js b/superset/assets/src/forecasting/client.js new file mode 100644 index 0000000000..e6761274bc --- /dev/null +++ b/superset/assets/src/forecasting/client.js @@ -0,0 +1,60 @@ +import delphiReponse from './delphi-response'; + +const forecastingSeries = [ + 'forecasting:forecast', + 'forecasting:lower', + 'forecasting:upper', +]; + +/** + * Validates forecasting flags and if conditions are met it will query delphi + * @param response + * @returns {Promise<{[p: string]: *}>} + */ +export const mutator = (response) => { + const { form_data: formData = {}, data = [] } = response; + + // we only perform forecasting on the first series + const series = data[0]; + let newData = [...data]; + + if (series && formData.forecasting_enable) { + const { values } = series; + if (values.length > 0) { + const { forecasting_horizon: forecastingHorizon = 1 } = formData; + + const lastActualSeriesPoint = series.values[series.values.length - 1]; + // create forecasting series placeholder values + // we are generating new series for forecasting + newData = forecastingSeries.reduce((allSeries, key) => [ + ...allSeries, + { + key, + values: values.map(({ x }, index) => ({ + x, + y: index === values.length - 1 ? lastActualSeriesPoint.y : null, + })), + }, + ], newData); + + const forecastingData = delphiReponse.data.slice(0, forecastingHorizon); + + // for each series create a fake value having the same value as the previous one + newData = newData.map(track => ({ + key: track.key, + values: [ + ...track.values, + ...forecastingData.map(v => ({ + x: Date.parse(v.Datetime), + y: track.key.includes('forecasting') ? v[track.key] : null, + })), + ], + })); + } + } + + return Promise.resolve({ + ...response, + data: newData, + }); +}; diff --git a/superset/assets/src/forecasting/controls.js b/superset/assets/src/forecasting/controls.js new file mode 100644 index 0000000000..f1e08975c0 --- /dev/null +++ b/superset/assets/src/forecasting/controls.js @@ -0,0 +1,36 @@ +import { t } from '@superset-ui/translation'; +import * as v from '../explore/validators'; + +export default { + forecasting_enable: { + type: 'CheckboxControl', + label: t('Enable forecasting'), + renderTrigger: false, + description: t('Enable forecasting for the current data'), + default: false, + }, + + forecasting_horizon: { + type: 'SliderControl', + isInt: true, + validators: [v.integer, v.nonEmpty], + renderTrigger: false, + min: 1, + max: 6, + label: t('Horizon'), + description: t('Forecasting horizon step'), + mapStateToProps: state => state, + }, + + forecasting_interval: { + type: 'SliderControl', + isInt: true, + validators: [v.integer, v.nonEmpty], + renderTrigger: false, + min: 1, + max: 99, + default: 80, + label: t('Confidence %'), + description: t('Forecasting horizon confidence in %'), + }, +}; diff --git a/superset/assets/src/forecasting/delphi-response.js b/superset/assets/src/forecasting/delphi-response.js new file mode 100644 index 0000000000..6d3ef58523 --- /dev/null +++ b/superset/assets/src/forecasting/delphi-response.js @@ -0,0 +1,40 @@ +export default { + data: [ + { + Datetime: '2015-10-01T07:00:00Z', + 'forecasting:forecast': 32.47064841167762, + 'forecasting:lower': 19.888155906968947, + 'forecasting:upper': 45.05314091638631, + }, + { + Datetime: '2015-10-02T07:00:00Z', + 'forecasting:forecast': 35.43333238960573, + 'forecasting:lower': 18.88316130982956, + 'forecasting:upper': 51.9835034693819, + }, + { + Datetime: '2015-10-03T07:00:00Z', + 'forecasting:forecast': 32.47064841167762, + 'forecasting:lower': 27.060319880393337, + 'forecasting:upper': 69.68848554118834, + }, + { + Datetime: '2015-10-04T07:00:00Z', + 'forecasting:forecast': 43.26449069170808, + 'forecasting:lower': 16.947618678010087, + 'forecasting:upper': 69.58136270540608, + }, + { + Datetime: '2015-10-04T22:00:00Z', + 'forecasting:forecast': 37.50254738920206, + 'forecasting:lower': 5.136441614219757, + 'forecasting:upper': 69.86865316418437, + }, + { + Datetime: '2015-10-04T07:00:00Z', + 'forecasting:forecast': 42.617215165808275, + 'forecasting:lower': 3.4214691866050586, + 'forecasting:upper': 81.81296114501151, + }, + ], +}; diff --git a/superset/assets/src/forecasting/sections.js b/superset/assets/src/forecasting/sections.js new file mode 100644 index 0000000000..ccdf4edd06 --- /dev/null +++ b/superset/assets/src/forecasting/sections.js @@ -0,0 +1,11 @@ +import { t } from '@superset-ui/translation'; + +export default { + label: t('Forecasting options'), + expanded: false, + controlSetRows: [ + ['forecasting_enable'], + ['forecasting_horizon'], + ['forecasting_interval'], + ], +}; diff --git a/superset/assets/src/welcome/Welcome.jsx b/superset/assets/src/welcome/Welcome.jsx index d059ee1113..f71690fbdf 100644 --- a/superset/assets/src/welcome/Welcome.jsx +++ b/superset/assets/src/welcome/Welcome.jsx @@ -23,7 +23,7 @@ export default class Welcome extends React.PureComponent { } render() { return ( - <div className="container welcome"> + <div className="container test welcome"> <Tabs defaultActiveKey={1} id="uncontrolled-tab-example"> <Tab eventKey={1} title={t('Dashboards')}> <Panel> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
