---
code: "INT-15"
id: "c-treedrill"
tab: "dynamic-1"
kind: "interactive"
title: "Drilldown Treemap · 드릴다운 트리맵"
library: "ECharts"
deps: ["echarts@5"]
load: "low"
pasteKind: "echarts-mount"
family: "hierarchy"
dataShape: "click-to-drill treemap"
tasks: ["explore data", "monitor change", "drill into structure", "show hierarchy", "drill into nested blocks"]
tags: ["interactive", "live", "exploration", "hierarchy", "tree", "treemap", "drilldown", "드릴다운", "트리맵"]
gallery: "https://graph.heal7.com/#INT-15"
js: "/sku/INT-15.js"
---

# [INT-15] Drilldown Treemap · 드릴다운 트리맵

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

## 언제 가져가나
사각형을 클릭해 한 단계씩 줌인하고 breadcrumb로 복귀 — 계층형 비중 분석의 실무형 인터랙션.

**응용** 카테고리→브랜드→상품 매출, 폴더 용량, 조직별 예산 구조.

## 데이터 모양
- family: `hierarchy`
- dataShape: click-to-drill treemap
- tasks: explore data, monitor change, drill into structure, show hierarchy, drill into nested blocks
- tags: interactive, live, exploration, hierarchy, tree, treemap, drilldown, 드릴다운, 트리맵


