ナビゲーション

v2.1.0
時間による変化

面グラフ

折れ線の下を同系色で塗り、単独で表示したり、積み上げて合計を示したりします。

このページの内容

面グラフでは、折れ線の下を同じ色で塗り、下に向かって徐々に色を薄くします。1〜2 系列を強調したいときに適しています。系列が増えると塗りが重なるため、折れ線グラフのほうが読み取りやすくなります。

面グラフ

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Requests</h3>    <p class="card-description">Millions per month, by region</p>  </div>  <figure class="chart" id="requests"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('requests'), {  type: 'area',  label: 'Requests per month by region, in millions',  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],  series: [    { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] },    { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] }  ]})})</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">Requests</h3>    <p className="card-description">Millions per month, by region</p>  </div>  <Chart    id="requests"    type="area"    label="Requests per month by region, in millions"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] },      { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] }    ]}  /></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">Requests</h3>    <p class="card-description">Millions per month, by region</p>  </div>  <Chart    id="requests"    type="area"    label="Requests per month by region, in millions"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] },      { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] }    ]}  /></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">Requests</h3>      <p class="card-description">Millions per month, by region</p>    </div>    <Chart      id="requests"      type="area"      label="Requests per month by region, in millions"      :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"      :series="[        { name: 'Tokyo', values: [32, 36, 34, 41, 46, 44, 52, 56, 54, 61, 68, 72] },        { name: 'Frankfurt', values: [12, 14, 18, 17, 22, 26, 25, 30, 34, 33, 39, 42] }      ]"    />  </div></template>
月にポインターを合わせるか、Tab キーと矢印キーで移動すると、その月の値を確認できます。凡例の項目を操作すると、対応する系列を非表示にできます。

#積み上げ

各系列が合計の内訳を表す場合は、stacked を設定します。各層を直前の層の上に重ね、最上部の輪郭で合計を示します。各層はそれぞれの色の淡い単色で塗ります。

積み上げ面グラフ

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Visits</h3>    <p class="card-description">Thousands per month, by source</p>  </div>  <figure class="chart" id="visits"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('visits'), {  type: 'area',  stacked: true,  label: 'Visits per month by source, in thousands',  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],  series: [    { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] },    { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] },    { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] }  ]})})</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">Visits</h3>    <p className="card-description">Thousands per month, by source</p>  </div>  <Chart    id="visits"    type="area"    stacked    label="Visits per month by source, in thousands"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] },      { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] },      { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] }    ]}  /></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">Visits</h3>    <p class="card-description">Thousands per month, by source</p>  </div>  <Chart    id="visits"    type="area"    stacked    label="Visits per month by source, in thousands"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] },      { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] },      { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] }    ]}  /></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">Visits</h3>      <p class="card-description">Thousands per month, by source</p>    </div>    <Chart      id="visits"      type="area"      stacked      label="Visits per month by source, in thousands"      :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"      :series="[        { name: 'Direct', values: [120, 130, 125, 150, 160, 155, 170, 180, 175, 190, 210, 220] },        { name: 'Search', values: [80, 95, 110, 105, 130, 150, 145, 160, 185, 180, 200, 230] },        { name: 'Social', values: [40, 45, 60, 55, 70, 65, 90, 85, 100, 120, 110, 140] }      ]"    />  </div></template>

#ストリームグラフ

stacked: 'stream' を設定すると、基準線から上に積み上げる代わりに、中央線を中心に面を積み上げます。下の層の変動に各層の位置が左右されなくなるため、各位置で層の厚みを読み取れ、全体の膨らみや細まりも把握できます。ストリームグラフには目盛りがなく、値表示で各層の値を確認できます。

