Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reviewable] [refactor] Split visTypes into one file for each visualization type #6290

Merged
merged 7 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { connect } from 'react-redux';
import { Alert, Tab, Tabs } from 'react-bootstrap';
import { t } from '@superset-ui/translation';

import visTypes, { sectionsToRender } from '../visTypes';
import controlPanelConfigs, { sectionsToRender } from '../controlPanels';
import ControlPanelSection from './ControlPanelSection';
import ControlRow from './ControlRow';
import Control from './Control';
Expand Down Expand Up @@ -40,7 +40,8 @@ class ControlPanelsContainer extends React.Component {
let mapF = controls[controlName].mapStateToProps;

// Looking to find mapStateToProps override for this viz type
const controlOverrides = visTypes[this.props.controls.viz_type.value].controlOverrides || {};
const config = controlPanelConfigs[this.props.controls.viz_type.value].controlOverrides;
const controlOverrides = config || {};
if (controlOverrides[controlName] && controlOverrides[controlName].mapStateToProps) {
mapF = controlOverrides[controlName].mapStateToProps;
}
Expand Down
48 changes: 48 additions & 0 deletions superset/assets/src/explore/controlPanels/Area.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { t } from '@superset-ui/translation';
import { NVD3TimeSeries, annotations } from './sections';
import { D3_TIME_FORMAT_OPTIONS } from '../controls';

export default {
requiresTime: true,
controlPanelSections: [
NVD3TimeSeries[0],
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['show_brush', 'show_legend'],
['line_interpolation', 'stacked_style'],
['color_scheme'],
['rich_tooltip', 'show_controls'],
],
},
{
label: t('X Axis'),
expanded: true,
controlSetRows: [
['x_axis_label', 'bottom_margin'],
['x_ticks_layout', 'x_axis_format'],
['x_axis_showminmax', null],
],
},
{
label: t('Y Axis'),
expanded: true,
controlSetRows: [
['y_axis_format', 'y_axis_bounds'],
['y_log_scale', null],
],
},
NVD3TimeSeries[1],
annotations,
],
controlOverrides: {
x_axis_format: {
default: 'smart_date',
choices: D3_TIME_FORMAT_OPTIONS,
},
color_scheme: {
renderTrigger: false,
},
},
};
47 changes: 47 additions & 0 deletions superset/assets/src/explore/controlPanels/Bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { t } from '@superset-ui/translation';
import { NVD3TimeSeries, annotations } from './sections';
import { D3_TIME_FORMAT_OPTIONS } from '../controls';

export default {
requiresTime: true,
controlPanelSections: [
NVD3TimeSeries[0],
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['color_scheme'],
['show_brush', 'show_legend', 'show_bar_value'],
['rich_tooltip', 'bar_stacked'],
['line_interpolation', 'show_controls'],
['bottom_margin'],
],
},
{
label: t('X Axis'),
expanded: true,
controlSetRows: [
['x_axis_label', 'bottom_margin'],
['x_ticks_layout', 'x_axis_format'],
['x_axis_showminmax', 'reduce_x_ticks'],
],
},
{
label: t('Y Axis'),
expanded: true,
controlSetRows: [
['y_axis_label', 'left_margin'],
['y_axis_showminmax', 'y_log_scale'],
['y_axis_format', 'y_axis_bounds'],
],
},
NVD3TimeSeries[1],
annotations,
],
controlOverrides: {
x_axis_format: {
choices: D3_TIME_FORMAT_OPTIONS,
default: 'smart_date',
},
},
};
29 changes: 29 additions & 0 deletions superset/assets/src/explore/controlPanels/BigNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { t } from '@superset-ui/translation';

export default {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['metric'],
['adhoc_filters'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['compare_lag', 'compare_suffix'],
['y_axis_format', null],
['show_trend_line', 'start_y_axis_at_zero'],
['color_picker', null],
],
},
],
controlOverrides: {
y_axis_format: {
label: t('Number format'),
},
},
};
27 changes: 27 additions & 0 deletions superset/assets/src/explore/controlPanels/BigNumberTotal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { t } from '@superset-ui/translation';

export default {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['metric'],
['adhoc_filters'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['subheader'],
['y_axis_format'],
],
},
],
controlOverrides: {
y_axis_format: {
label: t('Number format'),
},
},
};
24 changes: 24 additions & 0 deletions superset/assets/src/explore/controlPanels/BoxPlot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { t } from '@superset-ui/translation';

export default {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['metrics'],
['adhoc_filters'],
['groupby'],
['limit'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['color_scheme'],
['whisker_options'],
],
},
],
};
54 changes: 54 additions & 0 deletions superset/assets/src/explore/controlPanels/Bubble.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { t } from '@superset-ui/translation';

export default {
label: t('Bubble Chart'),
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['series', 'entity'],
['x'],
['y'],
['adhoc_filters'],
['size'],
['max_bubble_size'],
['limit', null],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['color_scheme'],
['show_legend', null],
],
},
{
label: t('X Axis'),
expanded: true,
controlSetRows: [
['x_axis_label', 'left_margin'],
['x_axis_format', 'x_ticks_layout'],
['x_log_scale', 'x_axis_showminmax'],
],
},
{
label: t('Y Axis'),
expanded: true,
controlSetRows: [
['y_axis_label', 'bottom_margin'],
['y_axis_format', null],
['y_log_scale', 'y_axis_showminmax'],
],
},
],
controlOverrides: {
x_axis_format: {
default: '.3s',
},
color_scheme: {
renderTrigger: false,
},
},
};
25 changes: 25 additions & 0 deletions superset/assets/src/explore/controlPanels/Bullet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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: [
['metric'],
['ranges', 'range_labels'],
['markers', 'marker_labels'],
['marker_lines', 'marker_line_labels'],
],
},
],
};
39 changes: 39 additions & 0 deletions superset/assets/src/explore/controlPanels/CalHeatmap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { t } from '@superset-ui/translation';

export default {
requiresTime: true,
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['domain_granularity', 'subdomain_granularity'],
['metrics'],
['adhoc_filters'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['linear_color_scheme'],
['cell_size', 'cell_padding'],
['cell_radius', 'steps'],
['y_axis_format', 'x_axis_time_format'],
['show_legend', 'show_values'],
['show_metric_name', null],
],
},
],
controlOverrides: {
y_axis_format: {
label: t('Number Format'),
},
x_axis_time_format: {
label: t('Time Format'),
},
show_values: {
default: false,
},
},
};
44 changes: 44 additions & 0 deletions superset/assets/src/explore/controlPanels/Chord.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { t } from '@superset-ui/translation';
import { nonEmpty } from '../validators';

export default {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
['groupby'],
['columns'],
['metric'],
['adhoc_filters'],
['row_limit'],
],
},
{
label: t('Chart Options'),
expanded: true,
controlSetRows: [
['y_axis_format', null],
['color_scheme'],
],
},
],
controlOverrides: {
y_axis_format: {
label: t('Number format'),
description: t('Choose a number format'),
},
groupby: {
label: t('Source'),
multi: false,
validators: [nonEmpty],
description: t('Choose a source'),
},
columns: {
label: t('Target'),
multi: false,
validators: [nonEmpty],
description: t('Choose a target'),
},
},
};
Loading