OrbChartsOrbCharts

PartitionPlot

PartitionPlot is the core Plugin for the series data format. It treats each series record as a "proportion" and can draw pie, rose, and bubble charts by switching its internal Layers.

Data format: series

Supported charts

PartitionPlot renders different charts through different Layer combinations:

Quick start

A minimal configuration draws a bubble chart. PartitionPlot shows only one Layer by default: Bubble:

import { OrbCharts } from '@orbcharts/core'
import type { RawData } from '@orbcharts/core'
import { PartitionPlot, Tooltip, Legend } from '@orbcharts/plugin-basic'
 
const data: RawData = [
  { series: 'A', value: 30 },
  { series: 'B', value: 70 },
  { series: 'C', value: 45 },
  { series: 'D', value: 85 },
]
 
const chart = new OrbCharts(document.querySelector('#chart')!, {
  data,
  plugins: [
    new PartitionPlot({ Bubble: {} }),
    new Tooltip(),
    new Legend(),
  ],
})
 
// chart.destroy()

Tip: The chart fills its container by default, so set a width and height on the #chart container. See Core Concepts.

Each record in this series data has series and value: value determines the proportion and size, and series is used for grouping and coloring.

How layer visibility works

PartitionPlot is composed of multiple Layers, and the Layer names you list in the params are the Layers that get shown. If you specify no Layers (new PartitionPlot()), it shows only Bubble by default (a bubble chart). You can also switch Layers dynamically with show/hide/showOnly after creation.

new PartitionPlot({ Pie: {} })     // pie chart
new PartitionPlot({ Bubble: {} })  // bubble chart

Tip: Layer visibility and the show/hide/showOnly/toggle methods are common to all Plugins. See Plugin API for the full explanation.

Chart examples

All examples below use the same series data—just swap the Layer to change the chart type.

Pie Chart

new PartitionPlot({ Pie: {} })

Pie draws the slices. Add PieLabel to show labels and PieEventText to display text in the center. Set Pie's innerRadius greater than 0 to turn it into a donut chart.

new PartitionPlot({ Pie: { innerRadius: 0.5 }, PieLabel: {} })  // donut chart

Rose Chart

new PartitionPlot({ Rose: {} })

Rose renders slices of equal angle whose radius varies with the value. Add RoseLabel to show labels.

Bubble Chart

new PartitionPlot({ Bubble: {} })

Bubble renders force-directed circular bubbles whose size corresponds to the value. This is PartitionPlot's default chart.

Tip: Pair with Legend and Tooltip for interactivity, added the same way as in GridPlot.

Plugin parameters

These parameters affect the whole PartitionPlot's behavior, listed alongside Layer names in the same params object:

ParameterTypeDefaultDescription
sort((a, b) => number) | nullnullData sort function; null means no sorting
separateSeriesbooleanfalseWhether to draw each series separately
separateNamebooleanfalseWhether to draw separately by name
datasetIndexnumber0Which dataset to use when data is multi-dataset
stylesGraphicStylespadding is { 20, 20, 60, 20 }Shared visual styles (see Plugin API)
containerContainersingle chartMulti-chart layout (see Plugin API)
visibleFilter(datum: ModelDatumSeries) => boolean | null() => trueFilter which data to show (see Plugin API)

Note: styles, container, and visibleFilter are shared by all chart Plugins; their structure and usage are documented centrally in Plugin API. Only PartitionPlot's default differences are noted here (styles.padding defaults to { top: 20, right: 20, bottom: 60, left: 20 }, and transitionDuration defaults to 800).

Layer parameters

Each Layer has its own parameters. The main parameters and defaults of each Layer are listed below.

About ColorType: color-related parameters use ColorType ('data', 'primary', etc.), mapping to the colors defined in the Theme. See Theme for the full explanation.

Pie

