Skip to main content

======================== DATAWRAPPER GRAPHICS

An (unofficial!) package for Datawrapper that allows you to interface between your pandas dataframes and Datawrapper locator maps, charts, and folders in Python.

====================== INSTALLATION AND SETUP

Install using pip:

pip install datawrappergraphics

Datawrappergraphics uses Datawrapper's API to interface with Datawrapper. In order to use it, you need to generate an API token with the following permissions:

  • Auth: read/write
  • Chart: read/write
  • Folder: read/write

This token can be generated in settings > API-Tokens. There are three ways to authenticate:

  1. By default, Datawrappergraphics will look for an environment variable called DW_AUTH_TOKEN.
  2. You can upload a auth.txt file in your project's root directory containing only your authentication key (don't forget to add this file to your .gitignore!).
  3. You can pass your token on instantiation using the auth_token arg.

Once you've authenticated, you're good to go!

==================== USAGE

There are currently two main classes that can be implemented using this module:

  • Map - This is a datawrapper locator map.
  • Chart - This is a datawrapper chart.

Each of these classes inherits from the DatawrapperGraphic class, which is not meant to be implemented directly.

Classes can be implemented by using:

.. code-block:: python

    import datawrappergraphics

    chart_id = "AbBe1"

    map = (Map(chart_id)
            .data(aPandasDataframe)
            .head("A cool headline for your chart")
            .deck("A great looking deck, or subheadline, for your chart".)
            .footer("This is a note")
    )

========================== GUIDE

Some simple usage patterns. Get started by importing the package:

.. code-block:: python

    import datawrappergraphics as dwg

Create a new chart.

.. code-block:: python

    dwg.Chart()

Copy an existing chart.

This will create a brand new chart by copying another chart. Useful if you've made a "template chart" and want to create a bunch of charts using different data based on that template.

.. code-block:: python

    dwg.Chart(copy_id="AbCd1")

Upload data to an existing chart.

Data is uploaded as a pandas dataframe. Charts do not require any special columns, so go wild with it.

.. code-block:: python

    dwg.Chart(chart_id="AbCd1").data(df)

Upload data to an existing locator map

The Map class is used to interact with locator map data. Your dataframe has to have a few required columns:

  • Type: Either "point" or "area", depending on whether the row is a point marker or an area.
  • latitude/longitude or geometry: Point markers use two columns to locate: latitude and longitude. Area markers need a geometry column with WKT in the rows.

When you're uploading your data, you can specify a number of optional columns to control how your marker points show:

  • Point markers:

    • icon: Specify the id of any icon available in Datawrapper's locator maps. Default: circle.
    • markerColor: What color the marker shows up as. Default: #C42127.
  • Area markers:

    • fill: A 6-digit hexcode or a boolean value that controls the fill color or visibility of the marker fill. Default: #C42127.
    • stroke: A 6-digit hexcode or a boolean value that controls the stroke color or visibility of the marker stroke. Default: #C42127.
    • fill-opacity: A float value that controls the opacity of the fill. Default: 0.5.
    • stroke-opacity: A float value that controls the opacity of the stroke. Default: 1.0.

The names of all columns are case sensitive!

.. code-block:: python

    dwg.Map(chart_id="AbCd1").data(df)

List charts in a folder

This is particularly useful if you're editing a large number of charts and want to iterate through charts in a folder.

.. code-block:: python

    dwg.Folder(folder_id="12345").chart_list

======================= CONTRIBUTING

======================= CHANGELOG

  • v0.3.27: Added all locator map icons.

Metadata

Release files for datawrappergraphics 0.3.38

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datawrappergraphics 0.3.38
File Size Uploaded
datawrappergraphics-0.3.38.tar.gz 43.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datawrappergraphics 0.3.38
File Interpreter ABI Platform
datawrappergraphics-0.3.38-py3-none-any.whl Python 3 none any Details

Total release size: 80.0 kB

Release files / datawrappergraphics-0.3.38.tar.gz

Download URL datawrappergraphics-0.3.38.tar.gz
Size 43.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e9a959e051bbdeb5d2a35d4f4d5f3c5f1bb8ce2b7caecb6025a3e39fcf88d73a
BLAKE2b-256 checksum
How to use checksums
26764a9e38a66a8ffed67e9200c6493d01f6a42328c034c10a8267aa5f04a99b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / datawrappergraphics-0.3.38-py3-none-any.whl

Download URL datawrappergraphics-0.3.38-py3-none-any.whl
Size 36.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e3cef6194c54bb9cdbbd0a1261dca0c20056005b3a78c48ba604d22f77f354b
BLAKE2b-256 checksum
How to use checksums
95ef4621d4d09effdab099847be748d058b49a384cb9aa770eb84b1557397b42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.3.38 This release

2 release files

0.3.34

1 release file

0.3.33

2 release files

0.3.28

2 release files

0.3.27

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page