You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Test functions: `test_base_chart_delete_success`, `test_base_chart_delete_no_chart_id`, `test_base_chart_duplicate_success`, `test_base_chart_duplicate_invalid_response`, `test_base_chart_fork_success`, `test_get_display_urls_success`, `test_get_display_urls_no_chart_id`, `test_get_display_urls_custom_token`, `test_get_iframe_code_success`, `test_get_iframe_code_responsive`, `test_get_iframe_code_no_chart_id`, `test_get_iframe_code_custom_token`, `test_get_editor_url_success`, `test_get_editor_url_no_chart_id`, `test_get_png_url_success`, `test_get_png_url_no_chart_id`, etc.
1151
1151
1152
+
### Method Chaining Pattern (v2.0.0+)
1153
+
1154
+
**BREAKING CHANGE**: Starting in version 2.0.0, the `create()`, `update()`, and `publish()` methods in BaseChart return `self` instead of their previous return types, enabling method chaining (fluent interface pattern).
1155
+
1156
+
**Return Type Changes:**
1157
+
- `create()`: Changed from `str` (chart_id) to `"BaseChart"` (self)
1158
+
- `update()`: Changed from `str` (chart_id) to `"BaseChart"` (self)
1159
+
- `publish()`: Changed from `bool` to `"BaseChart"` (self), now raises exception on failure instead of returning False
1160
+
1161
+
**Key Features:**
1162
+
- All three methods now return the chart instance (`self`) for method chaining
1163
+
- Methods can be chained together: `chart.create().update().publish()`
1164
+
- The `chart_id` is still set internally and accessible via `chart.chart_id`
1165
+
- `publish()` now raises an exception on failure instead of returning False
The iframe code can be directly embedded in HTML pages. The `responsive=True` option generates code that automatically adjusts to container width.
138
-
139
-
## Getting editor URL
140
-
141
-
Get the Datawrapper URL to continue editing your chart:
142
-
143
-
```python
144
-
# Get the editor URL
145
-
chart.get_editor_url()
146
130
```
147
131
148
132
## Getting png URL
149
133
150
134
Get the fallback image URL for use in noscript tags:
151
135
152
136
```python
153
-
# Get the PNG URL
154
137
png_url = chart.get_png_url()
155
-
print(f"PNG fallback: {png_url}")
156
138
157
-
# Use in HTML noscript tags
158
139
html =f'<noscript><img src="{png_url}" alt="Chart" /></noscript>'
159
140
```
160
-
161
-
This provides a static image fallback for environments where JavaScript is disabled. It's also a handy way to get a direct link to the chart image for other uses.
0 commit comments