From 7acc015aad3b51e5e7fc476ab4ce64abfe02b881 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Wed, 6 May 2020 12:45:54 -0700 Subject: [PATCH] feat(plugin-chart-sunburst): migrate control panel from incubator-superset (#443) * chore: pulling in controls from incubator-superset * style: adding extension to make eslint happy * un-bumping version * style: removing .ts, ignoring lint warning --- .../legacy-plugin-chart-sunburst/package.json | 3 +- .../src/controlPanel.ts | 59 +++++++++++++++++++ .../legacy-plugin-chart-sunburst/src/index.js | 3 + 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/controlPanel.ts diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/package.json b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/package.json index ff6b0691e8fe..ac6d4c89ea38 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/package.json @@ -35,6 +35,7 @@ "@superset-ui/chart": "^0.13.0", "@superset-ui/color": "^0.13.0", "@superset-ui/number-format": "^0.13.0", - "@superset-ui/translation": "^0.13.0" + "@superset-ui/translation": "^0.13.0", + "@superset-ui/control-utils": "^0.13.0" } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/controlPanel.ts new file mode 100644 index 000000000000..006cbaa2d8fe --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/controlPanel.ts @@ -0,0 +1,59 @@ +/** + * 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'; + +export default { + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['groupby'], + ['metric'], + ['secondary_metric'], + ['adhoc_filters'], + ['row_limit'], + ], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [['color_scheme', 'label_colors']], + }, + ], + controlOverrides: { + metric: { + label: t('Primary Metric'), + description: t('The primary metric is used to define the arc segment sizes'), + }, + secondary_metric: { + label: t('Secondary Metric'), + default: null, + description: t( + '[optional] this secondary metric is used to ' + + 'define the color as a ratio against the primary metric. ' + + 'When omitted, the color is categorical and based on labels', + ), + }, + groupby: { + label: t('Hierarchy'), + description: t('This defines the level of the hierarchy'), + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/index.js index 8a66c2bde4c5..7e356233d96f 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-plugin-chart-sunburst/src/index.js @@ -20,6 +20,8 @@ import { t } from '@superset-ui/translation'; import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import transformProps from './transformProps'; import thumbnail from './images/thumbnail.png'; +// eslint-disable-next-line import/extensions +import controlPanel from './controlPanel'; const metadata = new ChartMetadata({ credits: ['https://bl.ocks.org/kerryrodden/7090426'], @@ -35,6 +37,7 @@ export default class SunburstChartPlugin extends ChartPlugin { loadChart: () => import('./ReactSunburst.js'), metadata, transformProps, + controlPanel, }); } }