Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

New select menu widget #771

Closed
wants to merge 2 commits into from
Closed

New select menu widget #771

wants to merge 2 commits into from

Conversation

madebydna
Copy link
Contributor

I had a need for select menu "chart" type in dc and I have seen it requested in other places, so I created a simple widget that adds this functionality.

The widget creates an HTML select tag with options corresponding to the chart's (crossfilter) groups. By default the option text will display the group key and the group value separated by a colon. The select menu will filter the chart's dimension by the group key represented by the selected option ( also encoded in the option's value attribute).

On redraw, the chart filters out options whose value (according to the valueAccessor) is < 1. This behavior can be overridden by using the filterDisplayed function.

The generated HTML select tag is single select (rather than a multiple select) and on redraw the options that corresponds to the current filter will be selected. Not sure if a multiple select is more in keeping with the behavior of other dc.js charts, but I could change it to a multiple select if needed.

Let me know if there is any interest in pulling this in and, in case there is, whether I should make any changes.

@gordonwoodhull
Copy link
Contributor

Nice! This will be very helpful. I have been rather backlogged, but I see open seas ahead, and hope to review this soon.

I think multiple select would be a nice option, but I won't make that a condition for acceptance.

Thank you! And thank you for what look like thorough tests, much appreciated!

@madebydna
Copy link
Contributor Author

Really glad to be able to give back to the library!

Regarding the multiple select, I'd be happy to work on that too, but I may need some feedback on some details, e.g. which version (single or multiple) should be the default, etc.

@gordonwoodhull
Copy link
Contributor

Just saw this question on SO asking for the multiple selection version:

http://stackoverflow.com/questions/27335763/is-it-possible-to-search-in-bubble-chart-with-dc-js

I don't think it matters too much which is the default. The filter modes are a bit inconsistent/incomplete in dc.js anyway. (I have some ideas about that, but a lot of higher priorities, since people seem to be able to hack around it.)

@madebydna
Copy link
Contributor Author

Ok, I started working on the multiple select option for the menu. I should be able to submit a second PR soon.

@gordonwoodhull
Copy link
Contributor

Cool! I'll schedule this for 2.1 because I'm just trying to fix bugs for 2.0. So January is a good target.

@gordonwoodhull gordonwoodhull added this to the v2.1 milestone Dec 8, 2014
@madebydna
Copy link
Contributor Author

I made the changes to the new dc.selectMenu widget to optionally allow multiple selections.

Let me know if you would like anything changed whenever you get a chance to review it.

@anmolkoul
Copy link

The single select menu is working nicely. Just saw this thread in a long time. Will take the multi select widget for a spin

@gordonwoodhull
Copy link
Contributor

Merged to develop/2.1 branch. Added a .size() method to set the height, and an example.

Thanks @madebydna!

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

Successfully merging this pull request may close these issues.

3 participants