Skip to content

Commit

Permalink
Add option to hide Pivot Table totals (#3943)
Browse files Browse the repository at this point in the history
* Add option to hide Pivot Table totals

* Simplify implementation using DEFAULT_OPTIONS.

* Flip hide pivot controls to show pivot controls

* Update client/app/visualizations/pivot/Editor.jsx

Co-Authored-By: Ran Byron <ranbena@gmail.com>
  • Loading branch information
arikfr and ranbena authored Jun 30, 2019
1 parent 7ceb68a commit 6748e9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 20 additions & 4 deletions client/app/visualizations/pivot/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,31 @@ export default function Editor({ options, onOptionsChange }) {
};

return (
<div className="form-group">
<div className="form-group m-t-30">
<label className="d-flex align-items-center" htmlFor="pivot-show-controls">
<span className="m-r-10">Hide Pivot Controls</span>
<Switch
data-test="PivotEditor.HideControls"
id="pivot-show-controls"
checked={options.controls.enabled}
onChange={enabled => updateOptions({ controls: { enabled } })}
checked={!options.controls.enabled}
onChange={enabled => updateOptions({ controls: { enabled: !enabled } })}
/>
<span className="m-l-10">Show Pivot Controls</span>
</label>
<label className="d-flex align-items-center" htmlFor="pivot-show-row-totals">
<Switch
id="pivot-show-row-totals"
checked={options.rendererOptions.table.rowTotals}
onChange={rowTotals => updateOptions({ rendererOptions: { table: { rowTotals } } })}
/>
<span className="m-l-10">Show Row Totals</span>
</label>
<label className="d-flex align-items-center" htmlFor="pivot-show-col-totals">
<Switch
id="pivot-show-row-totals"
checked={options.rendererOptions.table.colTotals}
onChange={colTotals => updateOptions({ rendererOptions: { table: { colTotals } } })}
/>
<span className="m-l-10">Show Column Totals</span>
</label>
</div>
);
Expand Down
6 changes: 6 additions & 0 deletions client/app/visualizations/pivot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const DEFAULT_OPTIONS = {
controls: {
enabled: false, // `false` means "show controls" o_O
},
rendererOptions: {
table: {
colTotals: true,
rowTotals: true,
},
},
};

const PivotTableRenderer = {
Expand Down

0 comments on commit 6748e9a

Please sign in to comment.