{"spec_id":"radar-basic","library":"pygal","language":"python","code":"\"\"\" anyplot.ai\nradar-basic: Basic Radar Chart\nLibrary: pygal 3.1.3 | Python 3.13.14\nQuality: 93/100 | Updated: 2026-07-24\n\"\"\"\n\nimport importlib\nimport os\nimport sys\n\n\n# Prevent this file (pygal.py) from shadowing the installed pygal package\n_here = os.path.dirname(os.path.abspath(__file__))\nsys.path = [p for p in sys.path if os.path.abspath(p) != _here]\n\npygal = importlib.import_module(\"pygal\")\nStyle = importlib.import_module(\"pygal.style\").Style\n\nTHEME = os.getenv(\"ANYPLOT_THEME\", \"light\")\nPAGE_BG = \"#FAF8F1\" if THEME == \"light\" else \"#1A1A17\"\nINK = \"#1A1A17\" if THEME == \"light\" else \"#F0EFE8\"\nINK_MUTED = \"#6B6A63\" if THEME == \"light\" else \"#A8A79F\"\nINK_FAINT = \"rgba(107, 106, 99, 0.35)\" if THEME == \"light\" else \"rgba(168, 167, 159, 0.35)\"\n\nIMPRINT = (\"#009E73\", \"#C475FD\", \"#4467A3\", \"#BD8233\", \"#AE3030\", \"#2ABCCD\", \"#954477\")\n\n# Data: three employees with distinct competency profiles — technical expert,\n# collaborative leader, and creative visionary — to highlight trade-offs.\ncategories = [\"Communication\", \"Technical Skills\", \"Teamwork\", \"Problem Solving\", \"Leadership\", \"Creativity\"]\n\nemployee_a = [85, 92, 78, 88, 72, 80]  # Technical Expert: peaks at Technical Skills\nemployee_b = [80, 68, 92, 82, 88, 74]  # Team Leader: peaks at Teamwork & Leadership\nemployee_c = [72, 76, 70, 74, 85, 95]  # Creative Visionary: peaks at Creativity & Leadership\n\n# Highest overall average becomes the visual \"hero\" series — bolder stroke and\n# larger dots build a focal point so the viewer immediately spots the top\n# all-round performer, while the other two stay legible but recede slightly.\nseries = [\n    (\"Employee A — Technical Expert\", employee_a),\n    (\"Employee B — Team Leader\", employee_b),\n    (\"Employee C — Creative Visionary\", employee_c),\n]\nhero_label, _ = max(series, key=lambda s: sum(s[1]) / len(s[1]))\n\ntitle = \"radar-basic · python · pygal · anyplot.ai\"\n\n# Style — native-pixel font sizes targeting ~67 source-px title height at the\n# canonical 2400x2400 square canvas (see default-style-guide.md \"Proportional\n# Sizing\"); title is well under the 67-char baseline so no length scaling needed.\n# Radial gridlines get a two-tier treatment (faint dotted minor rings, slightly\n# firmer dashed major rings every 2nd label) instead of pygal's flat default —\n# a subtler ring rhythm beyond the mandated style-guide baseline.\ncustom_style = Style(\n    font_family='\"Liberation Sans\", \"DejaVu Sans\", Arial, sans-serif',\n    background=PAGE_BG,\n    plot_background=PAGE_BG,\n    foreground=INK,\n    foreground_strong=INK,\n    foreground_subtle=INK_MUTED,\n    colors=IMPRINT,\n    title_font_size=66,\n    label_font_size=56,\n    major_label_font_size=44,\n    legend_font_size=44,\n    value_font_size=36,\n    opacity=0.22,\n    opacity_hover=0.55,\n    stroke_opacity=0.9,\n    guide_stroke_color=INK_FAINT,\n    guide_stroke_dasharray=\"2,6\",\n    major_guide_stroke_color=INK_MUTED,\n    major_guide_stroke_dasharray=\"9,4\",\n)\n\n# Plot\nchart = pygal.Radar(\n    width=2400,\n    height=2400,\n    style=custom_style,\n    title=title,\n    show_legend=True,\n    legend_at_bottom=True,\n    legend_at_bottom_columns=1,\n    fill=True,\n    dots_size=5,\n    stroke_style={\"width\": 3, \"linecap\": \"round\", \"linejoin\": \"round\", \"dasharray\": \"14,6\"},\n    show_y_guides=True,\n    y_labels_major_every=2,\n    range=(0, 100),\n    margin=30,\n    spacing=16,\n)\n\nchart.x_labels = categories\nfor label, values in series:\n    is_hero = label == hero_label\n    # Hero series reads as a bold, solid focal line; supporting series recede\n    # behind a thinner dashed stroke and smaller dots — a wider gap than a flat\n    # stroke-width bump alone so the top performer reads at a glance.\n    chart.add(\n        label,\n        values,\n        dots_size=11 if is_hero else 5,\n        stroke_style={\"width\": 7.5, \"linecap\": \"round\", \"linejoin\": \"round\"}\n        if is_hero\n        else {\"width\": 3, \"linecap\": \"round\", \"linejoin\": \"round\", \"dasharray\": \"14,6\"},\n    )\n\n# Save\nchart.render_to_png(f\"plot-{THEME}.png\")\nwith open(f\"plot-{THEME}.html\", \"wb\") as f:\n    f.write(chart.render())\n"}