ナビゲーション

v2.1.0
データ表示

ガントチャート

期間のある項目を共通の時間軸上にバーで表示します。プロジェクトの工程、当番、リリース計画などに。

このページの内容

ガントチャートは、プロジェクトの各工程、オンコールのシフト、定期リリースの各サイクルなどの期間を、共通の時間軸上にバーで表示します。リストの各行には、バーの開始位置と終了位置、項目名、バーが伝える内容を記したテキストを持たせます。スタイルシートが項目名とバーを別々の列に配置し、時間軸の各単位を極細の目盛線で区切ります。チャートの表示にはスクリプトもSVGも必要ありません。読者が計画を立てる場面では、ganttビヘイビアを使ってバーを移動・リサイズできるようにします。

ガントチャート

<div class="card max-w(560) mx-auto">  <ol class="gantt gantt-now" style="--gantt-from: 0; --gantt-to: 8; --gantt-now: 4.4" aria-label="Launch plan, in weeks">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>W1</li>        <li>W2</li>        <li>W3</li>        <li>W4</li>        <li>W5</li>        <li>W6</li>        <li>W7</li>        <li>W8</li>      </ol>    </li>    <li class="gantt-row" style="--from: 0; --to: 3; --progress: 100">      <span class="gantt-label">Research</span><span class="gantt-bar">Weeks 1 to 3</span>    </li>    <li class="gantt-row" aria-current="true" style="--from: 2; --to: 6">      <span class="gantt-label">Design</span><span class="gantt-bar">Weeks 3 to 6</span>    </li>    <li class="gantt-row" style="--from: 4; --to: 7.5; --progress: 15">      <span class="gantt-label">Build</span><span class="gantt-bar">Weeks 5 to 8</span>    </li>    <li class="gantt-row" style="--from: 7.5">      <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone">Middle of week 8</span>    </li>  </ol></div>
<div className="card max-w(560) mx-auto">  <ol className="gantt gantt-now" style={{ '--gantt-from': '0', '--gantt-to': '8', '--gantt-now': '4.4' } as React.CSSProperties} aria-label="Launch plan, in weeks">    <li className="gantt-row gantt-scale" aria-hidden="true">      <ol className="gantt-ticks">        <li>W1</li>        <li>W2</li>        <li>W3</li>        <li>W4</li>        <li>W5</li>        <li>W6</li>        <li>W7</li>        <li>W8</li>      </ol>    </li>    <li className="gantt-row" style={{ '--from': '0', '--to': '3', '--progress': '100' } as React.CSSProperties}>      <span className="gantt-label">Research</span><span className="gantt-bar">Weeks 1 to 3</span>    </li>    <li className="gantt-row" aria-current="true" style={{ '--from': '2', '--to': '6' } as React.CSSProperties}>      <span className="gantt-label">Design</span><span className="gantt-bar">Weeks 3 to 6</span>    </li>    <li className="gantt-row" style={{ '--from': '4', '--to': '7.5', '--progress': '15' } as React.CSSProperties}>      <span className="gantt-label">Build</span><span className="gantt-bar">Weeks 5 to 8</span>    </li>    <li className="gantt-row" style={{ '--from': '7.5' } as React.CSSProperties}>      <span className="gantt-label">Launch</span><span className="gantt-bar gantt-milestone">Middle of week 8</span>    </li>  </ol></div>
<div class="card max-w(560) mx-auto">  <ol class="gantt gantt-now" style="--gantt-from: 0; --gantt-to: 8; --gantt-now: 4.4" aria-label="Launch plan, in weeks">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>W1</li>        <li>W2</li>        <li>W3</li>        <li>W4</li>        <li>W5</li>        <li>W6</li>        <li>W7</li>        <li>W8</li>      </ol>    </li>    <li class="gantt-row" style="--from: 0; --to: 3; --progress: 100">      <span class="gantt-label">Research</span><span class="gantt-bar">Weeks 1 to 3</span>    </li>    <li class="gantt-row" aria-current="true" style="--from: 2; --to: 6">      <span class="gantt-label">Design</span><span class="gantt-bar">Weeks 3 to 6</span>    </li>    <li class="gantt-row" style="--from: 4; --to: 7.5; --progress: 15">      <span class="gantt-label">Build</span><span class="gantt-bar">Weeks 5 to 8</span>    </li>    <li class="gantt-row" style="--from: 7.5">      <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone">Middle of week 8</span>    </li>  </ol></div>
<template>  <div class="card max-w(560) mx-auto">    <ol class="gantt gantt-now" style="--gantt-from: 0; --gantt-to: 8; --gantt-now: 4.4" aria-label="Launch plan, in weeks">      <li class="gantt-row gantt-scale" aria-hidden="true">        <ol class="gantt-ticks">          <li>W1</li>          <li>W2</li>          <li>W3</li>          <li>W4</li>          <li>W5</li>          <li>W6</li>          <li>W7</li>          <li>W8</li>        </ol>      </li>      <li class="gantt-row" style="--from: 0; --to: 3; --progress: 100">        <span class="gantt-label">Research</span><span class="gantt-bar">Weeks 1 to 3</span>      </li>      <li class="gantt-row" aria-current="true" style="--from: 2; --to: 6">        <span class="gantt-label">Design</span><span class="gantt-bar">Weeks 3 to 6</span>      </li>      <li class="gantt-row" style="--from: 4; --to: 7.5; --progress: 15">        <span class="gantt-label">Build</span><span class="gantt-bar">Weeks 5 to 8</span>      </li>      <li class="gantt-row" style="--from: 7.5">        <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone">Middle of week 8</span>      </li>    </ol>  </div></template>

#バーの位置の指定

時間軸の範囲は、リストに指定する--gantt-fromから--gantt-toまでです。単位には日、週、時間、スプリントなどを自由に使えます。各gantt-rowに同じ単位で--fromと--toを指定すると、その値に対応する位置でgantt-barが始まり、終わります。小数も使えるので、単位の途中でバーを終えられます。

項目名の列は最も長い名前に合わせ、残りの幅をバーの列に割り当てます。全行で2列を共有するため、幅を明示しなくてもバーの位置がそろいます。バーの背後には、時間軸の単位ごとに極細の目盛線が入ります。

バーのテキストには、日付、期間、担当者など、バーが伝える内容を記述します。スクリーンリーダーが読み上げるため、バーが短くテキストを表示しきれない場合も記述してください。収まりきらないテキストの末尾には省略記号が付きます。

#進捗、現在の行、現在位置

行に0〜100の値で--progressを指定すると、バーの該当する割合が濃い色で塗られます。aria-current="true"を付けた行のバーは、文字色と同じ濃い色で表示されます。読者が現在取り組んでいる工程や、ビューで取り上げている工程を示すのに使います。

リストにgantt-nowを指定すると、今日に当たる--gantt-nowの位置に、全行を貫く縦線が文字色で引かれます。行にポインターを重ねるとバーの色が一段濃くなり、項目名にも強調用の文字色が適用されるため、幅の広いチャートでも同じ行を追いやすくなります。

#マイルストーン

マイルストーンは時間軸上の一点を示します。--fromだけを指定した行のバーにgantt-milestoneを付けると、その位置に文字色の小さなひし形が表示されます。バーのテキストは支援技術向けにリスト内に残り、画面には表示されないため、行の名前でその時点に何が起きるかを示します。

#時間軸の目盛り

gantt-scaleを付けた行は、時間軸の各単位にラベルを付けます。この行にはgantt-ticksのリストを1つ置き、単位ごとに項目を1つ入れます。各ラベルは対応する単位の始点を示す目盛線の上に表示されます。バーのテキストにある情報を視覚的に示すものなので、aria-hiddenで支援技術から隠します。

