---
code: "DIS-09"
id: "c-stack100"
tab: "distribution"
kind: "core"
title: "Stacked 100% · 누적 비율 막대"
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", "stacked", "100%", "누적", "막대"]
gallery: "https://graph.heal7.com/#DIS-09"
js: "/sku/DIS-09.js"
---

# [DIS-09] Stacked 100% · 누적 비율 막대

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

## 언제 가져가나
각 카테고리 합을 100%로 정규화 — 구성비 변화에 집중.

**응용** 분기별 채널 매출 구성, 연령대별 응답 비율.

## 데이터 모양
- family: `composition`
- dataShape: category shares or weighted blocks
- tasks: show composition, show frequency, compare magnitudes, show part-to-whole
- tags: distribution, 비율, 빈도, composition, share, stacked, 100%, 누적, 막대


## 의존
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 cats = ['1Q','2Q','3Q','4Q'];
  const seriesDef = [
    {n:'직접', d:[40,35,30,25], c:T.gold},
    {n:'검색', d:[30,28,32,35], c:T.royal},
    {n:'SNS',  d:[20,25,28,30], c:T.rose},
    {n:'기타', d:[10,12,10,10], c:T.teal}
  ];
  reg('c-stack100', {
    backgroundColor:T.bg, tooltip:{},
    legend:{textStyle:{color:T.sub}, top:0, right:8},
    grid:{top:36, right:24, bottom:14, left:48},
    xAxis:{type:'value', max:100, axisLabel:{color:T.sub,fontSize:10, formatter:'{value}%'}, splitLine:{lineStyle:{color:T.grid}}},
    yAxis:{type:'category', data:cats, axisLabel:{color:T.fg,fontSize:11,fontWeight:600}, axisLine:{show:false}, axisTick:{show:false}},
    series: seriesDef.map(s=>({name:s.n, type:'bar', stack:'a', data:s.d, itemStyle:{color:s.c},
      label:{show:true, color:'#fff', fontSize:11, formatter:'{c}%'}}))
  });
};
factory();
```

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

```js
function(){
  const cats = ['1Q','2Q','3Q','4Q'];
  const seriesDef = [
    {n:'직접', d:[40,35,30,25], c:T.gold},
    {n:'검색', d:[30,28,32,35], c:T.royal},
    {n:'SNS',  d:[20,25,28,30], c:T.rose},
    {n:'기타', d:[10,12,10,10], c:T.teal}
  ];
  reg('c-stack100', {
    backgroundColor:T.bg, tooltip:{},
    legend:{textStyle:{color:T.sub}, top:0, right:8},
    grid:{top:36, right:24, bottom:14, left:48},
    xAxis:{type:'value', max:100, axisLabel:{color:T.sub,fontSize:10, formatter:'{value}%'}, splitLine:{lineStyle:{color:T.grid}}},
    yAxis:{type:'category', data:cats, axisLabel:{color:T.fg,fontSize:11,fontWeight:600}, axisLine:{show:false}, axisTick:{show:false}},
    series: seriesDef.map(s=>({name:s.n, type:'bar', stack:'a', data:s.d, itemStyle:{color:s.c},
      label:{show:true, color:'#fff', fontSize:11, formatter:'{c}%'}}))
  });
}
```

