{"spec_id":"bar-basic","library":"muix","language":"javascript","code":"// anyplot.ai\n// bar-basic: Basic Bar Chart\n// Library: muix 9.16.0 | JavaScript 22.23.3\n// Quality: 83/100 | Updated: 2026-10-23\nimport { BarChart } from \"@mui/x-charts/BarChart\";\nimport Box from \"@mui/material/Box\";\nimport Typography from \"@mui/material/Typography\";\n\nconst t = window.ANYPLOT_TOKENS;\n\n// --- Data (in-memory, deterministic) ---------------------------------------\n// Annual coffee consumption per capita — top consuming countries (kg/person/year)\nconst countries = [\"Finland\", \"Norway\", \"Iceland\", \"Denmark\", \"Netherlands\", \"Sweden\", \"Switzerland\"];\nconst kgPerCapita = [12.0, 9.9, 9.0, 8.7, 8.4, 8.2, 7.9];\n\nconst dataset = countries.map((country, i) => ({ country, kgPerCapita: kgPerCapita[i] }));\n\nconst TITLE_HEIGHT = 60;\n\n// --- Chart (default-exported component — the harness mounts it) -----------\nexport default function Chart() {\n  const { width, height } = window.ANYPLOT_SIZE;\n\n  return (\n    <Box sx={{ width, height, display: \"flex\", flexDirection: \"column\", paddingTop: \"20px\" }}>\n      <Typography\n        sx={{ color: t.ink, fontSize: 22, fontWeight: 500, textAlign: \"center\", lineHeight: 1.2 }}\n      >\n        bar-basic · javascript · muix · anyplot.ai\n      </Typography>\n      <BarChart\n        width={width}\n        height={height - TITLE_HEIGHT}\n        dataset={dataset}\n        colors={[t.palette[0]]}\n        skipAnimation\n        hideLegend\n        xAxis={[\n          {\n            scaleType: \"band\",\n            dataKey: \"country\",\n            label: \"Country\",\n            height: 72,\n            tickLabelStyle: { fontSize: 16 },\n            labelStyle: { fontSize: 18 },\n          },\n        ]}\n        yAxis={[\n          {\n            label: \"Coffee Consumption (kg per capita/year)\",\n            width: 84,\n            // headroom above the tallest bar so its outside value label is not clipped\n            domainLimit: (min, max) => ({ min, max: max * 1.08 }),\n            tickLabelStyle: { fontSize: 16 },\n            labelStyle: { fontSize: 18 },\n          },\n        ]}\n        series={[\n          {\n            dataKey: \"kgPerCapita\",\n            label: \"Coffee consumption\",\n            barLabel: (item) => item.value?.toFixed(1),\n            barLabelPlacement: \"outside\",\n          },\n        ]}\n        grid={{ horizontal: true }}\n        margin={{ top: 32, right: 32, bottom: 8, left: 16 }}\n        sx={{\n          \"& .MuiBarChart-label\": { fontSize: \"16px\", fontWeight: 500, fill: t.ink },\n        }}\n      />\n    </Box>\n  );\n}\n"}