How-to: Add Chart to the Report =============================== It is possible to add charts to sheets that are written to report output. These charts are always added to the last column in the report, which is automatically created and resized to fit all the charts. These charts use data from the whole columns as series or labels (domains). To add a chart, pass its definition in the ``embedded_charts`` argument of :py:class:`ppc_robot_lib.output.types.Table`. Each chart definition consists from two objects: an :py:class:`ppc_robot_lib.output.charts.EmbeddedChart` instance that defines chart width and height, and an instance of subclass of :py:class:`ppc_robot_lib.output.charts.ChartSpec`, that defines the chart type and parameters. Currently, there is only one :py:class:`ppc_robot_lib.output.charts.ChartSpec` subclass: line chart represented by :py:class:`ppc_robot_lib.output.charts.LineChart`. Example: .. code-block:: python from ppc_robot_lib.output.types import Table from ppc_robot_lib.output.charts import EmbeddedChart, LineChart, LineType, LineStyle from ppc_robot_lib.utils.types import Color line_chart = LineChart( title='Impressions over time', subtitle='Number of impressions in the whole account per day', domain_column='Date', bottom_axis_title='Day', left_axis_title='Impression Count', ) line_chart.add_series( column='Impressions', color=Color(0xCC0000), line_style=LineStyle(3, LineType.MEDIUM_DASHED) ) table = Table( table_name='daily_impressions', sheet_name='Impressions by day', # ... embedded_charts=[ EmbeddedChart( spec=line_chart, width=800, height=600, ) ] ) Please note that the chart is embedded as an interactive object in the target sheet and rendered directly in web browser or Excel. This means that all referenced columns must be part of the output.