Tabular and Text Data

This shows examples of TextBlock, LinkList, CodeBlock, DataTable and PivotTable.

Dataset Generation

We'll create a business analytics dataset for use throughout this documentation to show off all of the plottypes. The dataset contains sales data for a company employing door to door salesmen accross a wide area and with a large set of possible products.

The code that generates this dataset is shown below as the example of the CodeBlock type.




Julia
function generate_comprehensive_data()
    rng = StableRNG(42)

    # Time period: One year of daily data
    start_date = Date(2024, 1, 1)
    dates = start_date:Day(1):(start_date + Day(700))
    n = length(dates)

    # Product categories
    products = ["Laptop", "Tablet", "Phone"]
    regions = ["North", "South", "West"]
    segments = ["Enterprise", "SMB", "Consumer"]

    # Generate sales data
    records = DataFrame[]

    for (i, date) in enumerate(dates)
        for product in products
            for region in regions
                # Base sales with trends and seasonality
                base = 10000 + 1000 * sin(2π * i / 365)
                trend = i * 10

                # Product-specific multipliers
                product_mult = Dict(
                    "Laptop" => 3.0, "Tablet" => 2.0, "Phone" => 4.0
                )[product]

                # Region-specific multipliers
                region_mult = Dict("North" => 1.2, "South" => 1.0, "West" => 1.1)[region]

                sales = (base + trend) * product_mult * region_mult * (1 + 0.2 * randn(rng))
                quantity = round(Int, sales / (100 + 50 * randn(rng)))
                cost = sales * (0.6 + 0.1 * randn(rng))
                profit = sales - cost

                # Customer metrics
                customers = round(Int, quantity * (0.3 + 0.1 * randn(rng)))
                satisfaction = 3.5 + 1.0 * randn(rng)

                # Geographic coordinates
                lat = 35.0 + Dict("North" => 10, "South" => -10, "West" => 0)[region] + randn(rng)
                lon = -95.0 + Dict("North" => 0, "South" => 0, "West" => -15)[region] + randn(rng)

                # Random segment assignment
                segment = rand(rng, segments)

                push!(records, DataFrame(
                    date = date,
                    product = product,
                    region = region,
                    segment = segment,
                    sales = max(0, sales),
                    quantity = max(0, quantity),
                    cost = max(0, cost),
                    profit = profit,
                    customers = max(0, customers),
                    satisfaction = clamp(satisfaction, 1, 5),
                    latitude = lat,
                    longitude = lon,
                    month = month(date),
                    quarter = (month(date) - 1) ÷ 3 + 1,
                    day_of_year = dayofyear(date)
                ))
            end
        end
    end

    return vcat(records...)
end
We can use a CodeBlock to show code snippets with syntax highlighting. We have correct Syntax highlighting for Julia, Python, R, JavaScript, Java, C, C++, SQL, pl/pgsql, Rust. For anything else it will all be black.



PivotTable

PivotTables can do quite alot. Indeed many of the charttypes of this package would alternatively be doable just using a PivotTable so you might prefer doing that in some cases.Now we have example data generated (from the above function) we will shoow this in a pivottable (and it will be used throughout the rest of the examples). See here for PivotTable examples


Data: sales_data.parquet




Table

This just displays your DataFrame in a nice way on the html page. There is a download as csv button at the bottom of it. You could also just use a PivotTable but this is lighterweight for cases where a PivotTable is overkill. See here for Table examples

producttotal_salestotal_quantitytotal_profit
Phone1.2498934909082277e823346354.983743212838119e7
Laptop9.331932174333596e716907643.718559283865343e7
Tablet6.289886064762073e719872242.4985962429159395e7

Data: Table




LinkList




Pages

OverView

Tabular Data and Text

Multimedia

2D Plots

Distributional Plots

3D Plots

Situational Charts

A LinkList shows you a list of links with optional descriptions. These are automatically generated if you make a Pages struct where there is a LinkList on the top page with links to the others. You can also make your own. See here for LinkList examples

Data: no_data.parquet




TextBlock

You can write whatever HTML you want and put it in a TextBlock which will put it in the resultant HTML.

TextBlock allows you to add rich text, HTML, and annotations to your reports.

You can include formatting, styled text, and even inline code.

See here for TextBlock examples.


This page was created using JSPlots.jl.