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 all commits
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
1,186 changes: 633 additions & 553 deletions build/webcharts.js

Large diffs are not rendered by default.

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
1 change: 1 addition & 0 deletions src/chart/draw/consolidateData/setDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function setDefaults() {
this.config.marks = this.config.marks && this.config.marks.length ? this.config.marks : [{}];
this.config.marks.forEach(function(m, i) {
m.id = m.id ? m.id : 'mark' + (i + 1);
m.checkColumns = m.checkColumns !== false ? true : false;
});

this.config.date_format = this.config.date_format || '%x';
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
30 changes: 18 additions & 12 deletions src/chart/draw/consolidateData/transformData/makeNest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ export default function makeNest(mark, entries, sublevel) {
if (sublevel) {
this_nest.key(d => d[sublevel]);
this_nest.sortKeys((a, b) => {
return this.config.x.type === 'time'
? ascending(new Date(a), new Date(b))
: this.config.x.order
? ascending(this.config.x.order.indexOf(a), this.config.x.order.indexOf(b))
: sublevel === this.config.color_by && this.config.legend.order
? ascending(
this.config.legend.order.indexOf(a),
this.config.legend.order.indexOf(b)
)
: this.config.x.type === 'ordinal' || this.config.y.type === 'ordinal'
? naturalSorter(a, b)
: ascending(+a, +b);
let sort;

if (this.config.x.type === 'time') {
sort = ascending(new Date(a), new Date(b));
} else if (this.config.x.order) {
sort = ascending(this.config.x.order.indexOf(a), this.config.x.order.indexOf(b));
} else if (sublevel === this.config.color_by && this.config.legend.order) {
sort = ascending(
this.config.legend.order.indexOf(a),
this.config.legend.order.indexOf(b)
);
} else if (this.config.x.type === 'ordinal' || this.config.y.type === 'ordinal') {
sort = naturalSorter(a, b);
} else {
sort = ascending(+a, +b);
}

return sort;
});
}
this_nest.rollup(r => {
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
4 changes: 2 additions & 2 deletions src/chart/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function init(data, test = false) {
this.initial_data = data;

let startup = data => {
//connect this chart and its controls, if any
// connect this chart and its controls, if any
if (this.controls) {
this.controls.targets.push(this);
if (!this.controls.ready) {
Expand All @@ -36,7 +36,7 @@ export default function init(data, test = false) {
}
}

//make sure container is visible (has height and width) before trying to initialize
// make sure container is visible (has height and width) before trying to initialize
var visible = select(this.div).property('offsetWidth') > 0 || test;
if (!visible) {
console.warn(
Expand Down
2 changes: 1 addition & 1 deletion src/chart/init/checkRequired.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function checkRequired(data) {
requiredVars.push('this.config.marks[' + i + '].split');
requiredCols.push(e.split);
}
if (e.values) {
if (e.values && e.checkColumns) {
for (const value in e.values) {
requiredVars.push('this.config.marks[' + i + "].values['" + value + "']");
requiredCols.push(value);
Expand Down
Loading