本文へ移動

スケジューリングとリソース

アーンドバリュー

小規模な納品プロジェクトのアーンドバリュー管理です。選んだ状況日付での PV・EV・AC・SPI・CPI・EAC、集計行を含むガントチャートの EVM 列、累積コストの S カーブを表示します。

ライブデモGitHub で見る ↗

アーンドバリュー

computeEarnedValue · PV は平日 08:00–16:00 のカレンダーで積み上がります · 集計行は rollupEarnedValue

11月18日 16:00
計画価値(PV)
39.0k
出来高(EV)
36.9k
SV −2.1k
実コスト(AC)
38.5k
CV −1.6k
SPI
0.95
CPI
0.96
EAC
62.6k
BAC 60.0k · VAC −2.6k

11月18日 の状況: 日程の遅れ(SPI 0.95)、予算超過(CPI 0.96)。BAC 60.0k に対して EAC 62.6k。

累積コストの S カーブ12月07日 までの S カーブ: 計画価値は 12月01日 に 60.0k に達します。状況日付 11月18日 の PV 39.0k、EV 36.9k、AC 38.5k。予測は 12月02日 までに 62.6k。0.0k20.0k40.0k60.0k80.0k11月02日11月09日11月16日11月23日11月30日
  • 計画価値(PV)
  • 出来高(EV)
  • 実コスト(AC)
  • EAC までの予測
  • 完成時総予算
100%
作業パッケージ
BAC
PV
EV
AC
SPI
CPI
11月02日11月09日11月16日11月23日11月30日12月07日
技術
16.0k
16.0k
16.0k
17.5k
1.00
0.91
仕様策定
6.0k
6.0k
6.0k
6.0k
1.00
1.00
設計
10.0k
10.0k
10.0k
11.5k
1.00
0.87
納品
44.0k
23.0k
20.9k
21.0k
0.91
1.00
調達
14.0k
14.0k
14.0k
13.3k
1.00
1.05
組立
21.0k
9.0k
6.9k
7.7k
0.77
0.90
試験
8.0k
0.0k
0.0k
0.0k
該当なし
該当なし
引き渡し
1.0k
0.0k
0.0k
0.0k
該当なし
該当なし
矢印キーで移動、Shift で終了を、Alt で開始を伸縮します。Escape で取り消します。

デモの右下の角をドラッグすると高さを変えられます。

ソースコード

vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import {
  GanttChart, buildWorkPeriods, computeEarnedValue, invertWorkPeriods, rollupEarnedValue, type EarnedValueEacMethod,
  type EarnedValueMetrics, type EarnedValueRecord, type EarnedValueTask, type TimelineBar, type TimelineColumn, type TimelineRow,
} from '../src'
import { day, hour } from './data'
import DemoPanel from './components/DemoPanel.vue'
import { useDemoLocale } from './i18n'

const { t, labels, isJapanese } = useDemoLocale()

// Opt-in example of `computeEarnedValue` and `rollupEarnedValue`: a small delivery project with a budget per task and a
// baseline plan on a weekday 08:00–16:00 calendar. The "actual" progress and cost come from a made-up record of what
// happened (design ran a day long and over cost, assembly overran), sampled at the end of each working day up to the
// chosen status date. The chart shows the baseline with progress and EVM columns; summary rows roll up their tasks.
const origin = Date.parse('2026-11-02T00:00:00Z') // a Monday
const range = { start: origin, end: origin + 35 * day }
const week = { weekly: [1, 2, 3, 4, 5].map(weekday => ({ weekday, startMinute: 8 * 60, endMinute: 16 * 60 })) }
const periods = buildWorkPeriods(range, week)
const calendars = [{ id: 'office', periods }]
// Weekends only: the night hours would shade most of a chart at this zoom.
const weekends = invertWorkPeriods(buildWorkPeriods(range, { weekly: [1, 2, 3, 4, 5].map(weekday => ({ weekday, startMinute: 0, endMinute: 1440 })) }), range)
/** The start of the nth working day (0-based) at 08:00 and its end at 16:00. */
const dayStart = (n: number) => periods[n]!.start
const dayEnd = (n: number) => periods[n]!.end
const workBetween = (from: number, to: number) => periods.reduce((sum, period) => sum + Math.max(0, Math.min(to, period.end) - Math.max(from, period.start)), 0)