1日の時間帯

<div class="card max-w(560) mx-auto">  <ol class="gantt" style="--gantt-from: 0; --gantt-to: 24" aria-label="On call today">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>00</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>06</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>12</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>18</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>      </ol>    </li>    <li class="gantt-row" style="--from: 0; --to: 8">      <span class="gantt-label">Grace</span><span class="gantt-bar">00:00 to 08:00</span>    </li>    <li class="gantt-row" aria-current="true" style="--from: 8; --to: 16">      <span class="gantt-label">Ada</span><span class="gantt-bar">08:00 to 16:00</span>    </li>    <li class="gantt-row" style="--from: 16; --to: 24">      <span class="gantt-label">Alan</span><span class="gantt-bar">16:00 to 24:00</span>    </li>  </ol></div>
<div className="card max-w(560) mx-auto">  <ol className="gantt" style={{ '--gantt-from': '0', '--gantt-to': '24' } as React.CSSProperties} aria-label="On call today">    <li className="gantt-row gantt-scale" aria-hidden="true">      <ol className="gantt-ticks">        <li>00</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>06</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>12</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>18</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>      </ol>    </li>    <li className="gantt-row" style={{ '--from': '0', '--to': '8' } as React.CSSProperties}>      <span className="gantt-label">Grace</span><span className="gantt-bar">00:00 to 08:00</span>    </li>    <li className="gantt-row" aria-current="true" style={{ '--from': '8', '--to': '16' } as React.CSSProperties}>      <span className="gantt-label">Ada</span><span className="gantt-bar">08:00 to 16:00</span>    </li>    <li className="gantt-row" style={{ '--from': '16', '--to': '24' } as React.CSSProperties}>      <span className="gantt-label">Alan</span><span className="gantt-bar">16:00 to 24:00</span>    </li>  </ol></div>
<div class="card max-w(560) mx-auto">  <ol class="gantt" style="--gantt-from: 0; --gantt-to: 24" aria-label="On call today">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>00</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>06</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>12</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>        <li>18</li>        <li></li>        <li></li>        <li></li>        <li></li>        <li></li>      </ol>    </li>    <li class="gantt-row" style="--from: 0; --to: 8">      <span class="gantt-label">Grace</span><span class="gantt-bar">00:00 to 08:00</span>    </li>    <li class="gantt-row" aria-current="true" style="--from: 8; --to: 16">      <span class="gantt-label">Ada</span><span class="gantt-bar">08:00 to 16:00</span>    </li>    <li class="gantt-row" style="--from: 16; --to: 24">      <span class="gantt-label">Alan</span><span class="gantt-bar">16:00 to 24:00</span>    </li>  </ol></div>
<template>  <div class="card max-w(560) mx-auto">    <ol class="gantt" style="--gantt-from: 0; --gantt-to: 24" aria-label="On call today">      <li class="gantt-row gantt-scale" aria-hidden="true">        <ol class="gantt-ticks">          <li>00</li>          <li></li>          <li></li>          <li></li>          <li></li>          <li></li>          <li>06</li>          <li></li>          <li></li>          <li></li>          <li></li>          <li></li>          <li>12</li>          <li></li>          <li></li>          <li></li>          <li></li>          <li></li>          <li>18</li>          <li></li>          <li></li>          <li></li>          <li></li>          <li></li>        </ol>      </li>      <li class="gantt-row" style="--from: 0; --to: 8">        <span class="gantt-label">Grace</span><span class="gantt-bar">00:00 to 08:00</span>      </li>      <li class="gantt-row" aria-current="true" style="--from: 8; --to: 16">        <span class="gantt-label">Ada</span><span class="gantt-bar">08:00 to 16:00</span>      </li>      <li class="gantt-row" style="--from: 16; --to: 24">        <span class="gantt-label">Alan</span><span class="gantt-bar">16:00 to 24:00</span>      </li>    </ol>  </div></template>

#狭いコンテナーでの表示

ガントチャートはサイズコンテナーです。コンテナー自体の幅が26rem未満になると、各項目名がバーの横から上に移り、トラックが横幅いっぱいに広がります。スマートフォンでは目盛りを少なめにします。8目盛りなら読み取れますが、30目盛りでは読み取れません。

#バーの移動

バーにrole="slider"を指定してganttビヘイビアを適用すると、読者がバーを動かせるようになります。バー本体をドラッグすると時間軸に沿って移動し、端をドラッグすると開始または終了の時点を変更できます。バーは時間軸の単位(この例では日)ごとにスナップし、つかんでいる間はバーのテキストに変更後の期間が表示されます。Escapeで元に戻ります。ポインターでできる操作は、すべてキー操作でも行えます。

バーの移動

