Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Data visualization block

Bar, line, area, and pie charts for a series of labeled values.

data_visualization renders one chart from a series of labeled values, or segments for a pie. It isn’t part of the public @slack/types package, so treat this page’s field list as the reference.

Your AppAPP

Messages sent this week

Messages
05001,0001,5002,0002,5003,000MonTueWedThuFri
Day
Messages

Fields

PropType
typestring

Always data_visualization.

Typestring
title?string

Shown above the chart. Omit it and no heading renders.

Typestring
chartChart

The chart itself.

TypeChart

Chart

PropType
type"bar" | "line" | "area" | "pie"

The chart kind. No other values are supported.

Type"bar" | "line" | "area" | "pie"
series?ChartSeries[]

One or more series, for bar, line, and area charts. One entry draws a single series; two or more group bars or plot multiple lines/areas.

TypeChartSeries[]
segments?{ label: string; value: number }[]

Wedges, for a pie chart only. A negative value is clamped to 0.

Type{ label: string; value: number }[]
axis_config?AxisConfig

Axis labels and category overrides. Ignored for pie.

TypeAxisConfig

ChartSeries is { name: string; data: { label: string; value: number }[] }. AxisConfig is { categories?: string[]; x_label?: string; y_label?: string }. categories overrides the x-axis labels; when omitted they’re taken from the first series’ data[].label. A block without chart renders nothing. A series value matches its category by label, then by position; one with no value either way leaves that cell empty in View as table and the download.

When the category labels don’t fit side by side, as with 20 categories, Slack turns them 45° and gives the plot more room below; this does the same.

Slack allows 12 series (or pie segments) of at most 20 data points, one for each category. A chart with more draws, and tabulates, the first 12 series or segments, 20 points a series and 20 categories, and leaves out the rest.

Narrow messages

As in Slack, a chart card is never narrower than 400px. In a narrower message, such as Block Kit Builder’s mobile preview, where blocks are 320px wide, the card keeps its 400px and scrolls sideways inside the block: the plot keeps its spacing, a pie keeps its size, and the last category starts out of view until the reader scrolls to it. The More actions button sits on the card, so it starts out of view too and scrolls in with it. The page itself doesn’t scroll sideways.

Hover and actions

As in Slack, pointing at a chart shows its values. Over a bar, line or area chart, a dashed line marks the category under the pointer (the bar’s band, or the nearest point) and a tooltip lists each series’ value there; a bar chart lifts that category’s bars and a line chart lifts its lines. Over a pie, the slice under the pointer lifts, grows slightly and shows its label and value. Touch screens don’t hover, so they don’t show the tooltip.

The tooltip moves as Slack’s does: it appears at once the first time, then slides after the pointer (0.4s) and fades in and out (0.2s). After it has been hidden for more than half a second it comes back with the fade only. With reduced motion (prefers-reduced-motion: reduce) it only fades.

The More actions button in the chart’s top-right corner opens Slack’s menu:

  • View as table opens the chart’s data in a modal titled with the chart’s title, as a table: one row per series under Series and the categories, or a pie’s segments under Label and Value. Escape, the close button or a click outside closes it.
  • Download chart data saves the same table as a tab-separated file named after the title (messages-sent-by-platform.tsv). A label or name a spreadsheet would read as a formula (starting with =, +, - or @, and not a number) is saved with a leading ', so opening the file can’t run it.
  • Copy as image shows disabled, as it does in Block Kit Builder.

The menu opens beside the button above the page, so the card never clips or scrolls it, and works from the keyboard: the arrow keys move through it, Enter chooses, and Escape closes it and returns focus to the button. As in Slack, these actions stay in the page: none of them calls onAction.

Examples

Bar: single series

The preview at the top of this page is a bar chart with one series: one bar per category.

Bar: multiple series

Your AppAPP

Messages sent by platform

Messages
03006009001,2001,5001,800MonTueWedThuFri
Day
DesktopMobile

Bar: negative values

Your AppAPP

Net headcount change

People (delta)
-20246MonTueWedThuFri
Day
Delta

Bars for negative values extend below the zero line instead of being clipped or flipped.

Line: negative values

Your AppAPP

Net revenue delta (vs. forecast)

Delta ($)
-200-1000100200MonTueWedThuFri
Day
Delta

Area: multiple series

Your AppAPP

Concurrent users by platform

Users
01,0002,0003,0004,000MonTueWedThuFri
Day
DesktopMobile

Pie: multiple segments

Your AppAPP

Plan distribution by tier

FreeProBusiness+Enterprise

Pie: one dominant segment

Your AppAPP

Active sessions by client (one dominant)

DesktopMobileWebOther

Last updated on