To create an empty chart, you can use
which will use the API key stored locally on your system.
By default, Datawrapper will create an empty linechart, without a title. The function returns a dw_chart-object with the metadata-elements from the API. This object can be used to populate the
chart_id-argument in all other functions - which means you don’t have to deal with it. Just store the response from
dw_create_chart() in your R-environment.
To populate that chart with data, you can run
dw_data_to_chart(x = DATAFRAME, chart_id = CHART_ID_OR_dw_chart-object)
which uploads an R data.frame to an Datawrapper chart.
The data.frame should already be in the right format, only including the expected columns for the chart. The API will asume, that the first row contains headers. If that’s not true, you have to edit the metadata afterwards:
dw_edit_chart(chart_id = CHART_ID_OR_dw_chart-object, title = "I'm a title", data = list(`horizontal-header` = "false"))
Datawrapper offers a lot of variability in editing it’s charts’ metadata. You can find a whole Documentation here.
To speed things up, the
dw_edit_chart()-function has some built-in arguments for common transformations:
introwhich is the text below the title
annotatewhich is the text below the plot
bylinewhich is the name of the author
source_namewhich states the source
source_urlwhich links to the source - but only if a
If you want to edit specific arguments in your plot, you can use the arguments
publish to include lists to the API call which change all possible settings in a chart, as shown in the example above.
When you’re finished editing your chart, you might want to publish it:
dw_publish_chart(chart_id = CHART_ID_OR_dw_chart-object)
This function returns a URL to the chart and the embed code, if you set the argument return_urls to
Or you might want to delete a chart:
dw_delete_chart(chart_id = CHART_ID_OR_dw_chart-object)