Add filter panel columns without color layouts - #42
Merged
Conversation
The only way to get a column into the filter panel was add_color_layout, which also works out a colormap for it. That made adding a column just to filter on it slower than it needs to be. Add TmapViz.add_filter(name, values, categorical=False, add_as_label=True). It packs the column exactly like a color layout does (a slider for numbers, one clickable bar per group for categories) but skips the color work and stays out of the color selector. Color layouts can already be filtered on, so add_filter columns go into the panel on top of them. Setting filterable by hand still replaces the lot. No JavaScript changes were needed for the panel itself, which reads metadata.filters and fetches whatever it names. One template change: the neighbour comparison strip picked its numbers from the color layouts alone, so it came up empty on a map built only with add_filter. It now draws from the filter panel and the color layouts together. Fixes #29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29.
The problem
The only way to get a column into the filter panel was
add_color_layout,which also picks a colormap for it. If you only wanted to filter on a column,
you paid for colors you were never going to use.
The fix
The column is packed exactly the way a color layout is, so the panel behaves
the same: a slider for numbers, one clickable bar per group for categories.
What it skips is the color work, and it stays out of the color selector.
Color layouts can already be filtered on, so
add_filtercolumns go into thepanel on top of them rather than instead of them. Setting
filterableby handstill replaces the lot:
add_as_label=Falsekeeps a filter column out of the hover tooltip.Calling
add_filteron a name that is already a color layout raises, sincethat column can already be filtered on and overwriting it would lose its
colors.
What changed
TmapViz.add_filter, plus afilter/filter+labelcolumn role.add_color_layoutmoved into a shared helper, so bothmethods reject text in a numeric column the same way.
metadata.filtersand fetches whatever that names.
the color layouts alone, so it came up empty on a map built only with
add_filter. It now draws from the filter panel and the color layoutstogether.
docs/visualization_guide.mdanddocs/api_reference.md.Tests
12 new tests: the column is registered but is not a layout, no colormap is
produced for it, categorical and numeric packing,
add_as_label, the error ona name that is already a layout, panel ordering,
filterablestill winning,and the comparison strip falling back to the filter columns.