ストリームグラフ

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Listening</h3>    <p class="card-description">Hours a month by genre</p>  </div>  <figure class="chart" id="genres"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('genres'), {  type: 'area',  stacked: 'stream',  label: 'Listening hours a month by genre',  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],  series: [    { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] },    { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] },    { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] },    { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] }  ]})})</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">Listening</h3>    <p className="card-description">Hours a month by genre</p>  </div>  <Chart    id="genres"    type="area"    stacked="stream"    label="Listening hours a month by genre"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] },      { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] },      { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] },      { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] }    ]}  /></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">Listening</h3>    <p class="card-description">Hours a month by genre</p>  </div>  <Chart    id="genres"    type="area"    stacked="stream"    label="Listening hours a month by genre"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[      { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] },      { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] },      { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] },      { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] }    ]}  /></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">Listening</h3>      <p class="card-description">Hours a month by genre</p>    </div>    <Chart      id="genres"      type="area"      stacked="stream"      label="Listening hours a month by genre"      :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"      :series="[        { name: 'Rock', values: [20, 24, 30, 28, 22, 18, 16, 20, 26, 30, 34, 30] },        { name: 'Jazz', values: [10, 12, 11, 16, 22, 26, 24, 20, 16, 12, 10, 12] },        { name: 'Pop', values: [14, 12, 16, 20, 24, 30, 36, 32, 26, 20, 16, 18] },        { name: 'Folk', values: [6, 8, 7, 6, 8, 10, 12, 14, 12, 9, 7, 6] }      ]"    />  </div></template>

stacked: 'percent' を設定すると、各位置の合計が 100% になります。層全体が 0% から 100% まで描画領域を埋め、各層の割合を読み取れます。

#単一系列

系列が 1 つの場合は前景色で描画します。系列に category を指定した場合のみ、そのカテゴリの色を使います。

単一系列

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Revenue</h3>    <p class="card-description">Dollars per month, this year</p>  </div>  <figure class="chart" id="revenue"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('revenue'), {  type: 'area',  label: 'Revenue per month, in dollars',  labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],  series: [{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }],  format: function (value) { return '$' + value.toLocaleString('en-US') }})})</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">Revenue</h3>    <p className="card-description">Dollars per month, this year</p>  </div>  <Chart    id="revenue"    type="area"    label="Revenue per month, in dollars"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]}    format={function (value) { return '$' + value.toLocaleString('en-US') }}  /></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">Revenue</h3>    <p class="card-description">Dollars per month, this year</p>  </div>  <Chart    id="revenue"    type="area"    label="Revenue per month, in dollars"    labels={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}    series={[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]}    format={function (value) { return '$' + value.toLocaleString('en-US') }}  /></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">Revenue</h3>      <p class="card-description">Dollars per month, this year</p>    </div>    <Chart      id="revenue"      type="area"      label="Revenue per month, in dollars"      :labels="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']"      :series="[{ name: 'Revenue', values: [2100, 2400, 2250, 2900, 3300, 3150, 3700, 4100, 3950, 4600, 5200, 5600] }]"      :format="function (value) { return '$' + value.toLocaleString('en-US') }"    />  </div></template>

#オプション

オプション既定
labelなしグラフが示す内容と単位。描画領域のアクセシブル名になります
labels[]軸に沿って、レーダーチャートの周囲に、またはヒートマップの各列の上に表示する名前
series[]各系列に name と、グラフ形式に応じた values、value、points、ranges、children のいずれかを指定します。category、type、low と high、リングの max は任意です
stackedfalse棒や面を積み上げます。'percent' は各積み上げの合計を 100% にし、'stream' は積み上げた面を中央線の周りに配置します
curve'smooth'smooth、linear、step のいずれか
min, max, ticksデータに合わせる、4軸の両端の値と目盛りの目安となる数。散布図の横軸には xMin、xMax、xTicks を使います
format, tickFormatロケールに従う値と目盛りの表示形式。散布図の横軸には xFormat を使います
legend, toggle2 系列の場合に表示、true凡例を表示するか、凡例の項目をチェックボックスにするか

値表示、キー操作、凡例、色、目盛りは、どのグラフ形式でも共通です。すべてのオプション、CSS クラス、カスタムプロパティは チャート を参照してください。