Skip to content

Commit 6267f2a

Browse files
committed
more redivis API adjustment, exclude vars from color options if only 1 value
1 parent eb42e2d commit 6267f2a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

_load-data.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if ("redivis" %in% names(quarto) &&
2525
data <- table$to_tibble()
2626
2727
# get variable metadata
28-
vars <- map(table$list_variables(), \(v) v$get_statistics()$properties)
28+
vars <- map(table$list_variables(), \(v) c(v$get()$properties, v$get_statistics()))
2929
3030
# pass to OJS
3131
ojs_define(data = data)
@@ -44,10 +44,10 @@ d = transpose(data)
4444
distinct_cutoff = 10
4545
4646
disc_types = ['string', 'boolean']
47-
disc_vars = vars.filter(d => disc_types.includes(d.type) && d.statistics.numDistinct <= distinct_cutoff).map(d => [d.label ? d.label : d.name, d.name])
47+
disc_vars = vars.filter(d => disc_types.includes(d.type) && d.numDistinct <= distinct_cutoff && d.numDistinct > 1).map(d => [d.label ? d.label : d.name, d.name])
4848
disc_opts = new Map([['', null]].concat(disc_vars))
4949
5050
cont_types = ['integer', 'float', 'date', 'datetime', 'time']
51-
cont_vars = vars.filter(d => cont_types.includes(d.type) && d.statistics.numDistinct > distinct_cutoff).map(d => [d.label ? d.label : d.name, d.name])
51+
cont_vars = vars.filter(d => cont_types.includes(d.type) && d.numDistinct > distinct_cutoff).map(d => [d.label ? d.label : d.name, d.name])
5252
cont_opts = new Map(cont_vars)
5353
```

0 commit comments

Comments
 (0)