ナビゲーション

v2.1.0
関係

散布図

1つの対象を1つの点で表し、2つの指標の関係を示します。

このページの内容

散布図は2つの指標の関係を示します。各点は1つの対象を表し、xとyで位置が決まります。両軸の範囲は、すべての点が収まるように切りのよい数値で区切られ、0の近くに点がある場合に限り0から始まります。範囲を固定するには、xMin、xMax、min、maxを指定します。ポインターは点の周囲でも反応し、その点のlabelが値の表示の見出しになります。

散布図

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Responses</h3>    <p class="card-description">Time in milliseconds against size in kilobytes</p>  </div>  <figure class="chart" id="responses"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('responses'), {  type: 'scatter',  label: 'Response time in milliseconds against size in kilobytes',  series: [    { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) },    { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }  ]})})</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">Responses</h3>    <p className="card-description">Time in milliseconds against size in kilobytes</p>  </div>  <Chart    id="responses"    type="scatter"    label="Response time in milliseconds against size in kilobytes"    series={[      { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) },      { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }    ]}  /></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">Responses</h3>    <p class="card-description">Time in milliseconds against size in kilobytes</p>  </div>  <Chart    id="responses"    type="scatter"    label="Response time in milliseconds against size in kilobytes"    series={[      { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) },      { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }    ]}  /></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">Responses</h3>      <p class="card-description">Time in milliseconds against size in kilobytes</p>    </div>    <Chart      id="responses"      type="scatter"      label="Response time in milliseconds against size in kilobytes"      :series="[        { name: 'API', points: [[12, 38], [18, 52], [25, 61], [31, 70], [38, 96], [44, 88], [52, 120], [60, 131], [66, 150], [74, 142], [81, 171]].map(function (pair) { return { x: pair[0], y: pair[1] } }) },        { name: 'Pages', points: [[20, 160], [28, 150], [35, 175], [47, 190], [55, 168], [63, 210], [72, 224], [80, 205], [88, 240]].map(function (pair) { return { x: pair[0], y: pair[1] } }) }      ]"    />  </div></template>

#バブル

sizeを持つ点はバブルになり、3つ目の指標を点の面積で表します。サイズに比例するのは面積なので、値が4倍なら面積も4倍になります。バブルは同じ色の輪郭と半透明の塗りで描画されるため、重なった部分も透けて見えます。大きいものから順に描画されるため、大きなバブルに重なった小さなバブルにもポインターを合わせられます。

バブル

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Markets</h3>    <p class="card-description">Growth against share; a bubble is as large as its revenue</p>  </div>  <figure class="chart" id="markets"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('markets'), {  type: 'scatter',  label: 'Markets: growth in percent against share in percent, sized by revenue in millions',  series: [{    name: 'Markets',    points: [      { x: 4, y: 12, size: 40, label: 'Japan' },      { x: 9, y: 20, size: 120, label: 'Germany' },      { x: 14, y: 8, size: 20, label: 'Brazil' },      { x: 18, y: 26, size: 260, label: 'United States' },      { x: 6, y: 30, size: 64, label: 'India' },      { x: 12, y: 16, size: 90, label: 'France' }    ]  }]})})</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">Markets</h3>    <p className="card-description">Growth against share; a bubble is as large as its revenue</p>  </div>  <Chart    id="markets"    type="scatter"    label="Markets: growth in percent against share in percent, sized by revenue in millions"    series={[{      name: 'Markets',      points: [        { x: 4, y: 12, size: 40, label: 'Japan' },        { x: 9, y: 20, size: 120, label: 'Germany' },        { x: 14, y: 8, size: 20, label: 'Brazil' },        { x: 18, y: 26, size: 260, label: 'United States' },        { x: 6, y: 30, size: 64, label: 'India' },        { x: 12, y: 16, size: 90, label: 'France' }      ]    }]}  /></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">Markets</h3>    <p class="card-description">Growth against share; a bubble is as large as its revenue</p>  </div>  <Chart    id="markets"    type="scatter"    label="Markets: growth in percent against share in percent, sized by revenue in millions"    series={[{      name: 'Markets',      points: [        { x: 4, y: 12, size: 40, label: 'Japan' },        { x: 9, y: 20, size: 120, label: 'Germany' },        { x: 14, y: 8, size: 20, label: 'Brazil' },        { x: 18, y: 26, size: 260, label: 'United States' },        { x: 6, y: 30, size: 64, label: 'India' },        { x: 12, y: 16, size: 90, label: 'France' }      ]    }]}  /></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">Markets</h3>      <p class="card-description">Growth against share; a bubble is as large as its revenue</p>    </div>    <Chart      id="markets"      type="scatter"      label="Markets: growth in percent against share in percent, sized by revenue in millions"      :series="[{        name: 'Markets',        points: [          { x: 4, y: 12, size: 40, label: 'Japan' },          { x: 9, y: 20, size: 120, label: 'Germany' },          { x: 14, y: 8, size: 20, label: 'Brazil' },          { x: 18, y: 26, size: 260, label: 'United States' },          { x: 6, y: 30, size: 64, label: 'India' },          { x: 12, y: 16, size: 90, label: 'France' }        ]      }]"    />  </div></template>

面積の差は位置の差ほど正確に読み取れません。最も重要な指標は軸に割り当て、大小が伝わればよい指標をバブルのサイズに割り当てます。

#オプション

オプション既定値
labelなしグラフが示す内容とその単位を記述する、プロット領域のアクセシブルな名前
series[]各系列に name を指定し、グラフ形式に応じて values、円グラフの扇形1つまたはリング1本に対応する value、散布図の points のいずれかを指定します。category、type、リングのmaxは任意です。
min, max, ticksデータに合わせる、4軸の上下限と目盛りのおおよその分割数。散布図の横軸にはxMin、xMax、xTicksを使います。
format, tickFormatロケールに準拠値と目盛りの表記形式。散布図の横軸にはxFormatを使います。
legend, toggle系列が2つの場合に表示、true凡例を表示するかどうか、および凡例の各項目をチェックボックスにするかどうか

値の表示、キー、凡例、色、軸のスケールは、どのグラフ形式でも共通です。チャートにすべてのオプション、クラス、カスタムプロパティをまとめています。