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: Don't sort in pie function #27076

Merged
merged 1 commit into from
Jan 28, 2019

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Dec 12, 2018

Closes #27077

Don't sort data by labels in pie function, so that the user's sorting is preserved. Tests were also removed or updated.


Below, note that the order of the data is preserved in the pie chart, instead of being sorted alphabetically by label name.

screenshot 2018-12-12 13 22 53

@w33ble w33ble added the Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas label Dec 12, 2018
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-canvas

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@w33ble w33ble changed the title [WIP] fix: Don't sort in view functions Fix: Don't sort in pie function Jan 16, 2019
@w33ble w33ble requested review from cqliu1 and monfera January 16, 2019 17:51
@w33ble w33ble requested a review from a team as a code owner January 16, 2019 17:52
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@cqliu1 cqliu1 left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Tested with the flights sample data and it works!

screen shot 2019-01-17 at 11 03 29 am

filters
| esdocs index="kibana_sample_data_flights" fields=""
| ply by="Carrier" fn={math "sum(AvgTicketPrice)"}
| sort by="value" reverse=false 
| pointseries color="Carrier" size="value"
| pie
| render

Copy link
Contributor

@monfera monfera left a comment

Choose a reason for hiding this comment

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

Great PR! If one has a single, static pie chart then we most often need value based sorting. As Canvas is data driven, and can sport multiple piecharts on the same page in a grid formation (with like data), these are legit uses:

  • if the data gets updated frequently, eg. every few seconds or minutes, an alternative option is to keep slice indices fixed, so that slice areas / angles tween in place, rather than abruptly relocate (though for some purposes, slices rotating into a new position may be desirable, to make shifts in ranking salient)
  • when creating a small multiples chart with a row or grid of pie charts (eg. per country sales), per-pie value ordering is often the best, but some users may prefer consistent pie ordering across elements of the small multiple chart
  • if the categories form a natural order, this may trump the value order (eg. colors, magnitudes, basically anything that's a discretization of a continuous measure eg. 0 - 10 years old; 10-20 years old etc.) - in these cases, the category order should prevail

It looks like the change can alter preexisting workbooks, which is fine as it's not yet in GA, and it's clearly the better route. The pie is a renderer and any sorting can be relegated to a previous data processing step, otherwise we'd duplicate and couple data processing in pie.

@monfera monfera merged commit 052a3d4 into elastic:master Jan 28, 2019
@w33ble
Copy link
Contributor Author

w33ble commented Jan 28, 2019

It looks like the change can alter preexisting workbooks, which is fine as it's not yet in GA, and it's clearly the better route. The pie is a renderer and any sorting can be relegated to a previous data processing step, otherwise we'd duplicate and couple data processing in pie.

Exactly. And any existing pie charts that are not "incorrect" can be fixed by adding a | sort to the expression.

w33ble added a commit to w33ble/kibana that referenced this pull request Jan 28, 2019
w33ble added a commit to w33ble/kibana that referenced this pull request Jan 28, 2019
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v6.6.1 v6.7.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants