OrbChartsOrbCharts

RankedPlot

RankedPlot is the ranking Plugin for the grid data format. It sorts data by value and renders the ranking as bubbles (circles), paired with a rank axis and a category axis.

Data format: grid

Supported charts

Quick start

A minimal configuration draws a ranked bubble chart. RankedPlot shows three Layers by default: RankedBubble, RankAxis, and CategoryAxis:

import { OrbCharts } from '@orbcharts/core'
import type { RawData } from '@orbcharts/core'
import { RankedPlot, Tooltip, Legend } from '@orbcharts/plugin-basic'
 
const data: RawData = [
  { series: 'A', category: '0', value: 5 },
  { series: 'B', category: '0', value: 8 },
  { series: 'C', category: '0', value: 3 },
]
 
const chart = new OrbCharts(document.querySelector('#chart')!, {
  data,
  plugins: [
    new RankedPlot({ RankedBubble: {} }),
    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 grid data has series, category, and value: RankedPlot ranks the data by value, bubble size maps to the value, and series is used for grouping and coloring.

How layer visibility works

RankedPlot 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 RankedPlot()), it shows RankedBubble, RankAxis, CategoryAxis by default (a ranked bubble chart). CategoryGuide and CategoryZoom are hidden by default and must be listed explicitly. You can also switch Layers dynamically with show/hide/showOnly after creation.

new RankedPlot({ RankedBubble: {} })                          // ranked bubble chart (ranked by value)
new RankedPlot({ RankedBubble: {}, CategoryZoom: {} })        // also enable zoom

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

Plugin parameters

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

ParameterTypeDefaultDescription
rankedScale{ limit: number | 'auto' }{ limit: 10 }Rank axis settings; limit is the maximum number of ranks to show
categoryScaleCategoryAxissee CategoryAxisCategory axis settings
datasetIndexnumber0Which dataset to use when data is multi-dataset
stylesGraphicStylespadding is { 60, 60, 60, 200 }, transitionDuration is 100Shared visual styles (see Plugin API)
visibleFilter(datum) => boolean | null() => trueFilter which data to show (see Plugin API)

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

rankedScale

PropertyTypeDefaultDescription
limitnumber | 'auto'10Maximum number of ranks to show; 'auto' for automatic

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.

RankedBubble

ParameterTypeDefaultDescription
sizeAdjustnumber0.8Bubble size adjustment factor
arcScaleType'radius' | 'area''area'How bubble size maps to value
valueLinearOpacity[number, number][0.5, 1]Opacity range mapped linearly to value
showZeroValuebooleanfalseWhether to show data with a value of 0

RankAxis

ParameterTypeDefaultDescription
labelstring''Axis label
labelOffset[number, number][0, 0]Axis label offset
labelColorTypeColorType'primary'Axis label color
seriesLabelPaddingnumber20Series label padding
seriesLabelColorTypeColorType'primary'Series label color

CategoryAxis

ParameterTypeDefaultDescription
labelstring''Axis label
labelOffset[number, number][0, 0]Axis label offset
labelColorTypeColorType'primary'Axis label color
axisLineVisiblebooleantrueWhether to show the axis line
axisLineColorTypeColorType'primary'Axis line color
ticksnumber | null | 'all''all'Number of ticks
tickFormatstring | ((text) => string)text => textTick text formatter
tickLineVisiblebooleantrueWhether to show tick lines
tickPaddingnumber20Spacing between tick and text
tickFullLinebooleanfalseWhether to draw full gridlines
tickColorTypeColorType'secondary'Tick line color
tickTextRotatenumber0Tick text rotation angle
tickTextColorTypeColorType'primary'Tick text color
placement'top' | 'bottom''top'Category axis position

CategoryGuide

Hidden by default; enabled when listed.

ParameterTypeDefaultDescription
showLinebooleantrueWhether to show the guide line
showLabelbooleantrueWhether to show the label
lineDashArraystring'3, 3'Dash pattern
lineColorTypeColorType'primary'Guide line color
labelColorTypeColorType'primary'Label background color
labelTextColorTypeColorType'background'Label text color
labelTextFormatstring | ((text) => string)text => textLabel text formatter
labelPaddingnumber20Label padding

CategoryZoom

Hidden by default. When enabled, allows zooming and panning along the category axis. This Layer has no extra parameters:

new RankedPlot({ RankedBubble: {}, CategoryZoom: {} })

Full TypeScript interface

interface RankedPlotPluginParams {
  styles: GraphicStyles
  visibleFilter: (datum: ModelDatumGrid) => boolean | null
  categoryScale: CategoryAxis
  rankedScale: { limit: number | 'auto' }
  datasetIndex: number
}
 
interface RankedPlotAllLayerParams {
  RankedBubble: RankedPlotRankedBubbleParams
  RankAxis: RankedPlotRankAxisParams
  CategoryAxis: RankedPlotCategoryAxisParams
  CategoryGuide: RankedPlotCategoryGuideParams
  CategoryZoom: RankedPlotCategoryZoomParams
}
 
// The constructor accepts a DeepPartial of both (Layer names alongside Plugin params)
new RankedPlot(params?: DeepPartial<RankedPlotPluginParams & RankedPlotAllLayerParams>)