Skip to content

Commit

Permalink
feat(legacy-plugin-chart-nvd3): add control panels (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian authored and zhaoyongjie committed Nov 26, 2021
1 parent 761b1d7 commit 8281ac9
Show file tree
Hide file tree
Showing 23 changed files with 1,164 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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']],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -37,6 +38,7 @@ export default class AreaChartPlugin extends ChartPlugin {
loadChart: () => import('../ReactNVD3'),
metadata,
transformProps,
controlPanel,
});
}
}
Original file line number Diff line number Diff line change
@@ -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']],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -37,6 +38,7 @@ export default class BarChartPlugin extends ChartPlugin {
loadChart: () => import('../ReactNVD3'),
metadata,
transformProps,
controlPanel,
});
}
}
Original file line number Diff line number Diff line change
@@ -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,
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -35,6 +36,7 @@ export default class BubbleChartPlugin extends ChartPlugin {
loadChart: () => import('../ReactNVD3'),
metadata,
transformProps,
controlPanel,
});
}
}

0 comments on commit 8281ac9

Please sign in to comment.