<div class="card max-w(640) mx-auto">  <ol class="gantt gantt-now" id="sprint" style="--gantt-from: 0; --gantt-to: 12; --gantt-now: 4.5" aria-label="Sprint plan, November 2 to 13">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>2</li>        <li>3</li>        <li>4</li>        <li>5</li>        <li>6</li>        <li>7</li>        <li>8</li>        <li>9</li>        <li>10</li>        <li>11</li>        <li>12</li>        <li>13</li>      </ol>    </li>    <li class="gantt-row" data-value="research" style="--from: 0; --to: 3; --progress: 100">      <span class="gantt-label">Research</span><span class="gantt-bar" role="slider">Nov 2 – 4 · 3 days</span>    </li>    <li class="gantt-row" data-value="design" aria-current="true" style="--from: 2; --to: 6">      <span class="gantt-label">Design</span><span class="gantt-bar" role="slider">Nov 4 – 7 · 4 days</span>    </li>    <li class="gantt-row" data-value="build" style="--from: 5; --to: 10; --progress: 20">      <span class="gantt-label">Build</span><span class="gantt-bar" role="slider">Nov 7 – 11 · 5 days</span>    </li>    <li class="gantt-row" data-value="review" style="--from: 9; --to: 11">      <span class="gantt-label">Review</span><span class="gantt-bar" role="slider">Nov 11 – 12 · 2 days</span>    </li>    <li class="gantt-row" data-value="launch" style="--from: 11">      <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone" role="slider">Nov 13</span>    </li>  </ol>  <p class="gantt-status" role="status"></p></div><script>addEventListener('DOMContentLoaded', function () {var day = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric' })var date = function (offset = 0) { return new Date(2026, 10, 2 + offset) }MasterUI.gantt(document.getElementById('sprint'), {  format: function (start, end) {    if (start === end) return day.format(date(start))    var length = end - start    return day.formatRange(date(start), date(end - 1)) + ' · ' + length + (length === 1 ? ' day' : ' days')  }})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach, gantt } from '@master/ui/behaviors'var day = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric' })var date = function (offset = 0) { return new Date(2026, 10, 2 + offset) }export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => {    const detach = [      attach(root.current!),      gantt(document.getElementById('sprint')!, {        format: function (start, end) {          if (start === end) return day.format(date(start))          var length = end - start          return day.formatRange(date(start), date(end - 1)) + ' · ' + length + (length === 1 ? ' day' : ' days')        }      }),    ]    return () => detach.forEach(stop => stop())  }, [])  return (    <div ref={root} className="card max-w(640) mx-auto">      <ol className="gantt gantt-now" id="sprint" style={{ '--gantt-from': '0', '--gantt-to': '12', '--gantt-now': '4.5' } as React.CSSProperties} aria-label="Sprint plan, November 2 to 13">        <li className="gantt-row gantt-scale" aria-hidden="true">          <ol className="gantt-ticks">            <li>2</li>            <li>3</li>            <li>4</li>            <li>5</li>            <li>6</li>            <li>7</li>            <li>8</li>            <li>9</li>            <li>10</li>            <li>11</li>            <li>12</li>            <li>13</li>          </ol>        </li>        <li className="gantt-row" data-value="research" style={{ '--from': '0', '--to': '3', '--progress': '100' } as React.CSSProperties}>          <span className="gantt-label">Research</span><span className="gantt-bar" role="slider">Nov 2 – 4 · 3 days</span>        </li>        <li className="gantt-row" data-value="design" aria-current="true" style={{ '--from': '2', '--to': '6' } as React.CSSProperties}>          <span className="gantt-label">Design</span><span className="gantt-bar" role="slider">Nov 4 – 7 · 4 days</span>        </li>        <li className="gantt-row" data-value="build" style={{ '--from': '5', '--to': '10', '--progress': '20' } as React.CSSProperties}>          <span className="gantt-label">Build</span><span className="gantt-bar" role="slider">Nov 7 – 11 · 5 days</span>        </li>        <li className="gantt-row" data-value="review" style={{ '--from': '9', '--to': '11' } as React.CSSProperties}>          <span className="gantt-label">Review</span><span className="gantt-bar" role="slider">Nov 11 – 12 · 2 days</span>        </li>        <li className="gantt-row" data-value="launch" style={{ '--from': '11' } as React.CSSProperties}>          <span className="gantt-label">Launch</span><span className="gantt-bar gantt-milestone" role="slider">Nov 13</span>        </li>      </ol>      <p className="gantt-status" role="status"></p>    </div>  )}
<script>  import { attach, gantt } from '@master/ui/behaviors'  var day = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric' })  var date = function (offset = 0) { return new Date(2026, 10, 2 + offset) }  function mounted(root) {    const detach = [      attach(root),      gantt(document.getElementById('sprint'), {        format: function (start, end) {          if (start === end) return day.format(date(start))          var length = end - start          return day.formatRange(date(start), date(end - 1)) + ' · ' + length + (length === 1 ? ' day' : ' days')        }      }),    ]    return () => detach.forEach(stop => stop())  }</script><div class="card max-w(640) mx-auto" {@attach mounted}>  <ol class="gantt gantt-now" id="sprint" style="--gantt-from: 0; --gantt-to: 12; --gantt-now: 4.5" aria-label="Sprint plan, November 2 to 13">    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li>2</li>        <li>3</li>        <li>4</li>        <li>5</li>        <li>6</li>        <li>7</li>        <li>8</li>        <li>9</li>        <li>10</li>        <li>11</li>        <li>12</li>        <li>13</li>      </ol>    </li>    <li class="gantt-row" data-value="research" style="--from: 0; --to: 3; --progress: 100">      <span class="gantt-label">Research</span><span class="gantt-bar" role="slider">Nov 2 – 4 · 3 days</span>    </li>    <li class="gantt-row" data-value="design" aria-current="true" style="--from: 2; --to: 6">      <span class="gantt-label">Design</span><span class="gantt-bar" role="slider">Nov 4 – 7 · 4 days</span>    </li>    <li class="gantt-row" data-value="build" style="--from: 5; --to: 10; --progress: 20">      <span class="gantt-label">Build</span><span class="gantt-bar" role="slider">Nov 7 – 11 · 5 days</span>    </li>    <li class="gantt-row" data-value="review" style="--from: 9; --to: 11">      <span class="gantt-label">Review</span><span class="gantt-bar" role="slider">Nov 11 – 12 · 2 days</span>    </li>    <li class="gantt-row" data-value="launch" style="--from: 11">      <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone" role="slider">Nov 13</span>    </li>  </ol>  <p class="gantt-status" role="status"></p></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach, gantt } from '@master/ui/behaviors'var day = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric' })var date = function (offset = 0) { return new Date(2026, 10, 2 + offset) }const root = ref(null)let detach = []onMounted(() => {  detach = [    attach(root.value),    gantt(document.getElementById('sprint'), {      format: function (start, end) {        if (start === end) return day.format(date(start))        var length = end - start        return day.formatRange(date(start), date(end - 1)) + ' · ' + length + (length === 1 ? ' day' : ' days')      }    }),  ]})onUnmounted(() => detach.forEach(stop => stop()))</script><template>  <div ref="root" class="card max-w(640) mx-auto">    <ol class="gantt gantt-now" id="sprint" style="--gantt-from: 0; --gantt-to: 12; --gantt-now: 4.5" aria-label="Sprint plan, November 2 to 13">      <li class="gantt-row gantt-scale" aria-hidden="true">        <ol class="gantt-ticks">          <li>2</li>          <li>3</li>          <li>4</li>          <li>5</li>          <li>6</li>          <li>7</li>          <li>8</li>          <li>9</li>          <li>10</li>          <li>11</li>          <li>12</li>          <li>13</li>        </ol>      </li>      <li class="gantt-row" data-value="research" style="--from: 0; --to: 3; --progress: 100">        <span class="gantt-label">Research</span><span class="gantt-bar" role="slider">Nov 2 – 4 · 3 days</span>      </li>      <li class="gantt-row" data-value="design" aria-current="true" style="--from: 2; --to: 6">        <span class="gantt-label">Design</span><span class="gantt-bar" role="slider">Nov 4 – 7 · 4 days</span>      </li>      <li class="gantt-row" data-value="build" style="--from: 5; --to: 10; --progress: 20">        <span class="gantt-label">Build</span><span class="gantt-bar" role="slider">Nov 7 – 11 · 5 days</span>      </li>      <li class="gantt-row" data-value="review" style="--from: 9; --to: 11">        <span class="gantt-label">Review</span><span class="gantt-bar" role="slider">Nov 11 – 12 · 2 days</span>      </li>      <li class="gantt-row" data-value="launch" style="--from: 11">        <span class="gantt-label">Launch</span><span class="gantt-bar gantt-milestone" role="slider">Nov 13</span>      </li>    </ol>    <p class="gantt-status" role="status"></p>  </div></template>
バーまたはその端をドラッグします。または、Tabキーでチャートに移動し、ArrowUpとArrowDownでバーを選び、ArrowLeftとArrowRightで移動します。Shiftを押しながらだと終了位置、Alt(Option)を押しながらだと開始位置が動きます。

動かせるバーについて、スタイルシートは次のように描画します。

  • 通常時は、ほかのバーと同じ見た目で、カーソルはつかむ形になります。ホバー時とフォーカス時は両端に短い縦のグリップが表示され、その上ではカーソルがリサイズの矢印に変わります。ホバーのないタッチスクリーンではグリップが常に表示されて幅が広がり、バーの高さは28pxのままです。
  • フォーカス時は、フォーカスリングが周囲の行の上に重ねて描画されます。
  • つかんでいる間はaria-busy="true"になります。バーの色が一段濃くなり、浮き上がりを示す影が付きます。バーはイージングなしでポインターに追従します。ポインターがどこにあっても、カーソルは握った手の形のままか、端をつかんでいる間(gantt-resize-start、gantt-resize-end)はリサイズの矢印のままです。キー操作や外部から設定した値では、バーは新しい位置まで滑らかに移動します。動きを減らす設定では即座に移動します。
  • 読み取り専用(aria-readonly="true")のバーは、フォーカスを受けて読み上げられますが、動きません。無効(aria-disabled="true")のバーは動かず、キー操作でも飛ばされ、テキストは無効状態の文字色になります。

マイルストーンは点として移動し、リサイズする端はありません。

#ビヘイビア

