{"spec_id":"area-basic","library":"muix","language":"javascript","code":"// anyplot.ai\n// area-basic: Basic Area Chart\n// Library: muix 9.16.0 | JavaScript 22.23.3\n// Quality: 86/100 | Updated: 2026-10-23\n\nimport { LineChart } from \"@mui/x-charts/LineChart\";\nimport Box from \"@mui/material/Box\";\nimport Typography from \"@mui/material/Typography\";\n\nconst t = window.ANYPLOT_TOKENS;\n\n// Columns: set these to your data's column names\nconst X = \"Date\"; // role: x\nconst Y = \"Daily Visitors\"; // role: y\n\n// Data: replace this block with your own records, one object per row\nconst data = (() => {\n  let s = 42 >>> 0;\n  const rand = () => {\n    s = (Math.imul(1664525, s) + 1013904223) >>> 0;\n    return s / 4294967295;\n  };\n\n  const dayCount = 60;\n  const startDate = new Date(2026, 0, 5);\n  return Array.from({ length: dayCount }, (_, i) => {\n    const d = new Date(startDate);\n    d.setDate(d.getDate() + i);\n    const trend = 4100 + i * 34;\n    const isWeekend = d.getDay() === 0 || d.getDay() === 6;\n    const seasonality = isWeekend ? -950 : 180;\n    const noise = (rand() - 0.5) * 600;\n    return {\n      [X]: d,\n      [Y]: Math.max(0, Math.round(trend + seasonality + noise)),\n    };\n  });\n})();\n\n// Plot: reads only data and the constants above\nconst dates = data.map((d) => d[X]);\nconst visitors = data.map((d) => d[Y]);\nconst formatY = (v: number) => `${(v / 1000).toFixed(1)}k`;\n\nconst TITLE = \"Website Visitors · area-basic · javascript · muix · anyplot.ai\";\nconst TITLE_H = 58;\nconst AREA_GRADIENT_ID = \"areaBasicFillGradient\";\n\nexport default function Chart() {\n  const { width, height } = window.ANYPLOT_SIZE;\n\n  return (\n    <Box\n      sx={{\n        width,\n        height,\n        bgcolor: t.pageBg,\n        display: \"flex\",\n        flexDirection: \"column\",\n      }}\n    >\n      <Box\n        sx={{\n          height: TITLE_H,\n          display: \"flex\",\n          alignItems: \"center\",\n          px: \"40px\",\n          pt: \"10px\",\n        }}\n      >\n        <Typography\n          sx={{\n            color: t.ink,\n            fontSize: \"25px\",\n            fontWeight: 600,\n            lineHeight: 1,\n          }}\n        >\n          {TITLE}\n        </Typography>\n      </Box>\n\n      <LineChart\n        width={width}\n        height={height - TITLE_H}\n        skipAnimation\n        hideLegend\n        grid={{ horizontal: true }}\n        xAxis={[\n          {\n            data: dates,\n            scaleType: \"time\",\n            valueFormatter: (v: Date) =>\n              v.toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\" }),\n            tickNumber: 8,\n            height: 68,\n            label: X,\n            tickLabelStyle: { fontSize: 14, fill: t.inkSoft },\n            labelStyle: { fontSize: 16, fill: t.ink },\n          },\n        ]}\n        yAxis={[\n          {\n            min: 0,\n            width: 84,\n            label: Y,\n            valueFormatter: formatY,\n            tickLabelStyle: { fontSize: 14, fill: t.inkSoft },\n            labelStyle: { fontSize: 16, fill: t.ink },\n          },\n        ]}\n        series={[\n          {\n            id: \"visitors\",\n            data: visitors,\n            label: Y,\n            color: t.palette[0],\n            area: true,\n            showMark: false,\n            curve: \"monotoneX\",\n            baseline: 0,\n          },\n        ]}\n        margin={{ top: 20, bottom: 20, left: 24, right: 40 }}\n        sx={{\n          \"& .MuiLineChart-area\": { fill: `url(#${AREA_GRADIENT_ID})` },\n          \"& .MuiLineChart-line\": { strokeWidth: 3 },\n          \"& .MuiChartsAxis-line\": { stroke: t.inkSoft },\n          \"& .MuiChartsAxis-tick\": { stroke: t.inkSoft },\n          \"& .MuiChartsGrid-line\": { stroke: t.grid, strokeWidth: 1 },\n        }}\n      >\n        <defs>\n          <linearGradient id={AREA_GRADIENT_ID} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n            <stop offset=\"0%\" stopColor={t.palette[0]} stopOpacity={0.55} />\n            <stop offset=\"100%\" stopColor={t.palette[0]} stopOpacity={0.04} />\n          </linearGradient>\n        </defs>\n      </LineChart>\n    </Box>\n  );\n}\n"}