Get the filters selected by a user

215 views
Skip to first unread message

Rahul Desai

unread,
Apr 6, 2015, 4:21:26 PM4/6/15
to dc-js-us...@googlegroups.com
Hi all,

I am looking for building a web page with a number of graphs using dc and crossfilter and let the user slice and dice the data using these graphs. Once the user is comfortable with a set of filters that he/she has set, I would like to have a button which could identify all the filters that user has set and I would like to save this combination of filter in the backend. If the user comes back and logs in, he/she should be able to pull the saved filter and apply to the visualization.

So, currently I am researching how to:
  • identify the filters set by the user from the DOM so that I can save it to backend.
  • apply these saved filters on the visualization when the user logs back in.
Can someone point me in the right direction as I am finding any good examples which does something like this? Any help / direction will be greatly appreciated.

Thanks in advance,
Regards,
Rahul Desai

Blair Nilsson

unread,
Apr 7, 2015, 12:40:10 AM4/7/15
to dc-js-us...@googlegroups.com
We do this all the time.

for (var chart of dc.chartRegistry.list()) { console.log(chart.anchor(), chart.filters())}

Will give the you charts anchors, and the filters applied.

For each chart, you can also call chart.filters(['blue','green'])  etc to set the filters.

A nicety is to encode the filters used into the url and update the url when the filters change, so that if you copy the link to the page, and mail it to someone, they will see your charts with the same filters applied :)

Enjoy!!

--- Blair

Gordon Woodhull

unread,
Apr 7, 2015, 7:50:29 AM4/7/15
to dc-js-us...@googlegroups.com
There are some examples of the URL approach in this ticket: https://github.com/dc-js/dc.js/issues/490


--
You received this message because you are subscribed to the Google Groups "dc-js user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dc-js-user-gro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dc-js-user-group/7187f241-ac2d-44fa-98d6-a25852396e5d%40googlegroups.com.

Rahul Desai

unread,
Apr 7, 2015, 11:28:31 AM4/7/15
to dc-js-us...@googlegroups.com
Thank you, Gordon and Blair. This helps a lot. 

regards,
Rahul Desai

--
You received this message because you are subscribed to a topic in the Google Groups "dc-js user group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dc-js-user-group/J3zFvkNOorY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dc-js-user-gro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dc-js-user-group/4E1196F7-30E2-4A0C-AB71-4F3678727540%40woodhull.com.

Reply all
Reply to author
Forward
0 new messages