ganttは、ganttクラスを持つルート要素を受け取り、ビヘイビアを解除する関数を返します。動くのはrole="slider"を指定したバーだけで、それ以外のバーは図のままです。動かせる各バーには、スライダーに必要でページ側が省略した情報を書き込みます。行のgantt-labelから名前を、時間軸から最も早い開始と最も遅い終了としてaria-valueminとaria-valuemaxを、開始位置としてaria-valuenowを、期間についてformatが返す文字列としてaria-valuetextを書き込みます。より狭い範囲内にバーを収めるには、バーにaria-valueminとaria-valuemaxを自分で指定します。

app.js
import { gantt } from '@master/ui/behaviors/gantt.js'const plan = gantt(document.querySelector('.gantt'), {  // What a bar says for a range, as its text and to assistive technology.  format: (start, end) => `Days ${start + 1} to ${end}`,})plan.value // { research: [0, 3], design: [2, 6], … }plan.value = { design: [3, 7] }
  • 値は各バーの期間で、時間軸の単位での[start, end]です。キーは行のdata-value、なければラベルのテキストです。マイルストーンの期間は、その点で始まりその点で終わります。値を設定すると外部からバーを動かせます。このときイベントは発行されません。
  • イベント。 バーの期間が変わるたびに、ドラッグ中も含めて、ルートがinputを発行します。ドロップまたはキー操作で期間が変わったときには、changeを一度発行します。
  • ポインター。 押したまま4pxを超えて動かすとドラッグになり、移動が4px以下ならバーにフォーカスするだけです。スタイルシートが両端に描画する幅のグリップを押すとその端が動き、それ以外の場所ではバー全体が動きます。時間軸の1単位は描画されたバーの幅から読み取るため、どのレイアウトでもドラッグはstep単位(既定は1)でスナップします。ページを下方向に動かす指の操作では、引き続きページがスクロールします(touch-action: pan-y)。
  • 制限。 バーはaria-valueminとaria-valuemaxの間に収まり、1ステップより短くなることも、現在の長さより短くなることもありません。
  • 読み上げ。 バーは、ドロップやキー操作で新しい期間が確定した時点で、スライダーが値を伝えるのと同じようにaria-valuetextで新しい期間を伝えます。変更が拒否された、ドラッグが取り消されたなど、値だけでは伝えられないことは、ルートの直後にあるrole="status"のgantt-status領域で伝えます。ページの言語で伝えるにはmessagesを渡します。
  • 右から左に書くページでは、時間軸も、ポインターと矢印キーの向きも右から左になります。ArrowLeftが後の時点に進みます。

ビヘイビアがない場合でも、チャートは項目と日付を読み取れるリストのままです。

#ページ側のルール

依存関係、リソース、稼働日はページ側が管理します。バーが新しい期間を確定する前に、キャンセル可能なbeforechangeイベントが発行されます。イベントには、バーのid、確定しようとしているrange、それまでのpreviousが含まれます。preventDefault()を呼び出すと変更を拒否できます。キー操作では何も起こらず、ドロップではドラッグ開始時の位置に戻り、ステータス領域がバーは動かなかったことを伝えます。この例では、BuildはDesignが終わるまで開始できず、Freezeはリリースチームの管轄なので読み取り専用です。

ページ側のルール

<div class="card max-w(560) mx-auto">  <ol class="gantt" id="release" style="--gantt-from: 0; --gantt-to: 12" aria-label="Release plan, November 2 to 13">    <li class="gantt-row" data-value="design" style="--from: 0; --to: 4">      <span class="gantt-label">Design</span><span class="gantt-bar" role="slider">Nov 2 – 5 · 4 days</span>    </li>    <li class="gantt-row" data-value="build" style="--from: 4; --to: 9">      <span class="gantt-label">Build</span><span class="gantt-bar" role="slider">Nov 6 – 10 · 5 days</span>    </li>    <li class="gantt-row" data-value="freeze" style="--from: 9; --to: 11">      <span class="gantt-label">Freeze</span><span class="gantt-bar" role="slider" aria-readonly="true">Nov 11 – 12 · 2 days</span>    </li>  </ol>  <p class="gantt-status" role="status"></p>  <p class="mb(0) mt-sm text-sm fg-text-muted" id="release-note">    Build starts once Design is done.  </p></div><script>addEventListener('DOMContentLoaded', function () {var day = new Intl.DateTimeFormat('en', { month: 'short', day: 'numeric' })var date = function (offset = 0) { return new Date(2026, 10, 2 + offset) }var root = document.getElementById('release')var note = document.getElementById('release-note')var plan = MasterUI.gantt(root, {  format: function (start, end) {    var length = end - start    return day.formatRange(date(start), date(end - 1)) + ' · ' + length + (length === 1 ? ' day' : ' days')  }})root.addEventListener('beforechange', function (event) {  var ranges = plan.value  ranges[event.detail.id] = event.detail.range  if (ranges.build[0] < ranges.design[1]) {    event.preventDefault()    note.textContent = 'Build starts once Design is done, on ' + day.format(date(ranges.design[1])) + ' at the earliest.'  } else note.textContent = 'Build starts once Design is done.'})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
BuildをDesignの終了より前に、またはDesignをBuildの開始より後にドラッグすると、バーが元に戻ります。
app.js
root.addEventListener('beforechange', (event) => {  const ranges = { ...plan.value, [event.detail.id]: event.detail.range }  if (ranges.build[0] < ranges.design[1]) event.preventDefault()})

イベントはバブリングするため、ルートに登録した1つのリスナーですべてのバーを扱えます。確認が行われるのは、キー操作でバーが動こうとしたときと、ドラッグがドロップされたときで、ドラッグの途中の各ステップでは行われません。そのため読者は、留まることが許されない位置を越えてバーを運べます。

#キーボード操作

キー操作
Tab1 つのバーでチャートに入り、次の操作でチャートから出ます。チャート全体が 1 つのタブストップです。
ArrowUp, ArrowDown上または下のバーに移動します。無効なバーは飛ばします。
ArrowLeft, ArrowRight長さを保ったまま、バーを 1 ステップ前または後ろに移動します。右から左では ArrowLeft が後ろ方向です。
Shift+ArrowLeft, Shift+ArrowRightバーの終点を 1 ステップ動かします。始点との間隔は 1 ステップより短くなりません。
Alt+ArrowLeft, Alt+ArrowRightバーの始点を 1 ステップ動かします(Mac では Option)。
Home, Endバーを取りうる最も早い始点、または最も遅い終点まで移動します。Shift では終点、Alt では始点を動かします。
Escapeバーのドラッグ中に、ドラッグを始めた位置に戻します。

チャートは、ツールバーやツリーと同じく、Tabキーでの移動先が1か所です。項目が何十行あっても、Tabキーで行ごとに止まる必要はありません。行は縦に積み重なっているのでArrowUpとArrowDownでバー間を移動し、時間は横に流れるのでArrowLeftとArrowRightでバーを動かします。矢印キーは図の向きに従います。チャートはグリッドではなくリストのままです。各行で操作できるのはバー1つだけで、グリッドにすると、矢印キーでバーを操作する前にモードを切り替える必要があるためです。

#ガントチャート・タイムライン・チャートの使い分け

開始と終了がある項目にはガントチャートを使います。出来事を発生順に並べるにはタイムライン、時間軸を使わずに数量を比較するにはチャートを使います。

#アクセシビリティ

  • <ol>として記述し、aria-labelまたは見出しで名前を付けます。各行は1つの項目で、「Design、第3週から第6週」のように、項目名、バーのテキストの順に読み上げられます。
  • バー、細い罫線、現在時点を示す線はスタイルシートで描画します。バーが示す開始日と終了日をテキストに記載し、必要に応じて、どの行が現在の項目かも明記します。
  • 現在の行は、色相を使わず、淡い背景に濃いバーを重ねて区別します。強制カラーモードでは、現在の行のバーを塗りつぶし、ほかのバーは輪郭だけを表示します。
  • 動かせるバーは、行の名前を持つスライダーで、その値はページの言葉で表した期間です(例:「Design、スライダー、11月4日〜7日(4日間)」)。formatにはバーのテキストと同じ言葉を渡し、両者が同じ内容を伝えるようにします。
  • gantt-status領域は、最初から空の状態でページに置いておきます。読み上げる時点で追加した領域は、読み上げられないことがよくあります。この領域はスライダー自体の値では伝えられないことだけを伝えるため、同じ内容が二度読み上げられることはありません。
  • ポインターでできる操作は、すべてキー操作でも行えます。ポインターは使えてもドラッグができない読者のために、行から開くダイアログのフィールドなど、ドラッグせずに日付を設定する方法も用意してください。
  • 上のキャプションのように、キー操作でバーを動かす方法をチャートの近くに記載してください。ShiftやAltで端が動くスライダーは、読者が推測できるものではありません。

#React、Svelte、Vue

ganttコンポーネントは、データから行を生成します。各行はid、label、start、endを持ちます(endのない行はマイルストーンです)。各バーの位置とテキストは値{ [id]: [start, end] }から書き出します。時間軸の範囲はfromとto、現在時点はnow、各単位のラベルはticksで指定します。バーの移動中はonValueChange、ドロップ後はonValueCommitで通知し、バーが期間を確定する前にonBeforeChange(Vueでは発行されるbeforeChange)で確認します。npx master-ui add ganttでプロジェクトにコピーできます。コンポーネントの構成と使い方はReact、Svelte、Vueを参照してください。

ui/gantt.tsx
'use client'import { useId, useRef, useState, type ComponentProps, type CSSProperties } from 'react'import { gantt, type GanttChange, type GanttMessages, type GanttRange, type GanttValue } from '@master/ui/behaviors/gantt.js'import { useBehavior } from './use-behavior'export interface GanttRow {  /** What the bar stands for in the value. */  id: string  /** What the row is called; the bar is named by it. */  label: string  /** Where the bar begins, in the scale's unit. */  start: number  /** Where it ends. A row without an end is a milestone, a point at its start. */  end?: number  /** How much of the bar is done, from 0 to 100. */  progress?: number  /** The row that matters now: its bar is ink. */  current?: boolean  /** The bar takes focus and is read, and does not move. */  readOnly?: boolean  /** The bar does not move and the keys pass over it. */  disabled?: boolean  /** The earliest start and the latest end the bar may take. The scale's by default. */  min?: number  max?: number}export interface GanttProps extends Omit<ComponentProps<'ol'>, 'children' | 'defaultValue' | 'onChange' | 'ref'> {  rows: GanttRow[]  /** Where the scale begins and ends, in any unit: days, weeks, hours. */  from: number  to: number  /** Where the line of now stands on the scale; no line without it. */  now?: number  /** The names of the scale's units, one to a unit, drawn over the bars. */  ticks?: string[]  /** Each bar's range, `[start, end]`, keyed by its row's id. The rows' own by default. */  value?: GanttValue  defaultValue?: GanttValue  /** Called as a bar moves, while it is dragged too. */  onValueChange?: (value: GanttValue) => void  /** Called once a drop or a key has changed a bar. */  onValueCommit?: (value: GanttValue) => void  /** Asked before a bar takes a range: call `event.preventDefault()` to refuse it. */  onBeforeChange?: (event: CustomEvent<GanttChange>) => void  /** What a bar says for a range, as its text and to assistive technology. */  format?: (start: number, end: number) => string  /** How far a key moves a bar, and what the pointer snaps to, in the scale's unit. */  step?: number  /** What the status region says, in the page's language. */  messages?: GanttMessages}const plain = (start: number, end: number) => (start === end ? `${start}` : `${start} to ${end}`)/** * A gantt whose bars the reader moves. React writes the rows from its data and each bar's place and text * from the value; the behavior drags and resizes the bars, moves them with the keys and asks * `onBeforeChange` before a bar takes a range. */export function Gantt({ rows, from, to, now, ticks, value, defaultValue, onValueChange, onValueCommit, onBeforeChange, format = plain, step, messages, className, style, ...root }: GanttProps) {  const id = useId()  const [kept, setKept] = useState<GanttValue>(() => value ?? defaultValue ?? {})  const ranges = value ?? kept  const rangeOf = (row: GanttRow): GanttRange => ranges[row.id] ?? [row.start, row.end ?? row.start]  const latest = useRef<GanttValue>({})  latest.current = Object.fromEntries(rows.map(row => [row.id, rangeOf(row)]))  const ref = useBehavior(gantt, { format, step, messages, text: false }, {    value,    defaultValue,    onValueChange: (next: GanttValue) => {      latest.current = next      setKept(next)      onValueChange?.(next)    },    on: {      beforechange: event => onBeforeChange?.(event as CustomEvent<GanttChange>),      change: (event) => { if (event.target === event.currentTarget) onValueCommit?.(latest.current) },    },  })  const stop = rows.find(row => !row.disabled)?.id  const classes = now === undefined ? 'gantt' : 'gantt gantt-now'  return (    <>      <ol className={className ? `${classes} ${className}` : classes} style={{ '--gantt-from': from, '--gantt-to': to, '--gantt-now': now, ...style } as CSSProperties} ref={ref} {...root}>        {ticks && (          <li className="gantt-row gantt-scale" aria-hidden="true">            <ol className="gantt-ticks">{ticks.map((tick, index) => <li key={index}>{tick}</li>)}</ol>          </li>        )}        {rows.map((row, index) => {          const [start, end] = rangeOf(row)          const milestone = row.end === undefined          const words = format(start, end)          return (            <li className="gantt-row" data-value={row.id} key={row.id} aria-current={row.current || undefined} style={{ '--from': start, '--to': milestone ? undefined : end, '--progress': row.progress } as CSSProperties}>              <span className="gantt-label" id={`${id}label${index}`}>{row.label}</span>              <span                className={milestone ? 'gantt-bar gantt-milestone' : 'gantt-bar'}                role="slider"                tabIndex={row.id === stop ? 0 : -1}                aria-labelledby={`${id}label${index}`}                aria-valuemin={row.min ?? from}                aria-valuemax={row.max ?? to}                aria-valuenow={start}                aria-valuetext={words}                aria-readonly={row.readOnly || undefined}                aria-disabled={row.disabled || undefined}              >                {words}              </span>            </li>          )        })}      </ol>      <p className="gantt-status" role="status" />    </>  )}
ui/Gantt.svelte
<script lang="ts" module>  import type { HTMLOlAttributes } from 'svelte/elements'  import type { GanttChange, GanttMessages, GanttValue } from '@master/ui/behaviors/gantt.js'  export interface GanttRow {    /** What the bar stands for in the value. */    id: string    /** What the row is called; the bar is named by it. */    label: string    /** Where the bar begins, in the scale's unit. */    start: number    /** Where it ends. A row without an end is a milestone, a point at its start. */    end?: number    /** How much of the bar is done, from 0 to 100. */    progress?: number    /** The row that matters now: its bar is ink. */    current?: boolean    /** The bar takes focus and is read, and does not move. */    readOnly?: boolean    /** The bar does not move and the keys pass over it. */    disabled?: boolean    /** The earliest start and the latest end the bar may take. The scale's by default. */    min?: number    max?: number  }  export interface GanttProps extends Omit<HTMLOlAttributes, 'children'> {    rows: GanttRow[]    /** Where the scale begins and ends, in any unit: days, weeks, hours. */    from: number    to: number    /** Where the line of now stands on the scale; no line without it. */    now?: number    /** The names of the scale's units, one to a unit, drawn over the bars. */    ticks?: string[]    /** Each bar's range, `[start, end]`, keyed by its row's id. Bind it, or leave it out: the rows' own. */    value?: GanttValue    /** Called as a bar moves, while it is dragged too. */    onValueChange?: (value: GanttValue) => void    /** Called once a drop or a key has changed a bar. */    onValueCommit?: (value: GanttValue) => void    /** Asked before a bar takes a range: call `event.preventDefault()` to refuse it. */    onBeforeChange?: (event: CustomEvent<GanttChange>) => void    /** What a bar says for a range, as its text and to assistive technology. */    format?: (start: number, end: number) => string    /** How far a key moves a bar, and what the pointer snaps to, in the scale's unit. */    step?: number    /** What the status region says, in the page's language. */    messages?: GanttMessages  }</script><script lang="ts">  import { untrack } from 'svelte'  import { gantt } from '@master/ui/behaviors/gantt.js'  import { behavior } from './behavior.svelte.js'  let { rows, from, to, now, ticks, value = $bindable(), onValueChange, onValueCommit, onBeforeChange, format = (start: number, end: number) => (start === end ? `${start}` : `${start} to ${end}`), step, messages, class: className, ...root }: GanttProps = $props()  const id = $props.id()  // The ranges the bars are drawn at: the value given, or the one the reader left them at.  let kept = $state<GanttValue>(untrack(() => value) ?? {})  const ranges = $derived(value ?? kept)  const rangeOf = (row: GanttRow): [number, number] => ranges[row.id] ?? [row.start, row.end ?? row.start]  const stop = $derived(rows.find(row => !row.disabled)?.id)  const attach = behavior(gantt, () => ({ format, step, messages, text: false }), {    value: () => value,    change: (next) => { kept = next; value = next; onValueChange?.(next) },    settled: (held) => { kept = held },    on: {      beforechange: (event) => onBeforeChange?.(event as CustomEvent<GanttChange>),      change: (event) => { if (event.target === event.currentTarget) onValueCommit?.(Object.fromEntries(rows.map(row => [row.id, rangeOf(row)]))) },    },  })</script><!--  @component  A gantt whose bars the reader moves. Svelte writes the rows from its data and each bar's place and text  from the value; the behavior drags and resizes the bars, moves them with the keys and asks  `onBeforeChange` before a bar takes a range.--><ol class={['gantt', now !== undefined && 'gantt-now', className]} style:--gantt-from={from} style:--gantt-to={to} style:--gantt-now={now} {@attach attach} {...root}>  {#if ticks}    <li class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        {#each ticks as tick, index (index)}<li>{tick}</li>{/each}      </ol>    </li>  {/if}  {#each rows as row, index (row.id)}    {@const [start, end] = rangeOf(row)}    {@const words = format(start, end)}    <li class="gantt-row" data-value={row.id} aria-current={row.current || undefined} style:--from={start} style:--to={row.end === undefined ? undefined : end} style:--progress={row.progress}>      <span class="gantt-label" id="{id}-label-{index}">{row.label}</span>      <span        class={['gantt-bar', row.end === undefined && 'gantt-milestone']}        role="slider"        tabindex={row.id === stop ? 0 : -1}        aria-labelledby="{id}-label-{index}"        aria-valuemin={row.min ?? from}        aria-valuemax={row.max ?? to}        aria-valuenow={start}        aria-valuetext={words}        aria-readonly={row.readOnly || undefined}        aria-disabled={row.disabled || undefined}      >{words}</span>    </li>  {/each}</ol><p class="gantt-status" role="status"></p>
ui/Gantt.vue
<script setup lang="ts">import { computed, ref, useId, useTemplateRef } from 'vue'import { gantt, type GanttChange, type GanttMessages, type GanttRange, type GanttValue } from '@master/ui/behaviors/gantt.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })export interface GanttRow {  /** What the bar stands for in the value. */  id: string  /** What the row is called; the bar is named by it. */  label: string  /** Where the bar begins, in the scale's unit. */  start: number  /** Where it ends. A row without an end is a milestone, a point at its start. */  end?: number  /** How much of the bar is done, from 0 to 100. */  progress?: number  /** The row that matters now: its bar is ink. */  current?: boolean  /** The bar takes focus and is read, and does not move. */  readOnly?: boolean  /** The bar does not move and the keys pass over it. */  disabled?: boolean  /** The earliest start and the latest end the bar may take. The scale's by default. */  min?: number  max?: number}const { rows, from, to, now, ticks, format = (start: number, end: number) => (start === end ? `${start}` : `${start} to ${end}`), step, messages } = defineProps<{  rows: GanttRow[]  /** Where the scale begins and ends, in any unit: days, weeks, hours. */  from: number  to: number  /** Where the line of now stands on the scale; no line without it. */  now?: number  /** The names of the scale's units, one to a unit, drawn over the bars. */  ticks?: string[]  /** What a bar says for a range, as its text and to assistive technology. */  format?: (start: number, end: number) => string  /** How far a key moves a bar, and what the pointer snaps to, in the scale's unit. */  step?: number  /** What the status region says, in the page's language. */  messages?: GanttMessages}>()/** Each bar's range, `[start, end]`, keyed by its row's id: `v-model`. The rows' own by default. */const model = defineModel<GanttValue>()const emit = defineEmits<{  /** The ranges, once a drop or a key has changed a bar. */  valueCommit: [value: GanttValue]  /** Asked before a bar takes a range: call `event.preventDefault()` to refuse it. */  beforeChange: [event: CustomEvent<GanttChange>]}>()/* * A gantt whose bars the reader moves. Vue writes the rows from its data and each bar's place and text from * the value; the behavior drags and resizes the bars, moves them with the keys and asks `beforeChange` * before a bar takes a range. */const id = useId()const kept = ref<GanttValue>(model.value ?? {})const ranges = computed(() => model.value ?? kept.value)const rangeOf = (row: GanttRow): GanttRange => ranges.value[row.id] ?? [row.start, row.end ?? row.start]const stop = computed(() => rows.find(row => !row.disabled)?.id)// The ranges the reader leaves: what the model is told, kept here too for an owner that binds no model.const left = computed({  get: () => model.value,  set: (next) => {    kept.value = next ?? {}    model.value = next  },})const root = useTemplateRef<HTMLOListElement>('root')useBehavior(root, gantt, () => ({ format, step, messages, text: false }), left, {  beforechange: event => emit('beforeChange', event as CustomEvent<GanttChange>),  change: (event) => { if (event.target === event.currentTarget) emit('valueCommit', Object.fromEntries(rows.map(row => [row.id, rangeOf(row)]))) },})</script><template>  <ol class="gantt" :class="{ 'gantt-now': now !== undefined }" :style="{ '--gantt-from': from, '--gantt-to': to, '--gantt-now': now }" ref="root" v-bind="$attrs">    <li v-if="ticks" class="gantt-row gantt-scale" aria-hidden="true">      <ol class="gantt-ticks">        <li v-for="(tick, index) in ticks" :key="index">{{ tick }}</li>      </ol>    </li>    <li v-for="(row, index) in rows" :key="row.id" class="gantt-row" :data-value="row.id" :aria-current="row.current || undefined" :style="{ '--from': rangeOf(row)[0], '--to': row.end === undefined ? undefined : rangeOf(row)[1], '--progress': row.progress }">      <span :id="`${id}-label-${index}`" class="gantt-label">{{ row.label }}</span>      <span        class="gantt-bar"        :class="{ 'gantt-milestone': row.end === undefined }"        role="slider"        :tabindex="row.id === stop ? 0 : -1"        :aria-labelledby="`${id}-label-${index}`"        :aria-valuemin="row.min ?? from"        :aria-valuemax="row.max ?? to"        :aria-valuenow="rangeOf(row)[0]"        :aria-valuetext="format(...rangeOf(row))"        :aria-readonly="row.readOnly || undefined"        :aria-disabled="row.disabled || undefined"      >{{ format(...rangeOf(row)) }}</span>    </li>  </ol>  <p class="gantt-status" role="status" /></template>

#クラス

クラス説明
gantt名前とバーを別々の列に並べるリスト。目盛りの範囲は--gantt-fromから--gantt-toまでで、1 単位ごとに細線を表示
gantt-now今日を示すため、--gantt-now の位置に各行を縦に貫くインク色の線を引きます。gantt と併用します
gantt-row1行分の項目です。行のスタイルに --from と --to を設定し、進捗は --progress で指定します。ポインターを重ねるとバーの色が一段濃くなります。コンテナー幅が 26rem 未満の場合は、項目名をバーの上に表示します。
gantt-scale目盛りの単位を示す行。gantt-ticksを含み、トラックはありません。バー自体が日付を伝えている場合は、支援技術からこの行を隠します。gantt-row と併用します
gantt-label行の先頭に置く項目名。1行で表示し、あふれる場合は末尾を省略記号にする
gantt-bar高さ 28px のバーです。--from から --to までをインクの淡色で描き、バー全体のうち --progress で指定した割合を先頭からより濃い色で塗りつぶします。テキストには日付など、バーが表す内容を記載します。role="slider" を付けると動かせるようになり、ポインターで本体をドラッグし、両端のグリップでリサイズできます。タッチ画面ではグリップが常に表示されて幅が広がり、バーの高さは 28px のままです。
gantt-milestone一点の時刻を示すため、--from の位置にインク色の小さなひし形を表示します。テキストは支援技術向けに残します。gantt-bar と併用します
gantt-resize-startポインターがバーの始点をつかんでいる間、ビヘイビアが設定します。グリップがはっきり表示され、ポインターがどこにあってもカーソルはリサイズ用になります。gantt-bar と併用します
gantt-resize-endポインターがバーの終点をつかんでいる間、ビヘイビアが設定しますgantt-bar と併用します
gantt-ticksgantt-scale内に置く目盛りの単位名。1 単位につき 1 項目
gantt-statusチャートの直後に置く領域で、バーの値では伝えられない情報、たとえば変更が拒否されたことやドラッグが取り消されたことを伝えます。スペースは占めません。

#カスタムプロパティ

プロパティ既定値説明
--gantt-from0目盛りの開始値
--gantt-to12目盛りの終了値
--gantt-now0目盛り上での gantt-now の線の位置
--from行のバーの開始位置で、目盛りの単位で指定します。バーが動くとビヘイビアが書き込みます。指定先:gantt-row
--to行のバーの終了位置です。バーが移動またはリサイズされるとビヘイビアが書き込みます。指定先:gantt-row
--progressバー全体に対する進捗の割合。0 から 100 の数値で指定します。指定先:gantt-row
--gantt-gap.375rem行間隔
--gantt-colorvar(--color-surface-inverse)バーの淡色の元になるインク色

#ソース

@master/ui/components/gantt.css
/* * Gantt: things that last, as bars on one scale of time. * It is a list. The scale runs from --gantt-from to --gantt-to, in any unit: days, weeks, hours. Each row * carries where its bar begins and ends as --from and --to, its name in gantt-label and what the bar says as * the text of gantt-bar, so the list reads as data to anyone who is not looking at it. The stylesheet does the * placing: names in one column, bars in the other, a hairline at every unit of the scale. * A bar is a tint of ink, 28px tall, and fills with a firmer tint as far as --progress percent. The row * marked aria-current has an ink bar. A milestone is a point, not a span: a small ink diamond at --from. * gantt-now draws an ink line down the rows at --gantt-now. * In a narrow container the name stands over its bar instead of beside it. * A bar the reader moves is one the page marks role="slider"; the behavior then writes --from and --to as it * is dragged or moved with the keys. Such a bar shows a grab cursor, a grip at each end on hover and focus * (always on a touch screen, where they are wider too), and the focus ring. Held, it says aria-busy: it lifts * with the lifted shadow and a firmer tint, and follows the pointer at once, while a key or a value set from * outside glides it to its place. gantt-resize-start and gantt-resize-end mark the end the pointer holds, so * the cursor resizes wherever the pointer goes. A read-only or disabled bar has none of this. */@layer components.ui {  .gantt {    --gantt-from: 0;    --gantt-to: 12;    --gantt-now: 0;    --gantt-gap: .375rem;    --gantt-color: var(--color-surface-inverse);    --gantt-span: calc(var(--gantt-to) - var(--gantt-from));    container-type: inline-size;    display: grid;    grid-template-columns: auto minmax(0, 1fr);    gap: var(--gantt-gap) 1rem;    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-body);    font: 400 .8125rem/1.25rem var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    list-style: none;    /* The bars, the line of now and a held bar stack inside the chart, never over a sticky header beside it. */    isolation: isolate;    /*     * The line of now: drawn in every row, so it runs the height of the chart. It passes under the bars, as a     * schedule's passes under its events, so it never strikes through their words.     */    &.gantt-now .gantt-row:not(.gantt-scale)::after {      content: '';      z-index: 0;      grid-area: 1 / 2;      align-self: stretch;      justify-self: start;      width: 1px;      margin-block: calc(var(--gantt-gap) / -2);      margin-inline-start: calc((var(--gantt-now) - var(--gantt-from)) / var(--gantt-span) * 100% - .5px);      background: var(--color-text-strong);      pointer-events: none;    }    /* While a bar is held, the cursor stays what it was at the press, wherever the pointer goes. */    &:has(.gantt-bar[aria-busy="true"]) {      cursor: grabbing;      user-select: none;      -webkit-user-select: none;    }    &:has(.gantt-resize-start, .gantt-resize-end) {      cursor: ew-resize;    }    /* Under the pointer a row's bar is a step firmer and its name takes the strong ink, at once. */    @media (hover: hover) {      .gantt-row:not([aria-current="true"]):hover {        .gantt-bar {          --gantt-tint: color-mix(in oklab, var(--gantt-color) 16%, transparent);          --gantt-done: color-mix(in oklab, var(--gantt-color) 30%, transparent);        }        .gantt-label {          color: var(--color-text-strong);        }      }    }    @container (width < 26rem) {      .gantt-row {        grid-template-columns: minmax(0, 1fr);        row-gap: .125rem;      }      .gantt-label {        grid-area: 1 / 1;        max-width: none;      }      .gantt-row::before, .gantt-bar, .gantt-ticks {        grid-area: 2 / 1;      }      &.gantt-now .gantt-row:not(.gantt-scale)::after {        grid-area: 2 / 1;      }      .gantt-scale .gantt-ticks {        grid-area: 1 / 1;      }    }    @media (forced-colors: active) {      --gantt-color: CanvasText;      /* The line of now is a fill, which forced colors would otherwise paint as the canvas. */      &.gantt-now .gantt-row:not(.gantt-scale)::after {        forced-color-adjust: none;        background: CanvasText;      }    }  }  /* One row: the name in the first column, and the track with its bar in the second. */  .gantt-row {    display: grid;    grid-column: 1 / -1;    grid-template-columns: subgrid;    align-items: center;    min-width: 0;    min-height: 1.75rem;    margin: 0;    padding: 0;    /* A row the page filters out is hidden, as the behavior expects: the grid above would otherwise beat [hidden]. */    &[hidden] {      display: none;    }    /* The scale behind the bar: a hairline at each unit, joined to the row above and below. */    &::before {      content: '';      grid-area: 1 / 2;      align-self: stretch;      margin-block: calc(var(--gantt-gap) / -2);      background: repeating-linear-gradient(90deg, var(--color-line-hair) 0 1px, transparent 1px calc(100% / var(--gantt-span)));      box-shadow: 1px 0 0 var(--color-line-hair);      pointer-events: none;    }    /* Where the scale runs from the right, so do its hairlines, and the closing one is at the left. */    &:dir(rtl)::before {      background: repeating-linear-gradient(270deg, var(--color-line-hair) 0 1px, transparent 1px calc(100% / var(--gantt-span)));      box-shadow: -1px 0 0 var(--color-line-hair);    }    /* The hairlines are a gradient and a shadow, which forced colors drop: kept, in the system's gray. */    @media (forced-colors: active) {      &::before {        forced-color-adjust: none;        background: repeating-linear-gradient(90deg, GrayText 0 1px, transparent 1px calc(100% / var(--gantt-span)));        box-shadow: 1px 0 0 GrayText;      }      &:dir(rtl)::before {        background: repeating-linear-gradient(270deg, GrayText 0 1px, transparent 1px calc(100% / var(--gantt-span)));        box-shadow: -1px 0 0 GrayText;      }    }    /* The row that matters now: its bar is ink. */    &[aria-current="true"] {      .gantt-bar {        background: var(--gantt-color);        color: var(--color-text-inverse);        box-shadow: var(--shadow-ink-top);      }      .gantt-label {        color: var(--color-text-strong);      }    }    /* The row of the scale itself: its names, and no track of its own. */    &.gantt-scale {      min-height: 1.25rem;      &::before {        content: none;      }    }  }  /* What the row is. */  .gantt-label {    grid-area: 1 / 1;    max-width: 10rem;    overflow: hidden;    text-overflow: ellipsis;    white-space: nowrap;  }  /* The bar: from --from to --to of the scale, filled as far as --progress percent. Its text is what it says. */  .gantt-bar {    --gantt-tint: color-mix(in oklab, var(--gantt-color) 10%, transparent);    --gantt-done: color-mix(in oklab, var(--gantt-color) 22%, transparent);    z-index: 1;    grid-area: 1 / 2;    box-sizing: border-box;    width: calc((var(--to, 1) - var(--from, 0)) / var(--gantt-span) * 100%);    min-width: .25rem;    height: 1.75rem;    margin-inline-start: calc((var(--from, 0) - var(--gantt-from)) / var(--gantt-span) * 100%);    padding: .25rem .5rem;    border-radius: calc(var(--radius-chip) * var(--corner-scale));    corner-shape: var(--corner-shape);    overflow: hidden;    background: linear-gradient(90deg, var(--gantt-done) calc(var(--progress, 0) * 1%), var(--gantt-tint) 0);    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    font-size: .78125rem;    text-overflow: ellipsis;    white-space: nowrap;    /* A bar answers the pointer and is not a line to select. */    cursor: default;    &:dir(rtl) {      background-image: linear-gradient(270deg, var(--gantt-done) calc(var(--progress, 0) * 1%), var(--gantt-tint) 0);    }    /* A bar the reader moves: one stop in the tab order for the whole chart, with the focus ring above the rows. */    &[role="slider"] {      position: relative;      &:focus-visible {        z-index: 3;        @apply --focus-ring;      }    }    &[role="slider"]:not([aria-readonly="true"], [aria-disabled="true"]) {      cursor: grab;      /* A finger that moves along the bar drags it; one that moves down the page still scrolls it. */      touch-action: pan-y;      user-select: none;      -webkit-user-select: none;      -webkit-tap-highlight-color: transparent;      /* A key or a value set from outside glides the bar to its place; the pointer moves it at once. */      transition-property: margin-inline-start, width;      transition-duration: var(--duration-quick);      transition-timing-function: var(--easing-glide);      /* The grips: an end of the bar is where the pointer resizes it, marked with a short upright line. */      &::before, &::after {        content: '';        position: absolute;        inset-block: 0;        width: min(.5rem, 30%);        background: linear-gradient(currentColor 0 0) center / 2px .75rem no-repeat;        opacity: 0;        cursor: ew-resize;        transition: opacity var(--duration-quick) var(--easing-glide);      }      &::before {        inset-inline-start: 0;      }      &::after {        inset-inline-end: 0;      }      @media (hover: hover) {        &:hover::before, &:hover::after {          opacity: .45;        }      }      &:focus-visible::before, &:focus-visible::after, &[aria-busy="true"]::before, &[aria-busy="true"]::after {        opacity: .45;      }      /* A milestone is a point: it moves, and has no ends to resize. */      &.gantt-milestone {        &::before, &::after {          content: none;        }      }      /* Held: it lifts above the rows on a firmer tint, and follows the pointer with no easing. */      &[aria-busy="true"] {        --gantt-tint: color-mix(in oklab, var(--gantt-color) 16%, transparent);        --gantt-done: color-mix(in oklab, var(--gantt-color) 30%, transparent);        z-index: 3;        box-shadow: var(--shadow-lifted);        cursor: grabbing;        transition-property: none;      }      /* The end the pointer holds: its grip is firm and the cursor resizes. */      &.gantt-resize-start, &.gantt-resize-end {        cursor: ew-resize;      }      &.gantt-resize-start::before, &.gantt-resize-end::after {        opacity: 1;      }      /*       * A touch screen has no hover to show the grips, so they stay, and wider for a finger. The bar keeps its       * 28px: the rows stand too close for a target to reach past it, and 28px is more than a finger is owed.       */      @media (pointer: coarse) {        &::before, &::after {          width: min(.75rem, 30%);          opacity: .45;        }      }      @media (prefers-reduced-motion: reduce) {        transition-property: none;        &::before, &::after {          transition: none;        }      }    }    /* A disabled bar is drawn in the disabled ink; a read-only one looks as any bar does. */    &[aria-disabled="true"] {      color: var(--color-text-disabled);    }    /* A milestone: a point in time, drawn as a diamond on it. Its text is kept for assistive technology. */    &.gantt-milestone {      width: .75rem;      min-width: 0;      height: .75rem;      margin-inline-start: calc((var(--from, 0) - var(--gantt-from)) / var(--gantt-span) * 100% - .375rem);      padding: 0;      border-radius: 2px;      corner-shape: round;      background: var(--gantt-color);      color: transparent;      font-size: 0;      rotate: 45deg;    }    /* The canvas goes under the fill, so the part already done still shows, in either direction. */    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;      forced-color-adjust: none;      background-color: Canvas;      color: CanvasText;      &.gantt-milestone {        background: CanvasText;      }      /* A disabled bar takes the system's disabled ink, which the adjustment above would otherwise lose. */      &[aria-disabled="true"] {        outline-color: GrayText;        color: GrayText;      }      /* The current row's bar is the system's highlight, as a schedule's current event is, with its text for the words. */      .gantt-row[aria-current="true"] & {        background: Highlight;        color: HighlightText;      }      &[role="slider"]:focus-visible, &[aria-busy="true"] {        outline: 2px solid Highlight;        outline-offset: 2px;      }    }  }  /* The names of the scale's units, one to a unit, each over the hairline that begins it. */  .gantt-ticks {    display: grid;    grid-area: 1 / 2;    grid-auto-columns: minmax(0, 1fr);    grid-auto-flow: column;    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-muted);    font-size: .71875rem;    line-height: 1.25rem;    list-style: none;    white-space: nowrap;  }  /* What the status region says is for assistive technology: it takes no room. */  .gantt-status {    position: absolute;    width: 1px;    height: 1px;    margin: -1px;    padding: 0;    overflow: hidden;    clip-path: inset(50%);    white-space: nowrap;  }}