---
code: "INT-21"
id: "c-hex"
tab: "dynamic-2"
kind: "interactive"
title: "Hex Bin · 6각 격자"
library: "ECharts"
deps: ["echarts@5"]
load: "low"
pasteKind: "echarts-mount"
family: "distribution"
dataShape: "value distribution or density bins"
tasks: ["explore data", "filter subsets", "monitor change", "show spread"]
tags: ["interactive", "exploration", "linked view", "distribution", "density", "hex", "bin", "6각", "격자"]
gallery: "https://graph.heal7.com/#INT-21"
js: "/sku/INT-21.js"
---

# [INT-21] Hex Bin · 6각 격자

> AI 붙여넣기 카드. 갤러리 런타임(`main.js`)이 아니라 이 파일을 가져와라.

## 언제 가져가나
6각형 셀로 빈도/밀도 — 격자 정사각보다 시각적 균형이 부드러움.

**응용** 지리 격자 인구 밀도, 산점도 빈도 표현, 커버리지 맵.

## 데이터 모양
- family: `distribution`
- dataShape: value distribution or density bins
- tasks: explore data, filter subsets, monitor change, show spread
- tags: interactive, exploration, linked view, distribution, density, hex, bin, 6각, 격자


## 의존
echarts@5 · load `low` · library `ECharts`

## 붙여넣는 법
1. echarts 5.x 로드 (GL이면 echarts-gl도)
2. 컨테이너 id를 원본 id와 맞추거나 `document.getElementById` 한 줄만 바꾼다
3. `T`, `reg`, `cssv` 가 필요하면 갤러리 테마 스텁을 함께 가져간다

```js
const T = {
  "bg": "transparent",
  "fg": "#ece8f5",
  "sub": "#a59bbd",
  "grid": "rgba(255,255,255,.08)",
  "gold": "#e8c069",
  "royal": "#6b8cff",
  "rose": "#e07a9f",
  "teal": "#6dd2c4",
  "plum": "#b487e8"
};
const cssv = (n, fb) => (getComputedStyle(document.documentElement).getPropertyValue(n).trim() || fb);
const isDark = () => document.documentElement.getAttribute('data-theme') !== 'light';
const charts = [];
const reg = (id, opt) => {
  const dom = document.getElementById(id); if (!dom) return;
  const c = echarts.init(dom, null, {renderer:'canvas'});
  c.setOption(opt);
  charts.push(c);
  return c;
};
const factory = function(){
  const HEX = 'path://M30 0 L60 17 L60 51 L30 68 L0 51 L0 17 Z';
  const data = [];
  const W = 12, H = 7, cx = W*30, cy = H*26;
  for(let y=0;y<H;y++) for(let x=0;x<W;x++){
    const px = x*60 + (y%2)*30;
    const py = y*52;
    const v = Math.exp(-Math.hypot(px-cx, py-cy)/(W*15))*100 + Math.random()*15;
    data.push([px, py, Math.round(v)]);
  }
  reg('c-hex', {
    backgroundColor:T.bg, tooltip:{formatter:p=>'밀도: '+p.value[2]},
    grid:{top:8,right:8,bottom:8,left:8},
    xAxis:{show:false, min:-30, max:W*60+30}, yAxis:{show:false, min:-30, max:H*52+30, inverse:true},
    visualMap:{show:false, min:0, max:110, dimension:2, inRange:{color:['rgba(255,255,255,.04)', T.royal, T.plum, T.gold]}},
    series:[{type:'scatter', symbol:HEX, symbolSize:30, data,
      itemStyle:{borderColor:cssv('--bg','#000'), borderWidth:1.5}
    }]
  });
};
factory();
```

## 원본 factory (갤러리 정본 발췌)
- file: `frontend/js/graph-gallery/main.js`
- lines: 2251-2270
- gallery: https://graph.heal7.com/#INT-21
- raw js: https://graph.heal7.com/sku/INT-21.js

```js
function(){
  const HEX = 'path://M30 0 L60 17 L60 51 L30 68 L0 51 L0 17 Z';
  const data = [];
  const W = 12, H = 7, cx = W*30, cy = H*26;
  for(let y=0;y<H;y++) for(let x=0;x<W;x++){
    const px = x*60 + (y%2)*30;
    const py = y*52;
    const v = Math.exp(-Math.hypot(px-cx, py-cy)/(W*15))*100 + Math.random()*15;
    data.push([px, py, Math.round(v)]);
  }
  reg('c-hex', {
    backgroundColor:T.bg, tooltip:{formatter:p=>'밀도: '+p.value[2]},
    grid:{top:8,right:8,bottom:8,left:8},
    xAxis:{show:false, min:-30, max:W*60+30}, yAxis:{show:false, min:-30, max:H*52+30, inverse:true},
    visualMap:{show:false, min:0, max:110, dimension:2, inRange:{color:['rgba(255,255,255,.04)', T.royal, T.plum, T.gold]}},
    series:[{type:'scatter', symbol:HEX, symbolSize:30, data,
      itemStyle:{borderColor:cssv('--bg','#000'), borderWidth:1.5}
    }]
  });
}
```

