From 3102d932834e55fc982e6643e85c80f9be4e66c2 Mon Sep 17 00:00:00 2001 From: David Aaron Suddjian <1858430+suddjian@users.noreply.github.com> Date: Thu, 7 May 2020 21:25:55 -0700 Subject: [PATCH] feat(plugin-chart-world-map): add control panel (#462) --- .../package.json | 1 + .../src/controlPanel.js | 99 +++++++++++++++++++ .../src/index.js | 2 + 3 files changed, 102 insertions(+) create mode 100644 superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/controlPanel.js diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/package.json b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/package.json index f82e7635767a..38729446276d 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/package.json @@ -34,6 +34,7 @@ }, "peerDependencies": { "@superset-ui/chart": "^0.13.0", + "@superset-ui/control-utils": "^0.13.9", "@superset-ui/number-format": "^0.13.0", "@superset-ui/translation": "^0.13.0" } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/controlPanel.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/controlPanel.js new file mode 100644 index 000000000000..607403f930a2 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/controlPanel.js @@ -0,0 +1,99 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { t } from '@superset-ui/translation'; +import { formatSelectOptions } from '@superset-ui/control-utils'; + +export default { + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['entity'], + [ + { + name: 'country_fieldtype', + config: { + type: 'SelectControl', + label: t('Country Field Type'), + default: 'cca2', + choices: [ + ['name', 'Full name'], + ['cioc', 'code International Olympic Committee (cioc)'], + ['cca2', 'code ISO 3166-1 alpha-2 (cca2)'], + ['cca3', 'code ISO 3166-1 alpha-3 (cca3)'], + ], + description: t( + 'The country code standard that Superset should expect ' + + 'to find in the [country] column', + ), + }, + }, + ], + ['metric'], + ['adhoc_filters'], + ['row_limit'], + ], + }, + { + label: t('Bubbles'), + controlSetRows: [ + [ + { + name: 'show_bubbles', + config: { + type: 'CheckboxControl', + label: t('Show Bubbles'), + default: false, + renderTrigger: true, + description: t('Whether to display bubbles on top of countries'), + }, + }, + ], + ['secondary_metric'], + [ + { + name: 'max_bubble_size', + config: { + type: 'SelectControl', + freeForm: true, + label: t('Max Bubble Size'), + default: '25', + choices: formatSelectOptions(['5', '10', '15', '25', '50', '75', '100']), + }, + }, + ], + ], + }, + ], + controlOverrides: { + entity: { + label: t('Country Control'), + description: t('3 letter code of the country'), + }, + metric: { + label: t('Metric for color'), + description: t('Metric that defines the color of the country'), + }, + secondary_metric: { + label: t('Bubble size'), + description: t('Metric that defines the size of the bubble'), + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/index.js index c9a13fa87454..cb1ffdf10d61 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-world-map/src/index.js @@ -20,6 +20,7 @@ import { t } from '@superset-ui/translation'; import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import transformProps from './transformProps'; import thumbnail from './images/thumbnail.png'; +import controlPanel from './controlPanel'; const metadata = new ChartMetadata({ credits: ['http://datamaps.github.io/'], @@ -35,6 +36,7 @@ export default class WorldMapChartPlugin extends ChartPlugin { loadChart: () => import('./ReactWorldMap.js'), metadata, transformProps, + controlPanel, }); } }