diff --git a/R/dw_create_folder.R b/R/dw_create_folder.R index cc4c09a..fc408ff 100644 --- a/R/dw_create_folder.R +++ b/R/dw_create_folder.R @@ -45,7 +45,7 @@ dw_create_folder <- function(name = "", organization_id = "", parent_id = "", ap cat(paste0("New Folder '", parsed$name, "' successfully created!", "\n", "Folder-ID is: ", parsed$id, "\n")) } else { - warning(paste0("There has been an error in the folder creation process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) + stop(paste0("There has been an error in the folder creation process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) } return(parsed) diff --git a/R/dw_data_to_chart.R b/R/dw_data_to_chart.R index 1cd457b..11a1cd0 100644 --- a/R/dw_data_to_chart.R +++ b/R/dw_data_to_chart.R @@ -61,7 +61,7 @@ dw_data_to_chart <- function(x, chart_id, parse_dates = TRUE, api_key = "environ if (httr::status_code(r) %in% c(200, 201, 202, 204)) { cat(paste0("Data in ", chart_id, " successfully updated.", "\n")) } else { - warning(paste0("There has been an error in the upload process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) + stop(paste0("There has been an error in the upload process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) } } diff --git a/R/dw_delete_chart.R b/R/dw_delete_chart.R index 3e17081..eaea5e4 100644 --- a/R/dw_delete_chart.R +++ b/R/dw_delete_chart.R @@ -31,7 +31,7 @@ dw_delete_chart <- function(chart_id, api_key = "environment") { if (httr::status_code(r) == "204") { cat(paste0("Chart ", chart_id, " sucessfully deleted!", "\n")) } else { - warning("There has been an error while deleting the chart!", immediate. = TRUE) + stop("There has been an error while deleting the chart!", immediate. = TRUE) return(r) } diff --git a/R/dw_edit_chart.R b/R/dw_edit_chart.R index 010cc36..9491271 100644 --- a/R/dw_edit_chart.R +++ b/R/dw_edit_chart.R @@ -235,7 +235,7 @@ dw_edit_chart <- function(chart_id, api_key = "environment", title = "", intro = cat(paste0("Chart ", chart_id_response, " succesfully updated.", "\n")) } else { - warning(paste0("There has been an error in the upload process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) + stop(paste0("There has been an error in the upload process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) } httr::handle_reset(url_upload) diff --git a/R/dw_invite_user.R b/R/dw_invite_user.R index 5fb5e04..ebb603e 100644 --- a/R/dw_invite_user.R +++ b/R/dw_invite_user.R @@ -16,8 +16,7 @@ #' #' \dontrun{ #' dw_invite_user(team = "testTeam", email = "test_at_test.com", role = "admin") -#' # uses the preset key in the .Renviron-file -#' } +#' # uses the preset key in the .Renviron-file} #' #' @rdname dw_invite_user #' @export diff --git a/R/dw_publish_chart.R b/R/dw_publish_chart.R index 8187d6d..715a1fc 100644 --- a/R/dw_publish_chart.R +++ b/R/dw_publish_chart.R @@ -77,7 +77,7 @@ dw_publish_chart <- function(chart_id, api_key = "environment", return_urls = TR } } else { - warning(paste0("There has been an error in the publication process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) + stop(paste0("There has been an error in the publication process. Statuscode of the response: ", httr::status_code(r)), immediate. = TRUE) } } diff --git a/README.md b/README.md index 398f5f4..bce32f2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ All functions (except `datawrapper_auth()`) are preceded by `dw_`: * lists all created charts: `dw_list_charts()`. * lists all folders: `dw_list_folders()`. * creates a new Datawrapper chart via `dw_create_chart()` +* copy a existing chart with: `dw_copy_chart()` * adds data from a R-dataframe to an existing Datawrapper chart via `dw_data_to_chart()` * retrieves (`dw_retrieve_chart_metadata()`) or edits metadata, description and visualization of an existing chart via `dw_edit_chart()` * publishes and republishes a Datawrapper chart via `dw_publish_chart()` diff --git a/Readme.Rmd b/Readme.Rmd index eb3422b..983650f 100644 --- a/Readme.Rmd +++ b/Readme.Rmd @@ -26,6 +26,7 @@ All functions (except `datawrapper_auth()`) are preceded by `dw_`: * lists all created charts: `dw_list_charts()`. * lists all folders: `dw_list_folders()`. * creates a new Datawrapper chart via `dw_create_chart()` +* copy a existing chart with: `dw_copy_chart()` * adds data from a R-dataframe to an existing Datawrapper chart via `dw_data_to_chart()` * retrieves (`dw_retrieve_chart_metadata()`) or edits metadata, description and visualization of an existing chart via `dw_edit_chart()` * publishes and republishes a Datawrapper chart via `dw_publish_chart()` diff --git a/data/dw_basemaps.rda b/data/dw_basemaps.rda index 647f5b0..d26745d 100644 Binary files a/data/dw_basemaps.rda and b/data/dw_basemaps.rda differ diff --git a/docs/articles/map.html b/docs/articles/map.html index aabe44e..a3fc25a 100644 --- a/docs/articles/map.html +++ b/docs/articles/map.html @@ -126,7 +126,7 @@

title = "This is a automated choropleth map", type = "d3-maps-choropleth" ) -#> New chart's id: bwN6O +#> New chart's id: ZO9I5