interface PlanTask {
  id: string
  parentId: string
  label: string
  budget: number
  /** Planned working days, first and last (inclusive). */
  days: [number, number]
  /** What happened: actual first working day, working days taken and cost per unit of budget. */
  actual: { day: number; days: number; costRate: number }
}
const plan: PlanTask[] = [
  { id: 'spec', parentId: 'engineering', label: t({ en: 'Specification', ja: '仕様策定' }), budget: 6000, days: [0, 2], actual: { day: 0, days: 3, costRate: 1 } },
  { id: 'design', parentId: 'engineering', label: t({ en: 'Design', ja: '設計' }), budget: 10000, days: [3, 7], actual: { day: 3, days: 6, costRate: 1.15 } },
  { id: 'procure', parentId: 'delivery', label: t({ en: 'Procurement', ja: '調達' }), budget: 14000, days: [5, 9], actual: { day: 5, days: 5, costRate: 0.95 } },
  { id: 'assemble', parentId: 'delivery', label: t({ en: 'Assembly', ja: '組立' }), budget: 21000, days: [10, 16], actual: { day: 10, days: 9, costRate: 1.1 } },
  { id: 'test', parentId: 'delivery', label: t({ en: 'Testing', ja: '試験' }), budget: 8000, days: [17, 20], actual: { day: 19, days: 4, costRate: 1 } },
  { id: 'handover', parentId: 'delivery', label: t({ en: 'Handover', ja: '引き渡し' }), budget: 1000, days: [21, 21], actual: { day: 23, days: 0, costRate: 1 } },
]
const milestone = (task: PlanTask) => task.id === 'handover'
const plannedStart = (task: PlanTask) => dayStart(task.days[0])
const plannedEnd = (task: PlanTask) => milestone(task) ? dayStart(task.days[0]) : dayEnd(task.days[1])
const rows: TimelineRow[] = [
  { id: 'engineering', label: t({ en: 'Engineering', ja: '技術' }) },
  ...plan.filter(task => task.parentId === 'engineering').map(task => ({ id: task.id, parentId: task.parentId, label: task.label })),
  { id: 'delivery', label: t({ en: 'Delivery', ja: '納品' }) },
  ...plan.filter(task => task.parentId === 'delivery').map(task => ({ id: task.id, parentId: task.parentId, label: task.label })),
]
const children = new Map<string, string[]>()
for (const task of plan) children.set(task.parentId, [...children.get(task.parentId) ?? [], task.id])

/** The made-up record: progress and cost of a task at time t. */
function happened(task: PlanTask, t: number): EarnedValueRecord {
  const { actual } = task
  const progress = actual.days === 0
    ? (t >= dayStart(actual.day) ? 1 : 0)
    : Math.min(1, workBetween(dayStart(actual.day), t) / (actual.days * 8 * hour))
  return { time: t, progress: Math.round(progress * 100) / 100, actualCost: Math.round(progress * task.budget * actual.costRate) }
}

const lastDay = 24
const statusDay = ref(12)
const statusDate = computed(() => dayEnd(statusDay.value))
const method = ref<EarnedValueEacMethod>('cpi')
const methods: { value: EarnedValueEacMethod; label: string }[] = [
  { value: 'cpi', label: t({ en: 'Cost efficiency (CPI)', ja: 'コスト効率(CPI)' }) },
  { value: 'cpi-spi', label: t({ en: 'Cost and schedule (CPI × SPI)', ja: 'コストと日程(CPI × SPI)' }) },
  { value: 'budget', label: t({ en: 'Remaining at budget', ja: '残りは予算どおり' }) },
]

