Skip to content

Commit

Permalink
color helper
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Nov 14, 2018
1 parent 1799c9d commit df1ab61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Imports:
broom,
shiny,
scales
RoxygenNote: 6.1.0
RoxygenNote: 6.1.1
Suggests:
echarts4r.assets,
echarts4r.maps,
Expand Down
7 changes: 6 additions & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ e_color_range_ <- function(data, input, output, colors = c("#bf444c", "#d88273",

serie <- data[[input]]

data[[output]] <- colorRampPalette(colors, ...)(length(serie))
if(inherits(serie, "factor") || inherits(serie, "character"))
col <- scales::col_numeric(colors, domain = range(serie))(serie)
else
col <- scales::col_numeric(colors, domain = range(serie))(serie)

data[[output]] <- col
data
}

Expand Down

0 comments on commit df1ab61

Please sign in to comment.