---
code: "CMP-08"
id: "c-dumbbell"
tab: "compare"
kind: "core"
title: "Dumbbell · 덤벨 차트"
library: "ECharts"
deps: ["echarts@5"]
load: "low"
pasteKind: "echarts-mount"
family: "comparison"
dataShape: "ranked categories or before-after pairs"
tasks: ["compare alternatives", "show delta", "benchmark groups", "compare categories"]
tags: ["comparison", "benchmark", "delta", "ranking", "dumbbell", "덤벨", "차트"]
gallery: "https://graph.heal7.com/#CMP-08"
js: "/sku/CMP-08.js"
---

# [CMP-08] Dumbbell · 덤벨 차트

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

## 언제 가져가나
시작/끝 두 점을 선으로 연결 — 변화 폭 시각화.

**응용** 정책 전후 지표, 코호트 시작/종료 비교.

## 데이터 모양
- family: `comparison`
- dataShape: ranked categories or before-after pairs
- tasks: compare alternatives, show delta, benchmark groups, compare categories
- tags: comparison, benchmark, delta, ranking, dumbbell, 덤벨, 차트


## 의존
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 = ['창의','분석','관계','실행','보호','혁신','통찰'];
  const before = [40, 50, 35, 60, 55, 45, 50];
  const after  = [70, 75, 60, 85, 65, 80, 75];
  reg('c-dumbbell', {
    backgroundColor:T.bg, tooltip:{},
    legend:{data:['이전','현재'], top:0, right:8, textStyle:{color:T.sub}},
    grid:{top:32, right:14, bottom:30, left:32},
    xAxis:{type:'category', data:cats, axisLabel:{color:T.sub,fontSize:10, rotate:25}, axisLine:{lineStyle:{color:T.grid}}},
    yAxis:{type:'value', max:100, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
    series:[
      {type:'custom', silent:true, animation:false, data: cats.map((c,i)=>[i, before[i], after[i]]),
        renderItem: (params, api) => {
          const p1 = api.coord([api.value(0), api.value(1)]);
          const p2 = api.coord([api.value(0), api.value(2)]);
          return {type:'line', shape:{x1:p1[0], y1:p1[1], x2:p2[0], y2:p2[1]}, style:{stroke:'rgba(255,255,255,.3)', lineWidth:2}};
        }},
      {name:'이전', type:'scatter', data:before.map((v,i)=>[i,v]), symbolSize:14, itemStyle:{color:T.royal, borderColor:'#fff', borderWidth:1.5}},
      {name:'현재', type:'scatter', data:after.map((v,i)=>[i,v]),  symbolSize:14, itemStyle:{color:T.gold,  borderColor:'#fff', borderWidth:1.5}}
    ]
  });
};
factory();
```

## 원본 factory (갤러리 정본 발췌)
- file: `frontend/js/graph-gallery/main.js`
- lines: 2694-2715
- gallery: https://graph.heal7.com/#CMP-08
- raw js: https://graph.heal7.com/sku/CMP-08.js

```js
function(){
  const cats = ['창의','분석','관계','실행','보호','혁신','통찰'];
  const before = [40, 50, 35, 60, 55, 45, 50];
  const after  = [70, 75, 60, 85, 65, 80, 75];
  reg('c-dumbbell', {
    backgroundColor:T.bg, tooltip:{},
    legend:{data:['이전','현재'], top:0, right:8, textStyle:{color:T.sub}},
    grid:{top:32, right:14, bottom:30, left:32},
    xAxis:{type:'category', data:cats, axisLabel:{color:T.sub,fontSize:10, rotate:25}, axisLine:{lineStyle:{color:T.grid}}},
    yAxis:{type:'value', max:100, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
    series:[
      {type:'custom', silent:true, animation:false, data: cats.map((c,i)=>[i, before[i], after[i]]),
        renderItem: (params, api) => {
          const p1 = api.coord([api.value(0), api.value(1)]);
          const p2 = api.coord([api.value(0), api.value(2)]);
          return {type:'line', shape:{x1:p1[0], y1:p1[1], x2:p2[0], y2:p2[1]}, style:{stroke:'rgba(255,255,255,.3)', lineWidth:2}};
        }},
      {name:'이전', type:'scatter', data:before.map((v,i)=>[i,v]), symbolSize:14, itemStyle:{color:T.royal, borderColor:'#fff', borderWidth:1.5}},
      {name:'현재', type:'scatter', data:after.map((v,i)=>[i,v]),  symbolSize:14, itemStyle:{color:T.gold,  borderColor:'#fff', borderWidth:1.5}}
    ]
  });
}
```

