### Configure PyCha Chart Template Source: https://relatorio.readthedocs.io/en/latest/indepthexample.html Defines chart options and dataset structure using a YAML-based TextTemplate compatible with PyCha. ```yaml options: width: 600 height: 400 background: {hide: true} legend: {hide: true} axis: {labelFontSize: 14} padding: {bottom: 10, left: 10, right: 10, top: 10} chart: type: pie output_type: png dataset: {% for line in o.lines %} - - ${line.item.name} - - [0, $line.amount] {% end %} ``` -------------------------------- ### Generate Basic ODT Report with Relatorio Source: https://relatorio.readthedocs.io/en/latest/indepthexample.html Creates a basic OpenDocument Text (ODT) report using a predefined template. It binds the invoice data to the template and renders the output to a file. ```python from relatorio.templates.opendocument import Template basic = Template(source='', filepath='basic.odt') file('bonham_basic.odt', 'wb').write(basic.generate(o=inv).render().getvalue()) ``` -------------------------------- ### Generate ODT Document Source: https://relatorio.readthedocs.io/en/latest/quickexample.html Use the Relatorio Template engine to generate an ODT file from a template and the previously defined invoice data. The output is rendered to a StringIO object and then written to a file. ```python from relatorio.templates.opendocument import Template from data import bonham_invoice basic = Template(source='', filepath='basic.odt') basic_generated = basic.generate(o=bonham_invoice).render() file('bonham_basic.odt', 'wb').write(basic_generated.getvalue()) ``` -------------------------------- ### Define Invoice Data Object Source: https://relatorio.readthedocs.io/en/latest/quickexample.html Create a Python class to represent invoice data, including properties for total and VAT. This object will be used to populate the ODT template. ```python from os.path import dirname, join class Invoice(dict): @property def total(self): return sum(line['amount'] for line in self['lines']) @property def vat(self): return self.total * 0.21 inv = Invoice(customer={'name': 'John Bonham', 'address': {'street': 'Smirnov street', 'zip': 1000, 'city': 'Montreux'}}, lines=[{'item': {'name': 'Vodka 70cl', 'reference': 'VDKA-001', 'price': 10.34}, 'quantity': 7, 'amount': 7 * 10.34}, {'item': {'name': 'Cognac 70cl', 'reference': 'CGNC-067', 'price': 13.46}, 'quantity': 12, 'amount': 12 * 13.46}, {'item': {'name': 'Sparkling water 25cl', 'reference': 'WATR-007', 'price': 4}, 'quantity': 1, 'amount': 4}, {'item': {'name': 'Good customer', 'reference': 'BONM-001', 'price': -20}, 'quantity': 1, 'amount': -20}, ], id='MZY-20080703', status='late', bottle=(open(join(dirname(__file__), 'bouteille.png'), 'rb'), 'image/png')) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.