Skip to content

Commit

Permalink
Fix search mode and size (#227)
Browse files Browse the repository at this point in the history
* change default search to be AND, not OR, because AND is how the internet works
* fix: searchbar size modifier. change size to still reflect number of items within node (no longer multiply by ratio)
  • Loading branch information
deargle authored May 12, 2021
1 parent c7e09ed commit b79a508
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
8 changes: 8 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
- `plotlyviz.scomplex_to_graph` no longer casts `color_values` to a 2d array, and `visuals._tooltip_components` now generates
either 1d or 2d `member_histogram` depending on dimensionality of `color_values` (#225)

### Fixed/Changed

- The AND and OR searchbar queries no longer multiplies the base size of a node by the ratio of how many of its items match. Rather,
the base size of the node is simply multiplied by how many of its items match the query. With this change, the size of a node
during an AND or OR search query again directly reflects the number of items within the node. (#227)
- The default search mode is now AND -- because that's the expected behavior, because that's how the google works (#227)


## 2.0.0

### Visualization
Expand Down
8 changes: 4 additions & 4 deletions kmapper/kmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,11 @@ def visualize(
methods, all against lowercased tooltips.
* AND: the search query is split by whitespace. A data point's custom tooltip must
match _each_ of the query terms in order to match overall. The size of a node
is drawn as a ratio of how many of its datapoints match.
match _each_ of the query terms in order to match overall. The base size of a node
is multiplied by the number of datapoints matching the searchquery.
* OR: the search query is split by whitespace. A data point's custom tooltip must
match _any_ of the query terms in order to match overall. The size of a node
is drawn as a ratio of how many of its datapoints match.
match _any_ of the query terms in order to match overall. The base size of a node
is multiplied by the number of datapoints matching the searchquery.
* EXACT: A data point's custom tooltip must exactly match the query. Any nodes
with a matching datapoint are set to glow.
Expand Down
7 changes: 6 additions & 1 deletion kmapper/static/kmapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,14 @@ d3.select('#searchbar')
let node_ratio_fn = (d, i) => {
matches = d.tooltip.custom_tooltips_lowercase.map(map_fn)
let how_many = matches.filter(x=>x).length;

// Future optional feature -- size relative to ratio _within-node_
let out_of = d.tooltip.cluster_stats.size;
let ratio = how_many / out_of;
d.size_modifier = ratio * 100;

// Node sizes will be overall number of items in the node
// number of matching
d.size_modifier = how_many;
}

let map_fn;
Expand Down
4 changes: 2 additions & 2 deletions kmapper/templates/toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ <h3>Node Color Function
<button class='btn' type='submit'>Search</button>
<div class="inline-block">
<div class="inline-block">
<input type="radio" name="search_mode" id='search-mode-or' value="or" checked><label for="search-mode-or">OR</label>
<input type="radio" name="search_mode" id='search-mode-and' value="and" checked><label for="search-mode-and">AND</label>
</div>
<div class="inline-block">
<input type="radio" name="search_mode" id='search-mode-and' value="and"><label for="search-mode-and">AND</label>
<input type="radio" name="search_mode" id='search-mode-or' value="or" ><label for="search-mode-or">OR</label>
</div>
<div class="inline-block">
<input type="radio" name="search_mode" id='search-mode-exact' value="exact"><label for="search-mode-exact">Exact</label>
Expand Down

0 comments on commit b79a508

Please sign in to comment.