Skip to content
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

fix: Table visualization shows total for duration, percentage and bytes field formatters #54240

Merged

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Jan 8, 2020

Summary

Fixes #50036

Currently, we only show a total for number formatter. We also want to display it for duration, percentage and bytes.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@mbondyra mbondyra added Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 :KibanaApp/fix-it-week v7.6.0 labels Jan 8, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@mbondyra mbondyra added the release_note:skip Skip the PR/issue when compiling release notes label Jan 8, 2020
@mbondyra
Copy link
Contributor Author

mbondyra commented Jan 8, 2020

@elasticmachine merge upstream

….com:mbondyra/kibana into IS-50036_show-sum-for-a-field-with-formatter

* 'IS-50036_show-sum-for-a-field-with-formatter' of github.com:mbondyra/kibana:
  [Telemetry] Fix license page crashing on telemetry.enabled: fa… (elastic#54174)
  [ui/public/utils] Copy rarely used items to where they are consumed (elastic#53819)
  set AppArch team as an owner of the search endpoints (elastic#54131)
  Don't expose Elasticsearch client as Observable (elastic#53824)
  [SIEM] Cleanup unnecessary use of enzyme-to-json (elastic#53980)
@mbondyra mbondyra changed the title fix: Table visualization shows total for Duration and Bytes Field Formatters. fix: Table visualization shows total for duration, percentage and bytes field formatters Jan 8, 2020
};

const isDate = checkDimensionType(dimension, 'date');
const isNumeric = shouldShowTotal(dimension);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technique is pretty brittle- it says that there is a hardcoded list of formatters that can be used by the table, instead of looking at some property of the formatter. For example, I am adding new formatters: #53972

Is there a change we could make to the formatters API? We could take a different technique and add another property to number formats that would provide the formatted and raw data, but this might already exist?

Copy link
Contributor Author

@mbondyra mbondyra Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wylieconlon thank you for your comment, good point! How about adding additional property allowsNumericalAggregations for all the types we need NumberFormat, PercentFormat and BytesFormat and DurationFormat? Please, re-check my changes and let me know what you think.

@wylieconlon
Copy link
Contributor

Yes, I found the change I'm thinking of. We already apply formatting and totals in separate ways because otherwise it's buggy: #48090

@mbondyra mbondyra requested a review from a team as a code owner January 9, 2020 10:30
Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a small comment on the implementation, however overall LGTM


id = BytesFormat.id;
title = BytesFormat.title;
allowsNumericalAggregations = BytesFormat.allowsNumericalAggregations;
Copy link
Contributor

@lizozom lizozom Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks ok, However I don't understand why the attribute is set on both statically and as an attribute. I would opt for either of the options, but not both, unless there's specific reason to do so.

For example, if you prefer the static attribute, you could still access it in agg_table like this: formatter?.constructor.allowsNumericalAggregations. Or you can just set allowsNumericalAggregations = true and then access it as usual.

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change LGTM, although I didn't test it locally

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mbondyra mbondyra merged commit 982df2e into elastic:master Jan 9, 2020
@mbondyra mbondyra deleted the IS-50036_show-sum-for-a-field-with-formatter branch January 9, 2020 18:11
mbondyra added a commit to mbondyra/kibana that referenced this pull request Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table visualization won't total/sum a column with a field which has a field formatter.
6 participants