How to Create Multi-Page Reports

Learn how to use JSPlotPage and Pages to create multi-page HTML reports with automatic navigation

Creating Multi-Page Reports with JSPlotPage and Pages

Overview

JSPlots.jl makes it easy to create multi-page HTML reports. You create individual pages using JSPlotPage, then combine them into a multi-page report using Pages.

We have two examples that demonstrate the use of pages. See here and see here/a> with this script generating both of them.

Creating Individual Pages with JSPlotPage

A JSPlotPage represents a single HTML page with charts, tables, and text content:

page = JSPlotPage(
    Dict(:data_name => dataframe),  # Data dictionary
    [chart1, chart2, text_block],   # Content items
    tab_title = "My Page",          # Browser tab title
    page_header = "Analysis Report", # Page header
    dataformat = :parquet           # Data storage format
)

Combining Pages with the Pages Constructor

The Pages constructor creates a multi-page report with automatic navigation:

# Easy constructor - automatically creates LinkList!
report = Pages(
    [coverpage_content],  # Items for the coverpage
    [page1, page2, page3], # Your JSPlotPage objects
    tab_title = "Report Home",
    page_header = "Business Report",
    dataformat = :parquet
)

Automatic LinkList Generation

Key Feature: The Pages constructor automatically generates a LinkList from your pages and adds it to the coverpage!

Manual LinkList (Advanced)

You can also create LinkLists manually for custom navigation:

links = LinkList([
    ("Title 1", "page_1.html", "Description of page 1"),
    ("Title 2", "page_2.html", "Description of page 2")
])

Complete Example

# Create individual pages
analysis_page = JSPlotPage(
    Dict(:sales => sales_df),
    [scatter_chart, line_chart],
    tab_title = "Sales Analysis",
    notes = "Detailed sales trends and patterns"
)

metrics_page = JSPlotPage(
    Dict(:kpis => kpi_df),
    [kde_chart, dist_chart],
    tab_title = "Key Metrics",
    notes = "Performance indicators and distributions"
)

# Create multi-page report with automatic LinkList
report = Pages(
    [TextBlock("<h1>Q4 Report</h1>")],
    [analysis_page, metrics_page],
    tab_title = "Q4 2024 Report"
)

# Generate HTML
create_html(report, "my_report")
# Creates: my_report.html (coverpage with links)
#          page_1.html (Sales Analysis)
#          page_2.html (Key Metrics)

Benefits

Opening Multi-Page Reports

When you use external data formats (:parquet, :csv_external, :json_external), JSPlots.jl automatically generates launcher scripts in the project directory:

Why? Browsers block loading external files from file:// URLs for security. The launcher scripts solve this by either running a local web server or launching the browser with flags to allow local file access.


This page was created using JSPlots.jl.