View source: R/dw_legend_to_string.R
dw_legend_to_string | R Documentation |
deprecated A helper function that creates a legend as string, vector or HTML from an existing legend in a Datawrapper chart. Will be deprecated soon, as it's no longer needed. Datawrapper now offers a better option via its interface.
dw_legend_to_string(
legend,
return_val = c("string", "vector", "html"),
use_ranges = FALSE
)
legend |
Required. A vector containing the legend (e.g. retrieved from a call with |
return_val |
Required. One of c("string", "vector", "html"). Set the output type. Defaults to "string". |
use_ranges |
Optional. Filters out automatically generated ranges (e.g. |
A string, vector or HTML (as string), as defined in return_val
.
Create a chart that displays the required legend. Then use dw_retrieve_chart_metadata(chart_id)
to download the meta-information of your chart into a R-variable.
You may then extract the legend as a string. It might for example be stored in metadata[["content"]][["metadata"]][["visualize"]][["categories"]]
or in metadata[["content"]][["metadata"]][["visualize"]][["custom-colors"]]
.
Benedict Witzenberger
## Not run:
dw_legend_to_string(legend)
dw_legend_to_string(legend, return_val = "html") # return simple HTML-code
dw_legend_to_string(legend, use_ranges = TRUE) # filter out ranges
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.