Skip to content

Commit bc6446b

Browse files
committed
feat: ✨ support the data_visualization block (line, bar, area, pie charts)
Adds the new Slack data_visualization Block Kit block introduced in the 2026-06-16 Block Kit release. - Types: DataVisualizationBlock plus DataVizChart (cartesian line/bar/area via series + axis_config, and pie via segments) added to the Block union. - Renderer: a dependency-free inline-SVG chart component covering line, grouped bar, stacked-style area, and pie. Handles multi-series, negative values (zero baseline), "nice" auto-scaled Y ticks, axis/category labels, a color-swatch legend, and Slack's accessible aria-label patterns. Works in both light and dark mode. - Affordances: a "view as table" toggle and a CSV download, mirroring Slack's chart action buttons (SSR-safe). - Docs/playground: readme Supported Blocks row and a charts fixture. - Tests: renders the Block Kit example fixtures and locks in the h3 title, aria-labels, legend, axis labels, negative handling, and pie percentages. https://claude.ai/code/session_018T7Lik8eFCV8DMtTckZC6a
1 parent bb2b269 commit bc6446b

8 files changed

Lines changed: 1042 additions & 0 deletions

File tree

playground/src/fixtures.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,119 @@ export const FIXTURES: Fixture[] = [
238238
},
239239
],
240240
},
241+
{
242+
id: "data-visualization",
243+
label: "Data visualization · charts",
244+
blocks: [
245+
{
246+
type: "data_visualization",
247+
block_id: "viz-line-multi",
248+
title: "Weekly active users by platform",
249+
chart: {
250+
type: "line",
251+
series: [
252+
{
253+
name: "Desktop",
254+
data: [
255+
{ label: "Mon", value: 800 },
256+
{ label: "Tue", value: 920 },
257+
{ label: "Wed", value: 880 },
258+
{ label: "Thu", value: 1010 },
259+
{ label: "Fri", value: 1120 },
260+
],
261+
},
262+
{
263+
name: "Mobile",
264+
data: [
265+
{ label: "Mon", value: 400 },
266+
{ label: "Tue", value: 530 },
267+
{ label: "Wed", value: 500 },
268+
{ label: "Thu", value: 590 },
269+
{ label: "Fri", value: 600 },
270+
],
271+
},
272+
],
273+
axis_config: {
274+
categories: ["Mon", "Tue", "Wed", "Thu", "Fri"],
275+
x_label: "Day",
276+
y_label: "Users",
277+
},
278+
},
279+
},
280+
{
281+
type: "data_visualization",
282+
block_id: "viz-bar-negative",
283+
title: "Net headcount change",
284+
chart: {
285+
type: "bar",
286+
series: [
287+
{
288+
name: "Delta",
289+
data: [
290+
{ label: "Mon", value: 4 },
291+
{ label: "Tue", value: -2 },
292+
{ label: "Wed", value: 6 },
293+
{ label: "Thu", value: -1 },
294+
{ label: "Fri", value: 3 },
295+
],
296+
},
297+
],
298+
axis_config: {
299+
categories: ["Mon", "Tue", "Wed", "Thu", "Fri"],
300+
x_label: "Day",
301+
y_label: "People (delta)",
302+
},
303+
},
304+
},
305+
{
306+
type: "data_visualization",
307+
block_id: "viz-area-multi",
308+
title: "Concurrent users by platform",
309+
chart: {
310+
type: "area",
311+
series: [
312+
{
313+
name: "Desktop",
314+
data: [
315+
{ label: "Mon", value: 2800 },
316+
{ label: "Tue", value: 3000 },
317+
{ label: "Wed", value: 3400 },
318+
{ label: "Thu", value: 3200 },
319+
{ label: "Fri", value: 3500 },
320+
],
321+
},
322+
{
323+
name: "Mobile",
324+
data: [
325+
{ label: "Mon", value: 1400 },
326+
{ label: "Tue", value: 1500 },
327+
{ label: "Wed", value: 1700 },
328+
{ label: "Thu", value: 1600 },
329+
{ label: "Fri", value: 1800 },
330+
],
331+
},
332+
],
333+
axis_config: {
334+
categories: ["Mon", "Tue", "Wed", "Thu", "Fri"],
335+
x_label: "Day",
336+
y_label: "Users",
337+
},
338+
},
339+
},
340+
{
341+
type: "data_visualization",
342+
block_id: "viz-pie-multi",
343+
title: "Plan distribution by tier",
344+
chart: {
345+
type: "pie",
346+
segments: [
347+
{ label: "Free", value: 4200 },
348+
{ label: "Pro", value: 2300 },
349+
{ label: "Business+", value: 1100 },
350+
{ label: "Enterprise", value: 480 },
351+
],
352+
},
353+
},
354+
],
355+
},
241356
];

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ const blocks: Block[] = [
142142
| Markdown | ✅ Full | Standard markdown with GFM (tables, task lists, code blocks) |
143143
| Plan | ✅ Full | Sequential task display with status indicators |
144144
| Task Card | ✅ Full | Individual task with title, details, output, sources, status |
145+
| Data Visualization | ✅ Full | Line, bar, area, and pie charts with legend, axes, and "view as table" / CSV export |
145146

146147
## Supported Elements
147148

0 commit comments

Comments
 (0)