fix id() bug in ScalarDimension

This commit is contained in:
bkmartinjr
2018-05-30 09:23:25 -07:00
parent a0c6e3102b
commit 0b50f02d55
+8 -8
View File
@@ -65,7 +65,7 @@ class TypedCrossfilter {
_freeDimension(id) { _freeDimension(id) {
this.selection.freeDimension(id); this.selection.freeDimension(id);
this.filters = this.filters.filter(f => f.id != id); this.filters = this.filters.filter(f => f._id != id);
} }
// return array of all records that are selected/filtered // return array of all records that are selected/filtered
@@ -105,7 +105,7 @@ class TypedCrossfilter {
class ScalarDimension { class ScalarDimension {
constructor(value, valueArrayType, crossfilter, id) { constructor(value, valueArrayType, crossfilter, id) {
this.crossfilter = crossfilter; this.crossfilter = crossfilter;
this.id = id; this._id = id;
// current selection filter, expressed as PostiveIntervals. // current selection filter, expressed as PostiveIntervals.
this.currentFilter = []; this.currentFilter = [];
@@ -133,11 +133,11 @@ class ScalarDimension {
} }
dispose() { dispose() {
this.crossfilter._freeDimension(this.id); this.crossfilter._freeDimension(this._id);
} }
id() { id() {
return this.id; return this._id;
} }
_updateFilters(newFilter) { _updateFilters(newFilter) {
@@ -147,26 +147,26 @@ class ScalarDimension {
// more complex work and just clobber everything. // more complex work and just clobber everything.
// //
if (newFilter.length === 0) { if (newFilter.length === 0) {
this.crossfilter.selection.deselectAll(this.id); this.crossfilter.selection.deselectAll(this._id);
} else if ( } else if (
newFilter.length === 1 && newFilter.length === 1 &&
newFilter[0][0] === 0 && newFilter[0][0] === 0 &&
newFilter[0][1] == this.index.length newFilter[0][1] == this.index.length
) { ) {
this.crossfilter.selection.selectAll(this.id); this.crossfilter.selection.selectAll(this._id);
} else { } else {
const adds = PositiveIntervals.difference(newFilter, this.currentFilter); const adds = PositiveIntervals.difference(newFilter, this.currentFilter);
const dels = PositiveIntervals.difference(this.currentFilter, newFilter); const dels = PositiveIntervals.difference(this.currentFilter, newFilter);
dels.forEach(interval => dels.forEach(interval =>
this.crossfilter.selection.deselectIndirectFromRange( this.crossfilter.selection.deselectIndirectFromRange(
this.id, this._id,
this.index, this.index,
interval interval
) )
); );
adds.forEach(interval => adds.forEach(interval =>
this.crossfilter.selection.selectIndirectFromRange( this.crossfilter.selection.selectIndirectFromRange(
this.id, this._id,
this.index, this.index,
interval interval
) )