Report Generator

    The Report Generator node can generate a text (e.g. HTML) report with the data it receives. The report can be customized with a template in Tera (Jinja2) format.

    Each input must be configured with its own template. Then the Root Template is used to consolidate the individual reports into a single report.

    The node has the following configuration options:

    • Open in Panel: If checked, the report will be opened in a panel in the DataCogs UI. Otherwise, the report is opened directly in the node on the graph.
    • Limit Input Reports: If set, then only the last N input reports are included in the output report. If not set, all input reports are included. This is useful when the graph is long and you are using the report generator as a informational summary or dashboard, and only need to see the most recent data.
    • Template: The base template for the report. This consolidates the individual input reports. All input reports are stored in the input_reports variable.
    • Input Count: The number of inputs to expose on the node. Increasing this number automatically adds input connectors to the node.
    • Input Template: The template for each input. This is where the data from the input is rendered. The input template can access the input data using the payload variable. For example, {{ payload[0].name }} would access the name field of the first record.

    Inputs are expected to be in the serde-json::Value format. Since many data operations use Apache Arrow RecordBatch, the RecordBatch can be converted to serde-json::Value using a Data Stream to JSON node.

    Root Template🔗

    The base template for the report, used to consolidate the individual input reports into a single document.

    <h1>Report</h1>
    {% for input_id, reporter in input_reports %}
        <h1>Input: {{input_id}}</h1>
        {% for report in reporter %}
            {{ report }}
        {% endfor %}
    {% endfor %}
    

    The Root template can be a full HTML document. For example:

    <!DOCTYPE html>
    <html>
    <head>
        <style>
            table { width: 100%; }
        </style>
    </head>
    <body>
    <h1>Report</h1>
    {% for input_id, reporter in input_reports %}
        <h1>Input: {{input_id}}</h1>
        {% for report in reporter %}
            {{ report }}
        {% endfor %}
    {% endfor %}
    </body>
    </html>
    

    Input Template🔗

    The template for each input. This is where the data from the input is rendered. The input template can access the input data using the payload variable. For example, {{ payload[0].name }} would access the name field of the first record.

    <h2>Input Report</h2>
    <table>
    {% for row in payload %}
    {# If this is the first row, print the header first #}
        {% if loop.first %}
        <tr>
            {% for key,value in row %}
            <th>{{key}}</th>
            {% endfor %}
        </tr>
        {% endif %}
    
        <tr>
            {% for key,value in row %}
            <td>{{value}}</td>
            {% endfor %}
        </tr>
    {% endfor %}
    </table>
    

    Document Format🔗

    The node generates text. It could be used to generate other text formats, such as JSON or CSV.

    For example, to generate a JSON document:

    {
        "report": [
            {% for input_id, reporter in input_reports %}
            {
                "input_id": "{{input_id}}",
                "reports": [
                    {% for report in reporter %}
                    {{ report }},
                    {% endfor %}
                ]
            },
            {% endfor %}
        ]
    }
    

    Multimedia and Charts🔗

    Report Generator can render SVG inputs natively. By combining with the Plotter Node, you can generate charts and graphs in the report.

    Another way to create custom multimedia is to use the Data Stream to JSON node to convert the data to JSON and then use a custom HTML template to render the multimedia or charts.