-
-
Notifications
You must be signed in to change notification settings - Fork 26
Add choropleth map implementation #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Great start! Here's one thing. If you look in the tests/samples folder you will see that we've packaged some JSON configuration files and data uploads drawn from the real-world charts that Datawrapper includes in its documentation site. Those are then integrated into tests that verify the code is working. One sample is pulled out and featured in our documentation site with a Pythonic implementation as an example. Do you think you'd be able to try add those pieces yet? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for choropleth maps to the datawrapper library, enabling users to create geographic data visualizations where regions are colored based on data values.
Key changes:
- New
ChoroplethMapclass with comprehensive configuration options for data mapping, basemaps, colors, and tooltips - Three new enum classes (
ColorScale,ColorMode,BasemapProjection) for type-safe configuration - Integration with existing library architecture through proper imports and exports
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| datawrapper/charts/enums/color_scale.py | Defines ColorScale enum with scale types (linear, log, sqrt, quantile, jenks) |
| datawrapper/charts/enums/color_mode.py | Defines ColorMode enum for gradient vs buckets coloring |
| datawrapper/charts/enums/basemap_projection.py | Defines BasemapProjection enum with map projection types |
| datawrapper/charts/enums/init.py | Exports new enum classes for external use |
| datawrapper/charts/choropleth_map.py | Main implementation with ChoroplethMap class and Tooltip configuration |
| datawrapper/charts/base.py | Adds "d3-maps-choropleth" to supported chart types |
| datawrapper/charts/init.py | Exports ChoroplethMap and related classes |
| datawrapper/init.py | Re-exports ChoroplethMap and enums at package level |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| map_key_attr: str = Field( | ||
| default="", | ||
| alias="map-key-attr", | ||
| description="The attribute in the basemap to match against your keys column (e.g., 'iso-a3', 'fips', 'ags)", |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing closing single quote in the description string. The string should end with 'ags')" instead of 'ags)".
| description="The attribute in the basemap to match against your keys column (e.g., 'iso-a3', 'fips', 'ags)", | |
| description="The attribute in the basemap to match against your keys column (e.g., 'iso-a3', 'fips', 'ags')", |
| if self.color_scale == "quantile": | ||
| interpolation = "equidistant" | ||
| elif self.color_scale == "jenks": |
Copilot
AI
Oct 31, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 295 initializes interpolation to 'equidistant', then line 297 redundantly sets it to the same value when color_scale == 'quantile'. The if-condition on line 296-297 has no effect and should be removed.
| if self.color_scale == "quantile": | |
| interpolation = "equidistant" | |
| elif self.color_scale == "jenks": | |
| if self.color_scale == "jenks": |
|
Thank you!
Sure, that's a great idea!
Basically I create a map and downlod the json structure of the datawrapper object, correct?
Best
Claus
Norddeutscher Rundfunk
PB Programm- und Portfoliomanagement
PG Digitale Angebote / NDR DATA
Rothenbaumchaussee 132
20149 Hamburg
phone: +49.170.2039123
e-mail: ***@***.***
…________________________________
Von: Ben Welsh ***@***.***>
Gesendet: Friday, October 31, 2025 2:34:26 PM
An: chekos/Datawrapper ***@***.***>
Cc: Hesseling, Claus ***@***.***>; Author ***@***.***>
Betreff: Re: [chekos/Datawrapper] Add choropleth map implementation (PR #500)
[https://avatars.githubusercontent.com/u/9993?s=20&v=4]palewire left a comment (chekos/Datawrapper#500)<#500 (comment)>
Great start!
Here's one thing. If you look in the tests/samples folder you will see that we've packaged some JSON configuration files and data uploads drawn from the real-world charts that Datawrapper includes in its documentation site.
Those are then integrated into tests that verify the code is working. One sample is pulled out and featured in our documentation site with a Pythonic implementation as an example.
Do you think you'd be able to try add those pieces yet?
—
Reply to this email directly, view it on GitHub<#500 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AOZ2EIOVZKGGVKS2T4HDDXT32NQOFAVCNFSM6AAAAACKYXPCO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTINZTGEYTSNZVGI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
|
Yes, that's right. We use this tool to snatch the JSON from the official examples. https://palewi.re/docs/datawrapper-json-bookmarklet/ |
Added implementation for Datawrapper's choropleth map API