diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f928e052d6f5..8e4f0352801d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1089,7 +1089,6 @@ Note the `y_axis_format` is defined under various section for some charts. | `autozoom` | _N/A_ | | | `bar_stacked` | _N/A_ | | | `cache_timeout` | _N/A_ | | -| `clustering_radius` | _N/A_ | | | `code` | _N/A_ | | | `collapsed_fieldsets` | _N/A_ | | | `column_collection` | _N/A_ | | @@ -1135,7 +1134,6 @@ Note the `y_axis_format` is defined under various section for some charts. | `line_width` | _N/A_ | | | `linear_color_scheme` | _N/A_ | | | `log_scale` | _N/A_ | | -| `mapbox_color` | _N/A_ | | | `mapbox_label` | _N/A_ | | | `mapbox_style` | _N/A_ | | | `marker_labels` | _N/A_ | | @@ -1159,9 +1157,7 @@ Note the `y_axis_format` is defined under various section for some charts. | `partition_threshold` | _N/A_ | | | `period_ratio_type` | _N/A_ | | | `perm` | _N/A_ | | -| `point_radius` | _N/A_ | | | `point_radius_fixed` | _N/A_ | | -| `point_radius_unit` | _N/A_ | | | `point_unit` | _N/A_ | | | `prefix_metric_with_slice_name` | _N/A_ | | | `range_labels` | _N/A_ | | @@ -1170,7 +1166,6 @@ Note the `y_axis_format` is defined under various section for some charts. | `reduce_x_ticks` | _N/A_ | | | `refresh_frequency` | _N/A_ | | | `remote_id` | _N/A_ | | -| `render_while_dragging` | _N/A_ | | | `resample_fillmethod` | _N/A_ | | | `resample_how` | _N/A_ | | | `resample_method` | _N/A_ | | @@ -1211,6 +1206,4 @@ Note the `y_axis_format` is defined under various section for some charts. | `url` | _N/A_ | | | `userid` | _N/A_ | | | `viewport` | _N/A_ | | -| `viewport_latitude` | _N/A_ | | -| `viewport_longitude` | _N/A_ | | | `viewport_zoom` | _N/A_ | | diff --git a/superset-frontend/src/explore/controlPanels/Mapbox.js b/superset-frontend/src/explore/controlPanels/Mapbox.js index f2e4d080d5e8..46b6385707cf 100644 --- a/superset-frontend/src/explore/controlPanels/Mapbox.js +++ b/superset-frontend/src/explore/controlPanels/Mapbox.js @@ -17,6 +17,8 @@ * under the License. */ import { t } from '@superset-ui/translation'; +import { formatSelectOptions } from '../../modules/utils'; +import { columnChoices } from '../controls'; export default { controlPanelSections: [ @@ -25,7 +27,33 @@ export default { expanded: true, controlSetRows: [ ['all_columns_x', 'all_columns_y'], - ['clustering_radius'], + [ + { + name: 'clustering_radius', + config: { + type: 'SelectControl', + freeForm: true, + label: t('Clustering Radius'), + default: '60', + choices: formatSelectOptions([ + '0', + '20', + '40', + '60', + '80', + '100', + '200', + '500', + '1000', + ]), + description: t( + 'The radius (in pixels) the algorithm uses to define a cluster. ' + + 'Choose 0 to turn off clustering, but beware that a large ' + + 'number of points (>1000) will cause lag.', + ), + }, + }, + ], ['row_limit'], ['adhoc_filters'], ['groupby'], @@ -33,7 +61,42 @@ export default { }, { label: t('Points'), - controlSetRows: [['point_radius'], ['point_radius_unit']], + controlSetRows: [ + [ + { + name: 'point_radius', + config: { + type: 'SelectControl', + label: t('Point Radius'), + default: 'Auto', + description: t( + 'The radius of individual points (ones that are not in a cluster). ' + + 'Either a numerical column or `Auto`, which scales the point based ' + + 'on the largest cluster', + ), + mapStateToProps: state => ({ + choices: formatSelectOptions(['Auto']).concat( + columnChoices(state.datasource), + ), + }), + }, + }, + ], + [ + { + name: 'point_radius_unit', + config: { + type: 'SelectControl', + label: t('Point Radius Unit'), + default: 'Pixels', + choices: formatSelectOptions(['Pixels', 'Miles', 'Kilometers']), + description: t( + 'The unit of measure for the specified point radius', + ), + }, + }, + ], + ], }, { label: t('Labelling'), @@ -42,18 +105,94 @@ export default { { label: t('Visual Tweaks'), controlSetRows: [ - ['render_while_dragging'], + [ + { + name: 'render_while_dragging', + config: { + type: 'CheckboxControl', + label: t('Live render'), + default: true, + description: t( + 'Points and clusters will update as the viewport is being changed', + ), + }, + }, + ], ['mapbox_style'], ['global_opacity'], - ['mapbox_color'], + [ + { + name: 'mapbox_color', + config: { + type: 'SelectControl', + freeForm: true, + label: t('RGB Color'), + default: 'rgb(0, 122, 135)', + choices: [ + ['rgb(0, 139, 139)', 'Dark Cyan'], + ['rgb(128, 0, 128)', 'Purple'], + ['rgb(255, 215, 0)', 'Gold'], + ['rgb(69, 69, 69)', 'Dim Gray'], + ['rgb(220, 20, 60)', 'Crimson'], + ['rgb(34, 139, 34)', 'Forest Green'], + ], + description: t('The color for points and clusters in RGB'), + }, + }, + ], ], }, { label: t('Viewport'), expanded: true, controlSetRows: [ - ['viewport_longitude', 'viewport_latitude'], - ['viewport_zoom', null], + [ + { + name: 'viewport_longitude', + config: { + type: 'TextControl', + label: t('Default longitude'), + renderTrigger: true, + default: -122.405293, + isFloat: true, + description: t('Longitude of default viewport'), + places: 8, + // Viewport longitude changes shouldn't prompt user to re-run query + dontRefreshOnChange: true, + }, + }, + { + name: 'viewport_latitude', + config: { + type: 'TextControl', + label: t('Default latitude'), + renderTrigger: true, + default: 37.772123, + isFloat: true, + description: t('Latitude of default viewport'), + places: 8, + // Viewport latitude changes shouldn't prompt user to re-run query + dontRefreshOnChange: true, + }, + }, + ], + [ + { + name: 'viewport_zoom', + config: { + type: 'TextControl', + label: t('Zoom'), + renderTrigger: true, + isFloat: true, + default: 11, + description: t('Zoom level of the map'), + places: 8, + // Viewport zoom shouldn't prompt user to re-run query + dontRefreshOnChange: true, + }, + }, + null, + ], ], }, ], diff --git a/superset-frontend/src/explore/controls.jsx b/superset-frontend/src/explore/controls.jsx index 4deea5edd07d..b463d687200f 100644 --- a/superset-frontend/src/explore/controls.jsx +++ b/superset-frontend/src/explore/controls.jsx @@ -191,7 +191,7 @@ const jsFunctionInfo = ( ); -function columnChoices(datasource) { +export function columnChoices(datasource) { if (datasource && datasource.columns) { return datasource.columns .map(col => [col.column_name, col.verbose_name || col.column_name]) @@ -1612,29 +1612,6 @@ export const controls = { description: t('Base layer map style'), }, - clustering_radius: { - type: 'SelectControl', - freeForm: true, - label: t('Clustering Radius'), - default: '60', - choices: formatSelectOptions([ - '0', - '20', - '40', - '60', - '80', - '100', - '200', - '500', - '1000', - ]), - description: t( - 'The radius (in pixels) the algorithm uses to define a cluster. ' + - 'Choose 0 to turn off clustering, but beware that a large ' + - 'number of points (>1000) will cause lag.', - ), - }, - point_radius_fixed: { type: 'FixedOrMetricControl', label: t('Point Size'), @@ -1645,30 +1622,6 @@ export const controls = { }), }, - point_radius: { - type: 'SelectControl', - label: t('Point Radius'), - default: 'Auto', - description: t( - 'The radius of individual points (ones that are not in a cluster). ' + - 'Either a numerical column or `Auto`, which scales the point based ' + - 'on the largest cluster', - ), - mapStateToProps: state => ({ - choices: formatSelectOptions(['Auto']).concat( - columnChoices(state.datasource), - ), - }), - }, - - point_radius_unit: { - type: 'SelectControl', - label: t('Point Radius Unit'), - default: 'Pixels', - choices: formatSelectOptions(['Pixels', 'Miles', 'Kilometers']), - description: t('The unit of measure for the specified point radius'), - }, - point_unit: { type: 'SelectControl', label: t('Point Unit'), @@ -1729,55 +1682,6 @@ export const controls = { dontRefreshOnChange: true, }, - viewport_latitude: { - type: 'TextControl', - label: t('Default latitude'), - renderTrigger: true, - default: 37.772123, - isFloat: true, - description: t('Latitude of default viewport'), - places: 8, - // Viewport latitude changes shouldn't prompt user to re-run query - dontRefreshOnChange: true, - }, - - viewport_longitude: { - type: 'TextControl', - label: t('Default longitude'), - renderTrigger: true, - default: -122.405293, - isFloat: true, - description: t('Longitude of default viewport'), - places: 8, - // Viewport longitude changes shouldn't prompt user to re-run query - dontRefreshOnChange: true, - }, - - render_while_dragging: { - type: 'CheckboxControl', - label: t('Live render'), - default: true, - description: t( - 'Points and clusters will update as the viewport is being changed', - ), - }, - - mapbox_color: { - type: 'SelectControl', - freeForm: true, - label: t('RGB Color'), - default: 'rgb(0, 122, 135)', - choices: [ - ['rgb(0, 139, 139)', 'Dark Cyan'], - ['rgb(128, 0, 128)', 'Purple'], - ['rgb(255, 215, 0)', 'Gold'], - ['rgb(69, 69, 69)', 'Dim Gray'], - ['rgb(220, 20, 60)', 'Crimson'], - ['rgb(34, 139, 34)', 'Forest Green'], - ], - description: t('The color for points and clusters in RGB'), - }, - color: { type: 'ColorPickerControl', label: t('Color'),