qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
98 stars 0 forks source link

scale_custom or scale_identity for data annotation #62

Closed MilesMcBain closed 2 years ago

MilesMcBain commented 2 years ago

Useful where you have a column that you know is already transformed and you want to include that in the legend generated for the scale.

  n_incidents, # already transformed
  transform_txt = "sqrt(n_incidents)"
)

The legend then says:

Demand Heatmap colored by sqrt(incidents)

anthonynorth commented 2 years ago

New param for scales: col_label. Takes either a function with column name as input; or a string with optional "{.col}" template placeholder (which is replaced by the column name).

Examples:

scale_color_power(foo_column, col_label = "sqrt({.col})")
scale_color_power(foo_column, col_label = "a new name")
scale_color_power(foo_column, col_label = snakecase::to_sentence_case)
scale_color_power(foo_column, col_label = function(col) paste0("sqrt(", col, ")"))

Visual: image