Facet filtering using URL query strings in Exhibit 3

155 views
Skip to first unread message

Tully Hansen

unread,
Oct 29, 2015, 10:04:02 PM10/29/15
to SIMILE Widgets
Related to a previous post, but I've done enough dabbling to better formulate a question. At http://tullyhansen.github.io/botDB/nobel3ed.html, I have cobbled together (c/- answers here and random StackExchange posts) some sort-of working facet filtering based on parameters from URL query string, but it's a mess. URLs with query strings will seemingly work once http://tullyhansen.github.io/botDB/nobel3ed.html?deceased=yes but if I then 'Reset All Filters' that same URL with query ceases working until I clear cache. My question, then:

Given an Exhibit 3 site residing at baz.com/ex.html containing two facets with id="foo" & id="bar" respectively, what is the simplest way to make baz.com/ex.html?foo=yellow&bar=blue filter the Exhibit down to only yellow foos and blue bars on load?

I accept this may be more a JS/jQuery question, but I've found enough evidence here and elsewhere to suggest it should be possible to give up on the idea just yet. Elsewhere on here there is mention of 'native support for query strings in the next version of Exhibit', and Travis McCauley seems to manage it here – http://travismccauley.info/shalu/?year=1810 – with (I think) Exhibit 2. However, attempting to imitate his method as best I can, I get stuck at window.database.loadDataLinks throwing som kind of error. Hints or examples greatly appreciated!

Tully Hansen

unread,
Oct 29, 2015, 11:49:36 PM10/29/15
to SIMILE Widgets
Basically, my question is the Exhibit 3 equivalent of these (much) older questions:


The former has no posted solution; the latter depends on window.database.loadDataLinks(fDone) which doesn't seem to work (for me?) in Exhibit 3. So maybe my question is, what's the Exhibit 3 equivalent of window.database.loadDataLinks?

David Karger

unread,
Oct 29, 2015, 11:52:38 PM10/29/15
to simile-...@googlegroups.com
The new version of exhibit has a bookmark export functionality that encodes the state of a query.  Look for this icon on the page and click it; it will give you a messy string that will open the exhibit with a specific facet state.
--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.
Visit this group at http://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.

Tully Hansen

unread,
Oct 30, 2015, 12:43:21 AM10/30/15
to SIMILE Widgets
Thanks for your help as ever, David. To put to bed my original question, there's not an easy way to set facet filters from URL queries in Exhibit 3, then? I know about setting data-ex-query-param-name="foo" on a facet of data-ex-facet-class="TextSearch" to allow you to query 'bar' with example.com/exhibit.html?foo=bar, but otherwise there's no (easy) answer? Replicating the type of filtering on show at http://travismccauley.info/shalu/?age=40%20to%2049&year=1844 is not doable under Exhibit 3?

David Karger

unread,
Oct 30, 2015, 12:51:08 AM10/30/15
to simile-...@googlegroups.com
I don't think that syntax has been preserved.    If I had to do it, I'd take the following approach: write some javascript to read and parse the arguments from the url and then modify the facet tags in the html, adding the data-ex-selection attribute that allows you to specify the initial values for the facet.   run that js *before* loading and executing exhibit. 

On 10/30/2015 12:43 AM, Tully Hansen wrote:
Thanks for your help as ever, David. To put to bed my original question, there's not an easy way to set facet filters from URL queries in Exhibit 3, then? I know about setting data-ex-query-param-name="foo" on a facet of data-ex-facet-class="TextSearch" to allow you to query 'bar' with example.com/exhibit.html?foo=bar, but otherwise there's no (easy) answer? Replicating the type of filtering on show at http://travismccauley.info/shalu/?age=40%20to%2049&year=1844 is not doable under Exhibit 3?

Tully Hansen

unread,
Oct 30, 2015, 1:03:37 AM10/30/15
to SIMILE Widgets
Aha! Thanks, this gives me something to go on – what you describe is basically what I'm attempting to do now (I think), but I hadn't thought to do it before loading Exhibit…

Tully Hansen

