Skip to content
Closed
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
6 changes: 5 additions & 1 deletion R/generateSettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ generateSettings <- function(standard="None", charts=NULL, useDefaults=TRUE, par
type <- safetyGraphics::getSettingsMetadata(text_keys=text_key,cols="setting_type")
value <- key_values[row,"value"][[1]]
finalValue <- value[[1]]

if(type=="vector"){
print(text_key)
print(typeof(finalValue))
print(length(finalValue))
}
#print(paste(text_key," (",type,"):",toString(value),typeof(value),length(value),"->",finalValue,typeof(finalValue),length(finalValue)))
shell<-setSettingsValue(
settings = shell,
Expand Down
3 changes: 2 additions & 1 deletion inst/eDISH_app/modules/renderChart/render_edish_chart.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ render_edish_chart <- function(input, output, session, data, settings, valid){
req(settings())

# if (valid()==TRUE){
trimmed_data <- safetyGraphics:::trimData(data = data(), settings = settings())
#trimmed_data <- safetyGraphics:::trimData(data = data(), settings = settings())
trimmed_data<-data()
eDISH(data = trimmed_data, settings = settings())
# } else{
# return()
Expand Down
8 changes: 4 additions & 4 deletions inst/htmlwidgets/eDISH.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ dependencies:
src: htmlwidgets/lib/d3-3.5.17
script: d3.v3.min.js
- name: webcharts
version: 1.11.3
src: htmlwidgets/lib/webcharts-1.11.3
version: 1.11.5
src: htmlwidgets/lib/webcharts-1.11.5
script: webcharts.js
stylesheet: webcharts.css
- name: safety-eDish
version: 0.16.3
src: htmlwidgets/lib/safety-eDISH-0.16.3
version: 0.16.5
src: htmlwidgets/lib/safety-eDISH-0.16.5
script: safetyedish.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@

//make sure filters is an Array
if (!(settings.filters instanceof Array)) {
settings.filters = [];
settings.filters = typeof settings.filters == 'string' ? [settings.filters] : [];
}

//Define default details.
Expand Down Expand Up @@ -473,15 +473,29 @@

// If settings.analysisFlag is null
if (!settings.analysisFlag) settings.analysisFlag = { value_col: null, values: [] };

if (!settings.analysisFlag.value_col) settings.analysisFlag.value_col = null;
if (!(settings.analysisFlag.values instanceof Array)) {
settings.analysisFlag.values =
typeof settings.analysisFlag.values == 'string'
? [settings.analysisFlag.values]
: [];
}
//if it is null, set settings.baseline.value_col to settings.studyday_col.
if (!settings.baseline) settings.baseline = { value_col: null, values: [] };
if (settings.baseline.values.length == 0) settings.baseline.values = [0];
if (!settings.baseline.value_col) settings.baseline.value_col = settings.studyday_col;
if (!(settings.baseline.values instanceof Array)) {
settings.baseline.values =
typeof settings.baseline.values == 'string' ? [settings.baseline.values] : [];
}

//parse x_ and y_options to array if needed
if (typeof settings.x_options == 'string') settings.x_options = [settings.x_options];
if (typeof settings.y_options == 'string') settings.y_options = [settings.y_options];
if (!(settings.x_options instanceof Array)) {
settings.x_options = typeof settings.x_options == 'string' ? [settings.x_options] : [];
}

if (!(settings.x_options instanceof Array)) {
settings.y_options = typeof settings.y_options == 'string' ? [settings.y_options] : [];
}

// track initial Cutpoint (lets us detect when cutpoint should change)
settings.cuts.x = settings.x.column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
: (global.webCharts = factory(global.d3));
})(typeof self !== 'undefined' ? self : this, function(d3) {
'use strict';
var version = '1.11.3';
var version = '1.11.5';

function init(data) {
var _this = this;
Expand Down Expand Up @@ -518,7 +518,7 @@
if (this.filters.length) {
this.filters.forEach(function(filter) {
_this.filtered_data = _this.filtered_data.filter(function(d) {
return filter.val === 'All'
return filter.all === true && filter.index === 0
? d
: filter.val instanceof Array
? filter.val.indexOf(d[filter.col]) > -1
Expand Down Expand Up @@ -1092,7 +1092,7 @@
if (this.filters.length) {
this.filters.forEach(function(e) {
filtered = filtered.filter(function(d) {
return e.val === 'All'
return e.all === true && e.index === 0
? d
: e.val instanceof Array
? e.val.indexOf(d[e.col]) > -1
Expand Down Expand Up @@ -1831,6 +1831,7 @@
function drawBars(marks) {
var _this = this;

var chart = this;
var rawData = this.raw_data;
var config = this.config;

Expand Down Expand Up @@ -1896,7 +1897,7 @@
.attr('class', function(d) {
return 'wc-data-mark bar ' + d.key;
})
.style('clip-path', 'url(#' + this.id + ')')
.style('clip-path', 'url(#' + chart.id + ')')
.attr('y', this.y(0))
.attr('height', 0)
.append('title');
Expand Down Expand Up @@ -2029,7 +2030,7 @@
.attr('class', function(d) {
return 'wc-data-mark bar ' + d.key;
})
.style('clip-path', 'url(#' + this.id + ')')
.style('clip-path', 'url(#' + chart.id + ')')
.attr('x', this.x(0))
.attr('width', 0)
.append('title');
Expand Down Expand Up @@ -2157,7 +2158,7 @@
.attr('class', function(d) {
return 'wc-data-mark bar ' + d.key;
})
.style('clip-path', 'url(#' + this.id + ')')
.style('clip-path', 'url(#' + chart.id + ')')
.attr('y', this.y(0))
.attr('height', 0)
.append('title');
Expand Down Expand Up @@ -2267,7 +2268,7 @@
.attr('class', function(d) {
return 'wc-data-mark bar ' + d.key;
})
.style('clip-path', 'url(#' + this.id + ')')
.style('clip-path', 'url(#' + chart.id + ')')
.attr('x', this.x(0))
.attr('width', 0)
.append('title');
Expand Down Expand Up @@ -2362,6 +2363,7 @@
function drawLines(marks) {
var _this = this;

var chart = this;
var config = this.config;
var line = d3.svg
.line()
Expand Down Expand Up @@ -2409,6 +2411,7 @@
var linePaths = line_grps
.select('path')
.attr('class', 'wc-data-mark')
.style('clip-path', 'url(#' + chart.id + ')')
.datum(function(d) {
return d.values;
})
Expand Down Expand Up @@ -2458,6 +2461,7 @@
function drawPoints(marks) {
var _this = this;

var chart = this;
var config = this.config;

var point_supergroups = this.svg.selectAll('.point-supergroup').data(marks, function(d, i) {
Expand Down Expand Up @@ -2496,6 +2500,7 @@
//static attributes
points
.select('circle')
.style('clip-path', 'url(#' + chart.id + ')')
.attr(
'fill-opacity',
config.fill_opacity || config.fill_opacity === 0 ? config.fill_opacity : 0.6
Expand Down Expand Up @@ -2568,6 +2573,7 @@
function drawText(marks) {
var _this = this;

var chart = this;
var config = this.config;

var textSupergroups = this.svg.selectAll('.text-supergroup').data(marks, function(d, i) {
Expand Down Expand Up @@ -2610,7 +2616,7 @@
texts.each(attachMarks);

// parse text like tooltips
texts.select('text').text(function(d) {
texts.select('text').style('clip-path', 'url(#' + chart.id + ')').text(function(d) {
var tt = d.mark.text || '';
var xformat = config.x.summary === 'percent'
? d3.format('0%')
Expand Down Expand Up @@ -3061,13 +3067,16 @@
}

function makeSubsetterControl(control, control_wrap) {
var targets = this.targets;
var targets = this.targets; // associated charts and tables.

//dropdown selection
var changer = control_wrap
.append('select')
.attr('class', 'changer')
.classed('changer', true)
.attr('multiple', control.multiple ? true : null)
.datum(control);

//dropdown option data
var option_data = control.values
? control.values
: d3
Expand All @@ -3080,17 +3089,24 @@
return f;
})
)
.values();
option_data.sort(naturalSorter);
.values()
.sort(naturalSorter); // only sort when values are derived

//initial dropdown option
control.start = control.start ? control.start : control.loose ? option_data[0] : null;

//conditionally add All option
if (!control.multiple && !control.start) {
option_data.unshift('All');
control.all = true;
} else {
control.all = false;
}

//what does loose mean?
control.loose = !control.loose && control.start ? true : control.loose;

//dropdown options selection
var options = changer
.selectAll('option')
.data(option_data)
Expand All @@ -3103,6 +3119,7 @@
return d === control.start;
});

//define filter object for each associated target
targets.forEach(function(e) {
var match = e.filters
.slice()
Expand All @@ -3113,16 +3130,20 @@
if (match > -1) {
e.filters[match] = {
col: control.value_col,
val: control.start ? control.start : 'All',
val: control.start ? control.start : !control.multiple ? 'All' : option_data,
index: 0,
choices: option_data,
loose: control.loose
loose: control.loose,
all: control.all
};
} else {
e.filters.push({
col: control.value_col,
val: control.start ? control.start : 'All',
val: control.start ? control.start : !control.multiple ? 'All' : option_data,
index: 0,
choices: option_data,
loose: control.loose
loose: control.loose,
all: control.all
});
}
});
Expand All @@ -3139,6 +3160,7 @@
}
}

//add event listener to control
changer.on('change', function(d) {
if (control.multiple) {
var values = options
Expand All @@ -3152,8 +3174,10 @@
var new_filter = {
col: control.value_col,
val: values,
index: null, // could specify an array of indices but seems like a waste of resources give it doesn't inform anything without an overall 'All'
choices: option_data,
loose: control.loose
loose: control.loose,
all: control.all
};
targets.forEach(function(e) {
setSubsetter(e, new_filter);
Expand All @@ -3165,11 +3189,14 @@
});
} else {
var value = d3.select(this).select('option:checked').property('text');
var index = d3.select(this).select('option:checked').property('index');
var _new_filter = {
col: control.value_col,
val: value,
index: index,
choices: option_data,
loose: control.loose
loose: control.loose,
all: control.all
};
targets.forEach(function(e) {
setSubsetter(e, _new_filter);
Expand Down Expand Up @@ -3273,7 +3300,8 @@
this.filters &&
this.filters.some(function(filter) {
return (
(typeof filter.val === 'string' && filter.val !== 'All') ||
(typeof filter.val === 'string' &&
!(filter.all === true && filter.index === 0)) ||
(Array.isArray(filter.val) && filter.val.length < filter.choices.length)
);
})
Expand All @@ -3282,7 +3310,8 @@
this.filters
.filter(function(filter) {
return (
(typeof filter.val === 'string' && filter.val !== 'All') ||
(typeof filter.val === 'string' &&
!(filter.all === true && filter.index === 0)) ||
(Array.isArray(filter.val) && filter.val.length < filter.choices.length)
);
})
Expand Down
5 changes: 2 additions & 3 deletions inst/htmlwidgets/safetyHistogram.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ dependencies:
src: htmlwidgets/lib/d3-3.5.17
script: d3.v3.min.js
- name: webcharts
version: 1.11.3
src: htmlwidgets/lib/webcharts-1.11.3
version: 1.11.5
src: htmlwidgets/lib/webcharts-1.11.5
script: webcharts.js
stylesheet: webcharts.css
- name: safety-histogram
version: 2.2.2
src: htmlwidgets/lib/safety-histogram-2.2.2
script: safetyHistogram.js