Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make falsy filter options and legend values apparent #271

Open
wants to merge 8 commits into
base: dev-v1.11.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions build/webcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@
? d
: filter.val instanceof Array
? filter.val.indexOf(d[filter.col]) > -1
: d[filter.col] === filter.val;
: d[filter.col] + '' === filter.val + '';
});
});
} //Summarize data for each mark.
Expand Down Expand Up @@ -1116,7 +1116,7 @@
? d
: e.val instanceof Array
? e.val.indexOf(d[e.col]) > -1
: d[e.col] === e.val;
: d[e.col] + '' === e.val.toString() + '';
});
}); //get domain for all non-All values of first filter

Expand Down Expand Up @@ -1302,10 +1302,8 @@
return m[config.color_by];
})
)
.values()
.filter(function(f) {
return f && f !== 'undefined';
});
.values(); //.filter(f => f && f !== 'undefined');

if (config.legend.order)
colordom.sort(function(a, b) {
return d3.ascending(config.legend.order.indexOf(a), config.legend.order.indexOf(b));
Expand Down Expand Up @@ -3221,14 +3219,10 @@
? control.values
: d3
.set(
this.data
.map(function(m) {
return m[control.value_col];
})
.filter(function(f) {
return f;
})
)
this.data.map(function(m) {
return m[control.value_col];
})
) //.filter(f => f))
.values()
.sort(naturalSorter); // only sort when values are derived
//initial dropdown option
Expand Down
6 changes: 3 additions & 3 deletions build/webcharts.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/chart/draw/consolidateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function consolidateData(raw) {
? d
: filter.val instanceof Array
? filter.val.indexOf(d[filter.col]) > -1
: d[filter.col] === filter.val;
: d[filter.col] + '' === filter.val + '';
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/chart/draw/consolidateData/transformData.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function transformData(raw, mark) {
? d
: e.val instanceof Array
? e.val.indexOf(d[e.col]) > -1
: d[e.col] === e.val;
: d[e.col] + '' === e.val.toString() + '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samussiah why is this explicitly casted here but not elsewhere?

});
});
//get domain for all non-All values of first filter
Expand Down
5 changes: 2 additions & 3 deletions src/chart/draw/setColorScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ export default function setColorScale() {
const colordom =
Array.isArray(config.color_dom) && config.color_dom.length
? config.color_dom.slice()
: set(data.map(m => m[config.color_by]))
.values()
.filter(f => f && f !== 'undefined');
: set(data.map(m => m[config.color_by])).values();
//.filter(f => f && f !== 'undefined');

if (config.legend.order)
colordom.sort((a, b) =>
Expand Down
16 changes: 8 additions & 8 deletions src/controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import destroy from './destroy';
import init from './init';
import layout from './layout';
import makeControlItem from './makeControlItem';
import makeBtnGroupControl from './makeBtnGroupControl';
import makeCheckboxControl from './makeCheckboxControl';
import makeDropdownControl from './makeDropdownControl';
import makeListControl from './makeListControl';
import makeNumberControl from './makeNumberControl';
import makeRadioControl from './makeRadioControl';
import makeSubsetterControl from './makeSubsetterControl';
import makeTextControl from './makeTextControl';
import makeBtnGroupControl from './makeControlItem/makeBtnGroupControl';
import makeCheckboxControl from './makeControlItem/makeCheckboxControl';
import makeDropdownControl from './makeControlItem/makeDropdownControl';
import makeListControl from './makeControlItem/makeListControl';
import makeNumberControl from './makeControlItem/makeNumberControl';
import makeRadioControl from './makeControlItem/makeRadioControl';
import makeSubsetterControl from './makeControlItem/makeSubsetterControl';
import makeTextControl from './makeControlItem/makeTextControl';
import stringAccessor from './stringAccessor';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import naturalSorter from '../dataOps/naturalSorter';
import naturalSorter from '../../dataOps/naturalSorter';
import { set, select } from 'd3';

export default function makeSubsetterControl(control, control_wrap) {
Expand All @@ -14,7 +14,7 @@ export default function makeSubsetterControl(control, control_wrap) {
//dropdown option data
const option_data = control.values
? control.values
: set(this.data.map(m => m[control.value_col]).filter(f => f))
: set(this.data.map(m => m[control.value_col])) //.filter(f => f))
.values()
.sort(naturalSorter); // only sort when values are derived

Expand Down