dashboard-charts
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -265,3 +265,3 @@ (function(global, factory) { | ||
//Define ordered status set. | ||
this.status_set = d3 | ||
var status_set = d3 | ||
.set( | ||
@@ -302,3 +302,3 @@ this.raw_data.map(function(d) { | ||
if (!(Array.isArray(this.config.color_dom) && this.config.color_dom.length)) | ||
this.config.color_dom = this.status_set.map(function(status) { | ||
this.config.color_dom = status_set.map(function(status) { | ||
return status.split(':|:')[0]; | ||
@@ -308,3 +308,3 @@ }); | ||
this.config.color_dom = this.config.color_dom.concat( | ||
this.status_set | ||
status_set | ||
.map(function(status) { | ||
@@ -320,3 +320,3 @@ return status.split(':|:')[0]; | ||
if (variables.indexOf(status_color_col) > -1) | ||
this.config.colors = this.status_set.map(function(status) { | ||
this.config.colors = status_set.map(function(status) { | ||
return status.split(':|:')[2]; | ||
@@ -327,3 +327,3 @@ }); | ||
if (!(Array.isArray(this.config.legend.order) && this.config.legend.order.length)) | ||
this.config.legend.order = this.status_set.map(function(status) { | ||
this.config.legend.order = status_set.map(function(status) { | ||
return status.split(':|:')[0]; | ||
@@ -333,3 +333,3 @@ }); | ||
this.config.legend.order = this.config.legend.order.concat( | ||
this.status_set | ||
status_set | ||
.map(function(status) { | ||
@@ -342,2 +342,10 @@ return status.split(':|:')[0]; | ||
); | ||
//Order raw data so stacked bars are ordered correctly. | ||
this.raw_data.sort(function(a, b) { | ||
return ( | ||
_this.config.legend.order.indexOf(a[_this.config.status_col]) - | ||
_this.config.legend.order.indexOf(b[_this.config.status_col]) | ||
); | ||
}); | ||
} | ||
@@ -575,3 +583,91 @@ | ||
var slicedToArray = (function() { | ||
function sliceIterator(arr, i) { | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for ( | ||
var _i = arr[Symbol.iterator](), _s; | ||
!(_n = (_s = _i.next()).done); | ||
_n = true | ||
) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i['return']) _i['return'](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
return function(arr, i) { | ||
if (Array.isArray(arr)) { | ||
return arr; | ||
} else if (Symbol.iterator in Object(arr)) { | ||
return sliceIterator(arr, i); | ||
} else { | ||
throw new TypeError('Invalid attempt to destructure non-iterable instance'); | ||
} | ||
}; | ||
})(); | ||
function defineOrder(data, value_col, order_col) { | ||
//Define set of values. | ||
var values = d3 | ||
.set( | ||
data.map(function(d) { | ||
return d[value_col] + ':|:' + d[order_col]; | ||
}) | ||
) | ||
.values(); | ||
//Order values. | ||
var orderedValues = values | ||
.map(function(value_order) { | ||
var _value_order$split = value_order.split(':|:'), | ||
_value_order$split2 = slicedToArray(_value_order$split, 2), | ||
value = _value_order$split2[0], | ||
order = _value_order$split2[1]; | ||
return { | ||
value: value, | ||
order: order, | ||
float: parseFloat(order) | ||
}; | ||
}) | ||
.sort(function(a, b) { | ||
return !isNaN(a.float) && !isNaN(b.float) // numerical comparison | ||
? a.float - b.float | ||
: a.order < b.order // alphanumeric ordering - left-side order is smaller | ||
? -1 | ||
: b.order < a.order // alphanumeric ordering - right-side order is smaller | ||
? 1 | ||
: a.value < b.value // equal left- and right-side order - left-side value is smaller | ||
? -1 | ||
: 1; // equal left- and right-side order - right-side value is smaller | ||
}); | ||
return orderedValues; | ||
} | ||
function onInit$1() { | ||
this.config.x.order = defineOrder( | ||
this.raw_data, | ||
this.config.visit_col, | ||
this.config.visit_order_col | ||
).map(function(element) { | ||
return element.value; | ||
}); | ||
defineStatusSet.call( | ||
@@ -591,7 +687,17 @@ this, | ||
function setYFormat() { | ||
switch (this.config.marks[0].summarizeY) { | ||
case 'count': | ||
this.config.y.format = '1d'; | ||
break; | ||
case 'percent': | ||
this.config.y.format = '%'; | ||
break; | ||
default: | ||
this.config.y.format = null; | ||
} | ||
} | ||
function onDraw$1() { | ||
var summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} | ||
@@ -738,6 +844,3 @@ | ||
function onDraw$2() { | ||
var summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} | ||
@@ -1113,6 +1216,3 @@ | ||
function onDraw$4() { | ||
var summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} | ||
@@ -1119,0 +1219,0 @@ |
{ | ||
"name": "dashboard-charts", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Clinical Dashboards", | ||
@@ -5,0 +5,0 @@ "module": "./src/index.js", |
@@ -0,6 +1,5 @@ | ||
import setYFormat from '../../util/setYFormat'; | ||
export default function onDraw() { | ||
const summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} |
@@ -0,6 +1,5 @@ | ||
import setYFormat from '../../util/setYFormat'; | ||
export default function onDraw() { | ||
const summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} |
@@ -5,3 +5,3 @@ export default function defineStatusSet(status_col, status_order_col, status_color_col) { | ||
//Define ordered status set. | ||
this.status_set = d3 | ||
const status_set = d3 | ||
.set( | ||
@@ -40,6 +40,6 @@ this.raw_data.map( | ||
if (!(Array.isArray(this.config.color_dom) && this.config.color_dom.length)) | ||
this.config.color_dom = this.status_set.map(status => status.split(':|:')[0]); | ||
this.config.color_dom = status_set.map(status => status.split(':|:')[0]); | ||
else | ||
this.config.color_dom = this.config.color_dom.concat( | ||
this.status_set | ||
status_set | ||
.map(status => status.split(':|:')[0]) | ||
@@ -51,13 +51,20 @@ .filter(status => this.config.color_dom.indexOf(status) < 0) | ||
if (variables.indexOf(status_color_col) > -1) | ||
this.config.colors = this.status_set.map(status => status.split(':|:')[2]); | ||
this.config.colors = status_set.map(status => status.split(':|:')[2]); | ||
//Update legend order. | ||
if (!(Array.isArray(this.config.legend.order) && this.config.legend.order.length)) | ||
this.config.legend.order = this.status_set.map(status => status.split(':|:')[0]); | ||
this.config.legend.order = status_set.map(status => status.split(':|:')[0]); | ||
else | ||
this.config.legend.order = this.config.legend.order.concat( | ||
this.status_set | ||
status_set | ||
.map(status => status.split(':|:')[0]) | ||
.filter(status => this.config.legend.order.indexOf(status) < 0) | ||
); | ||
//Order raw data so stacked bars are ordered correctly. | ||
this.raw_data.sort( | ||
(a, b) => | ||
this.config.legend.order.indexOf(a[this.config.status_col]) - | ||
this.config.legend.order.indexOf(b[this.config.status_col]) | ||
); | ||
} |
@@ -0,6 +1,5 @@ | ||
import setYFormat from '../../util/setYFormat'; | ||
export default function onDraw() { | ||
const summarizeY = this.config.marks[0].summarizeY; | ||
if (summarizeY === 'count') this.config.y.format = '1d'; | ||
else if (summarizeY === 'percent') this.config.y.format = '%'; | ||
else this.config.y.format = null; | ||
setYFormat.call(this); | ||
} |
@@ -0,4 +1,10 @@ | ||
import defineOrder from '../../util/defineOrder'; | ||
import defineStatusSet from '../../util/defineStatusSet'; | ||
export default function onInit() { | ||
this.config.x.order = defineOrder( | ||
this.raw_data, | ||
this.config.visit_col, | ||
this.config.visit_order_col | ||
).map(element => element.value); | ||
defineStatusSet.call( | ||
@@ -5,0 +11,0 @@ this, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
166912
145
3577