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
TablePanel: Add support for Count calculation per column or per entire dataset #58134
Changes from all commits
fc371ae
af6d441
aca5c2b
a3951f8
f8eb71e
480930f
d5cce99
bf6329f
ba8802f
1c6a30b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,3 +160,15 @@ Columns with filters applied have a blue funnel displayed next to the title. | |
{{< figure src="/static/img/docs/tables/filtered-column.png" max-width="500px" caption="Filtered column" class="docs-image--no-shadow" >}} | ||
|
||
To remove the filter, click the blue funnel icon and then click **Clear filter**. | ||
|
||
## Table footer | ||
|
||
You can use the table footer to show [calculations]({{< relref "../../calculation-types/" >}}) on fields. | ||
|
||
After enabling the table footer, you can select your **Calculation** and select the **Fields** that should be calculated. Not selecting any field apply the calculation to all numeric fields. | ||
|
||
### Count rows | ||
|
||
On selecting the **Count** calculation, you will see the **Count rows** switch. | ||
|
||
By enabling this option the footer will show the number of rows in the dataset instead of the number of values in the selected fields. | ||
Comment on lines
+172
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can combine these two statements by saying: Select the Count calculation when you want to show the number of rows in the dataset instead of the number of values in the selected fields. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,14 @@ export const plugin = new PanelPlugin<PanelOptions, TableFieldOptions>(TablePane | |
defaultValue: [ReducerID.sum], | ||
showIf: (cfg) => cfg.footer?.show, | ||
}) | ||
.addBooleanSwitch({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good! I'm thinking we should add a description here and maybe change the name of this option as well to make it more clear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I'd say we might to reverse the language, like "Count Per Field" with a description along the lines of "Count the non-empty results of each field separately" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From this I understand we also reverse the functionality. E.g: We show a count for all fields in one column and when the "Count Per Field" switch is active we show a count for each field. This would change all existing table panels for the users. Is this something we'd want? |
||
path: 'footer.countRows', | ||
category: [footerCategory], | ||
name: 'Count rows', | ||
description: 'Display a single count for all data rows', | ||
defaultValue: defaultPanelOptions.footer?.countRows, | ||
showIf: (cfg) => cfg.footer?.reducer?.length === 1 && cfg.footer?.reducer[0] === ReducerID.count, | ||
}) | ||
.addMultiSelect({ | ||
path: 'footer.fields', | ||
category: [footerCategory], | ||
|
@@ -156,7 +164,9 @@ export const plugin = new PanelPlugin<PanelOptions, TableFieldOptions>(TablePane | |
}, | ||
}, | ||
defaultValue: '', | ||
showIf: (cfg) => cfg.footer?.show, | ||
showIf: (cfg) => | ||
(cfg.footer?.show && !cfg.footer?.countRows) || | ||
(cfg.footer?.reducer?.length === 1 && cfg.footer?.reducer[0] !== ReducerID.count), | ||
}) | ||
.addCustomEditor({ | ||
id: 'footer.enablePagination', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you enable the table footer:
The system applies the calculation to all numeric fields if you do not select a field.