Skip to content

Commit

Permalink
Merge pull request #159 from RhoInc/no-extra-columns
Browse files Browse the repository at this point in the history
No extra columns
  • Loading branch information
samussiah authored Jul 19, 2019
2 parents 5b54b21 + 3421917 commit 8661a8f
Show file tree
Hide file tree
Showing 7 changed files with 5,116 additions and 66 deletions.
97 changes: 63 additions & 34 deletions queryOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,10 @@
'.qo-component--controls .wc-controls {' +
' margin-bottom: 0;' +
' display: flex;' +
' width: 90%;' +
' width: 100%;' +
' justify-content: space-around;' +
' border-bottom: 1px solid #aaa;' +
' margin-bottom: 5px;' +
'}',
'.qo-control-grouping {' + ' display: inline-block;' + '}',
'.qo-button {' + ' float: left;' + ' display: block;' + '}',
Expand All @@ -716,22 +718,22 @@
Other controls
\---------------------------------------------------------------------------------****/
'.qo-control-grouping--other-controls {' +
' float: left;' +
' display: flex;' +
' flex-wrap: wrap;' +
' justify-content: space-evenly;' +
' float: right;' + //' display: flex;' +
//' flex-wrap: wrap;' +
//' justify-content: space-evenly;' +
' width: 25%;' +
'}',
'.qo-control-grouping--other-controls .control-group {' +
' width: 100%;' +
' margin-bottom: 15px;' +
' margin-bottom: 5px;' +
'}',
'.qo-control-grouping--other-controls .control-group:nth-child(n+3) {' +
' border-top: 1px solid #aaa;' +
'}',
'.qo-control-grouping--other-controls .control-group .wc-control-label {' +
' text-align: center;' +
' font-size: 110%;' +
' width: 100%;' +
'}', //dropdowns
'.qo-dropdown {' + '}',
'.qo-dropdown .wc-control-label {' + '}',
Expand Down Expand Up @@ -779,8 +781,11 @@
'.qo-component--chart {' +
' width: 100%;' +
' margin: 0 auto;' +
' margin-bottom: 5px;' +
' padding-bottom: 5px;' +
' float: left;' +
' position: relative;' +
' border-bottom: 1px solid #aaa;' +
'}',
'.qo-button--reset-chart {' +
' position: absolute;' +
Expand All @@ -799,6 +804,7 @@
' padding: 3px 0;' +
'}',
'.qo-component--chart .wc-chart {' + ' z-index: 1;' + '}',
'.qo-component--chart .legend {' + ' width: auto;' + '}',
'.qo-component--chart .legend-title {' + ' cursor: help;' + '}',
'.qo-component--chart .legend-item {' +
' cursor: pointer;' +
Expand Down Expand Up @@ -852,49 +858,37 @@
}

function defineListingSettings() {
var _this = this;

this.listing.config.cols = this.config.details
? this.config.details.map(function(d) {
return d.value_col;
})
: Object.keys(this.raw_data[0]).filter(function(key) {
return key !== 'Form: Field';
});
return ['Form: Field', _this.config.recency_category_col].indexOf(key) < 0;
}); // remove derived variables (recency_category_col is captured in variable queryrecency, derived in ./defineNewVariables)

this.listing.config.headers = this.config.details
? this.config.details.map(function(d) {
return d.label;
})
: Object.keys(this.raw_data[0]).filter(function(key) {
return key !== 'Form: Field';
return ['Form: Field', _this.config.recency_category_col].indexOf(key) < 0;
});
}

