{"spec_id":"gauge-activity-rings","library":"makie","language":"julia","code":"# anyplot.ai\n# gauge-activity-rings: Activity Rings Progress Chart\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 89/100 | Created: 2026-06-14\n\nusing CairoMakie\nusing Colors\nusing Statistics\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 INK_SOFT  = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\nconst INK_MUTED = THEME == \"light\" ? colorant\"#6B6A63\" : colorant\"#A8A79F\"\n\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\",  # 1 — brand green (first series, always)\n    colorant\"#C475FD\",  # 2 — lavender\n    colorant\"#4467A3\",  # 3 — blue\n    colorant\"#BD8233\",  # 4 — ochre\n    colorant\"#AE3030\",  # 5 — matte red\n    colorant\"#2ABCCD\",  # 6 — cyan\n    colorant\"#954477\",  # 7 — rose\n    colorant\"#99B314\",  # 8 — lime\n]\n\n# Data — daily fitness tracker: Move, Exercise, Stand\nconst metrics     = [\"Move\",  \"Exercise\", \"Stand\"]\nconst val_current = [420,      25,          9]\nconst val_goal    = [600,      30,         12]\nconst val_unit    = [\"kcal\",  \"min\",       \"hr\"]\nconst ring_radii  = [0.68,    0.50,        0.32]\nconst ring_colors = IMPRINT_PALETTE[1:3]\n\nconst fractions = val_current ./ val_goal     # [0.70, 0.833, 0.75]\nconst avg_pct   = round(Int, mean(fractions) * 100)   # 76\n\n# Figure — square canvas → 2400 × 2400 output\nfig = Figure(\n    size            = (1200, 1200),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"gauge-activity-rings · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    backgroundcolor    = PAGE_BG,\n    aspect             = DataAspect(),\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinevisible   = false,\n    bottomspinevisible = false,\n    xgridvisible       = false,\n    ygridvisible       = false,\n    xticksvisible      = false,\n    yticksvisible      = false,\n    xticklabelsvisible = false,\n    yticklabelsvisible = false,\n)\n\nlimits!(ax, -1.10, 1.10, -1.10, 1.10)\n\n# Ring drawing parameters\nconst N_PTS = 360\nconst LW    = 46   # device px → ×2 = 92 output px on 2400-px canvas\n\n# Draw rings outer → inner\nfor (r, frac, col) in zip(ring_radii, fractions, ring_colors)\n    # Faint background track — full circle; higher opacity in dark for contrast\n    bg_alpha = THEME == \"dark\" ? 0.22f0 : 0.12f0\n    θ_bg = range(0.0, 2π, length = N_PTS + 1)\n    lines!(ax, r .* cos.(θ_bg), r .* sin.(θ_bg);\n           linewidth = LW, color = (col, bg_alpha))\n\n    # Progress arc — starts at 12 o'clock (π/2), sweeps clockwise\n    sweep = min(frac, 1.0) * 2π\n    n_arc = max(4, round(Int, frac * N_PTS))\n    θ_arc = range(π / 2, π / 2 - sweep; length = n_arc)\n    x_arc = r .* cos.(θ_arc)\n    y_arc = r .* sin.(θ_arc)\n    lines!(ax, x_arc, y_arc; linewidth = LW, color = col)\n\n    # Circular end caps that match the line width for a rounded look\n    scatter!(ax, [x_arc[1]],   [y_arc[1]];   color = col, markersize = LW, strokewidth = 0)\n    scatter!(ax, [x_arc[end]], [y_arc[end]]; color = col, markersize = LW, strokewidth = 0)\nend\n\n# Center summary text\ntext!(ax, 0.0, 0.10;\n      text     = \"$(avg_pct)%\",\n      fontsize = 60,\n      color    = INK,\n      align    = (:center, :center))\ntext!(ax, 0.0, -0.12;\n      text     = \"COMPLETE\",\n      fontsize = 18,\n      color    = INK_MUTED,\n      align    = (:center, :center))\n\n# Bottom legend strip — color dot + metric name + value/goal\nconst x_pos = [-0.52, 0.0, 0.52]\nconst y_lbl = -0.84\nconst y_val = -0.97\n\nfor (i, (name, cur, goal, unit, col)) in\n        enumerate(zip(metrics, val_current, val_goal, val_unit, ring_colors))\n    xc = x_pos[i]\n    scatter!(ax, [xc - 0.14], [(y_lbl + y_val) / 2];\n             color = col, markersize = 22, strokewidth = 0)\n    text!(ax, xc - 0.04, y_lbl;\n          text = name, fontsize = 16, color = INK, align = (:left, :baseline))\n    text!(ax, xc - 0.04, y_val;\n          text = \"$(cur) / $(goal) $(unit)\", fontsize = 13, color = INK_SOFT,\n          align = (:left, :baseline))\nend\n\n# Save — px_per_unit = 2 doubles the resolution to 2400 × 2400\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}