## 의존
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 dom = document.getElementById('c-treedrill'); if(!dom) return;
  const c = echarts.init(dom);
  const data = [
    {name:'커머스', itemStyle:{color:T.gold}, children:[
      {name:'패션', value:38, children:[{name:'아우터', value:14},{name:'슈즈', value:10},{name:'액세서리', value:8},{name:'데님', value:6}]},
      {name:'뷰티', value:30, children:[{name:'스킨케어', value:13},{name:'메이크업', value:9},{name:'향수', value:8}]},
      {name:'리빙', value:22, children:[{name:'가구', value:10},{name:'주방', value:7},{name:'수납', value:5}]}
    ]},
    {name:'콘텐츠', itemStyle:{color:T.royal}, children:[
      {name:'교육', value:28, children:[{name:'통계', value:11},{name:'AI', value:9},{name:'언어', value:8}]},
      {name:'미디어', value:26, children:[{name:'숏폼', value:10},{name:'라이브', value:9},{name:'뉴스레터', value:7}]},
      {name:'커뮤니티', value:18, children:[{name:'포럼', value:8},{name:'Q&A', value:6},{name:'챌린지', value:4}]}
    ]},
    {name:'운영', itemStyle:{color:T.rose}, children:[
      {name:'마케팅', value:24, children:[{name:'광고', value:10},{name:'CRM', value:8},{name:'제휴', value:6}]},
      {name:'지원', value:20, children:[{name:'CS', value:9},{name:'온보딩', value:6},{name:'QA', value:5}]},
      {name:'인프라', value:16, children:[{name:'클라우드', value:7},{name:'관측성', value:5},{name:'보안', value:4}]}
    ]}
  ];
  const crumbFill = isDark() ? 'rgba(255,255,255,.06)' : 'rgba(255,255,255,.78)';
  const crumbStroke = isDark() ? 'rgba(255,255,255,.14)' : 'rgba(0,0,0,.12)';
  c.setOption({
    backgroundColor:T.bg,
    tooltip:{
      formatter: p => {
        const path = (p.treePathInfo || []).slice(1).map(x => x.name).join(' / ');
        return `<b>${path || p.name}</b><br>규모: ${p.value}`;
      }
    },
    series:[{
      type:'treemap',
      roam:false,
      nodeClick:'zoomToNode',
      animationDurationUpdate:500,
      animationEasingUpdate:'cubicInOut',
      leafDepth:1,
      visibleMin:4,
      colorMappingBy:'index',
      breadcrumb:{
        show:true,
        top:2,
        left:6,
        itemStyle:{color:crumbFill, borderColor:crumbStroke, borderWidth:1},
        emphasis:{itemStyle:{color:isDark() ? 'rgba(255,255,255,.12)' : 'rgba(255,255,255,.95)'}},
        textStyle:{color:T.fg, fontSize:10}
      },
      label:{show:true, color:T.fg, fontSize:11, overflow:'truncate'},
      upperLabel:{show:true, height:20, color:T.fg, fontSize:11, fontWeight:700},
      itemStyle:{borderColor:'rgba(0,0,0,.18)', borderWidth:2, gapWidth:2},
      levels:[
        {itemStyle:{borderColor:'rgba(255,255,255,.04)', gapWidth:3}},
        {colorSaturation:[0.38, 0.72], itemStyle:{gapWidth:3, borderColor:'rgba(255,255,255,.08)'}},
        {colorSaturation:[0.28, 0.62], itemStyle:{gapWidth:2, borderColor:'rgba(255,255,255,.12)'}, upperLabel:{show:true, height:18}},
        {itemStyle:{gapWidth:1, borderColor:'rgba(255,255,255,.18)'}}
      ],
      data
    }],
    graphic:[
      {type:'text', right:8, top:4, silent:true,
        style:{text:'click square to drill down', fill:T.sub, fontSize:10, textAlign:'right'}}
    ]
  });
  charts.push(c);
};
factory();
```

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

```js
function(){
  const dom = document.getElementById('c-treedrill'); if(!dom) return;
  const c = echarts.init(dom);
  const data = [
    {name:'커머스', itemStyle:{color:T.gold}, children:[
      {name:'패션', value:38, children:[{name:'아우터', value:14},{name:'슈즈', value:10},{name:'액세서리', value:8},{name:'데님', value:6}]},
      {name:'뷰티', value:30, children:[{name:'스킨케어', value:13},{name:'메이크업', value:9},{name:'향수', value:8}]},
      {name:'리빙', value:22, children:[{name:'가구', value:10},{name:'주방', value:7},{name:'수납', value:5}]}
    ]},
    {name:'콘텐츠', itemStyle:{color:T.royal}, children:[
      {name:'교육', value:28, children:[{name:'통계', value:11},{name:'AI', value:9},{name:'언어', value:8}]},
      {name:'미디어', value:26, children:[{name:'숏폼', value:10},{name:'라이브', value:9},{name:'뉴스레터', value:7}]},
      {name:'커뮤니티', value:18, children:[{name:'포럼', value:8},{name:'Q&A', value:6},{name:'챌린지', value:4}]}
    ]},
    {name:'운영', itemStyle:{color:T.rose}, children:[
      {name:'마케팅', value:24, children:[{name:'광고', value:10},{name:'CRM', value:8},{name:'제휴', value:6}]},
      {name:'지원', value:20, children:[{name:'CS', value:9},{name:'온보딩', value:6},{name:'QA', value:5}]},
      {name:'인프라', value:16, children:[{name:'클라우드', value:7},{name:'관측성', value:5},{name:'보안', value:4}]}
    ]}
  ];
  const crumbFill = isDark() ? 'rgba(255,255,255,.06)' : 'rgba(255,255,255,.78)';
  const crumbStroke = isDark() ? 'rgba(255,255,255,.14)' : 'rgba(0,0,0,.12)';
  c.setOption({
    backgroundColor:T.bg,
    tooltip:{
      formatter: p => {
        const path = (p.treePathInfo || []).slice(1).map(x => x.name).join(' / ');
        return `<b>${path || p.name}</b><br>규모: ${p.value}`;
      }
    },
    series:[{
      type:'treemap',
      roam:false,
      nodeClick:'zoomToNode',
      animationDurationUpdate:500,
      animationEasingUpdate:'cubicInOut',
      leafDepth:1,
      visibleMin:4,
      colorMappingBy:'index',
      breadcrumb:{
        show:true,
        top:2,
        left:6,
        itemStyle:{color:crumbFill, borderColor:crumbStroke, borderWidth:1},
        emphasis:{itemStyle:{color:isDark() ? 'rgba(255,255,255,.12)' : 'rgba(255,255,255,.95)'}},
        textStyle:{color:T.fg, fontSize:10}
      },
      label:{show:true, color:T.fg, fontSize:11, overflow:'truncate'},
      upperLabel:{show:true, height:20, color:T.fg, fontSize:11, fontWeight:700},
      itemStyle:{borderColor:'rgba(0,0,0,.18)', borderWidth:2, gapWidth:2},
      levels:[
        {itemStyle:{borderColor:'rgba(255,255,255,.04)', gapWidth:3}},
        {colorSaturation:[0.38, 0.72], itemStyle:{gapWidth:3, borderColor:'rgba(255,255,255,.08)'}},
        {colorSaturation:[0.28, 0.62], itemStyle:{gapWidth:2, borderColor:'rgba(255,255,255,.12)'}, upperLabel:{show:true, height:18}},
        {itemStyle:{gapWidth:1, borderColor:'rgba(255,255,255,.18)'}}
      ],
      data
    }],
    graphic:[
      {type:'text', right:8, top:4, silent:true,
        style:{text:'click square to drill down', fill:T.sub, fontSize:10, textAlign:'right'}}
    ]
  });
  charts.push(c);
}
```

