Skip to content

Commit

Permalink
[table] Allowing to show the time grain in table view
Browse files Browse the repository at this point in the history
Explicitely request to show the time grain in the table view as
a checkbox
  • Loading branch information
mistercrunch committed Feb 28, 2017
1 parent 675b819 commit e7edd63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions superset/assets/javascripts/explorev2/stores/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ export const controls = {
'displaying the Y scale',
},

include_time: {
type: 'CheckboxControl',
label: 'Include Time',
description: 'Whether to include the time granularity as defined in the time section',
default: false,
},

bar_stacked: {
type: 'CheckboxControl',
label: 'Stacked Bars',
Expand Down
4 changes: 4 additions & 0 deletions superset/assets/javascripts/explorev2/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const visTypes = {
description: 'Use this section if you want a query that aggregates',
controlSetRows: [
['groupby', 'metrics'],
['include_time'],
],
},
{
Expand All @@ -259,6 +260,9 @@ const visTypes = {
default: null,
validators: null,
},
time_grain_sqla: {
default: null,
},
},
},

Expand Down
7 changes: 6 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,15 @@ class TableViz(BaseViz):
def should_be_timeseries(self):
fd = self.form_data
# TODO handle datasource-type-specific code in datasource
return (
conditions_met = (
(fd.get('granularity') and fd.get('granularity') != 'all') or
(fd.get('granularity_sqla') and fd.get('time_grain_sqla'))
)
if fd.get('include_time') and not conditions_met:
raise Exception(
"Pick a granularity in the Time section or "
"uncheck 'Include Time'")
return fd.get('include_time')

def query_obj(self):
d = super(TableViz, self).query_obj()
Expand Down

0 comments on commit e7edd63

Please sign in to comment.