{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "marey-schedule",
  "type": "registry:component",
  "title": "Marey schedule",
  "description": "Vehicles moving through stops, against the plan. Sample data: four vans through six stops from 08:00 to 12:00, Van 19 late.",
  "registryDependencies": [
    "@chartory/core",
    "@chartory/plot-marey"
  ],
  "files": [
    {
      "path": "registry/chartory/components/marey-schedule.tsx",
      "type": "registry:component",
      "target": "components/chartory/marey-schedule.tsx",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// Marey schedule (Chartory chart 067): sizes xs | s | m | l, laid out again from the data at each\n// size; collection \"hearth\" (default) or \"signal\" (with @chartory/signal, Code and Complete). Data in the type's shape (default: the sample). Docs:\n// https://usechartory.com/docs/charts/marey-schedule\nimport { ChartView, type ChartViewProps } from \"@/lib/chartory/charts/chart-view\"\nimport { registerChart } from \"@/lib/chartory/charts/defs\"\nimport { data as sample } from \"@/lib/chartory/charts/types/067-marey-schedule/data\"\nimport { def } from \"@/lib/chartory/charts/types/067-marey-schedule/layout\"\n\nregisterChart(def, sample)\n\nexport type MareyScheduleData = typeof sample\nexport type MareyScheduleProps = Omit<ChartViewProps, \"def\" | \"data\" | \"states\"> & {\n  /** the data to draw (default: the sample) */\n  data?: MareyScheduleData\n  /** further data states: the chart morphs to them (update) or ticks through them (live, with interval) */\n  states?: MareyScheduleData[]\n}\n\nexport function MareySchedule(props: MareyScheduleProps) {\n  return <ChartView def={def} {...props} />\n}\n"
    },
    {
      "path": "registry/chartory/charts/types/067-marey-schedule/data.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/067-marey-schedule/data.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 067 Marey schedule · sample data (Figma chart/067, 4 vans on a 6-stop route, 08:00 to 12:00; times in minutes after 08:00, [arrive, depart]).\nimport type { MareyData } from \"../../plots/marey\";\n\nexport const data: MareyData = {\n  stops: [\"DEPOT\", \"MARKET\", \"CANAL\", \"PARK\", \"MILL\", \"PORT\"],\n  t0: 0, t1: 240,\n  xt: [[0, \"08:00\"], [60, \"09:00\"], [120, \"10:00\"], [180, \"11:00\"], [240, \"12:00\"]],\n  vans: [\n    { label: \"Van 11\", tok: \"data/cat-2\", times: [[0, 6], [26, 34], [52, 60], [80, 86], [104, 110], [130, 130]] },\n    { label: \"Van 12\", tok: \"data/cat-3\", times: [[30, 36], [56, 62], [84, 92], [112, 118], [136, 142], [160, 160]] },\n    { label: \"Van 17\", tok: \"data/cat-4\", times: [[60, 66], [86, 92], [112, 120], [140, 146], [166, 172], [192, 192]] },\n    { label: \"Van 19\", tok: \"status/danger\", late: true, times: [[90, 96], [120, 126], [150, 192], [214, 220], [232, 236], [240, 240]] },\n  ],\n  plan: [[90, 96], [116, 122], [142, 150], [170, 176], [196, 202], [222, 222]],\n};\n"
    },
    {
      "path": "registry/chartory/charts/types/067-marey-schedule/layout.ts",
      "type": "registry:lib",
      "target": "lib/chartory/charts/types/067-marey-schedule/layout.ts",
      "content": "// SPDX-License-Identifier: MIT · Copyright (c) 2026 BEY AGENCY LTD · Chartory, usechartory.com\n// 067 Marey schedule (Figma chart/067, \"Van schedule\"): C.marey, 4 vans on the route, Van 19 against its plan.\nimport type { ChartDef, TooltipSpec } from \"../../core/shell\";\nimport { marey } from \"../../plots/marey\";\nimport { data } from \"./data\";\n\nconst hm = (m: number) => String(8 + Math.floor(m / 60)).padStart(2, \"0\") + \":\" + String(m % 60).padStart(2, \"0\");\nconst name = (s: string) => s[0] + s.slice(1).toLowerCase();\nconst late = data.vans.find((v) => v.late)!;\nconst behind = late.times[late.times.length - 1][0] - data.plan![data.plan!.length - 1][0];\n\n// tooltip: one van's line (group = van): leaves the first stop, its longest stop, reaches the last stop (and the\n// plan for the late van)\nconst tip = (o: typeof data, g: number): TooltipSpec | null => {\n  const v = o.vans[g];\n  if (!v || !v.times.length) return null;\n  const n = v.times.length, sw = v.tok;\n  let k = 0;\n  v.times.forEach(([a, b], i) => { if (b - a > v.times[k][1] - v.times[k][0]) k = i; });\n  const rows = [\n    { label: \"Leaves \" + name(o.stops[0]), value: hm(v.times[0][1]), swatch: sw },\n    { label: \"Longest stop · \" + name(o.stops[k]), value: v.times[k][1] - v.times[k][0] + \" min\", swatch: sw },\n    { label: \"Reaches \" + name(o.stops[n - 1]), value: hm(v.times[n - 1][0]), swatch: sw },\n  ];\n  const pl = o.plan?.[o.plan.length - 1];\n  if (v.late && pl) rows.push({ label: \"Plan\", value: hm(pl[0]), swatch: \"text/action\" });\n  return { kind: \"range\", caps: v.label.toUpperCase() + (v.late ? \" · LATE\" : \"\"), rows };\n};\n\nexport const def: ChartDef = {\n  no: 67,\n  slug: \"marey-schedule\",\n  legend: [[\"data/cat-2\", \"Van 11\"], [\"data/cat-3\", \"Van 12\"], [\"data/cat-4\", \"Van 17\"], [\"status/danger\", \"Van 19 · late\"], [\"text/action\", \"Plan\"]],\n  plot: (K, p, w, d) => marey(K, p, w, (d as typeof data | undefined) ?? data),\n  tip: (d, g) => tip(d as typeof data, g),\n  // the next run: every van leaves a few minutes earlier or later; Van 19 shortens its stop at the third stop and\n  // catches up (times stay on the axis, each van's last stop keeps arrive = depart)\n  update: (d, step) => {\n    const o = d as typeof data;\n    const at = (t: number) => Math.min(o.t1, Math.max(o.t0, t));\n    return {\n      ...o,\n      vans: o.vans.map((v, j) => {\n        const sh = Math.round(6 * Math.sin(j * 1.7 + step * 2.1)), gain = v.late ? [8, 14, 20][(step - 1) % 3] : 0;\n        return { ...v, times: v.times.map(([a, b], i) => [at(a + sh - (i > 2 ? gain : 0)), at(b + sh - (i >= 2 ? gain : 0))] as [number, number]) };\n      }),\n    };\n  },\n  describe: {\n    title: \"Line schedule\",\n    summary: `${data.vans.length} vans on a ${data.stops.length}-stop route from ${hm(data.t0)} to ${hm(data.t1)}; ${late.label} reaches ${name(data.stops[data.stops.length - 1])} at ${hm(late.times[late.times.length - 1][0])}, ${behind} minutes after its plan, after a 42-minute stop at ${name(data.stops[2])}.`,\n    table: {\n      head: [\"Van\", ...data.stops.map(name)],\n      rows: [...data.vans.map((v) => [v.label, ...v.times.map(([a, d]) => (a === d ? hm(a) : hm(a) + \"–\" + hm(d)))]), [\"Van 19 plan\", ...data.plan!.map(([a, d]) => (a === d ? hm(a) : hm(a) + \"–\" + hm(d)))]],\n    },\n  },\n};\n"
    }
  ],
  "categories": [
    "charts",
    "schedule-and-status"
  ],
  "meta": {
    "access": "free",
    "no": 67,
    "family": "Schedule and status"
  }
}