function defineNewVariables() {
var _this = this;

var queryAgeCol = this.config.status_groups.find(function(status_group) {
return status_group.label === 'Query Age';
}).value_col;
var queryRecencyCol = this.config.filters.find(function(filter) {
return filter.label === 'Query Recency';
}).value_col;
var queryAgeCol = this.config.status_groups.find(function(status_group) {
return status_group.label === 'Query Age';
}).value_col;
this.raw_data.forEach(function(d) {
//Concatenate form and field to avoid duplicates across forms.
d['Form: Field'] = d[_this.config.form_col] + ': ' + d[_this.config.field_col]; //Define query age.

if (_this.config.age_statuses.indexOf(d[_this.config.status_col]) < 0)
d[queryAgeCol] = d[_this.config.status_col];
else {
var age = +d[_this.config.age_col];

_this.config.ageRanges.forEach(function(ageRange, i) {
if (i === 0 && ageRange[0] <= age && age <= ageRange[1])
d[queryAgeCol] = _this.config.ageRangeCategories[i];
else if (i === _this.config.ageRanges.length - 1 && ageRange[0] < age)
d[queryAgeCol] = _this.config.ageRangeCategories[i];
else if (ageRange[0] < age && age <= ageRange[1])
d[queryAgeCol] = _this.config.ageRangeCategories[i];
});
} //Define query recency.
d['Form: Field'] = d[_this.config.form_col] + ': ' + d[_this.config.field_col]; //Define query recency.

if (d.hasOwnProperty(_this.config.recency_category_col)) {
d[queryRecencyCol] = d[_this.config.recency_category_col] || 'N/A';
Expand All @@ -912,6 +906,21 @@
else if (recencyRange[0] < recency && recency <= recencyRange[1])
d[queryRecencyCol] = _this.config.recencyRangeCategories[i];
});
} //Define query age.

if (_this.config.age_statuses.indexOf(d[_this.config.status_col]) < 0)
d[queryAgeCol] = d[_this.config.status_col];
else {
var age = +d[_this.config.age_col];

_this.config.ageRanges.forEach(function(ageRange, i) {
if (i === 0 && ageRange[0] <= age && age <= ageRange[1])
d[queryAgeCol] = _this.config.ageRangeCategories[i];
else if (i === _this.config.ageRanges.length - 1 && ageRange[0] < age)
d[queryAgeCol] = _this.config.ageRangeCategories[i];
else if (ageRange[0] < age && age <= ageRange[1])
d[queryAgeCol] = _this.config.ageRangeCategories[i];
});
}
});
}
Expand Down Expand Up @@ -2388,12 +2397,6 @@
description:
'Number of days between query open date and data extraction date, regardless of query status.'
},
{
variable: this.chart.initialSettings.recency_category_col,
label: 'Query Recency',
description:
'Number of days by category between query open date and data extraction date, regardless of query status. Categories include last 7, 14, and 30 days.'
},
{
variable: 'queryrecency',
label: 'Query Recency',
Expand Down Expand Up @@ -2655,7 +2658,33 @@
}

function onDraw$1() {
var _this = this;

//console.log(this.table.selectAll('thead tr th'));
//console.log(this.table.selectAll('tbody tr:first-child td'));
var variables = Object.keys(this.data.raw[0]) //.sort(d3.ascending)
.map(function(variable, i) {
return {
variable: variable,
column: _this.config.cols.find(function(col) {
return col === variable;
}),
columnIndex: _this.config.cols.findIndex(function(col) {
return col === variable;
}),
header:
_this.config.headers[
_this.config.cols.findIndex(function(col) {
return col === variable;
})
],
headerIndex: _this.config.headers.findIndex(function(col) {
return col === variable;
})
};
}); //console.table(variables.sort((a,b) => a.index - b.index));
//Add tooltips to column headers.

addHeaderTooltips.call(this); //Update default Webcharts column sorting.

updateColumnSorting.call(this); //Truncate cells with length greater than `settings.truncation_cutoff`.
Expand Down
8 changes: 6 additions & 2 deletions src/chart/onInit/defineListingSettings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export default function defineListingSettings() {
this.listing.config.cols = this.config.details
? this.config.details.map(d => d.value_col)
: Object.keys(this.raw_data[0]).filter(key => key !== 'Form: Field');
: Object.keys(this.raw_data[0]).filter(
key => ['Form: Field', this.config.recency_category_col].indexOf(key) < 0
); // remove derived variables (recency_category_col is captured in variable queryrecency, derived in ./defineNewVariables)
this.listing.config.headers = this.config.details
? this.config.details.map(d => d.label)
: Object.keys(this.raw_data[0]).filter(key => key !== 'Form: Field');
: Object.keys(this.raw_data[0]).filter(
key => ['Form: Field', this.config.recency_category_col].indexOf(key) < 0
);
}
34 changes: 17 additions & 17 deletions src/chart/onInit/defineNewVariables.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
export default function defineNewVariables() {
const queryRecencyCol = this.config.filters.find(filter => filter.label === 'Query Recency')
.value_col;
const queryAgeCol = this.config.status_groups.find(
status_group => status_group.label === 'Query Age'
).value_col;
const queryRecencyCol = this.config.filters.find(filter => filter.label === 'Query Recency')
.value_col;

this.raw_data.forEach(d => {
//Concatenate form and field to avoid duplicates across forms.
d['Form: Field'] = d[this.config.form_col] + ': ' + d[this.config.field_col];

//Define query age.
if (this.config.age_statuses.indexOf(d[this.config.status_col]) < 0)
d[queryAgeCol] = d[this.config.status_col];
else {
const age = +d[this.config.age_col];
this.config.ageRanges.forEach((ageRange, i) => {
if (i === 0 && ageRange[0] <= age && age <= ageRange[1])
d[queryAgeCol] = this.config.ageRangeCategories[i];
else if (i === this.config.ageRanges.length - 1 && ageRange[0] < age)
d[queryAgeCol] = this.config.ageRangeCategories[i];
else if (ageRange[0] < age && age <= ageRange[1])
d[queryAgeCol] = this.config.ageRangeCategories[i];
});
}

//Define query recency.
if (d.hasOwnProperty(this.config.recency_category_col)) {
d[queryRecencyCol] = d[this.config.recency_category_col] || 'N/A';
Expand All @@ -38,5 +23,20 @@ export default function defineNewVariables() {
d[queryRecencyCol] = this.config.recencyRangeCategories[i];
});
}

//Define query age.
if (this.config.age_statuses.indexOf(d[this.config.status_col]) < 0)
d[queryAgeCol] = d[this.config.status_col];
else {
const age = +d[this.config.age_col];
this.config.ageRanges.forEach((ageRange, i) => {
if (i === 0 && ageRange[0] <= age && age <= ageRange[1])
d[queryAgeCol] = this.config.ageRangeCategories[i];
else if (i === this.config.ageRanges.length - 1 && ageRange[0] < age)
d[queryAgeCol] = this.config.ageRangeCategories[i];
else if (ageRange[0] < age && age <= ageRange[1])
d[queryAgeCol] = this.config.ageRangeCategories[i];
});
}
});
}
14 changes: 14 additions & 0 deletions src/listing/onDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import truncateCellText from './onDraw/truncateCellText';
import moveScrollBarLeft from './onDraw/moveScrollBarLeft';

