---
code: "DIS-06"
id: "c-waffle"
tab: "distribution"
kind: "core"
title: "Waffle · 와플 차트"
library: "ECharts"
deps: ["echarts@5"]
load: "low"
pasteKind: "echarts-mount"
family: "composition"
dataShape: "category shares or weighted blocks"
tasks: ["show composition", "show frequency", "compare magnitudes", "show part-to-whole"]
tags: ["distribution", "비율", "빈도", "composition", "share", "waffle", "와플", "차트"]
gallery: "https://graph.heal7.com/#DIS-06"
js: "/sku/DIS-06.js"
---

# [DIS-06] Waffle · 와플 차트

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

## 언제 가져가나
10×10 = 100칸 격자로 비율을 직관 표현 — 38%면 38칸이 채워짐.

**응용** 인포그래픽 비율, NPS 분포, 점유율 시각화.

## 데이터 모양
- family: `composition`
- dataShape: category shares or weighted blocks
- tasks: show composition, show frequency, compare magnitudes, show part-to-whole
- tags: distribution, 비율, 빈도, composition, share, waffle, 와플, 차트


## 의존
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 xs = Array.from({length:10},(_,i)=>''+i), ys = xs.slice();
  const filled = 38, data = [];
  let n = 0;
  for(let y=0;y<10;y++) for(let x=0;x<10;x++){ data.push([x, y, n<filled?1:0]); n++; }
  reg('c-waffle', {
    backgroundColor:T.bg, tooltip:{show:false},
    grid:{top:10,right:10,bottom:10,left:10},
    xAxis:{type:'category', data:xs, show:false},
    yAxis:{type:'category', data:ys, show:false, inverse:true},
    visualMap:{show:false, min:0, max:1, inRange:{color:['rgba(255,255,255,.06)', T.gold]}},
    series:[{type:'heatmap', data, itemStyle:{borderRadius:3, borderColor:cssv('--bg','#000'), borderWidth:3}}],
    graphic:[{type:'text', right:14, top:8, style:{text:filled+'%', fontSize:18, fontWeight:700, fill:T.gold}}]
  });
};
factory();
```

## 원본 factory (갤러리 정본 발췌)
- file: `frontend/js/graph-gallery/main.js`
- lines: 1696-1710
- gallery: https://graph.heal7.com/#DIS-06
- raw js: https://graph.heal7.com/sku/DIS-06.js

```js
function(){
  const xs = Array.from({length:10},(_,i)=>''+i), ys = xs.slice();
  const filled = 38, data = [];
  let n = 0;
  for(let y=0;y<10;y++) for(let x=0;x<10;x++){ data.push([x, y, n<filled?1:0]); n++; }
  reg('c-waffle', {
    backgroundColor:T.bg, tooltip:{show:false},
    grid:{top:10,right:10,bottom:10,left:10},
    xAxis:{type:'category', data:xs, show:false},
    yAxis:{type:'category', data:ys, show:false, inverse:true},
    visualMap:{show:false, min:0, max:1, inRange:{color:['rgba(255,255,255,.06)', T.gold]}},
    series:[{type:'heatmap', data, itemStyle:{borderRadius:3, borderColor:cssv('--bg','#000'), borderWidth:3}}],
    graphic:[{type:'text', right:14, top:8, style:{text:filled+'%', fontSize:18, fontWeight:700, fill:T.gold}}]
  });
}
```

