Basic Area Chart in MUI X Charts (JavaScript)

The same plot in 14 other libraries — JavaScript: Chart.js, D3.js, Apache ECharts, Highcharts; Python: Altair, Bokeh, lets-plot, Matplotlib, Plotly, plotnine, Pygal, Seaborn; R: ggplot2; Julia: Makie.jl. Compare all 15 side by side: Basic Area Chart in Python, R, Julia and JavaScript.

An area chart showing quantitative data over a continuous axis with the area below the line filled. It emphasizes the magnitude of values over time by filling the space between the line and axis, creating visual weight that helps readers understand volume and trends. Particularly effective for showing cumulative totals, resource consumption, or any data where the "amount" is as important as the trend.

Basic Area Chart rendered with MUI X Charts

Renders

JavaScript source (MUI X Charts)

// anyplot.ai
// area-basic: Basic Area Chart
// Library: muix 9.16.0 | JavaScript 22.23.3
// Quality: 86/100 | Updated: 2026-10-23

import { LineChart } from "@mui/x-charts/LineChart";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";

const t = window.ANYPLOT_TOKENS;

// Columns: set these to your data's column names
const X = "Date"; // role: x
const Y = "Daily Visitors"; // role: y

// Data: replace this block with your own records, one object per row
const data = (() => {
  let s = 42 >>> 0;
  const rand = () => {
    s = (Math.imul(1664525, s) + 1013904223) >>> 0;
    return s / 4294967295;
  };

  const dayCount = 60;
  const startDate = new Date(2026, 0, 5);
  return Array.from({ length: dayCount }, (_, i) => {
    const d = new Date(startDate);
    d.setDate(d.getDate() + i);
    const trend = 4100 + i * 34;
    const isWeekend = d.getDay() === 0 || d.getDay() === 6;
    const seasonality = isWeekend ? -950 : 180;
    const noise = (rand() - 0.5) * 600;
    return {
      [X]: d,
      [Y]: Math.max(0, Math.round(trend + seasonality + noise)),
    };
  });
})();

// Plot: reads only data and the constants above
const dates = data.map((d) => d[X]);
const visitors = data.map((d) => d[Y]);
const formatY = (v: number) => `${(v / 1000).toFixed(1)}k`;

const TITLE = "Website Visitors · area-basic · javascript · muix · anyplot.ai";
const TITLE_H = 58;
const AREA_GRADIENT_ID = "areaBasicFillGradient";

export default function Chart() {
  const { width, height } = window.ANYPLOT_SIZE;

  return (
    <Box
      sx={{
        width,
        height,
        bgcolor: t.pageBg,
        display: "flex",
        flexDirection: "column",
      }}
    >
      <Box
        sx={{
          height: TITLE_H,
          display: "flex",
          alignItems: "center",
          px: "40px",
          pt: "10px",
        }}
      >
        <Typography
          sx={{
            color: t.ink,
            fontSize: "25px",
            fontWeight: 600,
            lineHeight: 1,
          }}
        >
          {TITLE}
        </Typography>
      </Box>

      <LineChart
        width={width}
        height={height - TITLE_H}
        skipAnimation
        hideLegend
        grid={{ horizontal: true }}
        xAxis={[
          {
            data: dates,
            scaleType: "time",
            valueFormatter: (v: Date) =>
              v.toLocaleDateString("en-US", { month: "short", day: "numeric" }),
            tickNumber: 8,
            height: 68,
            label: X,
            tickLabelStyle: { fontSize: 14, fill: t.inkSoft },
            labelStyle: { fontSize: 16, fill: t.ink },
          },
        ]}
        yAxis={[
          {
            min: 0,
            width: 84,
            label: Y,
            valueFormatter: formatY,
            tickLabelStyle: { fontSize: 14, fill: t.inkSoft },
            labelStyle: { fontSize: 16, fill: t.ink },
          },
        ]}
        series={[
          {
            id: "visitors",
            data: visitors,
            label: Y,
            color: t.palette[0],
            area: true,
            showMark: false,
            curve: "monotoneX",
            baseline: 0,
          },
        ]}
        margin={{ top: 20, bottom: 20, left: 24, right: 40 }}
        sx={{
          "& .MuiLineChart-area": { fill: `url(#${AREA_GRADIENT_ID})` },
          "& .MuiLineChart-line": { strokeWidth: 3 },
          "& .MuiChartsAxis-line": { stroke: t.inkSoft },
          "& .MuiChartsAxis-tick": { stroke: t.inkSoft },
          "& .MuiChartsGrid-line": { stroke: t.grid, strokeWidth: 1 },
        }}
      >
        <defs>
          <linearGradient id={AREA_GRADIENT_ID} x1="0" y1="0" x2="0" y2="1">
            <stop offset="0%" stopColor={t.palette[0]} stopOpacity={0.55} />
            <stop offset="100%" stopColor={t.palette[0]} stopOpacity={0.04} />
          </linearGradient>
        </defs>
      </LineChart>
    </Box>
  );
}

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/area-basic/muix/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "area-basic",
  "language": "javascript",
  "library": "muix",
  "page": "https://anyplot.ai/area-basic/javascript/muix",
  "hub": "https://anyplot.ai/area-basic",
  "code_json": "https://api.anyplot.ai/specs/area-basic/muix/code",
  "spec_json": "https://api.anyplot.ai/specs/area-basic",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/area-basic/javascript/muix/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/area-basic/javascript/muix/plot-dark.png",
  "interactive_light_html": "https://storage.googleapis.com/anyplot-images/plots/area-basic/javascript/muix/plot-light.html",
  "interactive_dark_html": "https://storage.googleapis.com/anyplot-images/plots/area-basic/javascript/muix/plot-dark.html",
  "quality_score": 86.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of Basic Area Chart on anyplot.ai.

Other implementations