export default function onDraw() {
//console.log(this.table.selectAll('thead tr th'));
//console.log(this.table.selectAll('tbody tr:first-child td'));
const variables = Object.keys(this.data.raw[0])
//.sort(d3.ascending)
.map((variable, i) => {
return {
variable,
column: this.config.cols.find(col => col === variable),
columnIndex: this.config.cols.findIndex(col => col === variable),
header: this.config.headers[this.config.cols.findIndex(col => col === variable)],
headerIndex: this.config.headers.findIndex(col => col === variable)
};
});
//console.table(variables.sort((a,b) => a.index - b.index));
//Add tooltips to column headers.
addHeaderTooltips.call(this);

Expand Down
6 changes: 0 additions & 6 deletions src/listing/onInit/applyVariableMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ export default function applyVariableMetadata() {
description:
'Number of days between query open date and data extraction date, regardless of query status.'
},
{
variable: this.chart.initialSettings.recency_category_col,
label: 'Query Recency',
description:
'Number of days by category between query open date and data extraction date, regardless of query status. Categories include last 7, 14, and 30 days.'
},
{
variable: 'queryrecency',
label: 'Query Recency',
Expand Down
22 changes: 15 additions & 7 deletions src/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export default function styles(document) {
'.qo-component--controls .wc-controls {' +
' margin-bottom: 0;' +
' display: flex;' +
' width: 90%;' +
' width: 100%;' +
' justify-content: space-around;' +
' border-bottom: 1px solid #aaa;' +
' margin-bottom: 5px;' +
'}',
'.qo-control-grouping {' +
' display: inline-block;' +
Expand Down Expand Up @@ -59,24 +61,24 @@ export default function styles(document) {
Other controls
\---------------------------------------------------------------------------------****/


'.qo-control-grouping--other-controls {' +
' float: left;' +
' display: flex;' +
' flex-wrap: wrap;' +
' justify-content: space-evenly;' +
' float: right;' +
//' display: flex;' +
//' flex-wrap: wrap;' +
//' justify-content: space-evenly;' +
' width: 25%;' +
'}',
'.qo-control-grouping--other-controls .control-group {' +
' width: 100%;' +
' margin-bottom: 15px;' +
' margin-bottom: 5px;' +
'}',
'.qo-control-grouping--other-controls .control-group:nth-child(n+3) {' +
' border-top: 1px solid #aaa;' +
'}',
'.qo-control-grouping--other-controls .control-group .wc-control-label {' +
' text-align: center;' +
' font-size: 110%;' +
' width: 100%;' +
'}',

//dropdowns
Expand Down Expand Up @@ -151,8 +153,11 @@ export default function styles(document) {
'.qo-component--chart {' +
' width: 100%;' +
' margin: 0 auto;' +
' margin-bottom: 5px;' +
' padding-bottom: 5px;' +
' float: left;' +
' position: relative;' +
' border-bottom: 1px solid #aaa;' +
'}',
'.qo-button--reset-chart {' +
' position: absolute;' +
Expand All @@ -173,6 +178,9 @@ export default function styles(document) {
'.qo-component--chart .wc-chart {' +
' z-index: 1;' +
'}',
'.qo-component--chart .legend {' +
' width: auto;' +
'}',
'.qo-component--chart .legend-title {' +
' cursor: help;' +
'}',
Expand Down
Loading

0 comments on commit 8661a8f

Please sign in to comment.