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

Automatically sort (and re-sort) stacked bar chart? #1711

Open
brylie opened this issue Jul 3, 2016 · 11 comments
Open

Automatically sort (and re-sort) stacked bar chart? #1711

brylie opened this issue Jul 3, 2016 · 11 comments

Comments

@brylie
Copy link

brylie commented Jul 3, 2016

We have a multi-bar chart that is rendering data in the order it is passed in. How do we sort a multi-bar chart in ascending or descending order?

Observation

screenshot from 2016-07-03 14-47-03
screenshot from 2016-07-03 14-48-56

In the screenshots above, the bars are sorted based on the array order, and retain the sorting order when filtering.

Desired result

It would be desirable for the bars to be sorted by the sum of their values, so that the largest or smallest bars are at opposite ends of the graph. This makes it easy for people to read the charts.

References

This has been requested previously on Stack Overflow and Github. The suggested solutions seem non-trivial and would probably be better handled by the charting library.

@liquidpele
Copy link
Contributor

Sorting the data points must be done by whatever builds the data object, nvd3 is just going to display the data in the same order it appears in the array of series data.

@liquidpele
Copy link
Contributor

I should note that while this isn't a defect, feel free to implement a solution and send us a pull request and we'll check it out :)

@brylie
Copy link
Author

brylie commented Jul 4, 2016

Sorting the data points must be done by whatever builds the data object, nvd3 is just going to display the data in the same order it appears in the array of series data.

One problem with that approach, as identified in the original post, is that the items will not re-sort when a user interacts with the filter. This may genuinely need to be handled by the chart, unless we are expected to write hooks that re-sort the data and send it back when the chart is filtered.

What would be a proposed solution?

@brylie
Copy link
Author

brylie commented Jul 4, 2016

Sorting bar charts is a relatively common need, and would save developer time if the library were to support it. E.g. the proposed solutions to this task seem to differ, and force the developer to write procedural code.

A high level goal of a charting library is to allow charts to be designed declaratively.

@brylie
Copy link
Author

brylie commented Jul 4, 2016

Please re-open this issue, as a feature request. The idea merits discussion, and a community-oriented project should give community ideas time to season.

@liquidpele
Copy link
Contributor

It's a feature request, but realistically a feature request is going to be dependent on someone picking it up and sending us a pull request, I'm trying to only keep feature requests open that I intend to do myself if I have time (which isn't often). If you really want this then send us a pull request with the changes :)

@brylie
Copy link
Author

brylie commented Jul 5, 2016

I'm trying to only keep feature requests open that I intend to do myself if I have time (which isn't often).

In order for this to be a community project, we need to communicate and prioritize tasks collectively. That moves us out of the 'lone developer' mindset, where ideas can linger and be taken up in due time.

By using an issue tracker, you can provide a clear indication to your users as what to expect in future releases of your code. This means that if a user has a specific need for a feature or bug-fix that you have no intention of implementing in the short term, they can opt to invest some of their own resources in adding the feature or fixing the bug.

How about tagging this in some way, so that you can filter it out when deciding how to prioritize your time while allowing the community to 'remember' and discuss the feature?

@liquidpele
Copy link
Contributor

Oh okay, I'll open it and mark it as feature request if you really insist that much... but if you want this done you'll in all likelihood have to do it yourself.

@brylie
Copy link
Author

brylie commented Jul 5, 2016

Thanks @liquidpele 😄

@TheChifer
Copy link

TheChifer commented Sep 26, 2016

+1

1 similar comment
@ghost
Copy link

ghost commented Jul 19, 2017

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants