composeui.core.chartimage¶
A chart as a report’s figure, drawn by matplotlib alike on every backend, or with none.
A screen chart follows its window and theme; a report’s figure has its page’s size and
fonts, and a light background. So the figure is drawn from the ChartView’s data, e.g.
by a batch run writing a report’s figures:
save_chart_image(chart, Path(“pressure.pdf”), ImageOptions(width_mm=80))
It needs the report extra (matplotlib), imported only by these functions; without it
they raise an ImportError naming the extra, and is_available is False.
- class composeui.core.chartimage.ImageOptions[source]¶
Bases:
objectHow a chart’s image looks: its size, fonts and range.
- x_range: tuple[float, float] | None¶
the region shown, e.g. the one the user zoomed into; None: all the data
- __init__(width_mm=160, height_mm=100, dpi=300, font_size=9, show_title=False, x_range=None, y_range=None)¶
Method generated by attrs for class ImageOptions.
- composeui.core.chartimage.chart_figure(chart, options=ImageOptions(width_mm=160, height_mm=100, dpi=300, font_size=9, show_title=False, x_range=None, y_range=None))[source]¶
Draw
chartas a report’s figure, which app code can add to before saving it.Save it in
image_stylefor its text to stay text, or withsave_chart_image.- Parameters:
chart (ChartView)
options (ImageOptions)
- Return type:
Figure
- composeui.core.chartimage.save_chart_image(chart, path, options=ImageOptions(width_mm=160, height_mm=100, dpi=300, font_size=9, show_title=False, x_range=None, y_range=None))[source]¶
Save
chart’s figure topath, in the format its suffix names (seeFORMATS).- Parameters:
chart (ChartView)
path (Path)
options (ImageOptions)
- Return type:
None