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

fix #331 #332

Open
wants to merge 2 commits into
base: master
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
17 changes: 14 additions & 3 deletions build/webcodebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,8 @@
}

function onInit$2() {
var _this = this;

var context = this;
var config = this.initialSettings;
var measure = config.measure;
Expand Down Expand Up @@ -2352,7 +2354,12 @@
if (!this.group) {
this.initialSettings.unfilteredData = this.raw_data;
this.raw_data = this.initialSettings.unfilteredData.filter(function(d) {
return !isNaN(+d[measure]) && !/^\s*$/.test(d[measure]);
return (
_this.config.codebookConfig.missingValues.indexOf(d[measure]) ===
-1 &&
!isNaN(d[measure]) && // [NaN].indexOf(NaN) always returns -1
!/^\s*$/.test(d[measure])
);
});
}

Expand Down Expand Up @@ -2485,7 +2492,8 @@
margin: this_.margin,
nBins: d.bins,
chartType: d.chartType,
commonScale: d.commonScale == undefined ? true : d.commonScale
commonScale: d.commonScale == undefined ? true : d.commonScale,
codebookConfig: d.codebookConfig
};
var chartData = [];

Expand Down Expand Up @@ -3486,7 +3494,7 @@
tabs: ['codebook', 'listing', 'chartMaker', 'settings'],
dataName: '',
whiteSpaceAsMissing: true,
missingValues: [null, NaN, undefined]
missingValues: [null, undefined]
};

function setDefaults(codebook) {
Expand Down Expand Up @@ -4232,6 +4240,9 @@
else g.statistics = summarize.continuous(g.values, sub);
});
}

// Give charts access to codebook object.
varObj.codebookConfig = config;
return varObj;
});

Expand Down
23 changes: 14 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/charts/createHistogramBoxPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export function createHistogramBoxPlot(this_, d) {
margin: this_.margin,
nBins: d.bins,
chartType: d.chartType,
commonScale: d.commonScale == undefined ? true : d.commonScale
commonScale: d.commonScale == undefined ? true : d.commonScale,
codebookConfig: d.codebookConfig
};
let chartData = [];

Expand Down
5 changes: 4 additions & 1 deletion src/charts/histogramBoxPlot/onInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export default function onInit() {
if (!this.group) {
this.initialSettings.unfilteredData = this.raw_data;
this.raw_data = this.initialSettings.unfilteredData.filter(
d => !isNaN(+d[measure]) && !/^\s*$/.test(d[measure])
d =>
this.config.codebookConfig.missingValues.indexOf(d[measure]) === -1 &&
!isNaN(d[measure]) && // [NaN].indexOf(NaN) always returns -1
!/^\s*$/.test(d[measure])
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/codebook/data/makeSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ export function makeSummary(codebook) {
else g.statistics = summarize.continuous(g.values, sub);
});
}

// Give charts access to codebook object.
varObj.codebookConfig = config;
return varObj;
});

Expand Down
2 changes: 1 addition & 1 deletion src/codebook/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const defaultSettings = {
tabs: ['codebook', 'listing', 'chartMaker', 'settings'],
dataName: '',
whiteSpaceAsMissing: true,
missingValues: [null, NaN, undefined]
missingValues: [null, undefined]
};

export default defaultSettings;
6 changes: 1 addition & 5 deletions test-page/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ fetch(
.join(' ')
).replace(/\.csv/i, '');
});
console.log('Data file metadata:');
console.log(json);
//const fileObj = json[Math.floor(Math.random() * json.length)];
const fileObj = json[8];
console.log('Select data file metadata:');
console.log(fileObj);
d3.csv(
fileObj.github_url,
function(d) {
function(d, i) {
return d;
},
function(error, data) {
Expand Down