-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
show total in DataTable #4570
show total in DataTable #4570
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
My issue with this is that |
@@ -91,6 +92,12 @@ define(function (require) { | |||
formattedColumn.class = 'visualize-table-right'; | |||
} | |||
|
|||
if (field.type === 'number') { | |||
formattedColumn.total = table.rows.reduce(function (prev, curr, n, all) { |
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.
You could use lodash's _.sum
method here, maybe _.sum(table.rows, [i, 'value'])
@spalger Very good feedback 👍, thank you. |
I mean, for instance, if the column is averages of that row then the |
hm. interesting idea. Will try to do it tomorrow. One more, do you think it will be handy if user will be able to choose column where to display total, instead of calculating total everywhere? |
@sonenko I think it makes sense to display the total for all of the metric aggregation columns. That way, if they want to choose a field to total up all they have to do is add a metric agg on that field :) |
hm. ok. I will postpone this implementation till the weekend. Coz I started implementation for total for each column separately. Not need to rethink. So, your idea is to simply add one mode select component - Total function to Options tab? |
Yeah, I think that would make it simple and cover 90% of the desired use cases. Do you agree? |
I don't know:), I thought that Ideally, It would be more handy to configure this settings for each column. But from other perspective, it is just a little changes in code, and final user of kibana will not become confused because of many additional controls. |
@spalger seems like I'm not able to use _.sum(Array, [key1, key2]); |
could anybody please review that? |
There's more to this than just sum or avg, there's also min, max and probably a whole lot more. I'm not sure how to come at this in a generic way |
I will try to add few more aggregations on the next week. |
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
jenkins, test it |
jenkins, test it. |
This needs to be merged with or rebased on the latest master. |
jenkins, test it. |
jenkins, test it |
<select ng-disabled="!vis.params.showTotal" | ||
class="form-control" | ||
ng-model="vis.params.totalFunc" | ||
ng-options="x for x in ['sum', 'avg', 'min', 'max', 'count']"> |
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.
Can you make this a variable on the scope please?
@panda01 thank you for fast reaction |
This looks good to me. Although in all honesty I'm not sure if that's all the functions we want, and if they're calculated as we would like them to. Passing on to @spalger, or @rashidkpc for some feedback in regards to these issues. |
Jenkins, test it. |
Thanks @panda01 |
Hi @spalger, @rashidkpc, could you look at that please? |
Actually, I changed my mind. I will take responsibility for merging it, if there are any problems i will handle them accordingly. Thanks for all of your work @sonenko! |
show total in DataTable Former-commit-id: c6f5963
Any feedback encouraged :)