mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
add combine config for metrics in pivot table (#3086)
* add combine config for metrics in pivot table * change method to stack/unstack * update backendSync
This commit is contained in:
parent
1e325d9645
commit
b58cfbcb91
@ -750,6 +750,12 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"description": "Sort bars by x labels."
|
"description": "Sort bars by x labels."
|
||||||
},
|
},
|
||||||
|
"combine_metric": {
|
||||||
|
"type": "CheckboxControl",
|
||||||
|
"label": "Combine Metrics",
|
||||||
|
"default": false,
|
||||||
|
"description": "Display metrics side by side within each column, as opposed to each column being displayed side by side for each metric."
|
||||||
|
},
|
||||||
"show_controls": {
|
"show_controls": {
|
||||||
"type": "CheckboxControl",
|
"type": "CheckboxControl",
|
||||||
"label": "Extra Controls",
|
"label": "Extra Controls",
|
||||||
|
@ -249,6 +249,14 @@ export const controls = {
|
|||||||
description: 'Sort bars by x labels.',
|
description: 'Sort bars by x labels.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
combine_metric: {
|
||||||
|
type: 'CheckboxControl',
|
||||||
|
label: 'Combine Metrics',
|
||||||
|
default: false,
|
||||||
|
description: 'Display metrics side by side within each column, as ' +
|
||||||
|
'opposed to each column being displayed side by side for each metric.',
|
||||||
|
},
|
||||||
|
|
||||||
show_controls: {
|
show_controls: {
|
||||||
type: 'CheckboxControl',
|
type: 'CheckboxControl',
|
||||||
label: 'Extra Controls',
|
label: 'Extra Controls',
|
||||||
|
@ -337,7 +337,7 @@ export const visTypes = {
|
|||||||
controlSetRows: [
|
controlSetRows: [
|
||||||
['groupby', 'columns'],
|
['groupby', 'columns'],
|
||||||
['metrics', 'pandas_aggfunc'],
|
['metrics', 'pandas_aggfunc'],
|
||||||
['number_format', 'pivot_margins'],
|
['number_format', 'combine_metric', 'pivot_margins'],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -402,6 +402,9 @@ class PivotTableViz(BaseViz):
|
|||||||
aggfunc=self.form_data.get('pandas_aggfunc'),
|
aggfunc=self.form_data.get('pandas_aggfunc'),
|
||||||
margins=self.form_data.get('pivot_margins'),
|
margins=self.form_data.get('pivot_margins'),
|
||||||
)
|
)
|
||||||
|
# Display metrics side by side with each column
|
||||||
|
if self.form_data.get('combine_metric'):
|
||||||
|
df = df.stack(0).unstack()
|
||||||
return dict(
|
return dict(
|
||||||
columns=list(df.columns),
|
columns=list(df.columns),
|
||||||
html=df.to_html(
|
html=df.to_html(
|
||||||
|
Loading…
Reference in New Issue
Block a user