탐색

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로 표시할 점의 인덱스

값 표시, 키보드 조작, 범례, 색상, 척도는 모든 차트 형태에 공통으로 적용됩니다. 차트에서 자세한 설명과 모든 옵션, CSS 클래스, 사용자 지정 속성을 확인할 수 있습니다.