Pie / Donut
Compare a small number of categories by their share of the total.
Pie / Donut
The smallest runnable chart
Explore the chart and its data table. Open the code below to use this example.
Basic example
Loading
Basic example · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}- Quick API
pie()- Browser snapshot
graflume- mark
pie- Presets
- 3
minimal-implementation
Common features
Features shared by every chart
Use the tabs to compare header, tooltip, theme, legend, highlight, callout, selection, view controls, and accessibility one feature at a time. Hover over a data mark. On supported charts, move the pointer along the axis to see the nearest value. All exact values are available in the table below.
Header
Add a chart title and supporting description inside the visualization.
Loading
Header · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"title": {
"subtitle": "Pie chart uses runnable data and options to demonstrate start angle and direction; leader labels.",
"text": "Pie / Donut"
},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"title": {
"subtitle": "Pie chart uses runnable data and options to demonstrate start angle and direction; leader labels.",
"text": "Pie / Donut"
},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}header
Tooltip
Reveal exact values from a mark or axis position. Authors can choose locale-aware date/time styles and a time zone with declarative options.
Loading
Tooltip · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"hover": true,
"tooltip": {
"fields": [
{
"field": "category",
"format": "auto",
"label": "Category"
},
{
"field": "value",
"format": "number",
"label": "Value"
}
],
"title": "Pie / Donut · Tooltip",
"trigger": "mark"
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"hover": true,
"tooltip": {
"fields": [
{
"field": "category",
"format": "auto",
"label": "Category"
},
{
"field": "value",
"format": "number",
"label": "Value"
}
],
"title": "Pie / Donut · Tooltip",
"trigger": "mark"
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}tooltip
Theme
Apply the current built-in theme from the selector and update every active example together.
Loading
Theme · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"theme": "graflume-light",
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"theme": "graflume-light",
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}theme
Legend
Explain the visual meaning of layers, categories, or continuous values.
Loading
Legend · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"legend": {
"field": "category",
"interactive": true,
"labels": {
"hide": "Hide",
"show": "Show"
},
"maxItems": 8,
"mode": "categories",
"orientation": "horizontal",
"position": "bottom",
"title": "Category",
"visible": true
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"legend": {
"field": "category",
"interactive": true,
"labels": {
"hide": "Hide",
"show": "Show"
},
"maxItems": 8,
"mode": "categories",
"orientation": "horizontal",
"position": "bottom",
"title": "Category",
"visible": true
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}legend
- Legend:
legend · categories · category
Highlight
Emphasize a representative datum or spatial position to guide inspection.
Loading
Highlight · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"highlights": [
{
"id": "manual-focus",
"padding": 7,
"target": {
"field": "category",
"type": "datum",
"value": "Product referrals"
}
}
],
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"highlights": [
{
"id": "manual-focus",
"padding": 7,
"target": {
"field": "category",
"type": "datum",
"value": "Product referrals"
}
}
],
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}highlight
- Point and range highlights:
highlights[] · datum · category
Callout
Show an explanatory callout with automatic collision avoidance and multilingual wrapping.
Loading
Callout · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"annotations": [
{
"connector": {
"visible": true
},
"detail": "Attach user-authored safe text to a datum, axis range, or normalized plot position.",
"id": "manual-callout",
"placement": "auto",
"style": {
"maxWidth": 220,
"padding": 8
},
"target": {
"field": "category",
"type": "datum",
"value": "Product referrals"
},
"text": "Point and range highlights · Product referrals"
}
],
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"controls": {
"annotations": true,
"labels": {
"controls": "Chart controls",
"enterFullscreen": "Enter fullscreen",
"exitFullscreen": "Exit fullscreen",
"exportPng": "Download PNG",
"hideAnnotations": "Hide callouts",
"loop": "Loop playback",
"nextFrame": "Next frame",
"pause": "Pause",
"play": "Play",
"previousFrame": "Previous frame",
"reset": "Reset view",
"seek": "Playback position",
"showAnnotations": "Show callouts",
"speed": "Playback speed",
"zoomIn": "Zoom in",
"zoomOut": "Zoom out"
}
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"annotations": [
{
"connector": {
"visible": true
},
"detail": "Attach user-authored safe text to a datum, axis range, or normalized plot position.",
"id": "manual-callout",
"placement": "auto",
"style": {
"maxWidth": 220,
"padding": 8
},
"target": {
"field": "category",
"type": "datum",
"value": "Product referrals"
},
"text": "Point and range highlights · Product referrals"
}
],
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"controls": {
"annotations": true,
"labels": {
"controls": "Chart controls",
"enterFullscreen": "Enter fullscreen",
"exitFullscreen": "Exit fullscreen",
"exportPng": "Download PNG",
"hideAnnotations": "Hide callouts",
"loop": "Loop playback",
"nextFrame": "Next frame",
"pause": "Pause",
"play": "Play",
"previousFrame": "Previous frame",
"reset": "Reset view",
"seek": "Playback position",
"showAnnotations": "Show callouts",
"speed": "Playback speed",
"zoomIn": "Zoom in",
"zoomOut": "Zoom out"
}
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}callout
- Custom callouts:
annotations[] · datum · category · callout · placement:auto
Selection
Select and toggle data, then clear it from the background or Escape key.
Loading
Selection · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"selection": {
"ariaLabel": "Interactive selection",
"clearOnBackground": true,
"clearOnEscape": true,
"highlight": {
"padding": 5
},
"key": "category",
"mode": "multiple",
"toggle": true
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"selection": {
"ariaLabel": "Interactive selection",
"clearOnBackground": true,
"clearOnEscape": true,
"highlight": {
"padding": 5
},
"key": "category",
"mode": "multiple",
"toggle": true
}
},
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}selection
- Interactive selection:
selection · multiple · toggle
View controls
Show or hide zoom, pan, reset, projection, fullscreen, and PNG export one menu at a time. Set controls: false to remove the entire toolbar.
Loading
View controls · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"controls": {
"annotations": false,
"export": true,
"fullscreen": true,
"labels": {
"controls": "Chart controls",
"enterFullscreen": "Enter fullscreen",
"exitFullscreen": "Exit fullscreen",
"exportPng": "Download PNG",
"hideAnnotations": "Hide callouts",
"loop": "Loop playback",
"nextFrame": "Next frame",
"pause": "Pause",
"play": "Play",
"previousFrame": "Previous frame",
"reset": "Reset view",
"seek": "Playback position",
"showAnnotations": "Show callouts",
"speed": "Playback speed",
"zoomIn": "Zoom in",
"zoomOut": "Zoom out"
},
"playback": false,
"reset": true,
"zoom": true
},
"navigation": {
"drag": true,
"keyboard": true,
"maxZoom": 6,
"minZoom": 1,
"pinch": true,
"wheel": "modifier"
}
},
"locale": "en",
"mark": {},
"padding": {
"top": 52
},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"axes": {
"x": false,
"y": false
},
"height": 620,
"interaction": {
"controls": {
"annotations": false,
"export": true,
"fullscreen": true,
"labels": {
"controls": "Chart controls",
"enterFullscreen": "Enter fullscreen",
"exitFullscreen": "Exit fullscreen",
"exportPng": "Download PNG",
"hideAnnotations": "Hide callouts",
"loop": "Loop playback",
"nextFrame": "Next frame",
"pause": "Pause",
"play": "Play",
"previousFrame": "Previous frame",
"reset": "Reset view",
"seek": "Playback position",
"showAnnotations": "Show callouts",
"speed": "Playback speed",
"zoomIn": "Zoom in",
"zoomOut": "Zoom out"
},
"playback": false,
"reset": true,
"zoom": true
},
"navigation": {
"drag": true,
"keyboard": true,
"maxZoom": 6,
"minZoom": 1,
"pinch": true,
"wheel": "modifier"
}
},
"locale": "en",
"mark": {},
"padding": {
"top": 52
},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}controls
Accessibility
Pair ARIA descriptions and keyboard guidance with a semantic data table.
Loading
Accessibility · Row data
Row data and zero-copy TypedArray columns share one data contract.
categoryordinal | valuequantitative |
|---|---|
| Organic search | 38 |
| Direct | 27 |
| Product referrals | 18 |
| Community | 11 |
| Campaigns | 6 |
View code and settings
Browser API
Graflume.pie()
const data = [
{
"category": "Organic search",
"radius": 34,
"value": 38
},
{
"category": "Direct",
"radius": 28,
"value": 27
},
{
"category": "Product referrals",
"radius": 23,
"value": 18
},
{
"category": "Community",
"radius": 18,
"value": 11
},
{
"category": "Campaigns",
"radius": 13,
"value": 6
}
];
const options = {
"accessibility": {
"description": "Zoom and pan inspect the rendered surface without changing data axes or values. When playback controls are available, they move through real steps in the order each unique value first appears in the source data.",
"label": "Pie / Donut · Accessibility example"
},
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
};
Graflume.pie('#chart', data, options);Portable schema
ChartSpec 0.1 · options
{
"accessibility": {
"description": "Zoom and pan inspect the rendered surface without changing data axes or values. When playback controls are available, they move through real steps in the order each unique value first appears in the source data.",
"label": "Pie / Donut · Accessibility example"
},
"axes": {
"x": false,
"y": false
},
"height": 620,
"locale": "en",
"mark": {},
"width": "container",
"x": {
"field": "category",
"title": "Channel",
"type": "ordinal"
},
"y": {
"field": "value",
"title": "Share (%)",
"type": "quantitative"
}
}accessibility