Sunburst Charts

Note: See our Sunburst Chart Gallery for inspiration on all the different sunburst chart possibilities.

Sunburst Chart Type

To specify the chart type, add a type attribute to the chart object. Our standard sunburst chart is specified by the sunburst value. Without further modification, here is how the default sunburst chart appears:

{
  type: 'sunburst',
}
https://app.zingsoft.com/demos/embed/5KNX91AZ
https://app.zingsoft.com/demos/embed/5KNX91AZ

Data

Provide your chart data in the series array. In the array, create an object and assign a value to id, text, parent, and the optional value attribute.

id is the section where the series data object will be placed; text is the text that will be displayed in that section; parent is the parent section of the section you are adding data to; and value is the numerical value of the data object being added.

{
  series: [
    {id: 'flare', text: 'flare', parent: ''},
    {id: 'analytics', text: 'analytics', parent: 'flare'},
    {id: 'cluster', text: 'cluster', parent: 'analytics'},
    {id: 'agglomerativecluster', text: 'AgglomerativeCluster', parent: 'cluster', value: 3938},
    ...,
    {id: 'someId', text: 'someText', parent: 'someParent', values: [someValue]}
  ]
}

Note: ZingChart can automatically order your sunburst slices, from largest to smallest. Create a plot object and add a layout attribute. Set the value to auto. (This attribute also sets the sunburst chart’s default reference angle to 12 o'clock, or zero degrees. For more information, see the Reference Angle section below.)

Chart-Specific Properties

Once you've provided your chart type and data, you can configure the chart's elements such as offset, donut ring size, how pie slices are detached and/or clicked, and more.

Offset Slices

Use the offset-r attribute to pull out one or more slices from the rest of the sunburst. Often referred to as an exploded sunburst chart, the attribute can be applied globally in the plot object or locally in the applicable series object. Provide the sunburst slice offset as a percentage or pixel value.

{
  plot: {
    'offset-r': "10%"
  }
}
https://app.zingsoft.com/demos/embed/F1MO5OWS
https://app.zingsoft.com/demos/embed/F1MO5OWS

Further Customization

Scale Configuration

Use the scale-r object to set the sunburst chart's aperture and reference angle. Use the scale object to set the size factor.

Aperture

The sunburst chart is sized to 360 degrees (i.e., a circle) by default. You can change this by adding an aperture attribute to the scale-r object. Provide the desired aperture value (e.g., 180 is a half circle, 90 is a quarter circle, and so on).

{
  'scale-r': {
    aperture:300
  },
}
https://app.zingsoft.com/demos/embed/S19Y9C3R
https://app.zingsoft.com/demos/embed/S19Y9C3R

Reference Angle

The reference angle (or starting point) of our sunburst charts is set to 90 degrees (or 3 o'clock) by default. Add a ref-angle attribute to the scale-r object to change this. Provide the desired value, keeping in mind that the value is relative to the default starting angle. For example, providing a value of 270 would make the first sunburst slice appear at the 12 o'clock position. See the following chart:

{
  'scale-r': {
    'ref-angle':270 //relative to the starting 90 degree position.
  },
}
https://app.zingsoft.com/demos/embed/ZZHANHLU
https://app.zingsoft.com/demos/embed/ZZHANHLU

Alternatively, you can have the reference angle automatically set to zero and have the sunburst slices automatically sorted by size, from largest to smallest, by adding a layout': "auto attribute to the plot object. See the following chart:

{
  plot: {
    layout: "auto" //to order pie slices by size and have reference angle start at zero.
  },
}
https://app.zingsoft.com/demos/embed/RQLMJ5EX
https://app.zingsoft.com/demos/embed/RQLMJ5EX

Plot/Series Styling

Style the borders of the sunburst slices by adding border-width, border-color, line-style, alpha, and other styling attributes to your plot object.

Note: Refer to the Plot/Series Styling Tutorial and the plot / series JSON Configuration page for further information and a full attribute list.

{
  plot: {
    'border-width': 1,
    'border-color': "#cccccc",
    'line-style': "dotted"
  },
}
https://app.zingsoft.com/demos/embed/BKB38EKE
https://app.zingsoft.com/demos/embed/BKB38EKE

Tokens

Tokens (or string interpolation) are highly useful when customizing sunburst chart tooltips and value boxes. Commonly used sunburst chart tokens include:

TokenDescription
%data-_____Format for custom tokens. The custom token is defined in the plot or series object as an attribute or array using the "data" prefix (e.g., data-year). It is then recalled in the tooltips or value boxes (e.g., %data-year).
%node-percent-value %npvThe percentage value of the sunburst slice (node) relative to the entire pie (sum of all nodes)
%node-value %vThe sunburst slice (node) value
%pie-total-valueThe sum of all the sunburst slice (node) values
%plot-descriptionThe description of the current plot, pulled from the description attribute in the plot/series object
%plot-text %tThe text of the current plot, pulled from the text attribute in the plot/series object

Note: Refer to the Tokens Tutorial for a full list of available tokens.

Tooltips

Tooltips appear when you hover over the sunburst slices. Create a tooltip object in the plot object to customize the text and styling. Customize the tooltip's text with a text attribute and then provide your desired combination of text and tokens inside a string.

Note: Refer to the Tooltips Tutorial and tooltip JSON Configuration page for more information and a full attribute list.

{
  plot: {
    tooltip: {
      text: "%t: %v (%npv%)",
      'font-color': "black",
      'font-family': "Georgia",
      'text-alpha':1,
      'background-color': "white",
      alpha:0.7,
      'border-width': 1,
      'border-color': "#cccccc",
      'line-style': "dotted",
      'border-radius': "10px",
      padding: "10%",
      placement: "node:out" //"node:out" or "node:center"
    },
  },
}
https://app.zingsoft.com/demos/embed/TP2CN9XY
https://app.zingsoft.com/demos/embed/TP2CN9XY

Value Boxes

Value boxes are fixed labels that appear adjacent to the sunburst slices. Create a value-box object in the plot object to customize the text, placement (in, out, center), and styling. You can also incorporate rules.

Note: Refer to the Value Boxes Tutorial and the value-box JSON Configuration page for more information and a full attribute list.


In the following chart, rules were used to place value boxes in or out of the chart based on their value.

Note: Value boxes placed outside the sunburst slices are automatically drawn with connecting lines. To remove them, add a connected attribute and set the value to false.

{
  plot: {
    'value-box': {
      text: "%v",
      'font-size':12,
      'font-family': "Georgia",
      'font-weight': "normal",
      rules: [
        {
          rule: "%v > 6000",
          placement: "in",
          'offset-r': "50%",
          'font-color': "white",
        },
        {
          rule: "%v <= 6000",
          placement: "out",
          'font-color': "gray",
        }
      ]
    },
  }
}
https://app.zingsoft.com/demos/embed/8EK626IT
https://app.zingsoft.com/demos/embed/8EK626IT

Summary

Have questions about how sunburst charts work? We're happy to help! Email support@zingchart.com or start a chat right here on this page for support.