Skip to content

Commit 16c4bc1

Browse files
committed
adjust margin_left on the length of variable_names
1 parent e27ed77 commit 16c4bc1

File tree

10 files changed

+39
-13
lines changed

10 files changed

+39
-13
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ VignetteBuilder: knitr
4141
URL: https://modelstudio.drwhy.ai, https://github.com/ModelOriented/modelStudio
4242
BugReports: https://github.com/ModelOriented/modelStudio/issues
4343
Language: en-US
44+
LazyData: true

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* this version requires `R >=3.6`, `DALEX >=2.2.1`, `ingredients >=2.2.0` and `iBreakDown >=2.0.1`
44
* the deprecated alias `modelStudioOptions()` is removed from this version of the package; after being deprecated for over a year since **v1.1.0**. Use the recommended `ms_options()` instead.
55
* added new parameter to `modelStudio()`: `N_sv = 3*N`, which by default decreases the number of observations used for the calculation of `Shapley Values` (rows in `data`)
6+
* `margin_left = NULL` by default and it is adjusted based on the length of variable names
67
* add the `verbose` parameter to `modelStudio()` as an alias to `show_info` [(#101)](https://github.com/ModelOriented/modelStudio/issues/101)
78

89

R/data.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
#' social support, etc. \code{happiness_train} accumulates the data from years 2015-2018,
66
#' while \code{happiness_test} is the data from the year 2019, which imitates the
77
#' out-of-time validation.
8-
#'
8+
#'
9+
#' Source: \href{https://www.kaggle.com/unsdsn/world-happiness}
10+
#'
911
#' The following columns: GDP per Capita, Social Support, Life Expectancy,
1012
#' Freedom, Generosity, Corruption describe the extent to which these factors
1113
#' contribute in evaluating the happiness in each country.
14+
#'
1215
#' \itemize{
13-
#' \item \textbf{score} - target variable, continuous value between 0 and 10 (regression)
16+
#' \item \strong{score} - target variable, continuous value between 0 and 10 (regression)
1417
#' \item gdp_per_capita
1518
#' \item social_support
1619
#' \item healthy_life_expectancy

R/modelStudio.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ modelStudio.explainer <- function(explainer,
491491
if (!is.null(license)) options$license <- paste(readLines(license), collapse=" ")
492492
if (is.null(options$ms_title)) options$ms_title <- paste0("Interactive Studio for ", label, " Model")
493493
if (!is.null(options$ms_subtitle)) options$ms_margin_top <- options$ms_margin_top + 40
494-
494+
if (is.null(options$margin_left)) options$margin_left <- 7*max(nchar(variable_names))
495+
495496
options <- c(list(time = time,
496497
model_name = label,
497498
variable_names = as.list(variable_names),

R/ms_options.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ms_options <- function(...) {
113113
margin_top = 50,
114114
margin_right = 20,
115115
margin_bottom = 70,
116-
margin_left = 105,
116+
margin_left = NULL, # 105,
117117
margin_inner = 40,
118118
margin_small = 5,
119119
margin_big = 10,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ model <- xgb.train(params, xgb_matrix, nrounds = 500)
142142
explainer <- explain(model,
143143
data = test_matrix,
144144
y = test$survived,
145+
type = "classification",
145146
label = "xgboost")
146147

147148
# pick observations

inst/d3js/modelStudio.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,16 @@ var CLICKED_VARIABLE_NAME = variableNames[0],
111111
IS_BUTTON_CLICKED = false;
112112

113113
/// set dimensions
114-
var margin = {top: options.margin_top, right: options.margin_right,
115-
bottom: options.margin_bottom, left: options.margin_left,
116-
inner: options.margin_inner,
117-
small: options.margin_small, big: options.margin_big,
118-
ytitle: options.margin_ytitle};
114+
var margin = {
115+
top: options.margin_top,
116+
right: options.margin_right,
117+
bottom: options.margin_bottom,
118+
left: options.margin_left,
119+
inner: options.margin_inner,
120+
small: options.margin_small,
121+
big: options.margin_big,
122+
ytitle: options.margin_ytitle
123+
};
119124

120125
var w = options.w, h = options.h;
121126

inst/d3js/myTools.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ function getTextWidth(text, fontSize, fontFace) {
178178
return context.measureText(text).width;
179179
}
180180

181+
function getMaxTextWidth(textArray, fontSize, fontFace) {
182+
let maxTextWidth = 0;
183+
for (let i = 0; i < textArray.length; i++) {
184+
let textWidth = getTextWidth(textArray[i], fontSize, fontFace)
185+
if (textWidth > maxTextWidth) {
186+
maxTextWidth = textWidth
187+
}
188+
}
189+
return maxTextWidth
190+
}
191+
181192
function wrapText(text, width) {
182193
// this function wraps text
183194
text.each(function () {

man/happiness_train.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgdown/favicon/demo.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)