const tasks = computed<EarnedValueTask[]>(() => plan.map(task => {
  const history: EarnedValueRecord[] = []
  for (let n = 0; n < statusDay.value; n++) history.push(happened(task, dayEnd(n)))
  const now = happened(task, statusDate.value)
  return {
    id: task.id, budget: task.budget, start: plannedStart(task), end: plannedEnd(task), calendarId: 'office',
    progress: now.progress, actualCost: now.actualCost!, history,
  }
}))
const result = computed(() => computeEarnedValue(tasks.value, {
  statusDate: statusDate.value, calendars, eacMethod: method.value, series: { step: day / 2, start: range.start, end: range.end },
}))
const totals = computed(() => result.value.totals)
const byId = computed(() => new Map(result.value.tasks.map(task => [task.id, task])))
/** A task's metrics, or the rollup of a summary row's tasks. */
function metricsOf(rowId: string): EarnedValueMetrics | undefined {
  const ids = children.get(rowId)
  if (ids) return rollupEarnedValue(ids.map(id => byId.value.get(id)!), { eacMethod: method.value })
  return byId.value.get(rowId)
}

const notAvailable = t({ en: 'n/a', ja: '該当なし' })
const money = (value: number | undefined) => value === undefined ? notAvailable : (value / 1000).toFixed(1) + 'k'
const ratio = (value: number | undefined) => value === undefined ? notAvailable : value.toFixed(2)
const signedMoney = (value: number) => (value < 0 ? '−' : '+') + money(Math.abs(value))
const dateLocale = isJapanese.value ? 'ja-JP' : 'en-GB'
const formatDate = (time: number) => new Date(time).toLocaleDateString(dateLocale, { day: '2-digit', month: 'short', timeZone: 'UTC' })
const formatTime = (time: number) => new Date(time).toLocaleString(dateLocale, { day: '2-digit', month: 'short', hour: '2-digit', minute: '2-digit', hour12: false, timeZone: 'UTC' })

const columns: TimelineColumn[] = [
  { id: 'bac', label: 'BAC', width: 54, value: row => money(metricsOf(row.id)?.bac) },
  { id: 'pv', label: 'PV', width: 54, value: row => money(metricsOf(row.id)?.pv) },
  { id: 'ev', label: 'EV', width: 54, value: row => money(metricsOf(row.id)?.ev) },
  { id: 'ac', label: 'AC', width: 54, value: row => money(metricsOf(row.id)?.ac) },
  { id: 'spi', label: 'SPI', width: 48, value: row => ratio(metricsOf(row.id)?.spi) },
  { id: 'cpi', label: 'CPI', width: 48, value: row => ratio(metricsOf(row.id)?.cpi) },
]
const bars = computed<TimelineBar[]>(() => plan.map(task => ({
  id: task.id, rowId: task.id, label: task.label, start: plannedStart(task), end: plannedEnd(task), editable: false,
  progress: byId.value.get(task.id)?.percentComplete ?? 0, tone: task.parentId === 'engineering' ? 'violet' : 'blue',
})))