unread,
Oct 30, 2015, 7:53:20 PM10/30/15
to SIMILE Widgets
Further to this: adding "?persist=false" to window.Exhibit_parameters gives me the desired behaviour of being able to load a ur with appended query string to filter facets, click 'Reset All Filters', then reload the same url with query to display filtered facets again. (Exhibit 3.1.2-rc1.)

Andrea Borruso

unread,
Nov 15, 2015, 5:25:01 AM11/15/15
to SIMILE Widgets
Hi Tully,


On Saturday, 31 October 2015 00:53:20 UTC+1, Tully Hansen wrote:
Further to this: adding "?persist=false" to window.Exhibit_parameters gives me the desired behaviour of being able to load a ur with appended query string to filter facets, click 'Reset All Filters', then reload the same url with query to display filtered facets again. (Exhibit 3.1.2-rc1.)

I'm very interested. Do you have an example website in which I can see all in action?

Thank you 

Jared

unread,
Sep 19, 2016, 2:41:22 PM9/19/16
to SIMILE Widgets
Any updates on how to accomplish this?

I would love to be able to simply pass a parameter like ?color=red to apply a facet on load. I understand that there is the bookmarking functionality but that hash is really ugly and contains way too much information as its just the hashed version of Exhibit.History.getState().

David Karger

unread,
Sep 19, 2016, 2:42:39 PM9/19/16
to simile-...@googlegroups.com

there is a data-ex-selection attribute that you can set on a facet element to have it init with certain selections.  do you need to specify the selection in the url?

--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.

Jared Szechy

unread,
Sep 19, 2016, 3:00:13 PM9/19/16
to simile-...@googlegroups.com
Yes, I would like to use a url parameter.

Worst case I can add data-ex-selection dynamically from a parameter, however I would ideally not like to have the facets visible in this view.

Also, I've noticed that data-ex-selection attribute does not seem to work on arrays.



On Mon, Sep 19, 2016 at 2:42 PM, David Karger <kar...@mit.edu> wrote:

there is a data-ex-selection attribute that you can set on a facet element to have it init with certain selections.  do you need to specify the selection in the url?


On 9/19/2016 2:06 PM, Jared wrote:
Any updates on how to accomplish this?

I would love to be able to simply pass a parameter like ?color=red to apply a facet on load. I understand that there is the bookmarking functionality but that hash is really ugly and contains way too much information as its just the hashed version of Exhibit.History.getState().

On Sunday, November 15, 2015 at 5:25:01 AM UTC-5, Andrea Borruso wrote:
Hi Tully,

On Saturday, 31 October 2015 00:53:20 UTC+1, Tully Hansen wrote:
Further to this: adding "?persist=false" to window.Exhibit_parameters gives me the desired behaviour of being able to load a ur with appended query string to filter facets, click 'Reset All Filters', then reload the same url with query to display filtered facets again. (Exhibit 3.1.2-rc1.)

I'm very interested. Do you have an example website in which I can see all in action?

Thank you 
--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "SIMILE Widgets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simile-widgets/ILR1uLaPljQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.



--
Jared Szechy
Brilligent Solutions, Inc.

David Karger

unread,
Sep 19, 2016, 3:04:37 PM9/19/16
to simile-...@googlegroups.com

facets don't need to be visible for filtering to work.  setting style=display:none is fine

you don't specify an array for data-ex-selection, but you can specify a list.  i forget whether you separate by commas or semicolons

To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.

Jared Szechy

unread,
Sep 19, 2016, 3:10:12 PM9/19/16
to simile-...@googlegroups.com
I'm only trying to pass a single value but it's not working.

json:

    "items": [
        {
           ...
            "fieldX": [
                "foo"
            ],
            ...
        },
]

html:

<div data-ex-role="facet" data-ex-show-missing="false" data-ex-expression=".fieldX" data-ex-facet-label="Name" data-ex-selection="foo"></div>


On Mon, Sep 19, 2016 at 3:04 PM, David Karger <kar...@mit.edu> wrote:

facets don't need to be visible for filtering to work.  setting style=display:none is fine

you don't specify an array for data-ex-selection, but you can specify a list.  i forget whether you separate by commas or semicolons


On 9/19/2016 3:00 PM, Jared Szechy wrote:
Yes, I would like to use a url parameter.

