ナビゲーション

v2.1.0
分布

ヒストグラム

測定値の分布を示します。区切りのよい数値で階級を分け、度数を棒の高さで表します。

このページの内容

ヒストグラムは、測定値がどこに集中し、どの範囲に広がり、どちらかに偏っているかを示します。最初の系列の測定値を、区切りのよい数値を境界とする階級に振り分け、各階級に含まれる測定値の個数を棒の高さで表します。横軸が連続しているため、隣り合う棒は間隔を空けずに並びます。

ヒストグラム

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Response time</h3>    <p class="card-description">240 requests, in milliseconds</p>  </div>  <figure class="chart" id="spread"></figure></div><script>addEventListener('DOMContentLoaded', function () {var readings = Array.from({ length: 240 }, function (_, index) { return Math.round(180 + 60 * Math.sin(index * 1.7) + 40 * Math.cos(index * 0.37) + (index % 23) * 3 + (index % 5 === 0 ? 90 : 0)) })MasterUI.chart(document.getElementById('spread'), {  type: 'histogram',  label: 'Response time of 240 requests, in milliseconds',  series: [{ name: 'Requests', values: readings }]})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach, chart } from '@master/ui/behaviors'var readings = Array.from({ length: 240 }, function (_, index) { return Math.round(180 + 60 * Math.sin(index * 1.7) + 40 * Math.cos(index * 0.37) + (index % 23) * 3 + (index % 5 === 0 ? 90 : 0)) })export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => {    const detach = [      attach(root.current!),      chart(document.getElementById('spread')!, {        type: 'histogram',        label: 'Response time of 240 requests, in milliseconds',        series: [{ name: 'Requests', values: readings }]      }),    ]    return () => detach.forEach(stop => stop())  }, [])  return (    <div ref={root} className="card max-w(560) mx-auto">      <div className="card-header">        <h3 className="card-title">Response time</h3>        <p className="card-description">240 requests, in milliseconds</p>      </div>      <figure className="chart" id="spread"></figure>    </div>  )}
<script>  import { attach, chart } from '@master/ui/behaviors'  var readings = Array.from({ length: 240 }, function (_, index) { return Math.round(180 + 60 * Math.sin(index * 1.7) + 40 * Math.cos(index * 0.37) + (index % 23) * 3 + (index % 5 === 0 ? 90 : 0)) })  function mounted(root) {    const detach = [      attach(root),      chart(document.getElementById('spread'), {        type: 'histogram',        label: 'Response time of 240 requests, in milliseconds',        series: [{ name: 'Requests', values: readings }]      }),    ]    return () => detach.forEach(stop => stop())  }</script><div class="card max-w(560) mx-auto" {@attach mounted}>  <div class="card-header">    <h3 class="card-title">Response time</h3>    <p class="card-description">240 requests, in milliseconds</p>  </div>  <figure class="chart" id="spread"></figure></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach, chart } from '@master/ui/behaviors'var readings = Array.from({ length: 240 }, function (_, index) { return Math.round(180 + 60 * Math.sin(index * 1.7) + 40 * Math.cos(index * 0.37) + (index % 23) * 3 + (index % 5 === 0 ? 90 : 0)) })const root = ref(null)let detach = []onMounted(() => {  detach = [    attach(root.value),    chart(document.getElementById('spread'), {      type: 'histogram',      label: 'Response time of 240 requests, in milliseconds',      series: [{ name: 'Requests', values: readings }]    }),  ]})onUnmounted(() => detach.forEach(stop => stop()))</script><template>  <div ref="root" class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Response time</h3>      <p class="card-description">240 requests, in milliseconds</p>    </div>    <figure class="chart" id="spread"></figure>  </div></template>

系列の values には集計前の測定値を渡します。各階級の度数はグラフが数えます。bins には階級数の目安を指定します。省略すると、測定値の個数に応じて5から20の範囲で決まります。境界には区切りのよい数値を使うため、階級は「200から250」のように読み取れます。境界と等しい測定値は、その境界を下端とする階級に入ります。

ヒストグラムでは、一つの指標の値域を区切り、階級順に棒を並べます。項目ごとの量を比較するには 棒グラフ を使い、分布を五つの代表値で要約するには 箱ひげ図 を使います。

#オプション

オプション既定
labelなしグラフが示す内容と単位を表す、プロットのアクセシブルな名前
series[]各系列に name と、形式に応じて values、value、points、ranges、children のいずれかを指定します。category、type、low と high、円環の max は任意です
bins測定値の個数に応じて決定ヒストグラムで測定値を振り分ける階級数の目安
min, max, ticksデータに合わせて自動調整, 4スケールの両端と目盛り区間数の目安。散布図の横軸には xMin、xMax、xTicks を使用
format, tickFormatロケールに準拠値と目盛りの表示形式。散布図の横軸には xFormat を使用
currentなしaria-current を付けるデータ点のインデックス

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