{"spec_id":"radar-multi","library":"muix","language":"javascript","code":"// anyplot.ai\n// radar-multi: Multi-Series Radar Chart\n// Library: muix 9.17.0 | JavaScript 22.23.4\n// Quality: 88/100 | Updated: 2026-11-08\n//# anyplot-orientation: square\n\nimport { RadarChart, RadarAxis, RadarSeriesArea, RadarSeriesMarks } from \"@mui/x-charts/RadarChart\";\n\nconst t = window.ANYPLOT_TOKENS;\n\n// Constants\nconst SCALE_MAX = 100; // the 0–100 rating scale the spec recommends\nconst RINGS = 5; // gridlines at every fifth of the scale: 20, 40, 60, 80, 100\nconst TITLE_H = 48;\nconst SUBTITLE_H = 28;\nconst LEGEND_H = 48;\n\n// Columns: set these to your data's column names\nconst FEATURE = \"Feature\"; // role: category\nconst SCORE = \"Score (0–100)\"; // role: value\nconst MODEL = \"Headphones\"; // role: series\n\n// Data: replace this block with your own records, one object per row\n// Noise-cancelling headphone review: three models scored 0–100 on seven features\nconst data = [\n  [\"Sound Quality\", 92, 78, 65],\n  [\"Noise Cancelling\", 88, 95, 60],\n  [\"Battery Life\", 75, 90, 82],\n  [\"Comfort\", 80, 85, 70],\n  [\"Build Quality\", 85, 70, 60],\n  [\"Value\", 60, 55, 92],\n  [\"Connectivity\", 90, 82, 75],\n].flatMap(([feature, ...scores]) =>\n  [\"AudioMax Pro\", \"SoundWave Elite\", \"EchoBudget\"].map((model, i) => ({\n    [FEATURE]: feature,\n    [MODEL]: model,\n    [SCORE]: scores[i],\n  })),\n);\n\n// Plot: reads only data and the constants above\nconst features = [...new Set(data.map((d) => d[FEATURE]))];\nconst models = [...new Set(data.map((d) => d[MODEL]))];\nconst scores = new Map(data.map((d) => [`${d[MODEL]}\\u0000${d[FEATURE]}`, d[SCORE]]));\nconst series = models.map((model, i) => ({\n  id: `model-${i}`,\n  label: model,\n  data: features.map((f) => scores.get(`${model}\\u0000${f}`) ?? null),\n  fillArea: true,\n}));\n\nconst TITLE = \"radar-multi · javascript · muix · anyplot.ai\";\nconst SUBTITLE = `${models.length} series × ${features.length} axes · ${SCORE}`;\n\nexport default function Chart() {\n  const { width, height } = window.ANYPLOT_SIZE;\n\n  return (\n    <div style={{ width, height, display: \"flex\", flexDirection: \"column\" }}>\n      <div style={{ height: TITLE_H, display: \"flex\", alignItems: \"flex-end\", justifyContent: \"center\", fontSize: 22, fontWeight: 600, color: t.ink }}>\n        {TITLE}\n      </div>\n      <div style={{ height: SUBTITLE_H, display: \"flex\", alignItems: \"center\", justifyContent: \"center\", fontSize: 15, color: t.inkSoft }}>\n        {SUBTITLE}\n      </div>\n      <RadarChart\n        width={width}\n        height={height - TITLE_H - SUBTITLE_H - LEGEND_H}\n        skipAnimation\n        colors={t.palette}\n        margin={{ top: 64, right: 150, bottom: 64, left: 150 }}\n        radar={{ metrics: features, max: SCALE_MAX, labelGap: 22 }}\n        divisions={RINGS}\n        shape=\"sharp\"\n        stripeColor={null}\n        series={series}\n        slotProps={{\n          legend: {\n            direction: \"horizontal\",\n            position: { vertical: \"bottom\", horizontal: \"center\" },\n            sx: { fontSize: 16, color: t.ink },\n          },\n        }}\n        sx={{\n          \"& .MuiRadarChart-gridRadial, & .MuiRadarChart-gridDivider\": { stroke: t.grid, strokeOpacity: 1, strokeWidth: 1.5 },\n          // The chart's own areas carry only the fills; the outlines are drawn in a second pass\n          // above every fill, so no series' fill tints another series' outline\n          \"& .MuiRadarChart-seriesArea\": { fillOpacity: 0.22, strokeWidth: 0 },\n          \"& .MuiRadarChart-seriesMark\": { r: 5.5, stroke: t.pageBg, strokeWidth: 2 },\n          \"& .MuiRadarChart-axisLine\": { stroke: \"none\" },\n          \"& .MuiRadarChart-axisLabel\": {\n            fontSize: 15,\n            fill: t.inkSoft,\n            transform: \"translateX(8px)\",\n            stroke: t.pageBg,\n            strokeWidth: 4,\n            paintOrder: \"stroke\",\n          },\n          // The metric labels carry an inline 12 px caption style, which only an !important rule outranks\n          \"& .MuiChartsSvgLayer-root > text\": { fontSize: \"17px !important\", fontWeight: \"600 !important\" },\n        }}\n      >\n        <RadarSeriesArea className=\"radar-outline\" fill=\"none\" strokeWidth={3} strokeLinejoin=\"round\" />\n        <RadarSeriesMarks />\n        <RadarAxis metric={features[0]} divisions={RINGS} labelOrientation=\"horizontal\" textAnchor=\"start\" />\n      </RadarChart>\n    </div>\n  );\n}\n"}