Skip to content

Publish a study report

A single Report can produce interactive HTML and a paginated PDF. A report contains ordered sections, and each section can mix Figure and Table objects. A figure wraps a native Altair chart with an optional caption; a table retains numeric values and specifies how to display them.

from pathlib import Path

from paretorium.visualization import (
    Figure,
    Report,
    Section,
    export_html,
    export_pdf,
    parameter_atlas,
)

# chart and table are the comparison from Plot a tradespace.
report = Report(
    "Backup power review",
    (
        Section(
            "Long outage",
            (Figure(chart, "Cost versus remaining energy."), table),
        ),
        parameter_atlas(study),
    ),
)

export_html(report, Path("runs/backup/report.html"))
export_pdf(report, Path("runs/backup/report.pdf"))

Use the workshop comparison in the tradespace how-to to produce chart and table. The first page of the resulting PDF puts the chart, caption, and comparison table together:

First page of the backup power report: the long-outage tradespace appears above a table of three compatible designs.

You can also insert an Altair chart you created yourself. For a common style across built-in views, pass the same Theme while building them. Publishers don't restyle the charts.

  • HTML keeps Vega-Lite interactions and gives each table its own sort and filter controls. The page bundles everything those controls need. Use inline chart data and artwork if the report needs to work offline.
  • PDF uses the same Vega-Lite specifications for vector artwork. It scales charts to fit A4 pages, keeps short figure captions with their charts, and repeats table headers on continuation pages. It does not include browser interactions.
  • For standalone SVG, continue to use export_chart on the native Altair chart. It doesn't need a report.

Sort and filter HTML tables

Select a column heading to sort ascending; select it again to sort descending. Numbers sort by their underlying values rather than their formatted text, and missing values stay last.

Type in Filter rows to look for displayed values such as a design ID, an option name, or Pareto. The search is case-insensitive and all words must match. Use Search in to restrict the search to one column. Reset restores the original order and shows all rows. Each table is independent: sorting and filtering do not change the charts, data, or PDF.

For example, open the workshop report.html, choose Comparison status in Search in, and type Pareto in Filter rows. Only D-002 remains in the long-outage table; the chart still shows all three designs. Select Reset before sorting by reserve_wh (Wh) to compare all three again.

Document input assumptions

parameter_atlas(study) builds a section with one figure per declared input. A single figure is also available via parameter_distribution(parameter, scenarios=study.scenarios).

For example, pull out the workshop load assumption to include it in a shorter report, or publish it as a standalone chart:

from pathlib import Path

from studies.example_backup import study
from paretorium.visualization import export_chart, parameter_distribution

load = next(parameter for parameter in study.parameters if parameter.id == "load_w")
figure = parameter_distribution(load, scenarios=study.scenarios)
export_chart(figure.chart, Path("runs/backup"), name="load-assumption")

Triangular load assumption with a peak at 220 W and endpoints at 180 W and 270 W.

The atlas shows definitions, not sampled data. It includes the base assumption, each option-specific case, and explicit scenario overrides. It doesn't repeat inherited values. Scenario overrides take precedence over option cases, which take precedence over the base assumption.

Fixed values, continuous densities, and discrete probability masses use separate panels with a common value axis whenever they appear together. The current views support constants, Uniform, Triangular, Beta, Lognormal, and Discrete. Beta curves omit endpoints where the density is infinite. Lognormal curves show ±4 standard deviations in log space; this clips the plot, not the distribution used by the runner. A lognormal with zero variation is shown as a fixed value.

For other distributions, supply a custom Altair figure; the atlas reports unsupported definitions rather than estimating or silently skipping them.

See the satellite walkthrough for a report with two scenario comparisons and a six-parameter atlas.