@@ -213,7 +213,7 @@

#> $ share_foreign_population: num 15.5 13.2 18.5 4.7 18.1 16.4 16.2 4.5 9.4 13.3 ...

You can simply upload the data as you would do with any other {DatawRappr}-chart.

dw_data_to_chart(df_foreign_pop, chart_id = new_choropleth_chart)
-#> Chart data in bwN6O successfully updated.
+#> Data in ZO9I5 successfully updated.
@@ -241,7 +241,7 @@

"map-key-attr" = "name" ) ) -#> Chart bwN6O succesfully updated.

+#> Chart ZO9I5 succesfully updated.

At that point, you might want to switch to Datawrapper’s UI to make the final adjustments to the legend before publishing. But: You could do them via dw_edit_chart as well. It’s probably just not that much fun.

@@ -249,12 +249,12 @@

Publish the chart

This is probably the easiest part:

dw_publish_chart(new_choropleth_chart)
-#> Chart bwN6O published!### Responsive iFrame-code: ###
-#> <iframe title="This is a automated choropleth map" aria-label="Karte" id="datawrapper-chart-bwN6O" src="https://datawrapper.dwcdn.net/bwN6O/1/" scrolling="no" frameborder="0" style="width: 0; min-width: 100% !important; border: none;" height="undefined"></iframe><script type="text/javascript">!function(){"use strict";window.addEventListener("message",(function(a){if(void 0!==a.data["datawrapper-height"])for(var e in a.data["datawrapper-height"]){var t=document.getElementById("datawrapper-chart-"+e)||document.querySelector("iframe[src*='"+e+"']");t&&(t.style.height=a.data["datawrapper-height"][e]+"px")}}))}();
+#> Chart ZO9I5 published!### Responsive iFrame-code: ###
+#> <iframe title="This is a automated choropleth map" aria-label="Karte" id="datawrapper-chart-ZO9I5" src="https://datawrapper.dwcdn.net/ZO9I5/1/" scrolling="no" frameborder="0" style="width: 0; min-width: 100% !important; border: none;" height="undefined"></iframe><script type="text/javascript">!function(){"use strict";window.addEventListener("message",(function(a){if(void 0!==a.data["datawrapper-height"])for(var e in a.data["datawrapper-height"]){var t=document.getElementById("datawrapper-chart-"+e)||document.querySelector("iframe[src*='"+e+"']");t&&(t.style.height=a.data["datawrapper-height"][e]+"px")}}))}();
 #> </script>
 #> 
 #> ### Chart-URL:###
-#> https://datawrapper.dwcdn.net/bwN6O/1/
+#> https://datawrapper.dwcdn.net/ZO9I5/1/
Screenshot of the choropleth map

Screenshot of the choropleth map

@@ -274,7 +274,7 @@

title = "This is a automated symbol map", type = "d3-maps-symbols" ) -#> New chart's id: Gg1TH +#> New chart's id: X8IcM

@@ -335,7 +335,7 @@


With Lat and Lon-columns set, you can simply upload the data as you would do with any other {DatawRappr}-chart.

