時間による変化
折れ線グラフ
連続する値を、点と点を結ぶ線で表します。
このページの内容
折れ線は、月ごとのレイテンシーや日ごとの価格など、連続する値の推移を表します。グラフに棒がなければ、線はプロット領域の端から端まで伸びます。ポインターを重ねると、対応するデータ位置を細い線で示し、その位置での各系列の値を点で示します。
折れ線
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Latency</h3> <p class="card-description">Median by region, in milliseconds</p> </div> <figure class="chart" id="latency"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('latency'), { type: 'line', label: 'Median latency per month by region, in milliseconds', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [ { name: 'Tokyo', values: [42, 44, 41, 47, 52, 49, 46, 44, 48, 53, 51, 47] }, { name: 'Frankfurt', values: [61, 58, 63, 66, 62, 59, 57, 60, 64, 69, 66, 61] }, { name: 'Virginia', values: [78, 74, 71, 75, 80, 86, 83, 79, 76, 81, 85, 82] } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Latency</h3> <p className="card-description">Median by region, in milliseconds</p> </div> <Chart id="latency" type="line" label="Median latency per month by region, in milliseconds" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Tokyo', values: [42, 44, 41, 47, 52, 49, 46, 44, 48, 53, 51, 47] }, { name: 'Frankfurt', values: [61, 58, 63, 66, 62, 59, 57, 60, 64, 69, 66, 61] }, { name: 'Virginia', values: [78, 74, 71, 75, 80, 86, 83, 79, 76, 81, 85, 82] } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Latency</h3> <p class="card-description">Median by region, in milliseconds</p> </div> <Chart id="latency" type="line" label="Median latency per month by region, in milliseconds" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[ { name: 'Tokyo', values: [42, 44, 41, 47, 52, 49, 46, 44, 48, 53, 51, 47] }, { name: 'Frankfurt', values: [61, 58, 63, 66, 62, 59, 57, 60, 64, 69, 66, 61] }, { name: 'Virginia', values: [78, 74, 71, 75, 80, 86, 83, 79, 76, 81, 85, 82] } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Latency</h3> <p class="card-description">Median by region, in milliseconds</p> </div> <Chart id="latency" type="line" label="Median latency per month by region, in milliseconds" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[ { name: 'Tokyo', values: [42, 44, 41, 47, 52, 49, 46, 44, 48, 53, 51, 47] }, { name: 'Frankfurt', values: [61, 58, 63, 66, 62, 59, 57, 60, 64, 69, 66, 61] }, { name: 'Virginia', values: [78, 74, 71, 75, 80, 86, 83, 79, 76, 81, 85, 82] } ]" /> </div></template>#曲線
curve は点と点の結び方を指定します。既定の smooth は、隣り合う点の値の範囲を超えないように滑らかな曲線を描きます。linear は直線で結びます。step は次の点まで値を一定に保つので、プランの利用枠数や価格など、ある時点で値が切り替わるデータに適しています。
ステップ
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Seats</h3> <p class="card-description">On the plan, this year</p> </div> <figure class="chart" id="seats" style="--chart-height: 11rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('seats'), { type: 'line', curve: 'step', label: 'Seats on the plan per month', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [{ name: 'Seats', values: [12, 12, 12, 20, 20, 20, 20, 32, 32, 32, 40, 40] }], max: 40})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Seats</h3> <p className="card-description">On the plan, this year</p> </div> <Chart id="seats" style={{ '--chart-height': '11rem' } as React.CSSProperties} type="line" curve="step" label="Seats on the plan per month" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Seats', values: [12, 12, 12, 20, 20, 20, 20, 32, 32, 32, 40, 40] }]} max={40} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Seats</h3> <p class="card-description">On the plan, this year</p> </div> <Chart id="seats" style="--chart-height: 11rem" type="line" curve="step" label="Seats on the plan per month" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Seats', values: [12, 12, 12, 20, 20, 20, 20, 32, 32, 32, 40, 40] }]} max={40} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Seats</h3> <p class="card-description">On the plan, this year</p> </div> <Chart id="seats" style="--chart-height: 11rem" type="line" curve="step" label="Seats on the plan per month" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[{ name: 'Seats', values: [12, 12, 12, 20, 20, 20, 20, 32, 32, 32, 40, 40] }]" :max="40" /> </div></template>#欠損と点
値が null の箇所では線が途切れ、その位置の値表示には値がある系列だけが表示されます。dots: true を指定すると、ポインターを重ねた点に加え、折れ線上のすべての点に印が付きます。点の少ない折れ線に使います。
欠損と点
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Uptime</h3> <p class="card-description">Percent per month; no reading in May</p> </div> <figure class="chart" id="uptime" style="--chart-height: 11rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('uptime'), { type: 'line', curve: 'linear', dots: true, min: 99, max: 100, label: 'Uptime per month, in percent', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug'], series: [{ name: 'Uptime', values: [99.92, 99.97, 99.81, 99.95, null, 99.64, 99.9, 99.98] }], format: function (value) { return value + '%' }})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Uptime</h3> <p className="card-description">Percent per month; no reading in May</p> </div> <Chart id="uptime" style={{ '--chart-height': '11rem' } as React.CSSProperties} type="line" curve="linear" dots min={99} max={100} label="Uptime per month, in percent" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']} series={[{ name: 'Uptime', values: [99.92, 99.97, 99.81, 99.95, null, 99.64, 99.9, 99.98] }]} format={function (value) { return value + '%' }} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Uptime</h3> <p class="card-description">Percent per month; no reading in May</p> </div> <Chart id="uptime" style="--chart-height: 11rem" type="line" curve="linear" dots min={99} max={100} label="Uptime per month, in percent" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']} series={[{ name: 'Uptime', values: [99.92, 99.97, 99.81, 99.95, null, 99.64, 99.9, 99.98] }]} format={function (value) { return value + '%' }} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Uptime</h3> <p class="card-description">Percent per month; no reading in May</p> </div> <Chart id="uptime" style="--chart-height: 11rem" type="line" curve="linear" dots :min="99" :max="100" label="Uptime per month, in percent" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug']" :series="[{ name: 'Uptime', values: [99.92, 99.97, 99.81, 99.95, null, 99.64, 99.9, 99.98] }]" :format="function (value) { return value + '%' }" /> </div></template>#値の範囲
系列の各ラベルに low と high を1つずつ指定すると、予測の幅や2回の実行結果のばらつきなど、値が取りうる範囲を示せます。この範囲は折れ線の背後に線と同系色の淡い帯で描かれ、値表示では値に続けて表示されます。
帯
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">Thousands per month, with the range the forecast allows</p> </div> <figure class="chart" id="forecast"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('forecast'), { type: 'line', label: 'Sessions per month with the range of the forecast, in thousands', labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], series: [{ name: 'Sessions', values: [320, 360, 340, 410, 460, 440, 520, 560, 540, 610, 680, 720], low: [300, 335, 310, 370, 410, 385, 450, 470, 440, 490, 540, 560], high: [340, 385, 372, 452, 512, 498, 592, 650, 640, 730, 820, 880] }]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto"> <div className="card-header"> <h3 className="card-title">Sessions</h3> <p className="card-description">Thousands per month, with the range the forecast allows</p> </div> <Chart id="forecast" type="line" label="Sessions per month with the range of the forecast, in thousands" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Sessions', values: [320, 360, 340, 410, 460, 440, 520, 560, 540, 610, 680, 720], low: [300, 335, 310, 370, 410, 385, 450, 470, 440, 490, 540, 560], high: [340, 385, 372, 452, 512, 498, 592, 650, 640, 730, 820, 880] }]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">Thousands per month, with the range the forecast allows</p> </div> <Chart id="forecast" type="line" label="Sessions per month with the range of the forecast, in thousands" labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']} series={[{ name: 'Sessions', values: [320, 360, 340, 410, 460, 440, 520, 560, 540, 610, 680, 720], low: [300, 335, 310, 370, 410, 385, 450, 470, 440, 490, 540, 560], high: [340, 385, 372, 452, 512, 498, 592, 650, 640, 730, 820, 880] }]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">Thousands per month, with the range the forecast allows</p> </div> <Chart id="forecast" type="line" label="Sessions per month with the range of the forecast, in thousands" :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']" :series="[{ name: 'Sessions', values: [320, 360, 340, 410, 460, 440, 520, 560, 540, 610, 680, 720], low: [300, 335, 310, 370, 410, 385, 450, 470, 440, 490, 540, 560], high: [340, 385, 372, 452, 512, 498, 592, 650, 640, 730, 820, 880] }]" /> </div></template>#棒に重ねる折れ線
棒グラフで type: 'line' を指定した系列は、棒と同じ目盛りを使って折れ線として重ねて描画されます。目標値や移動平均を示すのに使えます。
#オプション
| オプション | 既定値 | |
|---|---|---|
label | なし | グラフが何をどの単位で示すかを伝える、プロットのアクセシブルな名前 |
labels | [] | 目盛りに沿って、レーダーチャートの周囲に、またはヒートマップの列の上に並ぶ名前 |
series | [] | 各系列に name と、グラフ形式に応じて values、単一の value、points、ranges、children のいずれかを指定。category、type、low と high、リングの max は任意 |
curve | 'smooth' | smooth、linear、step のいずれか |
min, max, ticks | データに合わせる、4 | 目盛りの下限と上限、およその目盛り数。散布図の横軸には xMin、xMax、xTicks を使用 |
format, tickFormat | ロケールに従う | 値と目盛りの表示形式。散布図の横軸には xFormat を使用 |
dots, values | false | 折れ線のすべての点に印を付けるか、各棒の値を表示するか |
legend, toggle | 2系列の場合、true | 凡例を表示するか、凡例の各項目をチェックボックスにするか |
値表示、キー操作、凡例、色、目盛りはすべてのグラフ形式で共通です。チャートに、すべてのオプション、クラス、カスタムプロパティとあわせて記載しています。