Sunburst
Overview
The sunburst
trace type is used to create sunburst charts, which visualize hierarchical data in a circular format. Sunburst charts are useful for showing relationships between parts and the whole, with nested levels of data radiating outward from the center.
You can customize the colors, labels, and hierarchy of the chart to represent your data effectively.
Common Uses
- Hierarchical Data Visualization: Displaying relationships between different levels of data.
- Part-to-Whole Relationships: Visualizing how parts contribute to the whole across multiple levels.
- Categorical Data: Showing categorical breakdowns with nested data.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
Here's a simple sunburst
plot showing a hierarchy of categories:
You can copy this code below to create this chart in your project:
models:
- name: sunburst-data
args:
- echo
- |
labels,parents,values
Total,,100
A,Total,40
B,Total,30
C,Total,30
D,A,10
E,A,20
F,B,10
traces:
- name: Simple Sunburst Plot
model: ${ref(sunburst-data)}
props:
type: sunburst
labels: ?{labels}
parents: ?{parents}
values: ?{"values"}
charts:
- name: Simple Sunburst Chart
traces:
- ${ref(Simple Sunburst Plot)}
layout:
title:
text: Simple Sunburst Chart<br><sub>Hierarchical Data Visualization</sub>
This example demonstrates a sunburst
plot where each category has custom colors:
Here's the code:
models:
- name: sunburst-data-colors
args:
- echo
- |
labels,parents,values,colors
Total,,100,#1f77b4
A,Total,40,#ff7f0e
B,Total,30,#2ca02c
C,Total,30,#d62728
D,A,10,#9467bd
E,A,20,#8c564b
F,B,10,#e377c2
traces:
- name: Sunburst Plot with Custom Colors
model: ${ref(sunburst-data-colors)}
props:
type: sunburst
labels: ?{labels}
parents: ?{parents}
values: ?{"values"}
marker:
colors: ?{colors}
charts:
- name: Sunburst Chart with Custom Colors
traces:
- ${ref(Sunburst Plot with Custom Colors)}
layout:
title:
text: Sunburst Plot with Custom Colors<br><sub>Custom Colors for Each Category</sub>
Here's a sunburst
plot where the size of each segment is customized based on additional values:
Here's the code:
models:
- name: sunburst-data-sizes
args:
- echo
- |
labels,parents,values,size
Total,,100,1
A,Total,40,2
B,Total,30,3
C,Total,30,4
D,A,10,5
E,A,20,6
F,B,10,7
traces:
- name: Sunburst Plot with Custom Sizes
model: ${ref(sunburst-data-sizes)}
props:
type: sunburst
labels: ?{labels}
parents: ?{parents}
values: ?{"values"}
marker:
line:
width: ?{size}
color: black
charts:
- name: Sunburst Chart with Custom Sizes
traces:
- ${ref(Sunburst Plot with Custom Sizes)}
layout:
title:
text: Sunburst Plot with Custom Sizes<br><sub>Custom Sizes for Each Segment</sub>
A schema to validate plotly trace properties
Attributes
These attributes apply to traces where trace.props.type
is set to sunburst
. You would configure these attributes on the trace with the trace.props
object.
branchvalues: any
count: string
customdata: array
customdatasrc: 'string' #(1)!
domain:
column: integer
row: integer
x: array
y: array
hoverinfo: array
hoverinfosrc: 'string' #(2)!
hoverlabel:
align: array
alignsrc: 'string' #(3)!
bgcolor: array
bgcolorsrc: 'string' #(4)!
bordercolor: array
bordercolorsrc: 'string' #(5)!
font:
color: array
colorsrc: 'string' #(6)!
family: 'string | array' #(7)!
familysrc: 'string' #(8)!
lineposition: array
linepositionsrc: 'string' #(9)!
shadow: 'string | array' #(10)!
shadowsrc: 'string' #(11)!
size: array
sizesrc: 'string' #(12)!
style: array
stylesrc: 'string' #(13)!
textcase: array
textcasesrc: 'string' #(14)!
variant: array
variantsrc: 'string' #(15)!
weight: array
weightsrc: 'string' #(16)!
namelength: array
namelengthsrc: 'string' #(17)!
hovertemplate: 'string | array' #(18)!
hovertemplatesrc: 'string' #(19)!
hovertext: 'string | array' #(20)!
hovertextsrc: 'string' #(21)!
ids: array
idssrc: 'string' #(22)!
insidetextfont:
color: array
colorsrc: 'string' #(23)!
family: 'string | array' #(24)!
familysrc: 'string' #(25)!
lineposition: array
linepositionsrc: 'string' #(26)!
shadow: 'string | array' #(27)!
shadowsrc: 'string' #(28)!
size: array
sizesrc: 'string' #(29)!
style: array
stylesrc: 'string' #(30)!
textcase: array
textcasesrc: 'string' #(31)!
variant: array
variantsrc: 'string' #(32)!
weight: array
weightsrc: 'string' #(33)!
insidetextorientation: any
labels: array
labelssrc: 'string' #(34)!
leaf:
opacity: number
legend: string
legendgrouptitle:
font:
color: any
family: 'string' #(35)!
lineposition: any
shadow: 'string' #(36)!
size: number
style: any
textcase: any
variant: any
weight: integer
text: 'string' #(37)!
legendrank: number
legendwidth: number
marker:
autocolorscale: boolean
cauto: boolean
cmax: number
cmid: number
cmin: number
coloraxis: string
colorbar:
bgcolor: any
bordercolor: any
borderwidth: number
exponentformat: any
len: number
lenmode: any
minexponent: number
nticks: integer
orientation: any
outlinecolor: any
outlinewidth: number
separatethousands: boolean
showexponent: any
showticklabels: boolean
showtickprefix: any
showticksuffix: any
thickness: number
thicknessmode: any
tickangle: number
tickcolor: any
tickfont:
color: any
family: 'string' #(38)!
lineposition: any
shadow: 'string' #(39)!
size: number
style: any
textcase: any
variant: any
weight: integer
tickformat: 'string' #(40)!
tickformatstops: array
ticklabeloverflow: any
ticklabelposition: any
ticklabelstep: integer
ticklen: number
tickmode: any
tickprefix: 'string' #(41)!
ticks: any
ticksuffix: 'string' #(42)!
ticktext: array
ticktextsrc: 'string' #(43)!
tickvals: array
tickvalssrc: 'string' #(44)!
tickwidth: number
title:
font:
color: any
family: 'string' #(45)!
lineposition: any
shadow: 'string' #(46)!
size: number
style: any
textcase: any
variant: any
weight: integer
side: any
text: 'string' #(47)!
x: number
xanchor: any
xpad: number
xref: any
y: number
yanchor: any
ypad: number
yref: any
colors: array
colorscale: any
colorssrc: 'string' #(48)!
line:
color: array
colorsrc: 'string' #(49)!
width: array
widthsrc: 'string' #(50)!
pattern:
bgcolor: array
bgcolorsrc: 'string' #(51)!
fgcolor: array
fgcolorsrc: 'string' #(52)!
fgopacity: number
fillmode: any
shape: array
shapesrc: 'string' #(53)!
size: array
sizesrc: 'string' #(54)!
solidity: array
soliditysrc: 'string' #(55)!
reversescale: boolean
showscale: boolean
maxdepth: integer
metasrc: 'string' #(56)!
name: 'string' #(57)!
opacity: number
outsidetextfont:
color: array
colorsrc: 'string' #(58)!
family: 'string | array' #(59)!
familysrc: 'string' #(60)!
lineposition: array
linepositionsrc: 'string' #(61)!
shadow: 'string | array' #(62)!
shadowsrc: 'string' #(63)!
size: array
sizesrc: 'string' #(64)!
style: array
stylesrc: 'string' #(65)!
textcase: array
textcasesrc: 'string' #(66)!
variant: array
variantsrc: 'string' #(67)!
weight: array
weightsrc: 'string' #(68)!
parents: array
parentssrc: 'string' #(69)!
root:
color: any
rotation: number
sort: boolean
stream:
maxpoints: number
token: 'string' #(70)!
text: array
textfont:
color: array
colorsrc: 'string' #(71)!
family: 'string | array' #(72)!
familysrc: 'string' #(73)!
lineposition: array
linepositionsrc: 'string' #(74)!
shadow: 'string | array' #(75)!
shadowsrc: 'string' #(76)!
size: array
sizesrc: 'string' #(77)!
style: array
stylesrc: 'string' #(78)!
textcase: array
textcasesrc: 'string' #(79)!
variant: array
variantsrc: 'string' #(80)!
weight: array
weightsrc: 'string' #(81)!
textinfo: any
textsrc: 'string' #(82)!
texttemplate: 'string | array' #(83)!
texttemplatesrc: 'string' #(84)!
type: sunburst
uid: 'string' #(85)!
values: array
valuessrc: 'string' #(86)!
visible: any
- Sets the source reference on Chart Studio Cloud for
customdata
. - Sets the source reference on Chart Studio Cloud for
hoverinfo
. - Sets the source reference on Chart Studio Cloud for
align
. - Sets the source reference on Chart Studio Cloud for
bgcolor
. - Sets the source reference on Chart Studio Cloud for
bordercolor
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
namelength
. - Template string used for rendering the information that appear on hover box. Note that this will override
hoverinfo
. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%xother}, {%_xother}, {%xother_}. When showing info for several points, xother will be added to those with different x positions from the first point. An underscore before or after (x|y)other will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available inhovertemplate
are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Finally, the template string has access to variablescurrentPath
,root
,entry
,percentRoot
,percentEntry
andpercentParent
. Anything contained in tag<extra>
is displayed in the secondary box, for example "{fullData.name} ". To hide the secondary box completely, use an empty tag<extra></extra>
. - Sets the source reference on Chart Studio Cloud for
hovertemplate
. - Sets hover text elements associated with each sector. If a single string, the same string appears for all data points. If an array of string, the items are mapped in order of this trace's sectors. To be seen, trace
hoverinfo
must contain a text flag. - Sets the source reference on Chart Studio Cloud for
hovertext
. - Sets the source reference on Chart Studio Cloud for
ids
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
labels
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the legend group.
- HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46
- Sets a tick label prefix.
- Sets a tick label suffix.
- Sets the source reference on Chart Studio Cloud for
ticktext
. - Sets the source reference on Chart Studio Cloud for
tickvals
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the color bar.
- Sets the source reference on Chart Studio Cloud for
colors
. - Sets the source reference on Chart Studio Cloud for
color
. - Sets the source reference on Chart Studio Cloud for
width
. - Sets the source reference on Chart Studio Cloud for
bgcolor
. - Sets the source reference on Chart Studio Cloud for
fgcolor
. - Sets the source reference on Chart Studio Cloud for
shape
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
solidity
. - Sets the source reference on Chart Studio Cloud for
meta
. - Sets the trace name. The trace name appears as the legend item and on hover.
- Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
parents
. - The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
- Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
text
. - Template string used for rendering the information text that appear on points. Note that this will override
textinfo
. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Finally, the template string has access to variablescurrentPath
,root
,entry
,percentRoot
,percentEntry
,percentParent
,label
andvalue
. - Sets the source reference on Chart Studio Cloud for
texttemplate
. - Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
- Sets the source reference on Chart Studio Cloud for
values
.