{"spec_id":"diagnostic-regression-panel","library":"muix","language":"javascript","code":"// anyplot.ai\n// diagnostic-regression-panel: Regression Diagnostic Panel (Four-Plot Display)\n// Library: muix 9.16.0 | JavaScript 22.23.3\n// Quality: 87/100 | Updated: 2026-10-24\n//# anyplot-orientation: square\n\nimport * as React from \"react\";\nimport { ChartsContainer } from \"@mui/x-charts/ChartsContainer\";\nimport { ScatterPlot } from \"@mui/x-charts/ScatterChart\";\nimport { LinePlot } from \"@mui/x-charts/LineChart\";\nimport { ChartsXAxis } from \"@mui/x-charts/ChartsXAxis\";\nimport { ChartsYAxis } from \"@mui/x-charts/ChartsYAxis\";\nimport { ChartsGrid } from \"@mui/x-charts/ChartsGrid\";\nimport { ChartsReferenceLine } from \"@mui/x-charts/ChartsReferenceLine\";\nimport { useDrawingArea, useXScale, useYScale } from \"@mui/x-charts/hooks\";\n\nconst t = window.ANYPLOT_TOKENS;\nconst FONT = \"system-ui, -apple-system, 'Segoe UI', sans-serif\";\n\n// Constants\nconst LOWESS_GRID_COUNT = 36;\nconst LOWESS_SPAN = 0.5;\nconst TOP_INFLUENTIAL_COUNT = 3;\nconst COOK_LEVELS = [0.5, 1.0];\nconst COOK_GRID_COUNT = 80;\nconst AXIS_PAD_RATIO = 0.08;\nconst MARKER_SIZE = 6.5;\n\nconst acklamA = [-3.969683028665376e1, 2.209460984245205e2, -2.759285104469687e2, 1.38357751867269e2, -3.066479806614716e1, 2.506628277459239];\nconst acklamB = [-5.447609879822406e1, 1.615858368580409e2, -1.556989798598866e2, 6.680131188771972e1, -1.328068155288572e1];\nconst acklamC = [-7.784894002430293e-3, -3.223964580411365e-1, -2.400758277161838, -2.549732539343734, 4.374664141464968, 2.938163982698783];\nconst acklamD = [7.784695709041462e-3, 3.224671290700398e-1, 2.445134137142996, 3.754408661907416];\n\n// Columns: set these to your data's column names\nconst OBS_ID = \"Observation\"; // role: extra\nconst FITTED = \"Fitted values\"; // role: fitted\nconst RESIDUALS = \"Residuals\"; // role: residuals\nconst STD_RESIDUALS = \"Standardized residuals\"; // role: std_residuals\nconst LEVERAGE = \"Leverage\"; // role: leverage\nconst COOKS_D = \"Cook's distance\"; // role: cooks_d\n\n// Data: replace this block with your own records\nconst data = (() => {\n  const sampleSize = 56;\n  const modelParams = 2;\n  let seed = 20260905;\n  const doses: number[] = [];\n  for (let i = 0; i < sampleSize; i++) {\n    seed = (seed * 1103515245 + 12345) & 0x7fffffff;\n    const u = seed / 0x7fffffff;\n    doses.push(4 + 92 * (i / (sampleSize - 1)) + (u - 0.5) * 3);\n  }\n  doses.sort((a, b) => a - b);\n\n  const responses = doses.map((d) => {\n    seed = (seed * 1103515245 + 12345) & 0x7fffffff;\n    const u1 = Math.max(seed / 0x7fffffff, 1e-9);\n    seed = (seed * 1103515245 + 12345) & 0x7fffffff;\n    const u2 = seed / 0x7fffffff;\n    const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);\n    const trend = 18 + 2.9 * d - 0.012 * d * d;\n    const noiseScale = 2.5 + 0.11 * d;\n    return trend + z * noiseScale;\n  });\n\n  responses[10] += 34;\n  doses[sampleSize - 2] = 118;\n  responses[sampleSize - 2] -= 46;\n\n  const doseMean = doses.reduce((a, b) => a + b, 0) / sampleSize;\n  const responseMean = responses.reduce((a, b) => a + b, 0) / sampleSize;\n  const sxx = doses.reduce((acc, d) => acc + (d - doseMean) ** 2, 0);\n  const sxy = doses.reduce((acc, d, i) => acc + (d - doseMean) * (responses[i] - responseMean), 0);\n  const olsSlope = sxy / sxx;\n  const olsIntercept = responseMean - olsSlope * doseMean;\n\n  const rawFitted = doses.map((d) => olsIntercept + olsSlope * d);\n  const rawResiduals = responses.map((y, i) => y - rawFitted[i]);\n  const rss = rawResiduals.reduce((acc, r) => acc + r * r, 0);\n  const sigmaHat = Math.sqrt(rss / (sampleSize - modelParams));\n\n  return doses.map((d, i) => {\n    const h = 1 / sampleSize + (d - doseMean) ** 2 / sxx;\n    const stdRes = rawResiduals[i] / (sigmaHat * Math.sqrt(1 - h));\n    const cooks = (stdRes * stdRes * h) / (modelParams * (1 - h));\n    return {\n      [OBS_ID]: i + 1,\n      [FITTED]: Number(rawFitted[i].toFixed(4)),\n      [RESIDUALS]: Number(rawResiduals[i].toFixed(4)),\n      [STD_RESIDUALS]: Number(stdRes.toFixed(4)),\n      [LEVERAGE]: Number(h.toFixed(5)),\n      [COOKS_D]: Number(cooks.toFixed(5)),\n    };\n  });\n})();\n\n// Plot: reads only data and the constants above\nconst n = data.length;\nconst fitted = data.map((r) => Number(r[FITTED]));\nconst residuals = data.map((r) => Number(r[RESIDUALS]));\nconst stdResiduals = data.map((r) => Number(r[STD_RESIDUALS]));\nconst leverage = data.map((r) => Number(r[LEVERAGE]));\nconst cooksD = data.map((r) => Number(r[COOKS_D]));\nconst scaleLocation = stdResiduals.map((r) => Math.sqrt(Math.abs(r)));\nconst p = Math.round(leverage.reduce((a, b) => a + b, 0));\n\nconst influentialIndices = cooksD\n  .map((cooks, idx) => ({ idx, cooks }))\n  .sort((a, b) => b.cooks - a.cooks)\n  .slice(0, TOP_INFLUENTIAL_COUNT)\n  .map((item) => item.idx);\n\nconst qqRanked = stdResiduals.map((v, i) => ({ v, origIdx: i })).sort((a, b) => a.v - b.v);\nconst theoreticalQuantiles = new Array<number>(n);\nconst qqTheoretical = new Array<number>(n);\n\nqqRanked.forEach(({ origIdx }, rank) => {\n  const pr = (rank + 0.5) / n;\n  const low = 0.02425;\n  let z = 0;\n  if (pr < low) {\n    const q = Math.sqrt(-2 * Math.log(pr));\n    z =\n      (((((acklamC[0] * q + acklamC[1]) * q + acklamC[2]) * q + acklamC[3]) * q + acklamC[4]) * q + acklamC[5]) /\n      ((((acklamD[0] * q + acklamD[1]) * q + acklamD[2]) * q + acklamD[3]) * q + 1);\n  } else if (pr > 1 - low) {\n    const q = Math.sqrt(-2 * Math.log(1 - pr));\n    z =\n      -(((((acklamC[0] * q + acklamC[1]) * q + acklamC[2]) * q + acklamC[3]) * q + acklamC[4]) * q + acklamC[5]) /\n      ((((acklamD[0] * q + acklamD[1]) * q + acklamD[2]) * q + acklamD[3]) * q + 1);\n  } else {\n    const q = pr - 0.5;\n    const r = q * q;\n    z =\n      ((((((acklamA[0] * r + acklamA[1]) * r + acklamA[2]) * r + acklamA[3]) * r + acklamA[4]) * r + acklamA[5]) * q) /\n      (((((acklamB[0] * r + acklamB[1]) * r + acklamB[2]) * r + acklamB[3]) * r + acklamB[4]) * r + 1);\n  }\n  theoreticalQuantiles[rank] = z;\n  qqTheoretical[origIdx] = z;\n});\n\nconst fittedMin = Math.min(...fitted);\nconst fittedMax = Math.max(...fitted);\nconst fittedSpan = fittedMax - fittedMin;\nconst fittedAxisMin = fittedMin - fittedSpan * AXIS_PAD_RATIO;\nconst fittedAxisMax = fittedMax + fittedSpan * AXIS_PAD_RATIO;\n\nconst fittedGrid = Array.from(\n  { length: LOWESS_GRID_COUNT },\n  (_, i) => fittedMin + (fittedSpan * i) / (LOWESS_GRID_COUNT - 1),\n);\n\nconst lowessK = Math.max(3, Math.round(LOWESS_SPAN * n));\nconst residLowess: number[] = [];\nconst scaleLocLowess: number[] = [];\n\nfor (const x0 of fittedGrid) {\n  const dists = fitted.map((xi) => Math.abs(xi - x0));\n  const bandwidth = [...dists].sort((a, b) => a - b)[Math.min(lowessK - 1, n - 1)];\n  let sw = 0;\n  let swx = 0;\n  let swxx = 0;\n  let swyRes = 0;\n  let swxyRes = 0;\n  let swySL = 0;\n  let swxySL = 0;\n  for (let i = 0; i < n; i++) {\n    const u = dists[i] / bandwidth;\n    if (u >= 1) continue;\n    const w = (1 - u ** 3) ** 3;\n    sw += w;\n    swx += w * fitted[i];\n    swxx += w * fitted[i] * fitted[i];\n    swyRes += w * residuals[i];\n    swxyRes += w * fitted[i] * residuals[i];\n    swySL += w * scaleLocation[i];\n    swxySL += w * fitted[i] * scaleLocation[i];\n  }\n  const denom = sw * swxx - swx * swx;\n  const b1Res = (sw * swxyRes - swx * swyRes) / denom;\n  const b0Res = (swyRes - b1Res * swx) / sw;\n  residLowess.push(b0Res + b1Res * x0);\n\n  const b1SL = (sw * swxySL - swx * swySL) / denom;\n  const b0SL = (swySL - b1SL * swx) / sw;\n  scaleLocLowess.push(b0SL + b1SL * x0);\n}\n\nconst residMin = Math.min(...residuals, ...residLowess);\nconst residMax = Math.max(...residuals, ...residLowess);\nconst residSpan = residMax - residMin;\nconst residAxisMin = residMin - residSpan * AXIS_PAD_RATIO;\nconst residAxisMax = residMax + residSpan * AXIS_PAD_RATIO;\n\nconst qqDataMin = Math.min(...theoreticalQuantiles);\nconst qqDataMax = Math.max(...theoreticalQuantiles);\nconst qqXSpan = qqDataMax - qqDataMin;\nconst qqXMin = qqDataMin - qqXSpan * AXIS_PAD_RATIO;\nconst qqXMax = qqDataMax + qqXSpan * AXIS_PAD_RATIO;\n\nconst stdResMin = Math.min(...stdResiduals);\nconst stdResMax = Math.max(...stdResiduals);\nconst stdResSpan = stdResMax - stdResMin;\nconst stdResAxisMin = stdResMin - stdResSpan * AXIS_PAD_RATIO;\nconst stdResAxisMax = stdResMax + stdResSpan * AXIS_PAD_RATIO;\nconst p4SymLim = Math.max(Math.abs(stdResAxisMin), Math.abs(stdResAxisMax));\n\nconst slMin = Math.min(...scaleLocation, ...scaleLocLowess);\nconst slMax = Math.max(...scaleLocation, ...scaleLocLowess);\nconst slSpan = slMax - slMin;\nconst slAxisMin = Math.max(0, slMin - slSpan * AXIS_PAD_RATIO);\nconst slAxisMax = slMax + slSpan * AXIS_PAD_RATIO;\n\nconst levMin = Math.min(...leverage);\nconst levMax = Math.max(...leverage);\nconst levSpan = levMax - levMin;\nconst levAxisMin = Math.max(0, levMin - levSpan * AXIS_PAD_RATIO);\nconst levAxisMax = levMax + levSpan * (AXIS_PAD_RATIO * 1.6);\n\nconst cookHStart = Math.max(levAxisMin, levSpan * 0.02);\nconst cookGrid = Array.from(\n  { length: COOK_GRID_COUNT },\n  (_, i) => cookHStart + ((levAxisMax - cookHStart) * i) / (COOK_GRID_COUNT - 1),\n);\n\nconst POINT_COLOR = t.palette[0];\nconst SMOOTH_COLOR = t.palette[2];\nconst CONTOUR_COLOR = t.inkSoft;\nconst REF_LINE_STYLE = { stroke: t.inkSoft, strokeWidth: 1.5, strokeDasharray: \"6 5\", opacity: 0.75 };\nconst AXIS_LABEL_STYLE = { fill: t.ink, fontSize: 15, fontWeight: 600, fontFamily: FONT };\nconst TICK_LABEL_STYLE = { fill: t.inkSoft, fontSize: 14, fontFamily: FONT };\nconst CHART_MARGIN = { top: 14, right: 26, bottom: 54, left: 74 };\n\nconst LABEL_FONT_SIZE = 14;\nconst LABEL_CHAR_W = 8.6;\nconst LABEL_STYLE = { fontSize: LABEL_FONT_SIZE, fontWeight: 600, fontFamily: FONT };\n\ntype Anchor = \"start\" | \"middle\" | \"end\";\n\n// Candidate label positions around a marker (dx, dy = baseline offset), in order of preference\nconst LABEL_CANDIDATES: { dx: number; dy: number; anchor: Anchor }[] = [\n  { dx: 9, dy: -6, anchor: \"start\" },\n  { dx: -9, dy: -6, anchor: \"end\" },\n  { dx: 9, dy: 16, anchor: \"start\" },\n  { dx: -9, dy: 16, anchor: \"end\" },\n  { dx: 11, dy: 5, anchor: \"start\" },\n  { dx: -11, dy: 5, anchor: \"end\" },\n  { dx: 0, dy: -11, anchor: \"middle\" },\n  { dx: 0, dy: 22, anchor: \"middle\" },\n];\n\ninterface Box {\n  x0: number;\n  y0: number;\n  x1: number;\n  y1: number;\n}\n\nfunction labelBox(tx: number, ty: number, text: string, anchor: Anchor): Box {\n  const w = text.length * LABEL_CHAR_W;\n  const x0 = anchor === \"start\" ? tx : anchor === \"end\" ? tx - w : tx - w / 2;\n  return { x0, y0: ty - LABEL_FONT_SIZE * 0.78, x1: x0 + w, y1: ty + LABEL_FONT_SIZE * 0.2 };\n}\n\nfunction boxCircleGap(b: Box, cx: number, cy: number) {\n  const nx = Math.max(b.x0, Math.min(cx, b.x1));\n  const ny = Math.max(b.y0, Math.min(cy, b.y1));\n  return Math.hypot(cx - nx, cy - ny);\n}\n\ninterface PanelOverlayProps {\n  xs: number[];\n  ys: number[];\n  qqLine?: boolean;\n  cookContours?: boolean;\n  clipId: string;\n}\n\nfunction PanelOverlay({ xs, ys, qqLine, cookContours, clipId }: PanelOverlayProps) {\n  const xScale = useXScale() as (v: number) => number;\n  const yScale = useYScale() as (v: number) => number;\n  const { left, top, width, height } = useDrawingArea();\n\n  const markers = xs.map((x, i) => ({ px: xScale(x), py: yScale(ys[i]) }));\n  const labelled = influentialIndices.map((i) => ({ i, ...markers[i], text: String(data[i][OBS_ID]) }));\n  const markerClearance = MARKER_SIZE + 2;\n\n  // Pick, per label, the candidate that stays clear of other markers and placed labels\n  // and keeps the label nearer to its own marker than to any other labelled one\n  const placed: (Box & { tx: number; ty: number; anchor: Anchor; text: string })[] = [];\n  labelled.forEach(({ i, px, py, text }) => {\n    let best = { score: Infinity, tx: px, ty: py, anchor: \"start\" as Anchor, box: labelBox(px, py, text, \"start\") };\n    LABEL_CANDIDATES.forEach(({ dx, dy, anchor }, order) => {\n      const tx = px + dx;\n      const ty = py + dy;\n      const box = labelBox(tx, ty, text, anchor);\n      const cx = (box.x0 + box.x1) / 2;\n      const cy = (box.y0 + box.y1) / 2;\n      let score = order * 0.5;\n      if (box.x0 < left || box.x1 > left + width || box.y0 < top || box.y1 > top + height) score += 200;\n      markers.forEach((m, j) => {\n        if (j !== i && boxCircleGap(box, m.px, m.py) < markerClearance) score += 8;\n      });\n      labelled.forEach((o) => {\n        if (o.i === i) return;\n        if (boxCircleGap(box, o.px, o.py) < markerClearance) score += 100;\n        if (Math.hypot(cx - o.px, cy - o.py) < 1.5 * Math.hypot(cx - px, cy - py)) score += 60;\n      });\n      placed.forEach((b) => {\n        if (box.x0 < b.x1 && box.x1 > b.x0 && box.y0 < b.y1 && box.y1 > b.y0) score += 150;\n      });\n      if (score < best.score) best = { score, tx, ty, anchor, box };\n    });\n    placed.push({ ...best.box, tx: best.tx, ty: best.ty, anchor: best.anchor, text });\n  });\n\n  return (\n    <g>\n      <defs>\n        <clipPath id={clipId}>\n          <rect x={left} y={top} width={width} height={height} />\n        </clipPath>\n      </defs>\n\n      {qqLine && (\n        <g clipPath={`url(#${clipId})`}>\n          <line\n            x1={xScale(qqXMin)}\n            y1={yScale(qqXMin)}\n            x2={xScale(qqXMax)}\n            y2={yScale(qqXMax)}\n            stroke={t.inkSoft}\n            strokeWidth={1.6}\n            strokeDasharray=\"6 5\"\n            opacity={0.8}\n          />\n        </g>\n      )}\n\n      {cookContours && (\n        <g clipPath={`url(#${clipId})`}>\n          {COOK_LEVELS.flatMap((level) =>\n            [1, -1].map((sign) => {\n              const cookAt = (h: number) => sign * Math.sqrt((level * p * (1 - h)) / h);\n              const path = cookGrid\n                .map((h, idx) => `${idx === 0 ? \"M\" : \"L\"}${xScale(h).toFixed(1)},${yScale(cookAt(h)).toFixed(1)}`)\n                .join(\" \");\n              const labelH = levAxisMax - levSpan * 0.04;\n              const ly = yScale(cookAt(labelH)) + (sign > 0 ? -6 : 15);\n              return (\n                <g key={`${level}-${sign}`}>\n                  <path d={path} fill=\"none\" stroke={CONTOUR_COLOR} strokeWidth={1.7} strokeDasharray=\"5 4\" />\n                  {ly > top + 14 && ly < top + height - 6 && (\n                    <text\n                      x={xScale(labelH) - 6}\n                      y={ly}\n                      textAnchor=\"end\"\n                      fill={t.ink}\n                      stroke={t.pageBg}\n                      strokeWidth={3.5}\n                      paintOrder=\"stroke\"\n                      style={LABEL_STYLE}\n                    >\n                      {level.toFixed(1)}\n                    </text>\n                  )}\n                </g>\n              );\n            }),\n          )}\n        </g>\n      )}\n\n      {placed.map(({ tx, ty, anchor, text }) => (\n        <text\n          key={text}\n          x={tx}\n          y={ty}\n          textAnchor={anchor}\n          fill={t.ink}\n          stroke={t.pageBg}\n          strokeWidth={3.5}\n          paintOrder=\"stroke\"\n          style={LABEL_STYLE}\n        >\n          {text}\n        </text>\n      ))}\n    </g>\n  );\n}\n\nconst panels = [\n  {\n    key: \"p1\",\n    title: `1. ${RESIDUALS} vs ${FITTED}`,\n    x: { min: fittedAxisMin, max: fittedAxisMax, label: FITTED, data: fittedGrid },\n    y: { min: residAxisMin, max: residAxisMax, label: RESIDUALS },\n    xs: fitted,\n    ys: residuals,\n    smooth: residLowess,\n    zeroLine: true,\n  },\n  {\n    key: \"p2\",\n    title: \"2. Normal Q-Q\",\n    x: { min: qqXMin, max: qqXMax, label: \"Theoretical quantiles\" },\n    y: { min: stdResAxisMin, max: stdResAxisMax, label: STD_RESIDUALS },\n    xs: qqTheoretical,\n    ys: stdResiduals,\n    qqLine: true,\n  },\n  {\n    key: \"p3\",\n    title: \"3. Scale-Location\",\n    x: { min: fittedAxisMin, max: fittedAxisMax, label: FITTED, data: fittedGrid },\n    y: { min: slAxisMin, max: slAxisMax, label: `√|${STD_RESIDUALS}|` },\n    xs: fitted,\n    ys: scaleLocation,\n    smooth: scaleLocLowess,\n  },\n  {\n    key: \"p4\",\n    title: `4. ${RESIDUALS} vs ${LEVERAGE}`,\n    x: { min: levAxisMin, max: levAxisMax, label: LEVERAGE },\n    y: { min: -p4SymLim, max: p4SymLim, label: STD_RESIDUALS },\n    xs: leverage,\n    ys: stdResiduals,\n    zeroLine: true,\n    cookContours: true,\n  },\n];\n\nexport default function Chart() {\n  const W = window.ANYPLOT_SIZE.width;\n  const H = window.ANYPLOT_SIZE.height;\n  const padX = 20;\n  const padBottom = 14;\n  const headerH = 74;\n  const subTitleH = 30;\n  const gap = 16;\n  const rowH = Math.floor((H - headerH - padBottom - gap) / 2);\n  const colW = Math.floor((W - padX * 2 - gap) / 2);\n  const chartH = rowH - subTitleH;\n  const chartW = colW;\n\n  return (\n    <div\n      style={{\n        width: W,\n        height: H,\n        backgroundColor: t.pageBg,\n        display: \"flex\",\n        flexDirection: \"column\",\n        padding: `0 ${padX}px ${padBottom}px ${padX}px`,\n        boxSizing: \"border-box\",\n        fontFamily: FONT,\n      }}\n    >\n      <div\n        style={{\n          height: headerH,\n          display: \"flex\",\n          flexDirection: \"column\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          gap: 4,\n        }}\n      >\n        <div style={{ fontSize: 22, fontWeight: 700, color: t.ink }}>\n          diagnostic-regression-panel · javascript · muix · anyplot.ai\n        </div>\n        <div\n          style={{\n            display: \"flex\",\n            alignItems: \"center\",\n            gap: 20,\n            fontSize: 14,\n            color: t.inkSoft,\n          }}\n        >\n          <span>OLS diagnostics (n = {n}, p = {p})</span>\n          <span style={{ display: \"inline-flex\", alignItems: \"center\", gap: 6 }}>\n            <span\n              style={{\n                width: 10,\n                height: 10,\n                borderRadius: \"50%\",\n                backgroundColor: POINT_COLOR,\n                display: \"inline-block\",\n              }}\n            />\n            {`${OBS_ID}s (top ${TOP_INFLUENTIAL_COUNT} by ${COOKS_D} labeled)`}\n          </span>\n          <span style={{ display: \"inline-flex\", alignItems: \"center\", gap: 6 }}>\n            <span\n              style={{\n                width: 18,\n                height: 2.5,\n                backgroundColor: SMOOTH_COLOR,\n                display: \"inline-block\",\n              }}\n            />\n            LOWESS smoother\n          </span>\n          <span style={{ display: \"inline-flex\", alignItems: \"center\", gap: 6 }}>\n            <span\n              style={{\n                width: 18,\n                borderTop: `2px dashed ${CONTOUR_COLOR}`,\n                display: \"inline-block\",\n              }}\n            />\n            {`${COOKS_D} (${COOK_LEVELS.map((l) => l.toFixed(1)).join(\", \")})`}\n          </span>\n        </div>\n      </div>\n\n      <div\n        style={{\n          display: \"grid\",\n          gridTemplateColumns: `${colW}px ${colW}px`,\n          gridTemplateRows: `${rowH}px ${rowH}px`,\n          columnGap: gap,\n          rowGap: gap,\n        }}\n      >\n        {panels.map((panel) => (\n          <div key={panel.key} style={{ width: chartW, height: rowH }}>\n            <div style={{ height: subTitleH, display: \"flex\", alignItems: \"flex-end\", paddingBottom: 4, paddingLeft: 74 }}>\n              <span style={{ fontSize: 16, fontWeight: 600, color: t.ink }}>{panel.title}</span>\n            </div>\n            <ChartsContainer\n              width={chartW}\n              height={chartH}\n              margin={CHART_MARGIN}\n              skipAnimation\n              xAxis={[\n                {\n                  id: `${panel.key}x`,\n                  scaleType: \"linear\",\n                  ...panel.x,\n                  height: 54,\n                  labelStyle: AXIS_LABEL_STYLE,\n                  tickLabelStyle: TICK_LABEL_STYLE,\n                },\n              ]}\n              yAxis={[\n                {\n                  id: `${panel.key}y`,\n                  scaleType: \"linear\",\n                  ...panel.y,\n                  width: 74,\n                  labelStyle: AXIS_LABEL_STYLE,\n                  tickLabelStyle: TICK_LABEL_STYLE,\n                },\n              ]}\n              series={[\n                {\n                  id: `${panel.key}-points`,\n                  type: \"scatter\",\n                  color: POINT_COLOR,\n                  markerSize: MARKER_SIZE,\n                  data: panel.xs.map((x, i) => ({ x, y: panel.ys[i], id: i })),\n                },\n                ...(panel.smooth\n                  ? [\n                      {\n                        id: `${panel.key}-smooth`,\n                        type: \"line\" as const,\n                        color: SMOOTH_COLOR,\n                        data: panel.smooth,\n                        showMark: false,\n                        curve: \"natural\" as const,\n                      },\n                    ]\n                  : []),\n              ]}\n            >\n              <ChartsGrid horizontal vertical />\n              {panel.zeroLine && <ChartsReferenceLine y={0} lineStyle={REF_LINE_STYLE} />}\n              <ScatterPlot />\n              {panel.smooth && <LinePlot />}\n              <ChartsXAxis axisId={`${panel.key}x`} />\n              <ChartsYAxis axisId={`${panel.key}y`} />\n              <PanelOverlay\n                xs={panel.xs}\n                ys={panel.ys}\n                qqLine={panel.qqLine}\n                cookContours={panel.cookContours}\n                clipId={`clip-${panel.key}`}\n              />\n            </ChartsContainer>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"}