Skip to content

Commit

Permalink
avoid double filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 8, 2018
1 parent 80ffe0d commit d55c37b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"src/**/*.d.ts": true,
"**/*.map": true,
".cache-loader": true
},
"editor.formatOnSave": true,
},
"beautify.options": {
"editorconfig": true,
"end_with_newline": true,
"preserve_newlines": true,
"space_in_paren": true,
Expand Down
19 changes: 4 additions & 15 deletions src/renderer/CategoricalCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ function staticSummary(col: ICategoricalLikeColumn, context: IRenderContext, int
return {
template: `${template}</div>`,
update: (n: HTMLElement) => {
return context.tasks.summaryCategoricalStats(col).then((data) => {
if (typeof data === 'symbol') {
return context.tasks.summaryCategoricalStats(col).then((r) => {
if (typeof r === 'symbol') {
return;
}
const {summary} = data;
const {summary, data} = r;
n.classList.toggle(cssClass('missing'), !summary);
if (!summary) {
return;
}
update(n, summary, summary);
update(n, summary, data);
});
}
};
Expand Down Expand Up @@ -169,7 +169,6 @@ export function interactiveHist(col: HasCategoricalFilter, node: HTMLElement) {
if (old == null || !Array.isArray(old.filter)) {
// deselect
const included = col.categories.slice();
bin.dataset.filtered = '';
included.splice(i, 1);
col.setFilter({
filterMissing: old ? old.filterMissing : false,
Expand All @@ -181,11 +180,9 @@ export function interactiveHist(col: HasCategoricalFilter, node: HTMLElement) {
const contained = filter.indexOf(cat.name);
if (contained >= 0) {
// remove
bin.dataset.filtered = '';
filter.splice(contained, 1);
} else {
// readd
delete bin.dataset.filtered;
filter.push(cat.name);
}
if (!old.filterMissing && filter.length === col.categories.length) {
Expand Down Expand Up @@ -222,15 +219,7 @@ export function interactiveHist(col: HasCategoricalFilter, node: HTMLElement) {

return (missing: number, actCol: HasCategoricalFilter) => {
col = actCol;
const cats = col.categories;
const f = col.getFilter();
bins.forEach((bin, i) => {
if (!isCategoryIncluded(f, cats[i])) {
bin.dataset.filtered = '';
} else {
delete bin.dataset.filtered;
}
});
if (filterMissing) {
filterMissing.checked = f != null && f.filterMissing;
updateFilterMissingNumberMarkup(<HTMLElement>filterMissing.parentElement, missing);
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/CategoricalStackedDistributionlCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export default class CategoricalStackedDistributionlCellRenderer implements ICel
if (typeof r === 'symbol') {
return;
}
const {summary, group} = r;
const {group} = r;

update(n, group, summary);
update(n, group);
});
}
};
Expand All @@ -53,13 +53,13 @@ function staticSummary(col: ICategoricalColumn, context: IRenderContext) {
if (typeof r === 'symbol') {
return;
}
const {summary} = r;
const {summary, data} = r;

n.classList.toggle(cssClass('missing'), !summary);
if (!summary) {
return;
}
update(n, summary);
update(n, summary, data);
});
}
};
Expand Down Expand Up @@ -87,7 +87,7 @@ function interactiveSummary(col: HasCategoricalFilter, context: IRenderContext,
if (!summary) {
return;
}
update(n, summary);
update(n, summary, data);
});
}
};
Expand Down
4 changes: 0 additions & 4 deletions src/styles/renderer/_histogram.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ span.#{$lu_css_prefix}-mapping-hint {
margin: 0 1px 0 0;
font-size: x-small;

&[data-filtered] {
opacity: $lu_filtered_opacity;
}

> div {
position: absolute;
left: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/EngineRanking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ export default class EngineRanking extends ACellTableSection<RenderColumn> imple
const length = group.order.length;

const n = provider.getTopNAggregated(this.ranking, groups[0]);
// -1 = show items, 0 = group only, 5 = group + top 5
if (n >= 0) {
r.push(Object.assign({meta: toGroupMeta(0, n)}, group));
}

const slice = Math.min(n > 0 ? n : Number.POSITIVE_INFINITY, length);
const slice = Math.min(n >= 0 ? n : Number.POSITIVE_INFINITY, length);
const metaShift = n > 0 ? 1 : 0; // shift by one to avoid having a start
for (let i = 0; i < slice; ++i) {
const dataIndex = group.order[i];
Expand Down

0 comments on commit d55c37b

Please sign in to comment.