---
code: "INT-12"
id: "c-realtime"
tab: "dynamic-1"
kind: "interactive"
title: "Real-time Stream · 실시간 라인"
library: "ECharts"
deps: ["echarts@5"]
load: "med"
pasteKind: "echarts-mount"
family: "monitoring"
dataShape: "sliding live time window"
tasks: ["explore data", "monitor change", "drill into structure", "show connections", "show trend over time", "monitor live metric"]
tags: ["interactive", "live", "exploration", "network", "flow", "time-series", "realtime", "monitoring", "real", "time", "stream", "실시간", "라인"]
gallery: "https://graph.heal7.com/#INT-12"
js: "/sku/INT-12.js"
---

# [INT-12] Real-time Stream · 실시간 라인

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

## 언제 가져가나
1초마다 새 값이 우측에서 들어오고 좌측에서 빠지는 슬라이딩 윈도 — 모니터링 차트의 표준.

**응용** CPU·메모리·트래픽 모니터링, 실시간 동시접속자, 센서 시계열.

## 데이터 모양
- family: `monitoring`
- dataShape: sliding live time window
- tasks: explore data, monitor change, drill into structure, show connections, show trend over time, monitor live metric
- tags: interactive, live, exploration, network, flow, time-series, realtime, monitoring, real, time, stream, 실시간, 라인


## 의존
echarts@5 · load `med` · 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-realtime'); if(!dom) return;
  const c = echarts.init(dom);
  const N = 60;
  const data = Array.from({length:N},(_,i)=>[i, 50 + Math.sin(i/4)*12 + Math.random()*8]);
  let t = N;
  function paint(){
    c.setOption({
      backgroundColor:T.bg, animation:false, tooltip:{trigger:'axis'},
      grid:{top:18,right:24,bottom:28,left:42},
      xAxis:{type:'value', min:d=>d.min, max:d=>d.max, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
      yAxis:{type:'value', min:0, max:100, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
      series:[{type:'line', data, smooth:true, symbol:'none',
        lineStyle:{color:T.gold, width:2, shadowBlur:10, shadowColor:T.gold},
        areaStyle:{color:{type:'linear',x:0,y:0,x2:0,y2:1, colorStops:[{offset:0,color:'rgba(232,192,105,.32)'},{offset:1,color:'rgba(232,192,105,0)'}]}}
      }]
    });
  }
  paint();
  setInterval(()=>{
    data.shift();
    const last = data[data.length-1][1];
    const v = Math.max(8, Math.min(96, last + (Math.random()*16-8)));
    data.push([t++, v]);
    paint();
  }, 1000);
  charts.push(c);
};
factory();
```

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

```js
function(){
  const dom = document.getElementById('c-realtime'); if(!dom) return;
  const c = echarts.init(dom);
  const N = 60;
  const data = Array.from({length:N},(_,i)=>[i, 50 + Math.sin(i/4)*12 + Math.random()*8]);
  let t = N;
  function paint(){
    c.setOption({
      backgroundColor:T.bg, animation:false, tooltip:{trigger:'axis'},
      grid:{top:18,right:24,bottom:28,left:42},
      xAxis:{type:'value', min:d=>d.min, max:d=>d.max, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
      yAxis:{type:'value', min:0, max:100, axisLabel:{color:T.sub,fontSize:10}, splitLine:{lineStyle:{color:T.grid}}},
      series:[{type:'line', data, smooth:true, symbol:'none',
        lineStyle:{color:T.gold, width:2, shadowBlur:10, shadowColor:T.gold},
        areaStyle:{color:{type:'linear',x:0,y:0,x2:0,y2:1, colorStops:[{offset:0,color:'rgba(232,192,105,.32)'},{offset:1,color:'rgba(232,192,105,0)'}]}}
      }]
    });
  }
  paint();
  setInterval(()=>{
    data.shift();
    const last = data[data.length-1][1];
    const v = Math.max(8, Math.min(96, last + (Math.random()*16-8)));
    data.push([t++, v]);
    paint();
  }, 1000);
  charts.push(c);
}
```

