in Exhibit - select multiple items from one facet - How to sort results according to number of items matched?

47 views
Skip to first unread message

lbjvg

unread,
Oct 30, 2009, 11:57:20 PM10/30/09
to SIMILE Widgets
HI - In an Exhibit - suppose more than one selection is made within
the same facet. By default the filtered results are sorted
alphabetically and there is no way to distinguish a result that
happens to match all selections versus results that match some but
all. I want to give priority to those that match the most selections.

As an example - from the CSAIL example:
http://simile-widgets.org/exhibit/examples/CSAIL-PIs/CSAIL-PIs.html
There are 3 people in the "medical vision group" and 10 in the
"vision" group. If you select both groups the total result is 10 (not
13) because 3 people are in both groups. But it is not immediately
evident from the alphabetical listing which 3 are in both groups. I
want to give priority to those three because they match more criteria
("vision" and "medical vision") than the other 7 (which match one or
the other but not both).

By priority, I mean, sort them at the top of the results or visually
distinguish them in some other way.

Perhaps there is a simple statement to accomplish this that I have
missed. Otherwise, perhaps there is some way to access some internal
Exhibit variables or counters that I could track and analyze?

Can this be done and if so how? Thanks, Jim Gallagher

Michiel

unread,
Nov 2, 2009, 1:18:17 PM11/2/09
to SIMILE Widgets

Hi Jim,

I hoped someone more experienced would have answered your question,
unfortunately not so.

I assume you are familiar with javascript and my "solution" sets the
background color of those items that match more then once. I do this
with the rowStyler (see tabular-view manual). The rowStyler is a
function that gets called with some arguments, but since you need to
iterate over all facets, you need an extra parameter. So copy the
Exhibit.TabularView.prototype._reconstruct method from the exhibit
source to your own script file (that you load after loading the
Exhibit apis) and change the lines (two times):
self._settings.rowStyler(item.id, database, tr, i);
into
self._settings.rowStyler(item.id, database, tr, i, collection);

Then define this rowStyler:

var facetMatchStyler = function(item, database, tr, tel, collection) {
for (var i in collection._facets) {
var facetSelection = collection._facets
[i].exportFacetSelection();
if (facetSelection) {
var expression = collection._facets
[i]._expression;
var results = expression.evaluate({"value":item},
"value":"item"},"value",database);
var itemSet = results.values;
// assume all facets are list-facets!
var nrMatches = Exhibit.Set.createIntersection
(itemSet,
collection._facets[i]._valueSet).size();
if (nrMatches > 1) {
tr.style.background = 'red';
}
}
}
}

Last step is to add this rowStyler to your tabular view:
ex:rowStyler="facetMatchStyler"

I realise this is absolutely not quality code, the real solution is
probably to do a feature request on the bug tracker.

Michiel
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

lbjvg

unread,
Nov 4, 2009, 2:16:33 PM11/4/09
to SIMILE Widgets
Thanks Michiel - I got it to work 99%.

The only issue now is some error messages that pop-up.

That is what happens in Chrome: The page seems to load fine but when
a facet selection is made the "Working" message spins forever.

In FF: there is a msgbox when the page first loads: "Caught exception:
undefined; Details:
TypeError: this._dom.topPagingDiv is undefined"

This string is found here in
Exhibit.TabularView.prototype._reconstruct = function()

if (generatePagingControls) {
if (this._settings.pagingControlLocations == "top" ||
this._settings.pagingControlLocations == "topbottom") {
this._renderPagingDiv(this._dom.topPagingDiv,
items.length, this._settings.page);
this._dom.topPagingDiv.style.display = "block";
}

if (this._settings.pagingControlLocations == "bottom" ||
this._settings.pagingControlLocations == "topbottom") {
this._renderPagingDiv(this._dom.bottomPagingDiv,
items.length, this._settings.page);
this._dom.bottomPagingDiv.style.display = "block";
}
} else {
this._dom.topPagingDiv.style.display = "none";
this._dom.bottomPagingDiv.style.display = "none";
}


Then if I proceed to make a facet selection I get this: Caught
exception: Error adding action {Select only Atypical Lymphocytes in
facet Dermis: Inflammatory Cells} to history


Details: TypeError: invalid 'in' operand F


In IE6 I get a msgbox when the page loads: Caught exception undefined;
Details Object
doesn't support this property or method.

then if I go ahead aand select something in a facet I get essentially
the same message as in FF above.

Here is the page: http://dermdudes.com/DD_querydriven2_ranktest.html

Note: I commented out a Search facet to prevent that from messing
things up.

- Jim

PS - I have updated this post multiple times as I discover new aspects
of the error.

Michiel

unread,
Nov 5, 2009, 11:23:58 AM11/5/09
to SIMILE Widgets
Hi Jim,

You use version 2.2.0 of exhibit as you see from the script tags at
the head of your html-file. This is correct, it is the last stable
release of Exhibit. Now my suspicion is that you copied
Exhibit.TabularView.prototype._reconstruct not from version 2.2.0 but
from "trunk" the most recent development version of exhibit. So, could
you copy Exhibit.TabularView.prototype._reconstruct from version 2.2.0
and make the two small adjustments in that file. You can find version
2.2.0 on Google's Exhbit page under Source - Browse - tags - 2.2.0 -
src - webapp - api - scripts - ui - views - tabular-view.js. Hopefully
that solves your error.

Michiel
Message has been deleted

lbjvg

unread,
Nov 6, 2009, 9:00:42 AM11/6/09
to SIMILE Widgets
Michiel - You are a genius! I know I've said that already, but I am
so happy you are available to do the heavy lifting. I never would
have figured this out in a million years.

This takes my Exhibit quite far along the road to perfection.
Ideally, it would be nice to have the highlighted items sorted to the
top of the items list and use numbers instead of or in addition to
colors.


Update - At my work I have to use IE6 - So, this AM I discovered that
the Exhibit doesn't doesn't work in IE6. Is there an easy fix for
this? Otherwise I believe that it is possible to detect the browser
and if it is IE6 can I direct it to another version of the Exhibit
that doesn't crash it?


Thanks again - Jim


contemplative

unread,
Nov 6, 2009, 11:28:02 AM11/6/09
to SIMILE Widgets
I have been fighting to make SIMILE work in IE6/7 for some time now
and finally found this.

http://code.google.com/chrome/chromeframe/developers_guide.html

I have been using it for two days now, and have had good luck with
it. The document at the link
provides everything one needs to do to make this work. My experience
thus far is that my heaviest
exhibit loads in IE7 in < 5 seconds, whereas the same exhibit would
load in just over a minute or not at all
previously. Implementing this took me all of 2 minutes!

I have not tested this in IE6 or IE8, so YMMV.

There is one other very nice feature included, "Inspect Element",
which I find to be much better than the
IE Developer Tool for examining DOM, CSS... etc...

Hope you find this helpful...

wjw

lbjvg

unread,
Nov 6, 2009, 9:51:59 PM11/6/09
to SIMILE Widgets
wjw - That is a great suggestion. It took me a little while to
understand the intent of Google Chrome Frame to improve IE - but I
have implemented and it works on IE7 at home. Hopefully it will
perform the same magic on IE6 at work. Thanks for pointing that out!
- Jim
Reply all
Reply to author
Forward
0 new messages