dw_data_to_chart(df_foreign_pop_symbol, chart_id = new_symbol_chart)
-#> Chart data in Gg1TH successfully updated.
+#> Data in X8IcM successfully updated.

@@ -370,7 +370,7 @@

basemap = "germany-states" ) ) -#> Chart Gg1TH succesfully updated.

+#> Chart X8IcM succesfully updated.

At that point, you might want to switch to Datawrapper’s UI to make the final adjustments to the legend before publishing. But: You could do them via dw_edit_chart as well. It’s probably just not that much fun.

@@ -378,12 +378,12 @@

Publish the chart

This is probably the easiest part:

dw_publish_chart(new_symbol_chart)
-#> Chart Gg1TH published!### Responsive iFrame-code: ###
-#> <iframe title="This is a automated symbol map" aria-label="Karte" id="datawrapper-chart-Gg1TH" src="https://datawrapper.dwcdn.net/Gg1TH/1/" scrolling="no" frameborder="0" style="width: 0; min-width: 100% !important; border: none;" height="undefined"></iframe><script type="text/javascript">!function(){"use strict";window.addEventListener("message",(function(a){if(void 0!==a.data["datawrapper-height"])for(var e in a.data["datawrapper-height"]){var t=document.getElementById("datawrapper-chart-"+e)||document.querySelector("iframe[src*='"+e+"']");t&&(t.style.height=a.data["datawrapper-height"][e]+"px")}}))}();
+#> Chart X8IcM published!### Responsive iFrame-code: ###
+#> <iframe title="This is a automated symbol map" aria-label="Karte" id="datawrapper-chart-X8IcM" src="https://datawrapper.dwcdn.net/X8IcM/1/" scrolling="no" frameborder="0" style="width: 0; min-width: 100% !important; border: none;" height="undefined"></iframe><script type="text/javascript">!function(){"use strict";window.addEventListener("message",(function(a){if(void 0!==a.data["datawrapper-height"])for(var e in a.data["datawrapper-height"]){var t=document.getElementById("datawrapper-chart-"+e)||document.querySelector("iframe[src*='"+e+"']");t&&(t.style.height=a.data["datawrapper-height"][e]+"px")}}))}();
 #> </script>
 #> 
 #> ### Chart-URL:###
-#> https://datawrapper.dwcdn.net/Gg1TH/1/
+#> https://datawrapper.dwcdn.net/X8IcM/1/
Screenshot of the symbol map

Screenshot of the symbol map

diff --git a/docs/index.html b/docs/index.html index a1d02ed..755b78a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -115,6 +115,8 @@

  • lists all folders: dw_list_folders().
  • creates a new Datawrapper chart via dw_create_chart()
  • +
  • copy a existing chart with: dw_copy_chart() +
  • adds data from a R-dataframe to an existing Datawrapper chart via dw_data_to_chart()
  • retrieves (dw_retrieve_chart_metadata()) or edits metadata, description and visualization of an existing chart via dw_edit_chart() diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index fc90a9e..d5029e3 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -4,5 +4,5 @@ pkgdown_sha: ~ articles: map: map.html usage: usage.html -last_built: 2020-10-15T11:26Z +last_built: 2020-10-22T16:19Z diff --git a/docs/reference/dw_basemaps.html b/docs/reference/dw_basemaps.html index 3693bb3..fccb2ca 100644 --- a/docs/reference/dw_basemaps.html +++ b/docs/reference/dw_basemaps.html @@ -162,7 +162,7 @@

    Source<https://api.datawrapper.de/plugin/basemaps>

    Examples

    -
    dw_basemaps
    #> # A tibble: 4,120 x 6 +
    dw_basemaps
    #> # A tibble: 4,137 x 6 #> id level slug value label description #> <chr> <chr> <chr> <chr> <chr> <chr> #> 1 world-20… World world DW_NAME Name The three-letter ISO-code of … @@ -175,7 +175,7 @@

    Examp #> 8 europe Europe europe ADMIN Names Olpe, Somerset, Toledo, ... #> 9 europe Europe europe GERMAN_NAME Names (Ge… Olpe, Somerset, Toledo, ... #> 10 europe Europe europe FIPS_10_ FIPS FIPS codes -#> # … with 4,110 more rows

    +#>
    # … with 4,127 more rows