ナビゲーション

v2.1.0
比較

ダンベルチャート

項目ごとに二つの値を線で結び、その長さで差を示します。

このページの内容

ダンベルチャートは、前後、異なる年、異なるグループなど、項目ごとに二つの値を比較します。各系列の値を点で示し、同じラベルの点を線で結ぶため、差の大きさとどちらの値が大きいかがひと目でわかります。2本の棒を並べたグラフと同じ情報を少ない描画要素で示せます。軸をゼロから始める必要もありません。

ダンベルチャート

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Pay</h3>    <p class="card-description">Median by role, 2019 and 2024</p>  </div>  <figure class="chart" id="pay"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('pay'), {  type: 'dumbbell',  horizontal: true,  label: 'Median pay by role in 2019 and 2024, in thousands of dollars',  labels: ['Design', 'Engineering', 'Product', 'Support', 'Sales'],  series: [    { name: '2019', values: [62, 84, 78, 41, 55] },    { name: '2024', values: [81, 112, 96, 52, 74] }  ],  format: function (value) { return '$' + value + 'k' }})})</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">Pay</h3>    <p className="card-description">Median by role, 2019 and 2024</p>  </div>  <Chart    id="pay"    type="dumbbell"    horizontal    label="Median pay by role in 2019 and 2024, in thousands of dollars"    labels={['Design', 'Engineering', 'Product', 'Support', 'Sales']}    series={[      { name: '2019', values: [62, 84, 78, 41, 55] },      { name: '2024', values: [81, 112, 96, 52, 74] }    ]}    format={function (value) { return '$' + value + 'k' }}  /></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">Pay</h3>    <p class="card-description">Median by role, 2019 and 2024</p>  </div>  <Chart    id="pay"    type="dumbbell"    horizontal    label="Median pay by role in 2019 and 2024, in thousands of dollars"    labels={['Design', 'Engineering', 'Product', 'Support', 'Sales']}    series={[      { name: '2019', values: [62, 84, 78, 41, 55] },      { name: '2024', values: [81, 112, 96, 52, 74] }    ]}    format={function (value) { return '$' + value + 'k' }}  /></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">Pay</h3>      <p class="card-description">Median by role, 2019 and 2024</p>    </div>    <Chart      id="pay"      type="dumbbell"      horizontal      label="Median pay by role in 2019 and 2024, in thousands of dollars"      :labels="['Design', 'Engineering', 'Product', 'Support', 'Sales']"      :series="[        { name: '2019', values: [62, 84, 78, 41, 55] },        { name: '2024', values: [81, 112, 96, 52, 74] }      ]"      :format="function (value) { return '$' + value + 'k' }"    />  </div></template>

通常は horizontal: true で横向きにし、項目名を縦に並べて読みやすくします。差の大きさか、どちらか一方の系列の値でラベルを並べ替えてから渡します。並び順もグラフが伝える情報の一部です。3系列以上では、ラベルごとに各系列の点を表示し、最小値から最大値までを線で結びます。

#オプション

オプション既定
labelなしグラフが示す内容と単位を表す、プロットのアクセシブルな名前
labels[]軸に沿った項目名、レーダーチャートの周囲の項目名、またはヒートマップの列名
series[]各系列に name と、形式に応じて values、value、points、ranges、children のいずれかを指定します。category、type、low と high、円環の max は任意です
horizontalfalse棒、範囲、ダンベル、箱ひげを横向きに表示
min, max, ticksデータに合わせて自動調整, 4軸の両端の値と目盛りの数の目安。散布図の横軸には xMin、xMax、xTicks を使用
format, tickFormatロケールに準拠値と目盛りの表示形式。散布図の横軸には xFormat を使用
currentなしaria-current を付けるデータ点のインデックス
legend, toggle2系列の場合に表示, true凡例を表示するかどうかと、凡例の項目をチェックボックスにするかどうか

値の表示、キー操作、凡例、色、スケールは、すべての形式で共通です。すべてのオプション、クラス、カスタムプロパティは チャート に記載しています。