logo

G2

  • Chart Gallery
  • Docs
  • Examples
  • Theme
  • Ecosystem
  • Productsantv logo arrow
  • 5.3.5
  • Get Started
  • Introduction
    • What is G2
    • Using in Frontend Frameworks
    • Experimental Spec API
  • Chart API
  • Core Concepts
    • G2's complete configuration system
    • Chart
      • Components of G2 Charts
      • Chart Lifecycle
    • Mark
      • Overview
      • area
      • box
      • boxplot
      • cell
      • chord
      • density
      • gauge
      • heatmap
      • image
      • interval
      • line
      • lineX
      • lineY
      • link
      • liquid
      • sunburst
      • point
      • polygon
      • range
      • rangeX
      • rangeY
      • rect
      • shape
      • text
      • vector
      • connector
      • wordCloud
    • View
    • Data
      • Overview
      • custom
      • ema
      • fetch
      • filter
      • fold
      • inline
      • join
      • kde
      • log
      • map
      • pick
      • rename
      • slice
      • sort
      • sortBy
    • Encode
    • Scale
      • Overview
      • band
      • linear
      • log
      • ordinal
      • point
      • quantile
      • quantize
      • sqrt
      • threshold
      • time
      • pow
    • Transform
      • Overview
      • bin
      • binX
      • diffY
      • dodgeX
      • flexX
      • group
      • groupColor
      • groupX
      • groupY
      • jitter
      • jitterX
      • jitterY
      • normalizeY
      • pack
      • sample
      • select
      • selectX
      • selectY
      • sortColor
      • sortX
      • sortY
      • stackEnter
      • stackY
      • symmetryY
    • Coordinate
      • Overview
      • fisheye
      • parallel
      • polar
      • theta
      • transpose
      • radial
      • cartesian3D
      • helix
    • Style
    • Animate
      • Overview
      • fadeIn
      • fadeOut
      • growInX
      • growInY
      • morphing
      • pathIn
      • scaleInX
      • scaleInY
      • scaleOutX
      • scaleOutY
      • waveIn
      • zoomIn
      • zoomOut
    • State
    • Interaction
      • Overview
      • brushAxisHighlight
      • brushHighlight
      • brushXHighlight
      • brushYHighlight
      • brushFilter
      • brushXFilter
      • brushYFilter
      • chartIndex
      • elementHighlight
      • elementHighlightByColor
      • elementHighlightByX
      • elementSelect
      • elementSelectByColor
      • elementSelectByX
      • legendFilter
      • legendHighlight
      • poptip
      • scrollbarFilter
      • sliderFilter
      • fisheye
    • Composition
      • Overview
      • facetCircle
      • facetRect
      • repeatMatrix
      • spaceFlex
      • spaceLayer
      • timingKeyframe
    • Theme
      • Overview
      • academy
      • classic
      • classicDark
    • Events
    • Color Mapping
  • Chart Component
    • Title
    • Axis
    • Legend
    • Scrollbar
    • Slider
    • Tooltip
    • Data Label
  • Extra Topics
    • Graph
      • forceGraph
      • pack
      • sankey
      • tree
      • treemap
    • Geo
      • geoPath
      • geoView
    • 3D
      • Draw 3D Chart
      • point3D
      • line3D
      • interval3D
      • surface3D
    • Plugin
      • renderer
      • rough
      • lottie
      • a11y
    • Package on demand
    • Set pattern
    • Server-Side Rendering (SSR)
    • Spec Function Expression Support (Available in 5.3.0)
  • Whats New
    • New Version Features
    • Migration from v4 to v5
  • Frequently Asked Questions (FAQ)

quantile

Previous
point
Next
quantize

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library
WeaveFox-AI Coding Assistant

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference
weavefoxWeaveFox-AI Developer Community

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-Interactive solution
weavefoxWeaveFox-AI Coding Assistant
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Overview

The quantile scale belongs to the discretizing scale category, primarily used to group continuous data by quantiles and map them to a specified range. It is a measurement that automatically segments based on data density, similar to threshold, but quantile automatically segments based on the sorted data indices rather than manually specified thresholds. It automatically determines segment points (ticks) based on data distribution density, where these segment points are determined by data quantiles rather than uniform distribution. During scaling, it performs segmented mapping based on these ticks, with tick calculation using the tickMethod: quantile approach. This characteristic makes the quantile scale particularly suitable for displaying datasets with non-uniform distributions, providing more accurate reflection of data density changes and suitable for scenarios requiring discretization based on data characteristics.

Mapping Effect Example

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'view',
autoFit: true,
data: [
{ year: '1991', value: 3 },
{ year: '1992', value: 4 },
{ year: '1993', value: 3 },
{ year: '1994', value: 5 },
{ year: '1995', value: 4 },
{ year: '1996', value: 5 },
{ year: '1997', value: 7 },
{ year: '1998', value: 7 },
{ year: '1999', value: 13 },
],
encode: { x: 'year', y: 'value' },
scale: {
y: {
type: 'quantile',
range: [1, 0.5, 0],
},
},
children: [
{ type: 'line', labels: [{ text: 'value', style: { dx: -10, dy: -12 } }] },
{ type: 'point', style: { fill: 'white' }, tooltip: false },
],
});
chart.render();

The above chart shows that more values around 4-5 are mapped to 0.5, indicating the highest data density is between 4-5.

Configuration Options

PropertyDescriptionTypeDefault ValueRequired
domainSets the domain range of the datanumber[][]
rangeSets the range for data mappingany[][]✔
unknownReturn value for undefined, NaN, null empty valuesanyundefined
tickCountSets the recommended number of ticks to generate, tickCount is only a suggestion and not guaranteed to be fully effectivenumber5
tickMethodSets the method for generating ticks, commonly used for custom ticks(min: number, max: number, count: number) => number[]wilkinson-extended
niceExtends the domain range to make output ticks display more friendlybooleanfalse

Complex Type Descriptions

  • tickMethod:
    • Type: (min: number, max: number, count: number) => number[]
    • Description: Function used to generate tick values, receiving the domain's minimum value, maximum value, and desired tick count as parameters. In quantile scales, while actual data segmentation is obtained through quantile-calculated thresholds, generating tick values for display is accomplished through tickMethod. The default uses the wilkinson-extended algorithm, which generates aesthetically pleasing, uniformly distributed ticks. Customizing this method allows control over the tick positions and quantities displayed on the axis.
    • Example: tickMethod: (min, max, count) => [min, (min+max)/2, max] will only generate ticks at minimum value, middle value, and maximum value.

Examples

Heatmap

The following example shows how to use quantile scale to divide salary data into three groups and map them to different colors:

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'cell',
height: 640,
data: {
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/bd287f2c-3e2b-4d0a-8428-6a85211dce33.json',
},
encode: { x: 'x', y: 'y', color: 'index' },
scale: {
color: { type: 'quantile', range: ['#eeeeee', '#ffc3ce', '#ff0d0d'] },
},
style: { stroke: '#000', inset: 2 },
animate: { enter: { type: 'fadeIn' } },
});
chart.render();

In the above example, the quantile scale automatically divides salaries into three groups based on data distribution and maps them to three different colors, suitable for displaying the layered effect of data distribution.