diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/package.json b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/package.json index 6979b8db28c1..f1cd8a52af9a 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/package.json @@ -43,7 +43,7 @@ "peerDependencies": { "@superset-ui/chart": "^0.13.0", "@superset-ui/color": "^0.13.0", - "@superset-ui/control-utils": "^0.13.0", + "@superset-ui/control-utils": "^0.13.9", "@superset-ui/core": "^0.13.0", "@superset-ui/dimension": "^0.13.0", "@superset-ui/number-format": "^0.13.0", diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/controlPanel.ts new file mode 100644 index 000000000000..eb0c7f7c81ef --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/controlPanel.ts @@ -0,0 +1,101 @@ +/** + * 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 { sections } from '@superset-ui/control-utils'; +import { + lineInterpolation, + showBrush, + showLegend, + showControls, + xAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + yLogScale, + yAxisBounds, + xAxisShowMinmax, + richTooltip, + timeSeriesSection, +} from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + timeSeriesSection[0], + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + [showBrush, showLegend], + [ + lineInterpolation, + { + name: 'stacked_style', + config: { + type: 'SelectControl', + label: t('Stacked Style'), + renderTrigger: true, + choices: [ + ['stack', 'stack'], + ['stream', 'stream'], + ['expand', 'expand'], + ], + default: 'stack', + description: '', + }, + }, + ], + ['color_scheme', 'label_colors'], + [richTooltip, showControls], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, xAxisFormat], + [xAxisShowMinmax, null], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + ['y_axis_format', yAxisBounds], + [yLogScale, null], + ], + }, + timeSeriesSection[1], + sections.annotations, + ], + controlOverrides: { + color_scheme: { + renderTrigger: false, + }, + }, + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/index.js index e0201c5c3b76..4bd50ea2c533 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Area/index.js @@ -21,6 +21,7 @@ import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import transformProps from '../transformProps'; import thumbnail from './images/thumbnail.png'; import { ANNOTATION_TYPES } from '../vendor/superset/AnnotationTypes'; +import controlPanel from './controlPanel.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -37,6 +38,7 @@ export default class AreaChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/controlPanel.ts new file mode 100644 index 000000000000..9413acdd5a35 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/controlPanel.ts @@ -0,0 +1,87 @@ +/** + * 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 { sections } from '@superset-ui/control-utils'; +import { + lineInterpolation, + showBrush, + showLegend, + showControls, + xAxisLabel, + yAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + yLogScale, + yAxisBounds, + xAxisShowMinmax, + yAxisShowMinmax, + richTooltip, + showBarValue, + barStacked, + reduceXTicks, + leftMargin, + timeSeriesSection, +} from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + timeSeriesSection[0], + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + ['color_scheme', 'label_colors'], + [showBrush, showLegend, showBarValue], + [richTooltip, barStacked], + [lineInterpolation, showControls], + [bottomMargin], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, xAxisFormat], + [xAxisShowMinmax, reduceXTicks], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + [yAxisLabel, leftMargin], + [yAxisShowMinmax, yLogScale], + ['y_axis_format', yAxisBounds], + ], + }, + timeSeriesSection[1], + sections.annotations, + ], + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/index.js index 44ac24c2cbc9..cc4c8b5d7184 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bar/index.js @@ -21,6 +21,7 @@ import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import transformProps from '../transformProps'; import thumbnail from './images/thumbnail.png'; import { ANNOTATION_TYPES } from '../vendor/superset/AnnotationTypes'; +import controlPanel from './controlPanel.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -37,6 +38,7 @@ export default class BarChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/controlPanel.ts new file mode 100644 index 000000000000..abbce843c508 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/controlPanel.ts @@ -0,0 +1,115 @@ +/** + * 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 { D3_FORMAT_OPTIONS, formatSelectOptions } from '@superset-ui/control-utils'; +import { + showLegend, + xAxisLabel, + yAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + yLogScale, + xAxisShowMinmax, + yAxisShowMinmax, + leftMargin, +} from '../NVD3Controls'; + +export default { + label: t('Bubble Chart'), + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['series', 'entity'], + ['x'], + ['y'], + ['adhoc_filters'], + ['size'], + [ + { + 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']), + }, + }, + ], + ['limit', null], + ], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + ['color_scheme', 'label_colors'], + [showLegend, null], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, leftMargin], + [ + { + name: xAxisFormat.name, + config: { + ...xAxisFormat.config, + default: 'SMART_NUMBER', + choices: D3_FORMAT_OPTIONS, + }, + }, + xTicksLayout, + ], + [ + { + name: 'x_log_scale', + config: { + type: 'CheckboxControl', + label: t('X Log Scale'), + default: false, + renderTrigger: true, + description: t('Use a log scale for the X-axis'), + }, + }, + xAxisShowMinmax, + ], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + [yAxisLabel, bottomMargin], + ['y_axis_format', null], + [yLogScale, yAxisShowMinmax], + ], + }, + ], + controlOverrides: { + color_scheme: { + renderTrigger: false, + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js index c0d13ccfd9c4..4c494bd0c8e9 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bubble/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class BubbleChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/controlPanel.ts new file mode 100644 index 000000000000..33281d13b669 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/controlPanel.ts @@ -0,0 +1,96 @@ +/** + * 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 { + requiresTime: false, + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [['metric'], ['adhoc_filters']], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + [ + { + name: 'ranges', + config: { + type: 'TextControl', + label: t('Ranges'), + default: '', + description: t('Ranges to highlight with shading'), + }, + }, + { + name: 'range_labels', + config: { + type: 'TextControl', + label: t('Range labels'), + default: '', + description: t('Labels for the ranges'), + }, + }, + ], + [ + { + name: 'markers', + config: { + type: 'TextControl', + label: t('Markers'), + default: '', + description: t('List of values to mark with triangles'), + }, + }, + { + name: 'marker_labels', + config: { + type: 'TextControl', + label: t('Marker labels'), + default: '', + description: t('Labels for the markers'), + }, + }, + ], + [ + { + name: 'marker_lines', + config: { + type: 'TextControl', + label: t('Marker lines'), + default: '', + description: t('List of values to mark with lines'), + }, + }, + { + name: 'marker_line_labels', + config: { + type: 'TextControl', + label: t('Marker line labels'), + default: '', + description: t('Labels for the marker lines'), + }, + }, + ], + ], + }, + ], +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/index.js index 6e4f40ae1c5f..2eb46dc5eda4 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Bullet/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class BulletChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/controlPanel.ts new file mode 100644 index 000000000000..d7f3a10edd45 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/controlPanel.ts @@ -0,0 +1,73 @@ +/** + * 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 { sections } from '@superset-ui/control-utils'; +import { + xAxisLabel, + yAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + yLogScale, + yAxisBounds, + xAxisShowMinmax, + yAxisShowMinmax, + leftMargin, + timeSeriesSection, +} from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + timeSeriesSection[0], + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [['color_scheme', 'label_colors']], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, xAxisFormat], + [xAxisShowMinmax, null], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + [yAxisLabel, leftMargin], + [yAxisShowMinmax, yLogScale], + ['y_axis_format', yAxisBounds], + ], + }, + timeSeriesSection[1], + sections.annotations, + ], + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/index.js index 344f138afa5b..fa1b400c25cb 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Compare/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class CompareChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts new file mode 100644 index 000000000000..3877a078b35f --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts @@ -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 { validateNonEmpty } from '@superset-ui/validator'; +import { + showLegend, + showControls, + xAxisLabel, + bottomMargin, + xTicksLayout, + showBarValue, + barStacked, + reduceXTicks, + yAxisLabel, +} from '../NVD3Controls'; + +export default { + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['metrics'], + ['adhoc_filters'], + ['groupby'], + ['columns'], + ['row_limit'], + [ + { + name: 'contribution', + config: { + type: 'CheckboxControl', + label: t('Contribution'), + default: false, + description: t('Compute the contribution to the total'), + }, + }, + ], + ], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + ['color_scheme', 'label_colors'], + [showLegend, showBarValue], + [ + barStacked, + { + name: 'order_bars', + config: { + type: 'CheckboxControl', + label: t('Sort Bars'), + default: false, + renderTrigger: true, + description: t('Sort bars by x labels.'), + }, + }, + ], + ['y_axis_format', yAxisLabel], + [showControls, null], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, reduceXTicks], + ], + }, + ], + controlOverrides: { + groupby: { + label: t('Series'), + validators: [validateNonEmpty], + }, + columns: { + label: t('Breakdowns'), + description: t('Defines how each series is broken down'), + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js index 9d7f318e36be..8a2753271dde 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DistBar/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class DistBarChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/controlPanel.ts new file mode 100644 index 000000000000..5a24b140a90f --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/controlPanel.ts @@ -0,0 +1,65 @@ +/** + * 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 { sections } from '@superset-ui/control-utils'; +import { xAxisFormat, yAxis2Format } from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [['color_scheme', 'label_colors'], [xAxisFormat]], + }, + { + label: t('Y Axis 1'), + expanded: true, + controlSetRows: [['metric', 'y_axis_format']], + }, + { + label: t('Y Axis 2'), + expanded: true, + controlSetRows: [['metric_2', yAxis2Format]], + }, + { + label: t('Query'), + expanded: true, + controlSetRows: [['adhoc_filters']], + }, + sections.annotations, + ], + controlOverrides: { + metric: { + label: t('Left Axis Metric'), + description: t('Choose a metric for left axis'), + }, + y_axis_format: { + label: t('Left Axis Format'), + }, + }, + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/index.js index 3cea0a57d1da..f230c7e17c8f 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/DualLine/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class DualLineChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/controlPanel.ts new file mode 100644 index 000000000000..6988973698dc --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/controlPanel.ts @@ -0,0 +1,101 @@ +/** + * 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 { sections } from '@superset-ui/control-utils'; +import { + lineInterpolation, + showBrush, + showLegend, + xAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + yLogScale, + yAxisBounds, + yAxisLabel, + xAxisShowMinmax, + yAxisShowMinmax, + richTooltip, + leftMargin, + showMarkers, + timeSeriesSection, +} from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + timeSeriesSection[0], + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + ['color_scheme', 'label_colors'], + [ + showBrush, + { + name: 'send_time_range', + config: { + type: 'CheckboxControl', + label: t('Propagate'), + renderTrigger: true, + default: false, + description: t('Send range filter events to other charts'), + }, + }, + showLegend, + ], + [richTooltip, showMarkers], + [lineInterpolation], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, xAxisFormat], + [xAxisShowMinmax, null], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + [yAxisLabel, leftMargin], + [yAxisShowMinmax, yLogScale], + ['y_axis_format', yAxisBounds], + ], + }, + timeSeriesSection[1], + sections.annotations, + ], + controlOverrides: { + row_limit: { + default: 50000, + }, + }, + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/index.js index be2f89f6b2ec..52cb40e34db8 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Line/index.js @@ -21,6 +21,7 @@ import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import transformProps from '../transformProps'; import thumbnail from './images/thumbnail.png'; import { ANNOTATION_TYPES } from '../vendor/superset/AnnotationTypes'; +import controlPanel from './controlPanel.ts'; const metadata = new ChartMetadata({ canBeAnnotationTypes: [ANNOTATION_TYPES.TIME_SERIES], @@ -43,6 +44,7 @@ export default class LineChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/controlPanel.ts new file mode 100644 index 000000000000..617762bc6285 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/controlPanel.ts @@ -0,0 +1,165 @@ +/* eslint-disable camelcase */ +/** + * 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 { validateNonEmpty } from '@superset-ui/validator'; +import { D3_TIME_FORMAT_OPTIONS, sections } from '@superset-ui/control-utils'; +import { + lineInterpolation, + showLegend, + xAxisLabel, + bottomMargin, + xTicksLayout, + xAxisFormat, + xAxisShowMinmax, + showMarkers, + yAxis2Format, +} from '../NVD3Controls'; + +export type Result = { + id: unknown; + slice_name: string; +}; + +export type Data = { + result?: Result[]; +}; + +export default { + requiresTime: true, + controlPanelSections: [ + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + ['color_scheme', 'label_colors'], + [ + { + name: 'prefix_metric_with_slice_name', + config: { + type: 'CheckboxControl', + label: t('Prefix metric name with slice name'), + default: false, + renderTrigger: true, + }, + }, + null, + ], + [showLegend, showMarkers], + [lineInterpolation, null], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [xTicksLayout, xAxisFormat], + [xAxisShowMinmax, null], + ], + }, + { + label: t('Y Axis 1'), + expanded: true, + controlSetRows: [ + [ + { + name: 'line_charts', + config: { + type: 'SelectAsyncControl', + multi: true, + label: t('Left Axis chart(s)'), + validators: [validateNonEmpty], + default: [], + description: t('Choose one or more charts for left axis'), + dataEndpoint: '/sliceasync/api/read?_flt_0_viz_type=line&_flt_7_viz_type=line_multi', + placeholder: t('Select charts'), + onAsyncErrorMessage: t('Error while fetching charts'), + mutator: (data?: Data) => { + if (!data || !data.result) { + return []; + } + return data.result.map(o => ({ + value: o.id, + label: o.slice_name, + })); + }, + }, + }, + 'y_axis_format', + ], + ], + }, + { + label: t('Y Axis 2'), + expanded: false, + controlSetRows: [ + [ + { + name: 'line_charts_2', + config: { + type: 'SelectAsyncControl', + multi: true, + label: t('Right Axis chart(s)'), + validators: [], + default: [], + description: t('Choose one or more charts for right axis'), + dataEndpoint: '/sliceasync/api/read?_flt_0_viz_type=line&_flt_7_viz_type=line_multi', + placeholder: t('Select charts'), + onAsyncErrorMessage: t('Error while fetching charts'), + mutator: (data: Data) => { + if (!data || !data.result) { + return []; + } + return data.result.map(o => ({ + value: o.id, + label: o.slice_name, + })); + }, + }, + }, + yAxis2Format, + ], + ], + }, + { + label: t('Query'), + expanded: true, + controlSetRows: [['adhoc_filters']], + }, + sections.annotations, + ], + controlOverrides: { + y_axis_format: { + label: t('Left Axis Format'), + }, + x_axis_format: { + choices: D3_TIME_FORMAT_OPTIONS, + default: 'smart_date', + }, + }, + sectionOverrides: { + sqlaTimeSeries: { + controlSetRows: [['time_range']], + }, + druidTimeSeries: { + controlSetRows: [['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/index.js index dfbf6662146e..ba642e8d620c 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/LineMulti/index.js @@ -19,6 +19,7 @@ import { t } from '@superset-ui/translation'; import { ChartMetadata, ChartPlugin } from '@superset-ui/chart'; import thumbnail from './images/thumbnail.png'; +import controlPanel from './controlPanel.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -33,6 +34,7 @@ export default class LineChartPlugin extends ChartPlugin { super({ loadChart: () => import('./LineMulti'), metadata, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/controlPanel.ts new file mode 100644 index 000000000000..970222897147 --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/controlPanel.ts @@ -0,0 +1,114 @@ +/** + * 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 { D3_FORMAT_OPTIONS } from '@superset-ui/control-utils'; +import { showLegend } from '../NVD3Controls'; + +export default { + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [['metric'], ['adhoc_filters'], ['groupby'], ['row_limit']], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + [ + { + name: 'pie_label_type', + config: { + type: 'SelectControl', + label: t('Label Type'), + default: 'key', + renderTrigger: true, + choices: [ + ['key', 'Category Name'], + ['value', 'Value'], + ['percent', 'Percentage'], + ['key_value', 'Category and Value'], + ['key_percent', 'Category and Percentage'], + ], + description: t('What should be shown on the label?'), + }, + }, + { + name: 'number_format', + config: { + type: 'SelectControl', + freeForm: true, + label: t('Number format'), + renderTrigger: true, + default: 'SMART_NUMBER', + choices: D3_FORMAT_OPTIONS, + description: `${t('D3 format syntax: https://github.com/d3/d3-format')} ${t( + 'Only applies when the "Label Type" is not set to a percentage.', + )}`, + }, + }, + ], + [ + { + name: 'donut', + config: { + type: 'CheckboxControl', + label: t('Donut'), + default: false, + renderTrigger: true, + description: t('Do you want a donut or a pie?'), + }, + }, + showLegend, + ], + [ + { + name: 'show_labels', + config: { + type: 'CheckboxControl', + label: t('Show Labels'), + renderTrigger: true, + default: true, + description: t( + 'Whether to display the labels. Note that the label only displays when the the 5% ' + + 'threshold.', + ), + }, + }, + { + name: 'labels_outside', + config: { + type: 'CheckboxControl', + label: t('Put labels outside'), + default: true, + renderTrigger: true, + description: t('Put the labels outside the pie?'), + }, + }, + ], + ['color_scheme', 'label_colors'], + ], + }, + ], + controlOverrides: { + row_limit: { + default: 25, + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/index.js index 83d3eb5f2b77..1c3da9ac175b 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/Pie/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class PieChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/controlPanel.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/controlPanel.ts new file mode 100644 index 000000000000..02503f70199e --- /dev/null +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/controlPanel.ts @@ -0,0 +1,125 @@ +/** + * 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 { D3_FORMAT_OPTIONS } from '@superset-ui/control-utils'; +import { + lineInterpolation, + showLegend, + xAxisLabel, + bottomMargin, + xAxisFormat, + yLogScale, + yAxisBounds, + xAxisShowMinmax, + yAxisShowMinmax, + yAxisLabel, + leftMargin, +} from '../NVD3Controls'; + +export default { + requiresTime: true, + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['metric'], + ['adhoc_filters'], + [ + { + name: 'freq', + config: { + type: 'SelectControl', + label: t('Frequency'), + default: 'W-MON', + freeForm: true, + clearable: false, + choices: [ + ['AS', 'Year (freq=AS)'], + ['52W-MON', '52 weeks starting Monday (freq=52W-MON)'], + ['W-SUN', '1 week starting Sunday (freq=W-SUN)'], + ['W-MON', '1 week starting Monday (freq=W-MON)'], + ['D', 'Day (freq=D)'], + ['4W-MON', '4 weeks (freq=4W-MON)'], + ], + description: t( + `The periodicity over which to pivot time. Users can provide + "Pandas" offset alias. + Click on the info bubble for more details on accepted "freq" expressions.`, + ), + tooltipOnClick: () => { + window.open( + 'https://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases', + ); + }, + }, + }, + ], + ], + }, + { + label: t('Chart Options'), + expanded: true, + controlSetRows: [ + [showLegend, lineInterpolation], + ['color_picker', null], + ], + }, + { + label: t('X Axis'), + expanded: true, + controlSetRows: [ + [xAxisLabel, bottomMargin], + [ + xAxisShowMinmax, + { + name: xAxisFormat.name, + config: { + ...xAxisFormat.config, + default: 'SMART_NUMBER', + choices: D3_FORMAT_OPTIONS, + }, + }, + ], + ], + }, + { + label: t('Y Axis'), + expanded: true, + controlSetRows: [ + [yAxisLabel, leftMargin], + [yAxisShowMinmax, yLogScale], + ['y_axis_format', yAxisBounds], + ], + }, + ], + controlOverrides: { + metric: { + clearable: false, + }, + }, + sectionOverrides: { + druidTimeSeries: { + controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']], + }, + sqlaTimeSeries: { + controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']], + }, + }, +}; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/index.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/index.js index de11d1c49235..76259ac967e0 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/legacy-preset-chart-nvd3/src/TimePivot/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.ts'; const metadata = new ChartMetadata({ credits: ['http://nvd3.org'], @@ -35,6 +36,7 @@ export default class TimePivotChartPlugin extends ChartPlugin { loadChart: () => import('../ReactNVD3'), metadata, transformProps, + controlPanel, }); } }