ablechart 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ablechart/__init__.py +351 -0
- ablechart/_log.py +34 -0
- ablechart/annotations.py +614 -0
- ablechart/api.py +518 -0
- ablechart/builder.py +370 -0
- ablechart/cleaner.py +144 -0
- ablechart/date_axis.py +673 -0
- ablechart/examples.py +113 -0
- ablechart/inspect.py +230 -0
- ablechart/layout.py +535 -0
- ablechart/metadata.py +198 -0
- ablechart/oxml/__init__.py +22 -0
- ablechart/oxml/axes.py +219 -0
- ablechart/oxml/plots.py +267 -0
- ablechart/oxml/series.py +509 -0
- ablechart/oxml_ns.py +8 -0
- ablechart/parser.py +1007 -0
- ablechart/plot_area.py +119 -0
- ablechart/polish.py +560 -0
- ablechart/presets.py +519 -0
- ablechart/range_chart.py +180 -0
- ablechart/range_snapshot.py +1174 -0
- ablechart/replace.py +321 -0
- ablechart/scatter.py +301 -0
- ablechart/schema.py +205 -0
- ablechart/semantic_anchor.py +125 -0
- ablechart/semantic_family.py +2239 -0
- ablechart/spec.py +1375 -0
- ablechart/styles.py +298 -0
- ablechart/tokens.py +163 -0
- ablechart/waterfall.py +750 -0
- ablechart-0.1.0.dist-info/METADATA +279 -0
- ablechart-0.1.0.dist-info/RECORD +36 -0
- ablechart-0.1.0.dist-info/WHEEL +5 -0
- ablechart-0.1.0.dist-info/licenses/LICENSE +21 -0
- ablechart-0.1.0.dist-info/top_level.txt +1 -0
ablechart/__init__.py
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"""ablechart
|
|
2
|
+
|
|
3
|
+
Core editable PowerPoint chart engine extracted from `ppt-st`.
|
|
4
|
+
|
|
5
|
+
Scope:
|
|
6
|
+
- native editable combo charts in `.pptx`
|
|
7
|
+
- dual-axis financial time-series charts
|
|
8
|
+
- date-axis presets
|
|
9
|
+
- chart parsing and cleanup helpers
|
|
10
|
+
- finance preset configs for common pension/investment charts
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .api import create_combo_chart
|
|
14
|
+
from .cleaner import ChartJunkCleaner, clean_chart
|
|
15
|
+
from .date_axis import (
|
|
16
|
+
BIWEEKLY_TICKS,
|
|
17
|
+
DAILY_TICKS,
|
|
18
|
+
MONTHLY_TICKS,
|
|
19
|
+
QUARTERLY_TICKS,
|
|
20
|
+
WEEKLY_TICKS,
|
|
21
|
+
YEARLY_TICKS,
|
|
22
|
+
DateAxisConfig,
|
|
23
|
+
)
|
|
24
|
+
from .layout import (
|
|
25
|
+
DEFAULT_CATEGORY_AXIS_CONFIG,
|
|
26
|
+
DEFAULT_LEGEND_CONFIG,
|
|
27
|
+
DEFAULT_VALUE_AXIS_CONFIG,
|
|
28
|
+
CategoryAxisConfig,
|
|
29
|
+
ChartLayoutConfig,
|
|
30
|
+
LegendConfig,
|
|
31
|
+
ValueAxisConfig,
|
|
32
|
+
)
|
|
33
|
+
from .annotations import (
|
|
34
|
+
add_value_labels,
|
|
35
|
+
apply_annotations,
|
|
36
|
+
apply_forecast_pattern,
|
|
37
|
+
highlight_category,
|
|
38
|
+
)
|
|
39
|
+
from .examples import SCENARIO_EXAMPLES, chart_spec_examples
|
|
40
|
+
from .parser import (
|
|
41
|
+
ChartParser,
|
|
42
|
+
parse_all_charts_from_pptx,
|
|
43
|
+
parse_all_semantic_components_from_pptx,
|
|
44
|
+
parse_chart_from_pptx,
|
|
45
|
+
parse_semantic_component_from_pptx,
|
|
46
|
+
)
|
|
47
|
+
from .range_chart import create_range_chart
|
|
48
|
+
from .schema import chart_spec_schema
|
|
49
|
+
from .spec import (
|
|
50
|
+
NormalizedSpec,
|
|
51
|
+
SpecError,
|
|
52
|
+
chart_spec_reference,
|
|
53
|
+
normalize_spec,
|
|
54
|
+
render_chart,
|
|
55
|
+
validate_spec,
|
|
56
|
+
)
|
|
57
|
+
from .presets import (
|
|
58
|
+
CHART_PRESET_FUNCTIONS,
|
|
59
|
+
FINANCE_PRESET_FUNCTIONS,
|
|
60
|
+
RANGE_SNAPSHOT_PRESET_FUNCTIONS,
|
|
61
|
+
VERTICAL_VALUATION_PRESET_FUNCTIONS,
|
|
62
|
+
build_range_snapshot_preset,
|
|
63
|
+
get_asx200_sector_valuation_snapshot_preset,
|
|
64
|
+
get_chart1_config,
|
|
65
|
+
get_chart2_config,
|
|
66
|
+
get_chart3_config,
|
|
67
|
+
get_chart4_config,
|
|
68
|
+
get_chart_config,
|
|
69
|
+
get_msci_emu_sector_valuation_snapshot_preset,
|
|
70
|
+
get_msci_japan_sector_valuation_snapshot_preset,
|
|
71
|
+
get_sp500_sector_valuation_snapshot_preset,
|
|
72
|
+
get_vertical_global_valuation_snapshot_preset,
|
|
73
|
+
get_vertical_sector_valuation_snapshot_preset,
|
|
74
|
+
)
|
|
75
|
+
from .styles import (
|
|
76
|
+
COLOR_SCHEMES,
|
|
77
|
+
DEFAULT_STYLE_CONFIG,
|
|
78
|
+
DARK_BLUE,
|
|
79
|
+
DARK_GRAY,
|
|
80
|
+
DARK_ORANGE,
|
|
81
|
+
DARK_RED,
|
|
82
|
+
LIGHT_BLUE,
|
|
83
|
+
LIGHT_GRAY,
|
|
84
|
+
LIGHT_ORANGE,
|
|
85
|
+
LIGHT_RED,
|
|
86
|
+
StyleConfig,
|
|
87
|
+
)
|
|
88
|
+
from .tokens import (
|
|
89
|
+
CHART_TOKENS,
|
|
90
|
+
CHART_PALETTE_TOKENS,
|
|
91
|
+
register_scheme,
|
|
92
|
+
register_schemes,
|
|
93
|
+
get_scheme,
|
|
94
|
+
list_schemes,
|
|
95
|
+
set_chart_tokens,
|
|
96
|
+
get_chart_token,
|
|
97
|
+
get_chart_palette,
|
|
98
|
+
reset_tokens,
|
|
99
|
+
)
|
|
100
|
+
from .scatter import (
|
|
101
|
+
ScatterParseResult,
|
|
102
|
+
create_bubble_chart,
|
|
103
|
+
create_scatter_chart,
|
|
104
|
+
parse_bubble_chart,
|
|
105
|
+
parse_bubble_from_pptx,
|
|
106
|
+
parse_scatter_chart,
|
|
107
|
+
parse_scatter_from_pptx,
|
|
108
|
+
)
|
|
109
|
+
from .range_snapshot import (
|
|
110
|
+
RangeSnapshotParseResult,
|
|
111
|
+
build_range_snapshot_spec,
|
|
112
|
+
create_range_snapshot_chart,
|
|
113
|
+
get_range_snapshot_spec,
|
|
114
|
+
parse_range_snapshot_chart,
|
|
115
|
+
parse_range_snapshot_from_pptx,
|
|
116
|
+
prepare_range_snapshot_dataframe,
|
|
117
|
+
restore_range_snapshot_dataframe,
|
|
118
|
+
)
|
|
119
|
+
from .waterfall import (
|
|
120
|
+
WaterfallParseResult,
|
|
121
|
+
build_waterfall_spec,
|
|
122
|
+
create_waterfall_chart,
|
|
123
|
+
get_waterfall_spec,
|
|
124
|
+
parse_waterfall_chart,
|
|
125
|
+
parse_waterfall_from_pptx,
|
|
126
|
+
prepare_waterfall_dataframe,
|
|
127
|
+
restore_waterfall_dataframe,
|
|
128
|
+
)
|
|
129
|
+
from .semantic_family import (
|
|
130
|
+
ATTRIBUTION_DECOMPOSITION_FAMILY,
|
|
131
|
+
AWARD_TIMELINE_PANEL_FAMILY,
|
|
132
|
+
CONCENTRATION_FAMILY,
|
|
133
|
+
DISTRIBUTION_PLUS_HISTORY_FAMILY,
|
|
134
|
+
DUAL_CHART_PANEL_FAMILY,
|
|
135
|
+
EVENT_TIMELINE_FAMILY,
|
|
136
|
+
FACTOR_EXPOSURE_FAMILY,
|
|
137
|
+
FACTOR_ATTRIBUTION_PANEL_FAMILY,
|
|
138
|
+
HEATMAP_MATRIX_FAMILY,
|
|
139
|
+
HOLDING_DETAIL_FAMILY,
|
|
140
|
+
MANAGER_TIMELINE_PROFILE_FAMILY,
|
|
141
|
+
PERFORMANCE_COMPARE_FAMILY,
|
|
142
|
+
REGIME_TABLE_PANEL_FAMILY,
|
|
143
|
+
RANKED_TILE_MATRIX_FAMILY,
|
|
144
|
+
SCORE_OVERLAY_FAMILY,
|
|
145
|
+
SEMANTIC_FAMILY_REGISTRY,
|
|
146
|
+
SELECTION_TIMING_GRID_FAMILY,
|
|
147
|
+
STYLE_ALLOCATION_FAMILY,
|
|
148
|
+
STYLE_BOX_FAMILY,
|
|
149
|
+
TABLE_PLUS_CHART_COMPOSITE_FAMILY,
|
|
150
|
+
SemanticChartParseResult,
|
|
151
|
+
create_attribution_decomposition_chart,
|
|
152
|
+
create_concentration_chart,
|
|
153
|
+
create_distribution_history_chart,
|
|
154
|
+
create_distribution_snapshot_chart,
|
|
155
|
+
create_dual_chart_panel,
|
|
156
|
+
create_event_timeline_chart,
|
|
157
|
+
create_factor_exposure_chart,
|
|
158
|
+
create_factor_attribution_panel,
|
|
159
|
+
create_award_timeline_panel,
|
|
160
|
+
create_heatmap_matrix_chart,
|
|
161
|
+
create_holding_detail_panel,
|
|
162
|
+
create_manager_timeline_profile,
|
|
163
|
+
create_performance_compare_chart,
|
|
164
|
+
create_regime_table_panel,
|
|
165
|
+
create_ranked_tile_matrix_chart,
|
|
166
|
+
create_score_overlay_chart,
|
|
167
|
+
create_semantic_chart,
|
|
168
|
+
create_selection_timing_grid,
|
|
169
|
+
create_style_allocation_chart,
|
|
170
|
+
create_style_box_chart,
|
|
171
|
+
create_table_plus_chart_composite,
|
|
172
|
+
get_semantic_chart_spec,
|
|
173
|
+
list_semantic_families,
|
|
174
|
+
parse_semantic_chart_from_layout_info,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
from .inspect import (
|
|
178
|
+
ChartInventoryItem,
|
|
179
|
+
ChartSelector,
|
|
180
|
+
inspect_pptx_charts,
|
|
181
|
+
)
|
|
182
|
+
from .metadata import (
|
|
183
|
+
METADATA_SCHEMA_VERSION,
|
|
184
|
+
METADATA_SHEET_NAME,
|
|
185
|
+
ChartMetadataV1,
|
|
186
|
+
write_chart_metadata,
|
|
187
|
+
)
|
|
188
|
+
from .replace import (
|
|
189
|
+
ReplaceResult,
|
|
190
|
+
SeriesData,
|
|
191
|
+
replace_pptx_chart_data,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
__version__ = "0.1.0"
|
|
195
|
+
|
|
196
|
+
__all__ = [
|
|
197
|
+
"BIWEEKLY_TICKS",
|
|
198
|
+
"CHART_PRESET_FUNCTIONS",
|
|
199
|
+
"COLOR_SCHEMES",
|
|
200
|
+
"CHART_TOKENS",
|
|
201
|
+
"CHART_PALETTE_TOKENS",
|
|
202
|
+
"register_scheme",
|
|
203
|
+
"register_schemes",
|
|
204
|
+
"get_scheme",
|
|
205
|
+
"list_schemes",
|
|
206
|
+
"set_chart_tokens",
|
|
207
|
+
"get_chart_token",
|
|
208
|
+
"get_chart_palette",
|
|
209
|
+
"reset_tokens",
|
|
210
|
+
"ChartJunkCleaner",
|
|
211
|
+
"ChartLayoutConfig",
|
|
212
|
+
"ChartParser",
|
|
213
|
+
"CategoryAxisConfig",
|
|
214
|
+
"DAILY_TICKS",
|
|
215
|
+
"DEFAULT_CATEGORY_AXIS_CONFIG",
|
|
216
|
+
"DEFAULT_LEGEND_CONFIG",
|
|
217
|
+
"DEFAULT_STYLE_CONFIG",
|
|
218
|
+
"DEFAULT_VALUE_AXIS_CONFIG",
|
|
219
|
+
"DARK_BLUE",
|
|
220
|
+
"DARK_GRAY",
|
|
221
|
+
"DARK_ORANGE",
|
|
222
|
+
"DARK_RED",
|
|
223
|
+
"DateAxisConfig",
|
|
224
|
+
"FINANCE_PRESET_FUNCTIONS",
|
|
225
|
+
"LIGHT_BLUE",
|
|
226
|
+
"LIGHT_GRAY",
|
|
227
|
+
"LIGHT_ORANGE",
|
|
228
|
+
"LIGHT_RED",
|
|
229
|
+
"LegendConfig",
|
|
230
|
+
"MONTHLY_TICKS",
|
|
231
|
+
"NormalizedSpec",
|
|
232
|
+
"QUARTERLY_TICKS",
|
|
233
|
+
"RANGE_SNAPSHOT_PRESET_FUNCTIONS",
|
|
234
|
+
"SpecError",
|
|
235
|
+
"VERTICAL_VALUATION_PRESET_FUNCTIONS",
|
|
236
|
+
"StyleConfig",
|
|
237
|
+
"chart_spec_examples",
|
|
238
|
+
"chart_spec_schema",
|
|
239
|
+
"chart_spec_reference",
|
|
240
|
+
"SCENARIO_EXAMPLES",
|
|
241
|
+
"normalize_spec",
|
|
242
|
+
"render_chart",
|
|
243
|
+
"validate_spec",
|
|
244
|
+
"ValueAxisConfig",
|
|
245
|
+
"WEEKLY_TICKS",
|
|
246
|
+
"YEARLY_TICKS",
|
|
247
|
+
"add_value_labels",
|
|
248
|
+
"apply_annotations",
|
|
249
|
+
"apply_forecast_pattern",
|
|
250
|
+
"ATTRIBUTION_DECOMPOSITION_FAMILY",
|
|
251
|
+
"AWARD_TIMELINE_PANEL_FAMILY",
|
|
252
|
+
"CONCENTRATION_FAMILY",
|
|
253
|
+
"DISTRIBUTION_PLUS_HISTORY_FAMILY",
|
|
254
|
+
"DUAL_CHART_PANEL_FAMILY",
|
|
255
|
+
"EVENT_TIMELINE_FAMILY",
|
|
256
|
+
"FACTOR_EXPOSURE_FAMILY",
|
|
257
|
+
"FACTOR_ATTRIBUTION_PANEL_FAMILY",
|
|
258
|
+
"HEATMAP_MATRIX_FAMILY",
|
|
259
|
+
"HOLDING_DETAIL_FAMILY",
|
|
260
|
+
"MANAGER_TIMELINE_PROFILE_FAMILY",
|
|
261
|
+
"PERFORMANCE_COMPARE_FAMILY",
|
|
262
|
+
"REGIME_TABLE_PANEL_FAMILY",
|
|
263
|
+
"RANKED_TILE_MATRIX_FAMILY",
|
|
264
|
+
"SCORE_OVERLAY_FAMILY",
|
|
265
|
+
"SEMANTIC_FAMILY_REGISTRY",
|
|
266
|
+
"SELECTION_TIMING_GRID_FAMILY",
|
|
267
|
+
"STYLE_ALLOCATION_FAMILY",
|
|
268
|
+
"STYLE_BOX_FAMILY",
|
|
269
|
+
"TABLE_PLUS_CHART_COMPOSITE_FAMILY",
|
|
270
|
+
"SemanticChartParseResult",
|
|
271
|
+
"clean_chart",
|
|
272
|
+
"create_attribution_decomposition_chart",
|
|
273
|
+
"create_bubble_chart",
|
|
274
|
+
"create_combo_chart",
|
|
275
|
+
"create_concentration_chart",
|
|
276
|
+
"create_distribution_history_chart",
|
|
277
|
+
"create_distribution_snapshot_chart",
|
|
278
|
+
"create_dual_chart_panel",
|
|
279
|
+
"create_event_timeline_chart",
|
|
280
|
+
"create_factor_exposure_chart",
|
|
281
|
+
"create_factor_attribution_panel",
|
|
282
|
+
"create_award_timeline_panel",
|
|
283
|
+
"create_heatmap_matrix_chart",
|
|
284
|
+
"create_holding_detail_panel",
|
|
285
|
+
"create_manager_timeline_profile",
|
|
286
|
+
"create_performance_compare_chart",
|
|
287
|
+
"create_range_chart",
|
|
288
|
+
"create_regime_table_panel",
|
|
289
|
+
"create_ranked_tile_matrix_chart",
|
|
290
|
+
"create_scatter_chart",
|
|
291
|
+
"create_score_overlay_chart",
|
|
292
|
+
"create_semantic_chart",
|
|
293
|
+
"create_selection_timing_grid",
|
|
294
|
+
"create_style_allocation_chart",
|
|
295
|
+
"create_style_box_chart",
|
|
296
|
+
"create_table_plus_chart_composite",
|
|
297
|
+
"highlight_category",
|
|
298
|
+
"get_chart1_config",
|
|
299
|
+
"get_chart2_config",
|
|
300
|
+
"get_chart3_config",
|
|
301
|
+
"get_chart4_config",
|
|
302
|
+
"get_chart_config",
|
|
303
|
+
"build_range_snapshot_preset",
|
|
304
|
+
"get_asx200_sector_valuation_snapshot_preset",
|
|
305
|
+
"get_vertical_global_valuation_snapshot_preset",
|
|
306
|
+
"get_vertical_sector_valuation_snapshot_preset",
|
|
307
|
+
"get_sp500_sector_valuation_snapshot_preset",
|
|
308
|
+
"get_msci_emu_sector_valuation_snapshot_preset",
|
|
309
|
+
"get_msci_japan_sector_valuation_snapshot_preset",
|
|
310
|
+
"get_semantic_chart_spec",
|
|
311
|
+
"list_semantic_families",
|
|
312
|
+
"parse_bubble_chart",
|
|
313
|
+
"parse_bubble_from_pptx",
|
|
314
|
+
"parse_all_charts_from_pptx",
|
|
315
|
+
"parse_all_semantic_components_from_pptx",
|
|
316
|
+
"parse_chart_from_pptx",
|
|
317
|
+
"parse_semantic_component_from_pptx",
|
|
318
|
+
"parse_semantic_chart_from_layout_info",
|
|
319
|
+
"parse_scatter_chart",
|
|
320
|
+
"parse_scatter_from_pptx",
|
|
321
|
+
"ScatterParseResult",
|
|
322
|
+
"build_range_snapshot_spec",
|
|
323
|
+
"create_range_snapshot_chart",
|
|
324
|
+
"get_range_snapshot_spec",
|
|
325
|
+
"prepare_range_snapshot_dataframe",
|
|
326
|
+
"restore_range_snapshot_dataframe",
|
|
327
|
+
"parse_range_snapshot_chart",
|
|
328
|
+
"parse_range_snapshot_from_pptx",
|
|
329
|
+
"RangeSnapshotParseResult",
|
|
330
|
+
"build_waterfall_spec",
|
|
331
|
+
"create_waterfall_chart",
|
|
332
|
+
"get_waterfall_spec",
|
|
333
|
+
"prepare_waterfall_dataframe",
|
|
334
|
+
"restore_waterfall_dataframe",
|
|
335
|
+
"parse_waterfall_chart",
|
|
336
|
+
"parse_waterfall_from_pptx",
|
|
337
|
+
"WaterfallParseResult",
|
|
338
|
+
# ADR-0007 §1 — inspect lifecycle (ADR-0006 §1)
|
|
339
|
+
"ChartInventoryItem",
|
|
340
|
+
"ChartSelector",
|
|
341
|
+
"inspect_pptx_charts",
|
|
342
|
+
# ADR-0007 §1 — metadata lifecycle (ADR-0004 §2 + ADR-0007 §3)
|
|
343
|
+
"ChartMetadataV1",
|
|
344
|
+
"METADATA_SCHEMA_VERSION",
|
|
345
|
+
"METADATA_SHEET_NAME",
|
|
346
|
+
"write_chart_metadata",
|
|
347
|
+
# ADR-0007 §1 — replace lifecycle (ADR-0006 §2)
|
|
348
|
+
"ReplaceResult",
|
|
349
|
+
"SeriesData",
|
|
350
|
+
"replace_pptx_chart_data",
|
|
351
|
+
]
|
ablechart/_log.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Internal logging helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import builtins
|
|
6
|
+
import logging
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
_LOGGER = logging.getLogger("ablechart")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def debug_print(*args, **kwargs) -> None:
|
|
14
|
+
"""Route legacy diagnostic prints to debug logging by default.
|
|
15
|
+
|
|
16
|
+
Set ``PPTCHARTENGINE_DEBUG_STDOUT=1`` to restore the old stdout diagnostics
|
|
17
|
+
while investigating OOXML output locally.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
if os.environ.get("PPTCHARTENGINE_DEBUG_STDOUT"):
|
|
21
|
+
builtins.print(*args, **kwargs)
|
|
22
|
+
return
|
|
23
|
+
|
|
24
|
+
file = kwargs.get("file")
|
|
25
|
+
if file is not None:
|
|
26
|
+
builtins.print(*args, **kwargs)
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
sep = kwargs.get("sep", " ")
|
|
30
|
+
end = kwargs.get("end", "\n")
|
|
31
|
+
message = sep.join(str(arg) for arg in args)
|
|
32
|
+
if end not in ("", "\n"):
|
|
33
|
+
message += end
|
|
34
|
+
_LOGGER.debug(message)
|