mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
Allowing to integrate time as a groupby value (#3229)
This commit is contained in:
committed by
GitHub
parent
91bd38a851
commit
4ea770068b
@@ -28,6 +28,36 @@ export const D3_TIME_FORMAT_OPTIONS = [
|
||||
['%H:%M:%S', '%H:%M:%S | 01:32:10'],
|
||||
];
|
||||
|
||||
const timeColumnOption = {
|
||||
verbose_name: 'Time',
|
||||
column_name: '__timestamp',
|
||||
description: (
|
||||
'A reference to the [Time] configuration, taking granularity into ' +
|
||||
'account'),
|
||||
};
|
||||
|
||||
const groupByControl = {
|
||||
type: 'SelectControl',
|
||||
multi: true,
|
||||
label: 'Group by',
|
||||
default: [],
|
||||
includeTime: false,
|
||||
description: 'One or many controls to group by',
|
||||
optionRenderer: c => <ColumnOption column={c} />,
|
||||
valueRenderer: c => <ColumnOption column={c} />,
|
||||
valueKey: 'column_name',
|
||||
mapStateToProps: (state, control) => {
|
||||
const newState = {};
|
||||
if (state.datasource) {
|
||||
newState.options = state.datasource.columns.filter(c => c.groupby);
|
||||
if (control && control.includeTime) {
|
||||
newState.options.push(timeColumnOption);
|
||||
}
|
||||
}
|
||||
return newState;
|
||||
},
|
||||
};
|
||||
|
||||
export const controls = {
|
||||
datasource: {
|
||||
type: 'DatasourceControl',
|
||||
@@ -323,33 +353,12 @@ export const controls = {
|
||||
'to find in the [country] column',
|
||||
},
|
||||
|
||||
groupby: {
|
||||
type: 'SelectControl',
|
||||
multi: true,
|
||||
label: 'Group by',
|
||||
default: [],
|
||||
description: 'One or many controls to group by',
|
||||
optionRenderer: c => <ColumnOption column={c} />,
|
||||
valueRenderer: c => <ColumnOption column={c} />,
|
||||
valueKey: 'column_name',
|
||||
mapStateToProps: state => ({
|
||||
options: (state.datasource) ? state.datasource.columns.filter(c => c.groupby) : [],
|
||||
}),
|
||||
},
|
||||
groupby: groupByControl,
|
||||
|
||||
columns: {
|
||||
type: 'SelectControl',
|
||||
multi: true,
|
||||
columns: Object.assign({}, groupByControl, {
|
||||
label: 'Columns',
|
||||
default: [],
|
||||
description: 'One or many controls to pivot as columns',
|
||||
optionRenderer: c => <ColumnOption column={c} />,
|
||||
valueRenderer: c => <ColumnOption column={c} />,
|
||||
valueKey: 'column_name',
|
||||
mapStateToProps: state => ({
|
||||
options: (state.datasource) ? state.datasource.columns : [],
|
||||
}),
|
||||
},
|
||||
}),
|
||||
|
||||
all_columns: {
|
||||
type: 'SelectControl',
|
||||
|
||||
Reference in New Issue
Block a user