feat(charts): add comprehensive export options for PNG, PDF, and SVG#518
feat(charts): add comprehensive export options for PNG, PDF, and SVG#518palewire merged 1 commit intochekos:mainfrom
Conversation
Add missing export parameters to align with Datawrapper API capabilities: - PNG: add scale, logo, logo_id, dark, ligatures, full_vector, download - PDF: add zoom, transparent, logo, logo_id, dark, ligatures, full_vector, download - SVG: add zoom, logo, logo_id, dark, ligatures, full_vector, download Also clarify distinction between scale (size multiplier) and zoom (resolution/DPI multiplier) in docstrings.
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive export options to align the PNG, PDF, and SVG export methods with Datawrapper API capabilities. The changes enhance all three export methods with additional parameters for customization such as scale/zoom control, logo configuration, dark mode, ligatures, and vector output options.
Key Changes:
- Added 7 new parameters to
export_png: scale, logo, logo_id, dark, ligatures, full_vector, and download - Added 8 new parameters to
export_pdf: zoom, transparent, logo, logo_id, dark, ligatures, full_vector, and download (plus timeout fix) - Added 9 new parameters to
export_svg: scale, zoom, transparent, border_width, border_color, logo, logo_id, dark, ligatures, full_vector, and download - Clarified docstrings to distinguish between scale (size multiplier) and zoom (resolution/DPI multiplier)
- Updated integration tests to cover all new parameters
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| datawrapper/charts/base.py | Added comprehensive export parameters to PNG, PDF, and SVG export methods with updated docstrings and parameter handling |
| tests/integration/test_base_export.py | Extended integration tests to verify all new export parameters are correctly passed to the API |
Comments suppressed due to low confidence (1)
tests/integration/test_base_export.py:52
- The test
test_export_png_with_all_parametersdoesn't actually test all newly added PNG export parameters. It's missing tests forscale,logo,logo_id,dark,ligatures,full_vector, anddownloadparameters. Consider adding these parameters to this test or creating a separate comprehensive test that includes all parameters.
def test_export_png_with_all_parameters(self):
"""Test PNG export with all parameters specified."""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| height: Height of visualization. If not specified, uses chart height. | ||
| plain: If True, exports only the visualization without header/footer. | ||
| scale: Size multiplier that changes actual dimensions (e.g., 2 = 2x size). | ||
| zoom: Resolution multiplier for sharper output at same visual size (e.g., 2 = 2x DPI). |
There was a problem hiding this comment.
The description of zoom for SVG export may be misleading. SVG is a vector format that doesn't have DPI (dots per inch) since it's resolution-independent. Consider revising the description to clarify how zoom applies to SVG format, or mention that it primarily affects rasterization when the SVG is converted.
| zoom: Resolution multiplier for sharper output at same visual size (e.g., 2 = 2x DPI). | |
| zoom: Scale multiplier for rendering. For SVG (a vector format), this affects the scale at which the SVG is rendered or rasterized (e.g., when converting to PNG). It does not affect intrinsic resolution or DPI. |
Add missing export parameters to align with Datawrapper API capabilities:
Also clarify distinction between scale (size multiplier) and zoom (resolution/DPI multiplier) in docstrings.