진행 막대: 범위와 구간별 색Progress bars: range and colors by band
숫자를 막대로 보여 줘요. 범위를 정하고, 값 구간에 따라 초록·노랑·빨강으로 바뀌게 하고, 막대만 보일지 숫자도 함께 보일지 고를 수 있어요.Show numbers as bars. Set the range, change green/yellow/red by band, and choose bar only or bar with number.
코드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)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<select aria-label="막대 표시" id="text">
<option value="both" selected>막대와 숫자</option>
<option value="bar">막대만</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>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('text').addEventListener('change', (event) => actions.text(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));// 내장 진행 막대에는 화면 읽기 프로그램용 이름이 없어서, 줄의 첫 칸 글자를 붙여 이름을 달아 줘요.
function nameBars(label, cell = 0) {
const root = document.getElementById('grid');
if (!root)
return () => undefined;
const apply = () => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label'))
continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine)]?.textContent?.trim();
bar.setAttribute('aria-label', `${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim());
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
// cellRenderer: 'progress'는 숫자를 막대로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 막대가 비어 있어요. min·max로 범위를, ranges로 구간별 색을, showText로 숫자 표시를 정해요.
const rows = [
{ id: 1, task: '디자인 검토', owner: '김서연', done: 100, load: 3, quota: 20 },
{ id: 2, task: '빌드 자동화', owner: '이준호', done: 72, load: 7, quota: 55 },
{ id: 3, task: '부하 시험', owner: '박민지', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: '문서 작성', owner: '김서연', done: 0, load: 1, quota: 8 },
{ id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, load: 5, quota: 45 },
{ id: 6, task: '아직 시작 전', owner: '박민지', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = () => [
{ id: 'task', title: '업무', width: 130 },
{
id: 'done',
title: '진행률',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : '해당 없음'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: '서버 부하(0~10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say = () => { };
export function setup(_api, log) {
say = log;
showText = true;
const stop = nameBars('진행');
log({
ko: '130%처럼 범위를 넘은 값은 막대가 100%에서 멈추고, 비어 있는 값은 막대가 비어 있어요.',
en: 'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
});
return stop;
}
export const actions = {
text: (api, value) => {
showText = value !== 'bar';
api.setColumns(columns());
say({
ko: showText ? '막대에 숫자도 함께 보여요.' : '막대만 보여요.',
en: showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.',
});
},
more: (api) => {
const changed = api
.getRows()
.flatMap((row) => typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: []);
api.updateRows(changed);
say({
ko: `진행률이 100% 미만인 ${changed.length}줄을 10%씩 올렸어요.`,
en: `Raised the ${changed.length} rows under 100% progress by 10%.`,
});
},
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>진행 막대: 범위와 구간별 색</title>
</head>
<body>
<div class="toolbar">
<select aria-label="막대 표시" id="text">
<option value="both" selected>막대와 숫자</option>
<option value="bar">막대만</option>
</select>
<button type="button" id="more">진행률 +10%</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// 내장 진행 막대에는 화면 읽기 프로그램용 이름이 없어서, 줄의 첫 칸 글자를 붙여 이름을 달아 줘요.
function nameBars(label, cell = 0) {
const root = document.getElementById('grid');
if (!root)
return () => undefined;
const apply = () => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label'))
continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine)]?.textContent?.trim();
bar.setAttribute('aria-label', `${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim());
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
// cellRenderer: 'progress'는 숫자를 막대로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 막대가 비어 있어요. min·max로 범위를, ranges로 구간별 색을, showText로 숫자 표시를 정해요.
const rows = [
{ id: 1, task: '디자인 검토', owner: '김서연', done: 100, load: 3, quota: 20 },
{ id: 2, task: '빌드 자동화', owner: '이준호', done: 72, load: 7, quota: 55 },
{ id: 3, task: '부하 시험', owner: '박민지', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: '문서 작성', owner: '김서연', done: 0, load: 1, quota: 8 },
{ id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, load: 5, quota: 45 },
{ id: 6, task: '아직 시작 전', owner: '박민지', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = () => [
{ id: 'task', title: '업무', width: 130 },
{
id: 'done',
title: '진행률',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : '해당 없음'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: '서버 부하(0~10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
const options = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say = () => { };
function setup(_api, log) {
say = log;
showText = true;
const stop = nameBars('진행');
log({
ko: '130%처럼 범위를 넘은 값은 막대가 100%에서 멈추고, 비어 있는 값은 막대가 비어 있어요.',
en: 'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
});
return stop;
}
const actions = {
text: (api, value) => {
showText = value !== 'bar';
api.setColumns(columns());
say({
ko: showText ? '막대에 숫자도 함께 보여요.' : '막대만 보여요.',
en: showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.',
});
},
more: (api) => {
const changed = api
.getRows()
.flatMap((row) => typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: []);
api.updateRows(changed);
say({
ko: `진행률이 100% 미만인 ${changed.length}줄을 10%씩 올렸어요.`,
en: `Raised the ${changed.length} rows under 100% progress by 10%.`,
});
},
};
options.ariaLabel = "진행 막대: 범위와 구간별 색";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('text').addEventListener('change', (event) => actions.text(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="막대 표시"
disabled={!api}
onChange={(event) => api && actions.text(api, event.target.value)}
>
<option value="both">막대와 숫자</option>
<option value="bar">막대만</option>
</select>
<button
type="button"
disabled={!api}
onClick={() => api && actions.more(api)}
>진행률 +10%</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
// 내장 진행 막대에는 화면 읽기 프로그램용 이름이 없어서, 줄의 첫 칸 글자를 붙여 이름을 달아 줘요.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress'는 숫자를 막대로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 막대가 비어 있어요. min·max로 범위를, ranges로 구간별 색을, showText로 숫자 표시를 정해요.
const rows: Row[] = [
{ id: 1, task: '디자인 검토', owner: '김서연', done: 100, load: 3, quota: 20 },
{ id: 2, task: '빌드 자동화', owner: '이준호', done: 72, load: 7, quota: 55 },
{ id: 3, task: '부하 시험', owner: '박민지', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: '문서 작성', owner: '김서연', done: 0, load: 1, quota: 8 },
{ id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, load: 5, quota: 45 },
{ id: 6, task: '아직 시작 전', owner: '박민지', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: '업무', width: 130 },
{
id: 'done',
title: '진행률',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : '해당 없음'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: '서버 부하(0~10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('진행');
log({
ko: '130%처럼 범위를 넘은 값은 막대가 100%에서 멈추고, 비어 있는 값은 막대가 비어 있어요.',
en: 'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
});
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say({
ko: showText ? '막대에 숫자도 함께 보여요.' : '막대만 보여요.',
en: showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.',
});
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say({
ko: `진행률이 100% 미만인 ${changed.length}줄을 10%씩 올렸어요.`,
en: `Raised the ${changed.length} rows under 100% progress by 10%.`,
});
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="막대 표시"
:disabled="!api"
@change="api && actions.text(api, ($event.target as HTMLSelectElement).value)"
>
<option value="both" selected>막대와 숫자</option>
<option value="bar">막대만</option>
</select>
<button type="button" :disabled="!api" @click="api && actions.more(api)">진행률 +10%</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
// 내장 진행 막대에는 화면 읽기 프로그램용 이름이 없어서, 줄의 첫 칸 글자를 붙여 이름을 달아 줘요.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress'는 숫자를 막대로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 막대가 비어 있어요. min·max로 범위를, ranges로 구간별 색을, showText로 숫자 표시를 정해요.
const rows: Row[] = [
{ id: 1, task: '디자인 검토', owner: '김서연', done: 100, load: 3, quota: 20 },
{ id: 2, task: '빌드 자동화', owner: '이준호', done: 72, load: 7, quota: 55 },
{ id: 3, task: '부하 시험', owner: '박민지', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: '문서 작성', owner: '김서연', done: 0, load: 1, quota: 8 },
{ id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, load: 5, quota: 45 },
{ id: 6, task: '아직 시작 전', owner: '박민지', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: '업무', width: 130 },
{
id: 'done',
title: '진행률',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : '해당 없음'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: '서버 부하(0~10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('진행');
log({
ko: '130%처럼 범위를 넘은 값은 막대가 100%에서 멈추고, 비어 있는 값은 막대가 비어 있어요.',
en: 'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
});
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say({
ko: showText ? '막대에 숫자도 함께 보여요.' : '막대만 보여요.',
en: showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.',
});
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say({
ko: `진행률이 100% 미만인 ${changed.length}줄을 10%씩 올렸어요.`,
en: `Raised the ${changed.length} rows under 100% progress by 10%.`,
});
},
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="막대 표시"
[disabled]="!api"
(change)="api && actions.text(api, $any($event.target).value)"
>
<option value="both" selected>막대와 숫자</option>
<option value="bar">막대만</option>
</select>
<button
type="button"
[disabled]="!api"
(click)="api && actions.more(api)"
>진행률 +10%</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
// 내장 진행 막대에는 화면 읽기 프로그램용 이름이 없어서, 줄의 첫 칸 글자를 붙여 이름을 달아 줘요.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress'는 숫자를 막대로 그려요. 기본 범위는 0~100이고 범위를 벗어난 값은 끝에 맞춰요.
// 숫자가 아니면 막대가 비어 있어요. min·max로 범위를, ranges로 구간별 색을, showText로 숫자 표시를 정해요.
const rows: Row[] = [
{ id: 1, task: '디자인 검토', owner: '김서연', done: 100, load: 3, quota: 20 },
{ id: 2, task: '빌드 자동화', owner: '이준호', done: 72, load: 7, quota: 55 },
{ id: 3, task: '부하 시험', owner: '박민지', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: '문서 작성', owner: '김서연', done: 0, load: 1, quota: 8 },
{ id: 5, task: '보고 과다 입력', owner: '이준호', done: 130, load: 5, quota: 45 },
{ id: 6, task: '아직 시작 전', owner: '박민지', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: '업무', width: 130 },
{
id: 'done',
title: '진행률',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : '해당 없음'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: '서버 부하(0~10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('진행');
log({
ko: '130%처럼 범위를 넘은 값은 막대가 100%에서 멈추고, 비어 있는 값은 막대가 비어 있어요.',
en: 'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
});
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say({
ko: showText ? '막대에 숫자도 함께 보여요.' : '막대만 보여요.',
en: showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.',
});
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say({
ko: `진행률이 100% 미만인 ${changed.length}줄을 10%씩 올렸어요.`,
en: `Raised the ${changed.length} rows under 100% progress by 10%.`,
});
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Bar display" id="text">
<option value="both" selected>Bar and number</option>
<option value="bar">Bar only</option>
</select>
<button type="button" id="more">Progress +10%</button>
</div>
<div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('text').addEventListener('change', (event) => actions.text(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));// The built-in progress bar has no name for screen readers, so this adds one using the text of the row's first cell.
function nameBars(label, cell = 0) {
const root = document.getElementById('grid');
if (!root)
return () => undefined;
const apply = () => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label'))
continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine)]?.textContent?.trim();
bar.setAttribute('aria-label', `${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim());
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
// cellRenderer: 'progress' draws a number as a bar. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves the bar empty. min/max set the range, ranges set colors per band, and showText controls the number display.
const rows = [
{ id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, load: 3, quota: 20 },
{ id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, load: 7, quota: 55 },
{ id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, load: 1, quota: 8 },
{ id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, load: 5, quota: 45 },
{ id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = () => [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'done',
title: 'Progress',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : 'N/A'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: 'Server load (0-10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say = () => { };
export function setup(_api, log) {
say = log;
showText = true;
const stop = nameBars('Progress');
log('A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.');
return stop;
}
export const actions = {
text: (api, value) => {
showText = value !== 'bar';
api.setColumns(columns());
say(showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.');
},
more: (api) => {
const changed = api
.getRows()
.flatMap((row) => typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: []);
api.updateRows(changed);
say(`Raised the ${changed.length} rows under 100% progress by 10%.`);
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Progress bars: range and colors by band</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Bar display" id="text">
<option value="both" selected>Bar and number</option>
<option value="bar">Bar only</option>
</select>
<button type="button" id="more">Progress +10%</button>
</div>
<div id="grid" style="height: 300px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
// The built-in progress bar has no name for screen readers, so this adds one using the text of the row's first cell.
function nameBars(label, cell = 0) {
const root = document.getElementById('grid');
if (!root)
return () => undefined;
const apply = () => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label'))
continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine)]?.textContent?.trim();
bar.setAttribute('aria-label', `${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim());
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
// cellRenderer: 'progress' draws a number as a bar. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves the bar empty. min/max set the range, ranges set colors per band, and showText controls the number display.
const rows = [
{ id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, load: 3, quota: 20 },
{ id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, load: 7, quota: 55 },
{ id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, load: 1, quota: 8 },
{ id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, load: 5, quota: 45 },
{ id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = () => [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'done',
title: 'Progress',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : 'N/A'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: 'Server load (0-10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
const options = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say = () => { };
function setup(_api, log) {
say = log;
showText = true;
const stop = nameBars('Progress');
log('A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.');
return stop;
}
const actions = {
text: (api, value) => {
showText = value !== 'bar';
api.setColumns(columns());
say(showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.');
},
more: (api) => {
const changed = api
.getRows()
.flatMap((row) => typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: []);
api.updateRows(changed);
say(`Raised the ${changed.length} rows under 100% progress by 10%.`);
},
};
options.ariaLabel = "Progress bars: range and colors by band";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('text').addEventListener('change', (event) => actions.text(api, event.target.value));
document.getElementById('more').addEventListener('click', () => actions.more(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<select
aria-label="Bar display"
disabled={!api}
onChange={(event) => api && actions.text(api, event.target.value)}
>
<option value="both">Bar and number</option>
<option value="bar">Bar only</option>
</select>
<button
type="button"
disabled={!api}
onClick={() => api && actions.more(api)}
>Progress +10%</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
// The built-in progress bar has no name for screen readers, so this adds one using the text of the row's first cell.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress' draws a number as a bar. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves the bar empty. min/max set the range, ranges set colors per band, and showText controls the number display.
const rows: Row[] = [
{ id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, load: 3, quota: 20 },
{ id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, load: 7, quota: 55 },
{ id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, load: 1, quota: 8 },
{ id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, load: 5, quota: 45 },
{ id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'done',
title: 'Progress',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : 'N/A'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: 'Server load (0-10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('Progress');
log(
'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
);
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say(showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.');
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say(`Raised the ${changed.length} rows under 100% progress by 10%.`);
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<select
aria-label="Bar display"
:disabled="!api"
@change="api && actions.text(api, ($event.target as HTMLSelectElement).value)"
>
<option value="both" selected>Bar and number</option>
<option value="bar">Bar only</option>
</select>
<button type="button" :disabled="!api" @click="api && actions.more(api)">Progress +10%</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
// The built-in progress bar has no name for screen readers, so this adds one using the text of the row's first cell.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress' draws a number as a bar. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves the bar empty. min/max set the range, ranges set colors per band, and showText controls the number display.
const rows: Row[] = [
{ id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, load: 3, quota: 20 },
{ id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, load: 7, quota: 55 },
{ id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, load: 1, quota: 8 },
{ id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, load: 5, quota: 45 },
{ id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'done',
title: 'Progress',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : 'N/A'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: 'Server load (0-10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('Progress');
log(
'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
);
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say(showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.');
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say(`Raised the ${changed.length} rows under 100% progress by 10%.`);
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<select
aria-label="Bar display"
[disabled]="!api"
(change)="api && actions.text(api, $any($event.target).value)"
>
<option value="both" selected>Bar and number</option>
<option value="bar">Bar only</option>
</select>
<button
type="button"
[disabled]="!api"
(click)="api && actions.more(api)"
>Progress +10%</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
// The built-in progress bar has no name for screen readers, so this adds one using the text of the row's first cell.
function nameBars(label: string, cell = 0): () => void {
const root = document.getElementById('grid');
if (!root) return () => undefined;
const apply = (): void => {
for (const bar of root.querySelectorAll('[role="progressbar"]')) {
if (bar.getAttribute('aria-label')) continue;
const row = bar.closest('[role="row"]');
const cells = [...(row?.querySelectorAll('[role="gridcell"]:not(.mxg-checkcell)') ?? [])];
const mine = bar.closest('[role="gridcell"]');
const headers = root.querySelectorAll('[role="columnheader"]');
const header = headers[cells.indexOf(mine as Element)]?.textContent?.trim();
bar.setAttribute(
'aria-label',
`${cells[cell]?.textContent?.trim() ?? ''} ${header || label}`.trim(),
);
}
};
const observer = new MutationObserver(apply);
observer.observe(root, { childList: true, subtree: true });
apply();
return () => observer.disconnect();
}
export interface Row {
id: number;
task: string;
owner: string;
done: number | null;
load: number;
quota: number;
}
// cellRenderer: 'progress' draws a number as a bar. The default range is 0-100 and out-of-range values are clamped to the ends.
// A non-number leaves the bar empty. min/max set the range, ranges set colors per band, and showText controls the number display.
const rows: Row[] = [
{ id: 1, task: 'Design review', owner: 'Olivia Reed', done: 100, load: 3, quota: 20 },
{ id: 2, task: 'Build automation', owner: 'Liam Carter', done: 72, load: 7, quota: 55 },
{ id: 3, task: 'Load test', owner: 'Emma Stone', done: 35, load: 9.5, quota: 90 },
{ id: 4, task: 'Write docs', owner: 'Olivia Reed', done: 0, load: 1, quota: 8 },
{ id: 5, task: 'Over-reported entry', owner: 'Liam Carter', done: 130, load: 5, quota: 45 },
{ id: 6, task: 'Not started yet', owner: 'Emma Stone', done: null, load: 2, quota: 12 },
];
let showText = true;
const columns = (): NonNullable<GridOptions<Row>['columns']> => [
{ id: 'task', title: 'Task', width: 150 },
{
id: 'done',
title: 'Progress',
kind: 'number',
width: 170,
formatValue: (value) => (typeof value === 'number' ? `${String(value)}%` : 'N/A'),
cellRenderer: 'progress',
cellRendererParams: { showText },
},
{
id: 'load',
title: 'Server load (0-10)',
kind: 'number',
width: 190,
formatValue: (value) => `${String(value)} / 10`,
cellRenderer: 'progress',
cellRendererParams: {
min: 0,
max: 10,
showText,
ranges: [
{ upTo: 60, tone: 'success' },
{ upTo: 85, tone: 'warning' },
{ upTo: 100, tone: 'danger' },
],
},
},
];
export const options: GridOptions<Row> = {
columns: columns(),
rows,
rowKey: 'id',
saveMode: 'none',
};
let say: (message: LogText) => void = () => {};
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
showText = true;
const stop = nameBars('Progress');
log(
'A value over the range like 130% stops the bar at 100%, and an empty value leaves the bar empty.',
);
return stop;
}
export const actions = {
text: (api: GridApi<Row>, value?: string) => {
showText = value !== 'bar';
api.setColumns(columns());
say(showText ? 'Showing numbers on the bar too.' : 'Showing only the bar.');
},
more: (api: GridApi<Row>) => {
const changed = api
.getRows()
.flatMap((row) =>
typeof row.done === 'number' && row.done < 100
? [{ ...row, done: Math.min(100, row.done + 10) }]
: [],
);
api.updateRows(changed);
say(`Raised the ${changed.length} rows under 100% progress by 10%.`);
},
};