Worst case I can add data-ex-selection dynamically from a parameter, however I would ideally not like to have the facets visible in this view.

Also, I've noticed that data-ex-selection attribute does not seem to work on arrays.


On Mon, Sep 19, 2016 at 2:42 PM, David Karger <kar...@mit.edu> wrote:

there is a data-ex-selection attribute that you can set on a facet element to have it init with certain selections.  do you need to specify the selection in the url?


On 9/19/2016 2:06 PM, Jared wrote:
Any updates on how to accomplish this?

I would love to be able to simply pass a parameter like ?color=red to apply a facet on load. I understand that there is the bookmarking functionality but that hash is really ugly and contains way too much information as its just the hashed version of Exhibit.History.getState().

On Sunday, November 15, 2015 at 5:25:01 AM UTC-5, Andrea Borruso wrote:
Hi Tully,

On Saturday, 31 October 2015 00:53:20 UTC+1, Tully Hansen wrote:
Further to this: adding "?persist=false" to window.Exhibit_parameters gives me the desired behaviour of being able to load a ur with appended query string to filter facets, click 'Reset All Filters', then reload the same url with query to display filtered facets again. (Exhibit 3.1.2-rc1.)

I'm very interested. Do you have an example website in which I can see all in action?

Thank you 
--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.
Visit this group at https://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "SIMILE Widgets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simile-widgets/ILR1uLaPljQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-...@googlegroups.com.
Visit this group at https://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.
--
Jared Szechy
Brilligent Solutions, Inc.

--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.
Visit this group at https://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "SIMILE Widgets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simile-widgets/ILR1uLaPljQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.
Visit this group at https://groups.google.com/group/simile-widgets.
For more options, visit https://groups.google.com/d/optout.

Jared Szechy

unread,
Sep 19, 2016, 3:11:55 PM9/19/16
to simile-...@googlegroups.com
I just tried a field that is not an array and it isn't working either.

"fieldY": "bar"

<div data-ex-role="facet" data-ex-show-missing="false" data-ex-expression=".fieldY" data-ex-facet-label="Name" data-ex-selection="bar"></div>

David Karger

unread,
Sep 19, 2016, 3:37:35 PM9/19/16
to simile-...@googlegroups.com

you can see it working fine in this (tweaked) example:

http://people.csail.mit.edu/karger/ExhibitK/demos/presidents/presidents.html

To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.

Jared Szechy

unread,
Sep 19, 2016, 3:43:49 PM9/19/16
to simile-...@googlegroups.com
Looking at the source I can see that its supposed to have Republican selected. However I'm getting nothing.

Chrome v52.


To post to this group, send email to simile-widgets@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "SIMILE Widgets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simile-widgets/ILR1uLaPljQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.

David Karger

unread,
Sep 19, 2016, 4:07:57 PM9/19/16
to simile-...@googlegroups.com

I bet you're running into problems with exhibit's "persistence" feature that sets facet values to be the same as they were the last time you visited the page.   This may have been a bad idea. try adding ?persist=false to the end of your url.

Jared Szechy

unread,
Sep 19, 2016, 4:14:27 PM9/19/16
to simile-...@googlegroups.com
That fixes it.

Is there a way I can programmatically set that in my code so it doesn't have to be in the URL?

To post to this group, send email to simile-widgets@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "SIMILE Widgets" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/simile-widgets/ILR1uLaPljQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to simile-widgets+unsubscribe@googlegroups.com.
To post to this group, send email to simile-widgets@googlegroups.com.

David Karger

unread,
Sep 19, 2016, 7:58:07 PM9/19/16
to simile-...@googlegroups.com

unfortunately not. there was a decision made some years ago that exhibit should persist its state when you reload a page.  I'm skeptical.  so i added the persist=false option to override.  but the url is the only way to activate it right now.

To unsubscribe from this group and stop receiving emails from it, send an email to simile-widget...@googlegroups.com.

David Karger

unread,
Sep 19, 2016, 7:59:00 PM9/19/16
to simile-...@googlegroups.com

it should really only be a problem during development, since people visiting your page for the first time will get whatever data-ex-expression you set permanently in the page.

Reply all
Reply to author
Forward
0 new messages