{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-bullet-set",
  "type": "registry:component",
  "title": "Bullet Chart Scorecard",
  "description": "A stack of bullet charts for quarterly goals: qualitative bands, the actual bar, a target tick and last quarter's marker, with status pills that update. An Actual and Projected switch reveals hatched end-of-quarter forecasts, and lower-is-better metrics invert the scale.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "charts",
    "chart",
    "bullet",
    "kpi",
    "scorecard",
    "targets",
    "forecast"
  ],
  "docs": "https://hyperblur.dev/effects/chart-bullet-set",
  "files": [
    {
      "path": "registry/hyperblur/chart-bullet-set.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/chart-bullet-set.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BulletMetric {\n  label: string;\n  hint?: string;\n  value: number;\n  target: number;\n  previous?: number;\n  projected?: number;\n  ranges: [number, number, number];\n  inverse?: boolean;\n  format?: \"currency\" | \"percent\" | \"number\" | \"hours\";\n}\n\nexport interface ChartBulletSetProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\" | \"title\"> {\n  metrics?: BulletMetric[];\n  title?: string;\n  period?: string;\n  accent?: string;\n  mode?: \"actual\" | \"projected\";\n  defaultMode?: \"actual\" | \"projected\";\n  onModeChange?: (mode: \"actual\" | \"projected\") => void;\n  showToggle?: boolean;\n}\n\nconst defaultMetrics: BulletMetric[] = [\n  { label: \"Revenue\", hint: \"Net new, USD\", value: 1840000, target: 2200000, previous: 1620000, projected: 2310000, ranges: [1500000, 2000000, 2600000], format: \"currency\" },\n  { label: \"New customers\", hint: \"Paid accounts\", value: 412, target: 500, previous: 368, projected: 538, ranges: [350, 450, 600], format: \"number\" },\n  { label: \"Net retention\", hint: \"Trailing 12 months\", value: 108, target: 115, previous: 104, projected: 111, ranges: [100, 110, 125], format: \"percent\" },\n  { label: \"Gross margin\", hint: \"Blended\", value: 71, target: 75, previous: 69, projected: 72, ranges: [60, 70, 85], format: \"percent\" },\n  { label: \"First response\", hint: \"Median, lower is better\", value: 3.2, target: 2, previous: 4.1, projected: 2.6, ranges: [6, 4, 2.5], inverse: true, format: \"hours\" },\n];\n\nfunction fmtValue(v: number, f: BulletMetric[\"format\"]) {\n  if (f === \"currency\") {\n    if (Math.abs(v) >= 1e6) return `$${(v / 1e6).toFixed(2)}M`;\n    if (Math.abs(v) >= 1e3) return `$${(v / 1e3).toFixed(0)}k`;\n    return `$${v.toFixed(0)}`;\n  }\n  if (f === \"percent\") return `${v.toFixed(v % 1 ? 1 : 0)}%`;\n  if (f === \"hours\") return `${v.toFixed(1)}h`;\n  return v.toLocaleString(\"en-US\");\n}\n\nfunction statusOf(m: BulletMetric, v: number) {\n  const ratio = m.inverse ? m.target / Math.max(0.0001, v) : v / Math.max(0.0001, m.target);\n  if (ratio >= 1) return { key: \"hit\", label: \"Target hit\" };\n  if (ratio >= 0.9) return { key: \"track\", label: \"On track\" };\n  if (ratio >= 0.8) return { key: \"risk\", label: \"At risk\" };\n  return { key: \"behind\", label: \"Behind\" };\n}\n\nconst css = `\n.hb-wi4 {\n  --hb-wi4-a: #2f7bff;\n  container-type: inline-size;\n  position: relative;\n  width: 100%;\n  box-sizing: border-box;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 12px;\n}\n.hb-wi4 *, .hb-wi4 *::before, .hb-wi4 *::after { box-sizing: border-box; }\n.hb-wi4-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }\n.hb-wi4-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }\n.hb-wi4-title b { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }\n.hb-wi4-title span { font-size: 11px; color: #8f8f8f; }\n.hb-wi4-seg {\n  position: relative;\n  display: inline-grid;\n  grid-template-columns: 1fr 1fr;\n  padding: 2px;\n  border-radius: 8px;\n  background: #111;\n  border: 1px solid #262626;\n  flex: none;\n}\n.hb-wi4-seg::before {\n  content: \"\";\n  position: absolute;\n  top: 2px;\n  bottom: 2px;\n  left: 2px;\n  width: calc(50% - 2px);\n  border-radius: 6px;\n  background: linear-gradient(#262626, #1d1d1d);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.4);\n  transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);\n}\n.hb-wi4-seg[data-mode=\"projected\"]::before { transform: translateX(100%); }\n.hb-wi4-seg button {\n  position: relative;\n  height: 24px;\n  padding: 0 10px;\n  border: 0;\n  background: transparent;\n  color: #8f8f8f;\n  font: inherit;\n  font-size: 11px;\n  font-weight: 500;\n  cursor: pointer;\n  border-radius: 6px;\n  transition: color 0.2s ease;\n}\n.hb-wi4-seg button[aria-pressed=\"true\"] { color: #ededed; }\n.hb-wi4-seg button:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(127, 179, 255, 0.7); }\n.hb-wi4-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }\n.hb-wi4-row {\n  display: grid;\n  grid-template-columns: minmax(92px, 26%) 1fr auto;\n  align-items: center;\n  gap: 12px;\n  padding: 7px 8px;\n  border-radius: 9px;\n  outline: none;\n  transition: background 0.2s ease;\n}\n.hb-wi4-row:hover, .hb-wi4-row:focus-visible { background: #121212; }\n.hb-wi4-row:focus-visible { box-shadow: inset 0 0 0 1px rgba(127, 179, 255, 0.55); }\n.hb-wi4-lab { display: flex; flex-direction: column; gap: 1px; min-width: 0; }\n.hb-wi4-lab b { font-size: 12px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wi4-lab span { font-size: 10.5px; color: #6f6f6f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wi4-track { position: relative; height: 22px; }\n.hb-wi4-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }\n.hb-wi4-band { transition: opacity 0.2s ease; }\n.hb-wi4-bar {\n  fill: var(--hb-wi4-a);\n  transform-box: view-box;\n  transform-origin: 0 0;\n  transform: scaleX(0);\n  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1) var(--hb-wi4-d, 0ms);\n}\n.hb-wi4-ghost {\n  opacity: 0;\n  transform-box: view-box;\n  transform-origin: 0 0;\n  transition: opacity 0.4s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);\n}\n.hb-wi4[data-mode=\"projected\"] .hb-wi4-ghost { opacity: 1; }\n.hb-wi4-tgt { stroke: #ededed; stroke-width: 2; stroke-linecap: round; vector-effect: non-scaling-stroke; opacity: 0; transition: opacity 0.4s ease calc(var(--hb-wi4-d, 0ms) + 500ms); }\n.hb-wi4-prev { fill: #0a0a0a; stroke: #a1a1a1; stroke-width: 1.4; vector-effect: non-scaling-stroke; opacity: 0; transition: opacity 0.4s ease calc(var(--hb-wi4-d, 0ms) + 700ms); }\n.hb-wi4[data-in=\"true\"] .hb-wi4-tgt, .hb-wi4[data-in=\"true\"] .hb-wi4-prev { opacity: 1; }\n.hb-wi4-val { display: flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 120px; }\n.hb-wi4-num { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-variant-numeric: tabular-nums; }\n.hb-wi4-num b { font-size: 12.5px; font-weight: 600; transition: color 0.3s ease; }\n.hb-wi4-num span { font-size: 10.5px; color: #6f6f6f; }\n.hb-wi4-pill {\n  display: inline-flex;\n  align-items: center;\n  gap: 5px;\n  height: 20px;\n  padding: 0 7px;\n  border-radius: 999px;\n  font-size: 10.5px;\n  font-weight: 500;\n  white-space: nowrap;\n  border: 1px solid transparent;\n  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;\n}\n.hb-wi4-pill::before { content: \"\"; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }\n.hb-wi4-pill[data-s=\"hit\"] { color: #4ade80; background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.2); }\n.hb-wi4-pill[data-s=\"track\"] { color: #7fb3ff; background: rgba(127, 179, 255, 0.1); border-color: rgba(127, 179, 255, 0.2); }\n.hb-wi4-pill[data-s=\"risk\"] { color: #f5b544; background: rgba(245, 181, 68, 0.1); border-color: rgba(245, 181, 68, 0.2); }\n.hb-wi4-pill[data-s=\"behind\"] { color: #ff7a6b; background: rgba(255, 122, 107, 0.1); border-color: rgba(255, 122, 107, 0.2); }\n.hb-wi4-key { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; padding: 0 8px; font-size: 10.5px; color: #8f8f8f; }\n.hb-wi4-key span { display: inline-flex; align-items: center; gap: 5px; }\n.hb-wi4-key i { display: inline-block; }\n@container (max-width: 440px) {\n  .hb-wi4-row { grid-template-columns: 1fr auto; gap: 4px 10px; padding: 5px 8px; }\n  .hb-wi4-lab span { display: none; }\n  .hb-wi4-track { grid-column: 1 / -1; grid-row: 2; height: 14px; }\n  .hb-wi4-val { min-width: 0; }\n  .hb-wi4-num span { display: none; }\n  .hb-wi4-key { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wi4-bar, .hb-wi4-ghost, .hb-wi4-tgt, .hb-wi4-prev, .hb-wi4-seg::before, .hb-wi4-pill { transition: none !important; }\n}\n`;\n\nexport function ChartBulletSet({\n  metrics = defaultMetrics,\n  title = \"Q4 scorecard\",\n  period = \"Day 58 of 92\",\n  accent = \"#2f7bff\",\n  mode,\n  defaultMode = \"actual\",\n  onModeChange,\n  showToggle = true,\n  className,\n  style,\n  ...rest\n}: ChartBulletSetProps) {\n  const id = React.useId().replace(/:/g, \"\");\n  const [inner, setInner] = React.useState(defaultMode);\n  const [inView, setInView] = React.useState(false);\n  const current = mode ?? inner;\n\n  React.useEffect(() => {\n    const t = window.setTimeout(() => setInView(true), 60);\n    return () => window.clearTimeout(t);\n  }, []);\n\n  const setMode = (m: \"actual\" | \"projected\") => {\n    if (mode === undefined) setInner(m);\n    onModeChange?.(m);\n  };\n\n  const VW = 300;\n\n  return (\n    <div\n      {...rest}\n      className={[\"hb-wi4\", className].filter(Boolean).join(\" \")}\n      style={{ ...style, [\"--hb-wi4-a\" as string]: accent } as React.CSSProperties}\n      data-in={inView}\n      data-mode={current}\n    >\n      <style href=\"hb-chart-bullet-set\" precedence=\"default\">{css}</style>\n      <svg width=\"0\" height=\"0\" style={{ position: \"absolute\" }} aria-hidden=\"true\">\n        <defs>\n          <pattern id={`${id}-hatch`} width=\"5\" height=\"5\" patternUnits=\"userSpaceOnUse\" patternTransform=\"rotate(45)\">\n            <rect width=\"5\" height=\"5\" fill={accent} opacity=\"0.18\" />\n            <line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"5\" stroke={accent} strokeWidth=\"2.2\" opacity=\"0.75\" />\n          </pattern>\n        </defs>\n      </svg>\n      <div className=\"hb-wi4-top\">\n        <div className=\"hb-wi4-title\">\n          <b>{title}</b>\n          <span>{period}</span>\n        </div>\n        {showToggle ? (\n          <div className=\"hb-wi4-seg\" data-mode={current} role=\"group\" aria-label=\"Show values\">\n            <button type=\"button\" aria-pressed={current === \"actual\"} onClick={() => setMode(\"actual\")}>\n              Actual\n            </button>\n            <button type=\"button\" aria-pressed={current === \"projected\"} onClick={() => setMode(\"projected\")}>\n              Projected\n            </button>\n          </div>\n        ) : null}\n      </div>\n      <ul className=\"hb-wi4-list\">\n        {metrics.map((m, i) => {\n          const max = Math.max(...m.ranges, m.target, m.value, m.projected ?? 0, m.previous ?? 0) * 1.02;\n          const sc = (v: number) => (m.inverse ? (1 - v / max) * VW : (v / max) * VW);\n          const bands = m.ranges.map((r) => Math.max(0, sc(r))).sort((a, b) => b - a);\n          const shown = current === \"projected\" && m.projected !== undefined ? m.projected : m.value;\n          const st = statusOf(m, shown);\n          const actualW = Math.max(0, sc(m.value));\n          const projW = m.projected !== undefined ? sc(m.projected) : actualW;\n          const delta = m.previous !== undefined ? shown - m.previous : null;\n          const better = delta === null ? null : m.inverse ? delta < 0 : delta > 0;\n          return (\n            <li\n              key={m.label}\n              className=\"hb-wi4-row\"\n              tabIndex={0}\n              aria-label={`${m.label}: ${fmtValue(shown, m.format)}${current === \"projected\" ? \" projected\" : \"\"}, target ${fmtValue(m.target, m.format)}, ${st.label}`}\n            >\n              <div className=\"hb-wi4-lab\">\n                <b>{m.label}</b>\n                {m.hint ? <span>{m.hint}</span> : null}\n              </div>\n              <div className=\"hb-wi4-track\">\n                <svg className=\"hb-wi4-svg\" viewBox={`0 0 ${VW} 22`} preserveAspectRatio=\"none\" role=\"img\" aria-labelledby={`${id}-${i}`}>\n                  <title id={`${id}-${i}`}>{`${m.label} ${fmtValue(m.value, m.format)} of ${fmtValue(m.target, m.format)} target`}</title>\n                  {bands.map((w, k) => (\n                    <rect key={k} className=\"hb-wi4-band\" x={0} y={1} width={w.toFixed(2)} height={20} rx={3} fill={[\"#1a1a1a\", \"#222\", \"#2c2c2c\"][k] ?? \"#2c2c2c\"} />\n                  ))}\n                  {m.projected !== undefined ? (\n                    <rect className=\"hb-wi4-ghost\" fill={`url(#${id}-hatch)`} x={0} y={7} width={Math.max(0, projW).toFixed(2)} height={8} rx={1.5} />\n                  ) : null}\n                  <rect\n                    className=\"hb-wi4-bar\"\n                    x={0}\n                    y={7}\n                    width={Math.max(0, actualW).toFixed(2)}\n                    height={8}\n                    rx={1.5}\n                    style={{ transform: inView ? \"scaleX(1)\" : \"scaleX(0)\", [\"--hb-wi4-d\" as string]: `${120 + i * 110}ms` } as React.CSSProperties}\n                  />\n                  <line className=\"hb-wi4-tgt\" x1={sc(m.target).toFixed(2)} x2={sc(m.target).toFixed(2)} y1={3} y2={19} style={{ [\"--hb-wi4-d\" as string]: `${120 + i * 110}ms` } as React.CSSProperties} />\n                  {m.previous !== undefined ? (\n                    <circle className=\"hb-wi4-prev\" cx={sc(m.previous).toFixed(2)} cy={11} r={2.6} style={{ [\"--hb-wi4-d\" as string]: `${120 + i * 110}ms` } as React.CSSProperties} />\n                  ) : null}\n                </svg>\n              </div>\n              <div className=\"hb-wi4-val\">\n                <div className=\"hb-wi4-num\">\n                  <b>{fmtValue(shown, m.format)}</b>\n                  <span>\n                    of {fmtValue(m.target, m.format)}\n                    {delta !== null ? (\n                      <span style={{ color: better ? \"#4ade80\" : \"#ff7a6b\", marginLeft: 4 }}>\n                        {delta > 0 ? \"+\" : \"\"}\n                        {m.format === \"currency\" ? fmtValue(delta, \"currency\") : m.format === \"hours\" ? `${delta.toFixed(1)}h` : m.format === \"percent\" ? `${delta.toFixed(1)}pt` : delta.toLocaleString(\"en-US\")}\n                      </span>\n                    ) : null}\n                  </span>\n                </div>\n                <span className=\"hb-wi4-pill\" data-s={st.key}>\n                  {st.label}\n                </span>\n              </div>\n            </li>\n          );\n        })}\n      </ul>\n      <div className=\"hb-wi4-key\" aria-hidden=\"true\">\n        <span>\n          <i style={{ width: 12, height: 4, borderRadius: 1, background: accent }} />\n          Actual\n        </span>\n        <span>\n          <i style={{ width: 2, height: 10, borderRadius: 1, background: \"#ededed\" }} />\n          Target\n        </span>\n        <span>\n          <i style={{ width: 6, height: 6, borderRadius: \"50%\", border: \"1.4px solid #a1a1a1\" }} />\n          Last quarter\n        </span>\n        <span>\n          <i style={{ width: 12, height: 4, borderRadius: 1, background: `repeating-linear-gradient(45deg, ${accent} 0 2px, transparent 2px 4px)` }} />\n          Projected\n        </span>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}