This shows examples of TextBlock, LinkList, CodeBlock, DataTable and PivotTable.
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.
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
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
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
| product | total_sales | total_quantity | total_profit |
|---|---|---|---|
| Phone | 1.2498934909082277e8 | 2334635 | 4.983743212838119e7 |
| Laptop | 9.331932174333596e7 | 1690764 | 3.718559283865343e7 |
| Tablet | 6.289886064762073e7 | 1987224 | 2.4985962429159395e7 |
Data: Table
Data: no_data.parquet
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.