ParameterTypeDefaultDescription
outerRadiusnumber0.85Outer radius (ratio of the available radius)
innerRadiusnumber0Inner radius; greater than 0 makes a donut chart
outerRadiusWhileHighlightnumber0.9Outer radius while highlighted
startAnglenumber0Start angle (radians)
endAnglenumber6.283185307179586End angle (radians, default 2π)
padAnglenumber0Gap angle between slices
strokeColorTypeColorType'background'Stroke color
strokeWidthnumber1Stroke width
cornerRadiusnumber0Slice corner radius

Rose

ParameterTypeDefaultDescription
outerRadiusnumber0.95Outer radius (ratio)
padAnglenumber0Gap angle between slices
strokeColorTypeColorType'background'Stroke color
strokeWidthnumber0.5Stroke width
cornerRadiusnumber0Slice corner radius
arcScaleType'radius' | 'area''area'How values map (radius or area)
angleIncreaseWhileHighlightnumber0.05Angle increment while highlighted

Bubble

ParameterTypeDefaultDescription
force.strengthnumber0.08Force attraction strength
force.velocityDecaynumber0.3Velocity decay
force.collisionSpacingnumber2Bubble collision spacing
bubbleLabel.labelFn(datum) => stringshows the series nameLabel text function
bubbleLabel.colorTypeColorType'dataContrast'Label text color
bubbleLabel.fillRatenumber0.6Label fill rate
bubbleLabel.lineHeightnumber1Line height
bubbleLabel.maxLineLengthnumber6Max characters per line
bubbleLabel.wordBreakAllbooleantrueWhether to allow breaking anywhere
arcScaleType'radius' | 'area''area'How values map (radius or area)

PieLabel

ParameterTypeDefaultDescription
outerRadiusnumber0.85Outer radius for label positioning
outerRadiusWhileHighlightnumber0.9Outer radius while highlighted
startAnglenumber0Start angle (radians)
endAnglenumber6.283185307179586End angle (radians, default 2π)
labelCentroidnumber2.1Label position relative to the slice centroid
labelFn(datum) => stringshows the valueLabel text function
labelColorTypeColorType'primary'Label text color

RoseLabel

ParameterTypeDefaultDescription
outerRadiusnumber0.95Outer radius for label positioning
labelCentroidnumber2.1Label position relative to the slice centroid
labelFn(datum) => stringshows the valueLabel text function
labelColorTypeColorType'primary'Label text color
arcScaleType'radius' | 'area''area'How values map (radius or area)

PieEventText

Displays text in the center of the pie, often used for a total or title in the center of a donut chart.

ParameterTypeDefaultDescription
renderFn(eventData) => string | string[]Returns the text to display based on event data
textAttrsArray<{ [key: string]: string | number }>SVG attributes for each line of text
textStylesArray<{ [key: string]: string | number }>CSS styles for each line of text

Indicator

Renders a single value as a gauge-like needle, often paired with a donut chart.

ParameterTypeDefaultDescription
startAnglenumber-1.5707963267948966Start angle (radians, default -π/2)
endAnglenumber1.5707963267948966End angle (radians, default π/2)
radiusnumber0.6Needle radius (ratio)
indicatorTypestring'needle'Indicator type
sizenumber10Indicator size
colorTypeColorType'data'Indicator color
valuenumber0The value the indicator points to

Full TypeScript interface

interface PartitionPlotPluginParams {
  styles: GraphicStyles
  visibleFilter: (datum: ModelDatumSeries) => boolean | null
  container: Container
  sort: ((a: ComputedDatumSeries, b: ComputedDatumSeries) => number) | null
  separateSeries: boolean
  separateName: boolean
  datasetIndex: number
}
 
interface PartitionPlotAllLayerParams {
  Bubble: PartitionPlotBubbleParams
  Pie: PartitionPlotPieParams
  PieEventText: PartitionPlotPieEventTextParams
  PieLabel: PartitionPlotPieLabelParams
  Rose: PartitionPlotRoseParams
  RoseLabel: PartitionPlotRoseLabelParams
  Indicator: PartitionPlotIndicatorParams
}
 
// The constructor accepts a DeepPartial of both (Layer names alongside Plugin params)
new PartitionPlot(params?: DeepPartial<PartitionPlotPluginParams & PartitionPlotAllLayerParams>)