const plannedFinish = Math.max(...plan.map(plannedEnd))
const projectStart = Math.min(...plan.map(plannedStart))
/** A simple time forecast for the chart: the planned duration divided by the SPI (the planned finish without one). */
const forecastFinish = computed(() => {
  const spi = totals.value.spi
  const finish = spi ? projectStart + (plannedFinish - projectStart) / spi : plannedFinish
  return Math.min(range.end, Math.max(statusDate.value, finish))
})
const verdict = computed(() => {
  const { spi, cpi, eac, bac } = totals.value
  if (isJapanese.value) {
    const schedule = spi === undefined ? 'まだ計画価値がありません' : spi >= 1 ? `日程どおりか前倒し(SPI ${ratio(spi)})` : `日程の遅れ(SPI ${ratio(spi)})`
    const cost = cpi === undefined ? 'まだコストがありません' : cpi >= 1 ? `予算内(CPI ${ratio(cpi)})` : `予算超過(CPI ${ratio(cpi)})`
    return `${formatDate(statusDate.value)} の状況: ${schedule}、${cost}。BAC ${money(bac)} に対して EAC ${money(eac)}。`
  }
  const schedule = spi === undefined ? 'no planned value yet' : spi >= 1 ? `on or ahead of schedule (SPI ${ratio(spi)})` : `behind schedule (SPI ${ratio(spi)})`
  const cost = cpi === undefined ? 'no cost yet' : cpi >= 1 ? `on or under budget (CPI ${ratio(cpi)})` : `over budget (CPI ${ratio(cpi)})`
  return `Status ${formatDate(statusDate.value)}: ${schedule}, ${cost}; EAC ${money(eac)} against BAC ${money(bac)}.`
})

// ---- S-curve ----
const width = 720, height = 260
const pad = { left: 46, right: 16, top: 14, bottom: 28 }
const yMax = computed(() => {
  const top = Math.max(totals.value.bac, totals.value.eac ?? 0, ...result.value.series.map(point => point.ac ?? 0))
  return Math.ceil(top / 20000) * 20000
})
const x = (time: number) => pad.left + (time - range.start) / (range.end - range.start) * (width - pad.left - pad.right)
const y = (value: number) => height - pad.bottom - value / yMax.value * (height - pad.top - pad.bottom)
const path = (points: readonly { time: number; value: number | undefined }[]) => points
  .filter(point => point.value !== undefined)
  .map((point, index) => `${index ? 'L' : 'M'}${x(point.time).toFixed(1)},${y(point.value!).toFixed(1)}`).join(' ')
const pvPath = computed(() => path(result.value.series.map(point => ({ time: point.time, value: point.pv }))))
const evPath = computed(() => path(result.value.series.map(point => ({ time: point.time, value: point.ev }))))
const acPath = computed(() => path(result.value.series.map(point => ({ time: point.time, value: point.ac }))))
const forecastPath = computed(() => totals.value.eac === undefined ? '' : path([
  { time: statusDate.value, value: totals.value.ac }, { time: forecastFinish.value, value: totals.value.eac },
]))
const yTicks = computed(() => Array.from({ length: yMax.value / 20000 + 1 }, (_, index) => index * 20000))
const xTicks = Array.from({ length: 5 }, (_, index) => range.start + index * 7 * day)
const curveSummary = computed(() => isJapanese.value
  ? `${formatDate(range.end)} までの S カーブ: 計画価値は ${formatDate(plannedFinish)} に ${money(totals.value.bac)} に達します。`
    + `状況日付 ${formatDate(statusDate.value)} の PV ${money(totals.value.pv)}、EV ${money(totals.value.ev)}、AC ${money(totals.value.ac)}。`
    + `予測は ${formatDate(forecastFinish.value)} までに ${money(totals.value.eac)}。`
  : `S-curve to ${formatDate(range.end)}: planned value reaches ${money(totals.value.bac)} on ${formatDate(plannedFinish)}; `
  + `at the status date ${formatDate(statusDate.value)} PV ${money(totals.value.pv)}, EV ${money(totals.value.ev)}, AC ${money(totals.value.ac)}; `
  + `forecast ${money(totals.value.eac)} by ${formatDate(forecastFinish.value)}.`)
</script>

