본문으로 건너뛰기Skip to content
예제 첫화면Examples home

진행 링: 동그란 % 완료 표시Progress rings: round percent-complete display

cellRenderer: 'progressRing'은 숫자를 작은 동그란 링과 가운데 숫자로 보여 줘요. 100%면 초록, 0%면 흐리게, 값이 비어 있으면 빈 링이에요.cellRenderer: 'progressRing' shows a number as a small round ring with the number inside. It turns green at 100%, dims at 0%, and stays an empty ring when the value is empty.

입문Beginner
직접 써 보기Live preview진행 링: 동그란 % 완료 표시Progress rings: round percent-complete display

코드Code

탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.

이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<div id="app">
  <div class="toolbar">
    <select aria-label="숫자 표시" id="label">
      <option value="show" selected>링과 숫자</option>
      <option value="hide">링만</option>
    </select>
    <button type="button" id="more">완료율 +10</button>
  </div>
  <div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('label').addEventListener('change', (event) => actions.label(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));
example.js
// cellRenderer: 'progressRing'은 숫자를 동그란 링과 가운데 숫자로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 빈 링이에요. 100이면 초록, 0이면 숫자가 흐려져요. 링 색은 테마 토큰을 따라가서 다크 모드와 오른쪽→왼쪽 방향에서도 그대로 써요.
// cellRendererParams: min·max(범위), size·thickness(px), showLabel(숫자 표시), decimals(소수 자릿수), animate(값이 바뀔 때 움직임, 기본 꺼짐).
const rows = [
  { id: 1, task: '디자인 검토', owner: '김서연', done: 100, score: 4.8, big: 100 },
  { id: 2, task: '빌드 자동화', owner: '이준호', done: 72, score: 3.6, big: 72 },
  { id: 3, task: '부하 시험', owner: '박민지', done: 35, score: 2.1, big: 35 },
  { id: 4, task: '문서 작성', owner: '김서연', done: 0, score: 0, big: 0 },
  { id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, score: 5, big: 130 },
  { id: 6, task: '아직 시작 전', owner: '박민지', done: null, score: 1.2, big: 0 },
];
let showLabel = true;
const columns = () => [
  { id: 'task', title: '업무', width: 140 },
  {
    id: 'done',
    title: '완료율',
    kind: 'number',
    width: 90,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { showLabel },
  },
  {
    id: 'score',
    title: '점수(0~5)',
    kind: 'number',
    width: 110,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { min: 0, max: 5, decimals: 1, size: 36, showLabel },
  },
  {
    id: 'big',
    title: '큰 링',
    kind: 'number',
    width: 90,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { size: 30, thickness: 4, animate: true, showLabel },
  },
];
export const options = {
  columns: columns(),
  rows,
  rowKey: 'id',
  saveMode: 'none',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  showLabel = true;
  log({
    ko: '130처럼 범위를 넘은 값은 링이 100%에서 멈추고, 비어 있는 값은 빈 링이에요.',
    en: 'A value over the range like 130 stops the ring at 100%, and an empty value leaves an empty ring.',
  });
}
export const actions = {
  label: (api, value) => {
    showLabel = value !== 'hide';
    api.setColumns(columns());
    say({
      ko: showLabel ? '링 가운데에 숫자도 보여요.' : '링만 보여요.',
      en: showLabel ? 'Showing the number inside the ring.' : 'Showing only the ring.',
    });
  },
  more: (api) => {
    const changed = api
      .getRows()
      .flatMap((row) => typeof row.done === 'number' && row.done < 100
      ? [{ ...row, done: Math.min(100, row.done + 10), big: Math.min(100, row.big + 10) }]
      : []);
    api.updateRows(changed);
    say({
      ko: `완료율이 100 미만인 ${changed.length}줄을 10씩 올렸어요.`,
      en: `Raised the ${changed.length} rows under 100 by 10.`,
    });
  },
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<div id="app">
  <div class="toolbar">
    <select aria-label="Number" id="label">
      <option value="show" selected>Ring and number</option>
      <option value="hide">Ring only</option>
    </select>
    <button type="button" id="more">Done +10</button>
  </div>
  <div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('label').addEventListener('change', (event) => actions.label(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));
example.js
// cellRenderer: 'progressRing' draws a number as a round ring with the number inside. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves an empty ring. At 100 the ring turns green and at 0 the number is dimmed. Ring colors follow the theme tokens, so dark mode and right-to-left work as they are.
// cellRendererParams: min/max (range), size/thickness (px), showLabel (number), decimals (fraction digits), animate (movement when the value changes, off by default).
const rows = [
  { id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, score: 4.8, big: 100 },
  { id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, score: 3.6, big: 72 },
  { id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, score: 2.1, big: 35 },
  { id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, score: 0, big: 0 },
  { id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, score: 5, big: 130 },
  { id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, score: 1.2, big: 0 },
];
let showLabel = true;
const columns = () => [
  { id: 'task', title: 'Task', width: 160 },
  {
    id: 'done',
    title: 'Done',
    kind: 'number',
    width: 90,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { showLabel },
  },
  {
    id: 'score',
    title: 'Score (0-5)',
    kind: 'number',
    width: 110,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { min: 0, max: 5, decimals: 1, size: 36, showLabel },
  },
  {
    id: 'big',
    title: 'Big ring',
    kind: 'number',
    width: 90,
    align: 'center',
    cellRenderer: 'progressRing',
    cellRendererParams: { size: 30, thickness: 4, animate: true, showLabel },
  },
];
export const options = {
  columns: columns(),
  rows,
  rowKey: 'id',
  saveMode: 'none',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  showLabel = true;
  log('A value over the range like 130 stops the ring at 100%, and an empty value leaves an empty ring.');
}
export const actions = {
  label: (api, value) => {
    showLabel = value !== 'hide';
    api.setColumns(columns());
    say(showLabel ? 'Showing the number inside the ring.' : 'Showing only the ring.');
  },
  more: (api) => {
    const changed = api
      .getRows()
      .flatMap((row) => typeof row.done === 'number' && row.done < 100
      ? [{ ...row, done: Math.min(100, row.done + 10), big: Math.min(100, row.big + 10) }]
      : []);
    api.updateRows(changed);
    say(`Raised the ${changed.length} rows under 100 by 10.`);
  },
};