{"spec_id":"sparkline-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# sparkline-basic: Basic Sparkline\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 82/100 | Created: 2026-09-09\n\nusing CairoMakie\nusing Colors\nusing Random\n\nRandom.seed!(42)\n\n# --- Theme tokens -----------------------------------------------------------\nconst THEME    = get(ENV, \"ANYPLOT_THEME\", \"light\")\nconst PAGE_BG  = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst INK      = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\", colorant\"#C475FD\", colorant\"#4467A3\", colorant\"#BD8233\",\n    colorant\"#AE3030\", colorant\"#2ABCCD\", colorant\"#954477\", colorant\"#99B314\",\n]\nconst BRAND = IMPRINT_PALETTE[1]\n\n# --- Data ---------------------------------------------------------------\n# Daily active users for a SaaS product over a quarter, mild upward drift\nn = 60\nday = 1:n\ndaily_steps = randn(n - 1) .* 140 .+ 6\ndaily_active_users = 11_800.0 .+ cumsum(vcat(0.0, daily_steps))\n\n# --- Plot -----------------------------------------------------------------\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\ntitle_str = \"sparkline-basic · julia · makie · anyplot.ai\"\n\nax = Axis(\n    fig[1, 1];\n    title           = title_str,\n    titlesize       = 26,\n    titlecolor      = INK,\n    titlegap        = 36,\n    backgroundcolor = PAGE_BG,\n)\nhidedecorations!(ax)\nhidespines!(ax)\n\ny_min, y_max = extrema(daily_active_users)\ny_range = y_max - y_min\ny_pad = y_range * 1.0\nylims!(ax, y_min - y_pad, y_max + y_pad)\nxlims!(ax, day[1] - 0.5, day[end] + 0.5)\n\nidx_min = argmin(daily_active_users)\nidx_max = argmax(daily_active_users)\n\n# True area-fill effect: shade down to the series' own minimum, not the padded canvas.\nband!(ax, day, fill(y_min, n), daily_active_users; color = (BRAND, 0.22))\nlines!(ax, day, daily_active_users; color = BRAND, linewidth = 3.5)\n\n# Optional sparkline conventions: min/max highlights + first/last reference points.\nscatter!(\n    ax, [day[idx_min]], [daily_active_users[idx_min]];\n    color = IMPRINT_PALETTE[3], markersize = 16, strokewidth = 0,\n)\nscatter!(\n    ax, [day[idx_max]], [daily_active_users[idx_max]];\n    color = IMPRINT_PALETTE[4], markersize = 16, strokewidth = 0,\n)\nscatter!(\n    ax, [day[1]], [daily_active_users[1]];\n    color = PAGE_BG, markersize = 18, strokewidth = 2, strokecolor = BRAND,\n)\nscatter!(\n    ax, [day[end]], [daily_active_users[end]];\n    color = BRAND, markersize = 22, strokewidth = 2, strokecolor = PAGE_BG,\n)\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}