<template>
  <DemoPanel title-id="earned-value-title" :title="t({ en: 'Earned value', ja: 'アーンドバリュー' })" :subtitle="t({ en: 'computeEarnedValue · PV accrues on a weekday 08:00–16:00 calendar · summary rows use rollupEarnedValue', ja: 'computeEarnedValue · PV は平日 08:00–16:00 のカレンダーで積み上がります · 集計行は rollupEarnedValue' })">
    <template #options>
      <label>{{ t({ en: 'Status date', ja: '状況日付' }) }} <input v-model.number="statusDay" type="range" min="0" :max="lastDay" step="1" :aria-valuetext="formatTime(statusDate)"></label>
      <output :aria-label="t({ en: 'Selected status date', ja: '選択中の状況日付' })">{{ formatTime(statusDate) }}</output>
      <label>{{ t({ en: 'EAC method', ja: 'EAC の算出方法' }) }} <select v-model="method"><option v-for="item in methods" :key="item.value" :value="item.value">{{ item.label }}</option></select></label>
    </template>
    <dl class="schedule-metrics evm-tiles" :aria-label="t({ en: 'Earned value at the status date', ja: '状況日付のアーンドバリュー' })">
      <div><dt>{{ t({ en: 'Planned value (PV)', ja: '計画価値(PV)' }) }}</dt><dd>{{ money(totals.pv) }}</dd></div>
      <div><dt>{{ t({ en: 'Earned value (EV)', ja: '出来高(EV)' }) }}</dt><dd>{{ money(totals.ev) }}</dd><small>SV {{ signedMoney(totals.sv) }}</small></div>
      <div><dt>{{ t({ en: 'Actual cost (AC)', ja: '実コスト(AC)' }) }}</dt><dd>{{ money(totals.ac) }}</dd><small>CV {{ signedMoney(totals.cv) }}</small></div>
      <div><dt>SPI</dt><dd>{{ ratio(totals.spi) }}</dd></div>
      <div><dt>CPI</dt><dd>{{ ratio(totals.cpi) }}</dd></div>
      <div><dt>EAC</dt><dd>{{ money(totals.eac) }}</dd><small>BAC {{ money(totals.bac) }} · VAC {{ totals.vac === undefined ? notAvailable : signedMoney(totals.vac) }}</small></div>
    </dl>
    <p role="status" :aria-label="t({ en: 'Earned value summary', ja: 'アーンドバリューの概要' })" class="evm-verdict">{{ verdict }}</p>
    <figure class="evm-curve">
      <svg :viewBox="`0 0 ${width} ${height}`" role="img" aria-labelledby="evm-curve-title" aria-describedby="evm-curve-desc">
        <title id="evm-curve-title">{{ t({ en: 'Cumulative cost S-curve', ja: '累積コストの S カーブ' }) }}</title>
        <desc id="evm-curve-desc">{{ curveSummary }}</desc>
        <g class="evm-grid">
          <g v-for="tick in yTicks" :key="tick">
            <line :x1="pad.left" :x2="width - pad.right" :y1="y(tick)" :y2="y(tick)" />
            <text :x="pad.left - 6" :y="y(tick)" text-anchor="end" dominant-baseline="middle">{{ money(tick) }}</text>
          </g>
          <text v-for="tick in xTicks" :key="tick" :x="x(tick)" :y="height - 8" text-anchor="middle">{{ formatDate(tick) }}</text>
        </g>
        <line class="evm-bac" :x1="pad.left" :x2="width - pad.right" :y1="y(totals.bac)" :y2="y(totals.bac)" />
        <line class="evm-status" :x1="x(statusDate)" :x2="x(statusDate)" :y1="pad.top" :y2="height - pad.bottom" />
        <path class="evm-line evm-pv" :d="pvPath" />
        <path class="evm-line evm-forecast" :d="forecastPath" />
        <path class="evm-line evm-ac" :d="acPath" />
        <path class="evm-line evm-ev" :d="evPath" />
      </svg>
      <figcaption>
        <ul class="evm-legend" :aria-label="t({ en: 'S-curve legend', ja: 'S カーブの凡例' })">
          <li><span class="evm-key evm-pv" aria-hidden="true"></span>{{ t({ en: 'Planned value (PV)', ja: '計画価値(PV)' }) }}</li>
          <li><span class="evm-key evm-ev" aria-hidden="true"></span>{{ t({ en: 'Earned value (EV)', ja: '出来高(EV)' }) }}</li>
          <li><span class="evm-key evm-ac" aria-hidden="true"></span>{{ t({ en: 'Actual cost (AC)', ja: '実コスト(AC)' }) }}</li>
          <li><span class="evm-key evm-forecast" aria-hidden="true"></span>{{ t({ en: 'Forecast to EAC', ja: 'EAC までの予測' }) }}</li>
          <li><span class="evm-key evm-bac" aria-hidden="true"></span>{{ t({ en: 'Budget at completion', ja: '完成時総予算' }) }}</li>
        </ul>
      </figcaption>
    </figure>
    <GanttChart :rows="rows" :bars="bars" :range="range" :columns="columns" show-summaries readonly :status-date="statusDate"
      :format-time="formatDate" :pixels-per-unit="26 / day" :tick-steps="[day, 7 * day]" :non-working-periods="weekends"
      :row-height="40" :height="372" :labels="{ ...labels.gantt, region: t({ en: 'Earned value plan', ja: 'アーンドバリューの計画' }) }">
      <template #row-heading>{{ t({ en: 'Work package', ja: '作業パッケージ' }) }}</template>
    </GanttChart>
  </DemoPanel>
