sorting chart xValues by metric sum#8397
Conversation
|
currently this will reorder values on x-axis no matter the sorting method selected. sorting method only applies to elasticsearch query (so if for example i am aggregating by geo.src instead of getting the buckets with highest counts i will get first 5 countries alphabetically) but then kibana would always order them from biggest to smallest. i think its correct we dont take query sort order into account, but maybe we could add another option: sort buckets (or dont) in the visualization. |
|
i think im gonna add the option to enable/disable this first thing in the morning |
|
@ppisljar what's your assessment of this zero injection library? There are a few smells here which make me wonder if we should improve this code more fundamentally:
Also, after looking at the code more carefully, I find it confusing and difficult to follow. There are numerous conditions, return values of differing types, variables that hold different types of values based on different conditions, and references to specific array elements without any explanations of what those elements are. On one hand it would be great to clean this up and make it easier to read (and review). On the other hand, cleaning this code up seems like a major task. Clearly you understood it well enough to make this change, so maybe we can compromise with some comments to document the things you learned about it, if a more thorough cleanup effort isn't worth it at this time? |
|
@cjcenizal i agree the library is not the best, but in this PR i am not gonna rewrite it. its not the only part of kibana that cries for rewrite ...
|
cjcenizal
left a comment
There was a problem hiding this comment.
Looks great! Just had a few small suggestions for making the code easier to follow.
There was a problem hiding this comment.
I think renaming this to orderBucketsBySum everywhere will make it a little clearer, since technically the buckets are going to be sorted anyway, right? They'll just be sorted by their index by default.
There was a problem hiding this comment.
"Correct order" isn't very precise. Let's make this description more explicit, so people reading this will know exactly what to expect of this text:
it('should return an array of values ordered by their sum when orderBucketsBySum is true', function () {I think it's worth updating the preceding test's description to provide better contrast:
it('should return an array of values ordered by their index by default', function () {There was a problem hiding this comment.
How about "Order buckets by descending sum"?
b4e6dbf to
cccc06f
Compare
Backports PR #8397 **Commit 1:** sorting chart xValues by metric sum * Original sha: 64db47e * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:14:49Z **Commit 2:** fixing tests * Original sha: b6bcd55 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:40:54Z **Commit 3:** adding order buckets by value option to point series charts * Original sha: c03bc99 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T07:50:02Z **Commit 4:** fixing tests * Original sha: 5917293 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:11:40Z **Commit 5:** fixing tests * Original sha: 19bcdfe * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:21:07Z **Commit 6:** Updating based on CJs comments and adding documentation * Original sha: cccc06f * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:06:06Z
Backports PR #8397 **Commit 1:** sorting chart xValues by metric sum * Original sha: 64db47e * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:14:49Z **Commit 2:** fixing tests * Original sha: b6bcd55 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:40:54Z **Commit 3:** adding order buckets by value option to point series charts * Original sha: c03bc99 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T07:50:02Z **Commit 4:** fixing tests * Original sha: 5917293 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:11:40Z **Commit 5:** fixing tests * Original sha: 19bcdfe * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:21:07Z **Commit 6:** Updating based on CJs comments and adding documentation * Original sha: cccc06f * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:06:06Z
* sorting chart xValues by metric sum * fixing tests * adding order buckets by value option to point series charts * fixing tests * fixing tests * Updating based on CJs comments and adding documentation
Backports PR elastic#8397 **Commit 1:** sorting chart xValues by metric sum * Original sha: 64db47e * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:14:49Z **Commit 2:** fixing tests * Original sha: b6bcd55 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-21T09:40:54Z **Commit 3:** adding order buckets by value option to point series charts * Original sha: c03bc99 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T07:50:02Z **Commit 4:** fixing tests * Original sha: 5917293 * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:11:40Z **Commit 5:** fixing tests * Original sha: 19bcdfe * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-22T15:21:07Z **Commit 6:** Updating based on CJs comments and adding documentation * Original sha: cccc06f * Authored by ppisljar <peter.pisljar@gmail.com> on 2016-09-23T06:06:06Z Former-commit-id: 4a76abc
fixes #5512
fixes #3314
reorder values on ordinal x axis from largest to smallest