</template>

<style scoped>
.evm-tiles small { display: block; margin-top: 2px; color: var(--vw-muted, #526579); font-size: 11px; }
.evm-verdict { margin: 0 0 10px; font-size: 13px; }
.evm-curve { margin: 0 0 14px; }
.evm-curve svg { display: block; width: 100%; max-width: 760px; height: auto; }
.evm-grid line { stroke: var(--vw-border, #dbe3ec); stroke-width: 1; }
.evm-grid text { fill: var(--vw-muted, #526579); font-size: 10px; font-variant-numeric: tabular-nums; }
.evm-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.evm-pv { stroke: #5f7387; stroke-dasharray: 6 4; }
.evm-ev { stroke: #1f7a6d; }
.evm-ac { stroke: #b4531a; }
.evm-forecast { stroke: #b4531a; stroke-dasharray: 2 4; }
.evm-bac { stroke: var(--vw-muted, #526579); stroke-width: 1; stroke-dasharray: 1 3; }
.evm-status { stroke: var(--vw-accent, #245e96); stroke-width: 1.5; }
.evm-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 12px; }
.evm-legend li { display: inline-flex; align-items: center; gap: 5px; }
.evm-key { display: inline-block; width: 22px; height: 0; border-top: 2px solid; }
.evm-key.evm-pv { border-top-style: dashed; border-color: #5f7387; }
.evm-key.evm-ev { border-color: #1f7a6d; }
.evm-key.evm-ac { border-color: #b4531a; }
.evm-key.evm-forecast { border-top-style: dotted; border-color: #b4531a; }
.evm-key.evm-bac { border-top: 1px dotted var(--vw-muted, #526579); }
:global(.dark .evm-pv) { stroke: #9fb2c4; }
:global(.dark .evm-ev) { stroke: #4fc1ae; }
:global(.dark .evm-ac), :global(.dark .evm-forecast) { stroke: #f0965a; }
:global(.dark .evm-key.evm-pv) { border-color: #9fb2c4; }
:global(.dark .evm-key.evm-ev) { border-color: #4fc1ae; }
:global(.dark .evm-key.evm-ac), :global(.dark .evm-key.evm-forecast) { border-color: #f0965a; }
@media (forced-colors: active) {
  .evm-line, .evm-bac, .evm-status { stroke: CanvasText; }
  .evm-key { border-color: CanvasText !important; }
}
</style>
ts
import type { GraphEdge, NetworkNode, TimelineBar, TimelineDependency, TimelineRow } from '../src'

export const minute = 60_000
export const hour = 60 * minute
export const day = 24 * hour
export const origin = Date.parse('2026-11-09T08:00:00Z')
export const range = { start: origin, end: origin + 9 * hour }
export const formatTime = (value: number) => new Date(value).toISOString().slice(11, 16)

export interface ExampleData {
  nodes: NetworkNode[]
  edges: GraphEdge[]
  rows: TimelineRow[]
  /** A bar's `data` is the ID of the graph node it belongs to, so the chart and the graph select together. */
  bars: TimelineBar<string>[]
  dependencies: TimelineDependency[]
}

/** The data sets of `makeExample`, with the text of their buttons in English and Japanese. */
export const datasets: readonly { id: string; label: string; labelJa: string }[] = [
  { id: 'manufacturing', label: 'Manufacturing', labelJa: '製造' },
  { id: 'project', label: 'Project delivery', labelJa: 'プロジェクト納品' },
  { id: 'scale', label: '1,000 resources', labelJa: '1,000 リソース' },
  { id: 'large', label: 'Large graph', labelJa: '大規模グラフ' },
]

export function makeExample(name: string): ExampleData {
  if (name === 'large') {
    // 150 ranks of 25 nodes: 3,750 nodes and about 7,400 edges, far wider than one viewport.
    const ranks = 150, perRank = 25
    const nodes: NetworkNode[] = [], edges: GraphEdge[] = []
    for (let rank = 0; rank < ranks; rank++) {
      for (let row = 0; row < perRank; row++) {
        const id = `n-${rank}-${row}`
        nodes.push({ id, label: 'Node ' + (rank * perRank + row + 1), detail: 'Rank ' + (rank + 1), tone: (['blue', 'teal', 'amber', 'violet'] as const)[(rank + row) % 4] })
        if (rank === ranks - 1) continue
        edges.push({ id: id + '>a', from: id, to: `n-${rank + 1}-${row}` })
        edges.push({ id: id + '>b', from: id, to: `n-${rank + 1}-${(row + 7) % perRank}` })
      }
    }
    return { ...makeExample('manufacturing'), nodes, edges }
  }
  if (name === 'scale') {
    const rows = Array.from({ length: 1000 }, (_, i) => ({ id: 'r' + i, label: 'Resource ' + (i + 1), detail: 'Virtualized row' }))
    return {
      nodes: [{ id: 'a', label: 'Controller' }, { id: 'b', label: 'Worker' }, { id: 'c', label: 'Result' }],
      edges: [{ id: 'ab', from: 'a', to: 'b' }, { id: 'bc', from: 'b', to: 'c' }, { id: 'ba', from: 'b', to: 'a', label: 'Retry' }],
      rows,
      bars: rows.flatMap((row, i) => Array.from({ length: 3 }, (_, j) => ({
        id: row.id + '-' + j, rowId: row.id, label: 'Batch ' + (j + 1),
        start: origin + (j * 2.5 + (i % 3) * .25) * hour,
        end: origin + (j * 2.5 + 1.5 + (i % 3) * .25) * hour,
        editable: true, progress: .35, tone: 'teal' as const,
      }))),
      dependencies: [],
    }
  }
  if (name === 'project') return {
    nodes: [
      { id: 'design', label: 'Design', detail: 'Product team', tone: 'violet', ports: [{ id: 'out', label: 'Output', side: 'right', direction: 'source' }] },
      { id: 'api', label: 'API', detail: 'Platform team', tone: 'blue', ports: [{ id: 'in', label: 'Input', side: 'left', direction: 'target' }, { id: 'out', label: 'Output', side: 'right', direction: 'source' }] },
      { id: 'ui', label: 'Interface', detail: 'Web team', tone: 'blue', ports: [{ id: 'in', label: 'Input', side: 'left', direction: 'target' }, { id: 'out', label: 'Output', side: 'right', direction: 'source' }] },
      { id: 'release', label: 'Release', detail: 'Milestone', tone: 'teal', ports: [{ id: 'in', label: 'Input', side: 'left', direction: 'target' }] },
    ],
    edges: [
      { id: 'da', from: 'design', to: 'api', fromPort: 'out', toPort: 'in' }, { id: 'du', from: 'design', to: 'ui', fromPort: 'out', toPort: 'in' },
      { id: 'ar', from: 'api', to: 'release', fromPort: 'out', toPort: 'in' }, { id: 'ur', from: 'ui', to: 'release', fromPort: 'out', toPort: 'in' },
    ],
    rows: [
      { id: 'product', label: 'Product team' }, { id: 'platform', label: 'Platform team' },
      { id: 'web', label: 'Web team' }, { id: 'delivery', label: 'Delivery' },
    ],
    bars: [
      { id: 'design', rowId: 'product', label: 'Design', start: origin, end: origin + 2 * hour, editable: true, tone: 'violet', progress: 1 },
      { id: 'api', rowId: 'platform', label: 'API', start: origin + 2 * hour, end: origin + 6 * hour, editable: true, progress: .65 },
      { id: 'ui', rowId: 'web', label: 'Interface', start: origin + 2 * hour, end: origin + 6 * hour, editable: true, progress: .4 },
      { id: 'release', rowId: 'delivery', label: 'Release', start: origin + 7 * hour, end: origin + 7 * hour, editable: true, tone: 'teal' },
    ],
    dependencies: [
      { id: 'da', from: 'design', to: 'api' }, { id: 'au', from: 'api', to: 'ui', type: 'SS' },
      { id: 'ar', from: 'api', to: 'release' }, { id: 'ur', from: 'ui', to: 'release', type: 'FF' },
    ],
  }
  return {
    nodes: [
      { id: 'raw', label: 'Material A1', detail: '120 units', tone: 'teal' },
      { id: 'split', label: 'Split', detail: 'Operation 101', shape: 'rounded' },
      { id: 'lot1', label: 'Lot A123-01', detail: '72 units', tone: 'teal' },
      { id: 'lot2', label: 'Lot A123-02', detail: '48 units', tone: 'teal' },
      { id: 'finish', label: 'Finish', detail: 'Operation 102', shape: 'rounded' },
      { id: 'product', label: 'Product B', detail: '120 units', tone: 'violet' },
    ],
    edges: [
      { id: 'rs', from: 'raw', to: 'split' },
      { id: 's1', from: 'split', to: 'lot1', label: '72' },
      { id: 's2', from: 'split', to: 'lot2', label: '48' },
      { id: '1f', from: 'lot1', to: 'finish' }, { id: '2f', from: 'lot2', to: 'finish' },
      { id: 'fp', from: 'finish', to: 'product' },
    ],
    rows: [{ id: 'cut', label: 'Cutting station', detail: 'Machine 01' }, { id: 'line', label: 'Finishing line', detail: 'Machine 02' }],
    bars: [
      { id: 'split-plan', rowId: 'cut', label: 'Split · plan', start: origin + hour, end: origin + 3 * hour, editable: true, appearance: 'outline', data: 'split' },
      { id: 'split-actual', rowId: 'cut', label: 'Split · actual', start: origin + 1.25 * hour, end: origin + 3.5 * hour, lane: 1, tone: 'teal', data: 'split' },
      { id: 'finish-plan', rowId: 'line', label: 'Finish · plan', start: origin + 4 * hour, end: origin + 7 * hour, editable: true, appearance: 'outline', data: 'finish' },
      { id: 'finish-actual', rowId: 'line', label: 'Finish · actual', start: origin + 4.5 * hour, end: origin + 7.5 * hour, lane: 1, tone: 'teal', data: 'finish' },
    ],
    dependencies: [{ id: 'sf', from: 'split-actual', to: 'finish-actual' }],
  }
}

MIT ライセンスで公開しています。