• English
  • Sankey

    Encoding Mapping

    The Sankey chart supports the following visual channels:

    source: source channel, supports multiple dimensions

    target: target channel, supports multiple dimensions

    color: color channel, supports multiple dimensions

    size: size channel, supports one measure

    label: label channel, supports multiple dimensions and multiple measures

    tooltip: tooltip channel, supports multiple dimensions and multiple measures

    Description

    Sankey chart, used to display flow relationships from source to target, with link width representing flow magnitude.

    Applicable scenarios:

    - Display flow relationships in a regular node-link structure

    - Display path transfer after concatenating multiple source dimensions and multiple target dimensions

    Warning

    Data requirements:

    - At least 1 source dimension or default dimension that can be mapped to source

    - At least 1 target dimension

    - At least 1 numeric field (measure) is required to map flow size

    - The advanced pipeline needs to convert tidyData into a regular source / target / value structure consumable by sankey

    chartType

    Type: "sankey"

    Description

    Sankey chart

    Sankey chart, displaying regular source-target flow relationships and flow magnitude

    Example 'sankey'

    dataset

    Type: Record[]

    Description

    Dataset

    An aggregated dataset that conforms to the TidyData specification, used to define the chart's data source and structure

    Example [{fromRegion: 'North China', toRegion: 'East China', value: 30}]

    dimensions

    Type: SankeyDimension[] | undefined

    Description

    Dimensions

    Dimension configuration, used to define the source / target node structure and supports the source / target / color / detail / label / tooltip / row / column channels

    Example [{id: 'fromRegion', alias: 'Source Region'}, {id: 'toRegion', alias: 'Target Region', encoding: 'target'}]

    id

    Type: string

    Description

    Field ID corresponding to the dimension

    alias

    Type: string | undefined

    Description

    Dimension alias

    timeFormat

    Type: TimeFormat | undefined

    Description

    Dimension date format configuration

    type

    Type: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second"

    Description

    Time granularity, determines the date display precision

    encoding

    Type: "color" | "detail" | "tooltip" | "label" | "row" | "column" | "source" | "target" | undefined

    Description

    Channel to which the dimension is mapped

    - source: supports mapping multiple dimensions to the source channel; the advanced stage concatenates them into an upstream node path

    - target: supports mapping multiple dimensions to the target channel; the advanced stage concatenates them into a downstream node path

    - color: supports mapping multiple dimensions to the color channel, used to generate the color category key for sankey

    - detail: supports mapping multiple dimensions to the detail channel

    - label: supports mapping multiple dimensions to the label channel

    - tooltip: supports mapping multiple dimensions to the tooltip channel

    - row: supports mapping multiple dimensions to the row channel, used for pivot charts

    - column: supports mapping multiple dimensions to the column channel, used for pivot charts

    measures

    Type: SankeyMeasure[] | undefined

    Description

    Measures

    Measure configuration, used to define flow size and supports the size / detail / label / tooltip channels

    Example [{id: 'sales', alias: 'Sales'}]

    id

    Type: string

    Description

    Measure ID, must be unique

    alias

    Type: string | undefined

    Description

    Measure alias, duplicates are allowed; when not set, alias defaults to id

    autoFormat

    Type: boolean | undefined

    Description

    Automatic number formatting, enabled by default, highest priority

    When autoFormat=true, it overrides all numFormat configurations

    When enabled, chart data labels and tooltips automatically select an appropriate format based on measure values and locale

    Formatting rules: decimal numbers with compact notation enabled, minimum 0 decimal places, maximum 2 decimal places, automatic rounding, using the browser's Intl.NumberFormat implementation

    For example:

    - locale=zh-CN: 749740.264 → 74.45万

    - locale=en-US: 749740.264 → 744.5K

    numFormat

    Type: NumFormat | undefined

    Description

    Custom number formatting for measures; automatically applied to labels and tooltips

    Note: To use custom formatting, you must explicitly set autoFormat=false; otherwise autoFormat will override this config

    type

    Type: "number" | "percent" | "permille" | "scientific" | undefined

    Description

    Number format type, supports: number (decimal), percent (%), permille (‰), scientific notation

    ratio

    Type: number | undefined

    Description

    Number format ratio, cannot be 0

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    symbol

    Type: string | undefined

    Description

    Number format symbol, e.g. %, ‰

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    thousandSeparator

    Type: boolean | undefined

    Description

    Thousands separator for number formatting

    suffix

    Type: string | undefined

    Description

    Number format suffix

    prefix

    Type: string | undefined

    Description

    Number format prefix

    fractionDigits

    Type: number | undefined

    Description

    Decimal places for number formatting, using the browser's Intl.NumberFormat minimumFractionDigits and maximumFractionDigits; lower priority than significantDigits

    Example - 1234.5678 converts to 1235, fractionDigits:0 (roundingMode:halfCeil) - 1234.5678 converts to 1234.6, fractionDigits:1 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, fractionDigits:2 (roundingMode:halfCeil) - 1234.5678 converts to 1230.568, fractionDigits:3 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, fractionDigits:4 (roundingMode:halfCeil) - 1234.5678 converts to 1234.56780, fractionDigits:5 (roundingMode:halfCeil)

    significantDigits

    Type: number | undefined

    Description

    Significant digits for number formatting, using the browser's Intl.NumberFormat minimumSignificantDigits and maximumSignificantDigits; higher priority than fractionDigits

    Example - 1234.5678 converts to 1000, significantDigits:1 - 1234.5678 converts to 1200, significantDigits:2 - 1234.5678 converts to 1230, significantDigits:3 - 1234.5678 converts to 1234, significantDigits:4 - 1234.5678 converts to 1234.6, significantDigits:5 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, significantDigits:6 (roundingMode:halfCeil) - 1234.5678 converts to 1234.568, significantDigits:7 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, significantDigits:8 (roundingMode:halfCeil)

    roundingPriority

    Type: "morePrecision" | "lessPrecision" | undefined

    Description

    Rounding priority for number formatting when both significantDigits and fractionDigits are set; uses the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingPriority

    Example - 1234.5678 converts to 1230, significantDigits:3 (roundingPriority:lessPrecision) - 1234.5678 converts to 1234.5678, significantDigits:3 (roundingPriority:morePrecision)

    roundingMode

    Type: "floor" | "ceil" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined

    Description

    Rounding mode for number formatting, using the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingMode

    format

    Type: NumFormat | undefined

    type

    Type: "number" | "percent" | "permille" | "scientific" | undefined

    Description

    Number format type, supports: number (decimal), percent (%), permille (‰), scientific notation

    ratio

    Type: number | undefined

    Description

    Number format ratio, cannot be 0

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    symbol

    Type: string | undefined

    Description

    Number format symbol, e.g. %, ‰

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    thousandSeparator

    Type: boolean | undefined

    Description

    Thousands separator for number formatting

    suffix

    Type: string | undefined

    Description

    Number format suffix

    prefix

    Type: string | undefined

    Description

    Number format prefix

    fractionDigits

    Type: number | undefined

    Description

    Decimal places for number formatting, using the browser's Intl.NumberFormat minimumFractionDigits and maximumFractionDigits; lower priority than significantDigits

    Example - 1234.5678 converts to 1235, fractionDigits:0 (roundingMode:halfCeil) - 1234.5678 converts to 1234.6, fractionDigits:1 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, fractionDigits:2 (roundingMode:halfCeil) - 1234.5678 converts to 1230.568, fractionDigits:3 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, fractionDigits:4 (roundingMode:halfCeil) - 1234.5678 converts to 1234.56780, fractionDigits:5 (roundingMode:halfCeil)

    significantDigits

    Type: number | undefined

    Description

    Significant digits for number formatting, using the browser's Intl.NumberFormat minimumSignificantDigits and maximumSignificantDigits; higher priority than fractionDigits

    Example - 1234.5678 converts to 1000, significantDigits:1 - 1234.5678 converts to 1200, significantDigits:2 - 1234.5678 converts to 1230, significantDigits:3 - 1234.5678 converts to 1234, significantDigits:4 - 1234.5678 converts to 1234.6, significantDigits:5 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, significantDigits:6 (roundingMode:halfCeil) - 1234.5678 converts to 1234.568, significantDigits:7 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, significantDigits:8 (roundingMode:halfCeil)

    roundingPriority

    Type: "morePrecision" | "lessPrecision" | undefined

    Description

    Rounding priority for number formatting when both significantDigits and fractionDigits are set; uses the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingPriority

    Example - 1234.5678 converts to 1230, significantDigits:3 (roundingPriority:lessPrecision) - 1234.5678 converts to 1234.5678, significantDigits:3 (roundingPriority:morePrecision)

    roundingMode

    Type: "floor" | "ceil" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined

    Description

    Rounding mode for number formatting, using the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingMode

    encoding

    Type: "detail" | "tooltip" | "label" | "size" | undefined

    Description

    Channel to which the measure is mapped

    - size: measure mapped to the edge width / flow size channel

    - label: measure mapped to the label channel

    - tooltip: measure mapped to the tooltip channel

    parentId

    Type: string | undefined

    Description

    In flat measure configuration form, builds a tree-shaped measure group. parentId points to the id of the parent measure group, used for building the measure tree

    Tip

    There are two ways to configure the measure tree: Option 1 is directly configuring a measure tree with children; Option 2 is configuring a flat measure list with parentId. These two methods cannot be used simultaneously

    page

    Type: Page | undefined

    Description

    Pagination configuration

    Used to specify the field name for pagination; must be a dimension

    field

    Type: string

    Description

    Pagination field; specifies the field name for pagination, must be a dimension

    currentValue

    Type: string

    Description

    Current pagination value; specifies the value used to determine the current page

    Example '2023-01-01'

    backgroundColor

    Type: BackgroundColor

    Description

    Chart background color

    Background color can be a color string, such as 'red' or 'blue', or a hex, rgb, or rgba value, such as '#ff0000' or 'rgba(255,0,0,0.5)'

    color

    Type: Color | undefined

    Description

    Color

    Color configuration, used to define the chart's color scheme, including color lists, color mappings, and color gradients

    colorScheme

    Type: string[] | undefined

    Description

    Discrete color scheme used to define the colors of different elements in the chart

    Example ['#FFCDD2,#F8BBD0,#E1BEE7,#D1C4E9,#C5CAE9,#BBDEFB,#B3E5FC,#B2EBF2,#B2DFDB,#C8E6C9,#DCEDC8,#F0F4C3,#FFF9C4,#FFECB3,#FFE0B2']

    linearColorScheme

    Type: string[] | undefined

    Description

    Linear gradient color scheme used to define the colors of different elements in the chart

    Example ['#FFCDD2, #F8BBD0]

    colorMapping

    Type: Record<string, string> | undefined

    Description

    Color mapping used to map data values to specific colors

    Example { 'profit': 'red', 'sales': 'blue', }

    positiveColor

    Type: string | undefined

    Description

    Positive/negative color configuration; defines the color for positive values in the chart

    negativeColor

    Type: string | undefined

    Description

    Positive/negative color configuration; defines the color for negative values in the chart

    label

    Type: Label | undefined

    Description

    Label

    Label configuration, used to define chart data labels, including position, format, style, etc.

    enable

    Type: false | true

    Description

    Whether label functionality is enabled

    wrap

    Type: boolean | undefined

    Description

    Whether labels wrap to the next line

    showValue

    Type: boolean | undefined

    Description

    Whether labels display measure values

    In multi-measure scenarios, there is no concern about conflicting values, because all plot-related measures go through foldMeasures processing and are merged into one measure representing a single data point

    Note: encoding's label has higher priority; this config does not affect encoding's label

    showValuePercent

    Type: boolean | undefined

    Description

    Whether labels display the percentage of measure values

    In multi-measure scenarios, there is no concern about conflicting values, because all plot-related measures go through foldMeasures processing and are merged into one measure representing a single data point

    Note: encoding's label has higher priority; this config does not affect encoding's label

    showDimension

    Type: boolean | undefined

    Description

    Whether labels display dimension labels

    Display all dimension labels

    Note: encoding's label has higher priority; this config does not affect encoding's label

    autoFormat

    Type: boolean | undefined

    Description

    Whether label values are automatically formatted; when autoFormat is true, numFormat configuration is ignored

    numFormat

    Type: NumFormat | undefined

    Description

    Label value format configuration; merged with the format in measure, where measure's format has higher priority. numFormat priority is lower than autoFormat

    type

    Type: "number" | "percent" | "permille" | "scientific" | undefined

    Description

    Number format type, supports: number (decimal), percent (%), permille (‰), scientific notation

    ratio

    Type: number | undefined

    Description

    Number format ratio, cannot be 0

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    symbol

    Type: string | undefined

    Description

    Number format symbol, e.g. %, ‰

    Example - 100000 converts to 10万, ratio:10000, symbol:"万" - 100000 converts to 10K, ratio:1000, symbol:"K"

    thousandSeparator

    Type: boolean | undefined

    Description

    Thousands separator for number formatting

    suffix

    Type: string | undefined

    Description

    Number format suffix

    prefix

    Type: string | undefined

    Description

    Number format prefix

    fractionDigits

    Type: number | undefined

    Description

    Decimal places for number formatting, using the browser's Intl.NumberFormat minimumFractionDigits and maximumFractionDigits; lower priority than significantDigits

    Example - 1234.5678 converts to 1235, fractionDigits:0 (roundingMode:halfCeil) - 1234.5678 converts to 1234.6, fractionDigits:1 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, fractionDigits:2 (roundingMode:halfCeil) - 1234.5678 converts to 1230.568, fractionDigits:3 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, fractionDigits:4 (roundingMode:halfCeil) - 1234.5678 converts to 1234.56780, fractionDigits:5 (roundingMode:halfCeil)

    significantDigits

    Type: number | undefined

    Description

    Significant digits for number formatting, using the browser's Intl.NumberFormat minimumSignificantDigits and maximumSignificantDigits; higher priority than fractionDigits

    Example - 1234.5678 converts to 1000, significantDigits:1 - 1234.5678 converts to 1200, significantDigits:2 - 1234.5678 converts to 1230, significantDigits:3 - 1234.5678 converts to 1234, significantDigits:4 - 1234.5678 converts to 1234.6, significantDigits:5 (roundingMode:halfCeil) - 1234.5678 converts to 1234.57, significantDigits:6 (roundingMode:halfCeil) - 1234.5678 converts to 1234.568, significantDigits:7 (roundingMode:halfCeil) - 1234.5678 converts to 1234.5678, significantDigits:8 (roundingMode:halfCeil)

    roundingPriority

    Type: "morePrecision" | "lessPrecision" | undefined

    Description

    Rounding priority for number formatting when both significantDigits and fractionDigits are set; uses the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingPriority

    Example - 1234.5678 converts to 1230, significantDigits:3 (roundingPriority:lessPrecision) - 1234.5678 converts to 1234.5678, significantDigits:3 (roundingPriority:morePrecision)

    roundingMode

    Type: "floor" | "ceil" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined

    Description

    Rounding mode for number formatting, using the browser's Intl.NumberFormat, following the same rules as Intl.NumberFormat's roundingMode

    labelFontSize

    Type: number | undefined

    Description

    Label font size

    labelFontWeight

    Type: string | number | undefined

    Description

    Label font weight

    labelBackgroundColor

    Type: string | undefined

    Description

    Label background color

    labelStroke

    Type: string | undefined

    Description

    Label stroke color

    labelColor

    Type: string | undefined

    Description

    Label font color

    labelColorSmartInvert

    Type: boolean | undefined

    Description

    Whether the label font color automatically inverts based on the graphical element color

    labelPosition

    Type: "inside" | "outside" | undefined

    Description

    Label position

    labelOverlap

    Type: boolean | undefined

    Description

    Whether the label anti-overlap function is enabled

    selector

    Type: Selector | Selectors | undefined

    Description

    Label filtering; the default relationship between selectors is OR

    field

    Type: string

    Description

    Dimension field; ID of a specific dimension item

    operator

    Type: "in" | "not in" | undefined

    Description

    Operator

    - in: Select data items whose dimension field value is within the specified value

    - not in: Select data items whose dimension field value is not within the specified value

    op

    Type: "in" | "not in" | undefined

    Description

    Operator

    - in: Select data items whose dimension field value is within the specified value

    - not in: Select data items whose dimension field value is not within the specified value

    Same as operator

    value

    Type: string | number | (string | number)[]

    Description

    Select dimension field values; supports arrays

    dynamicFilter

    Type: ChartDynamicFilter | undefined

    Description

    Dynamic filter (AI-generated code execution)

    Implements complex data filtering logic via AI-generated JavaScript code

    Core capabilities:

    - Supports arbitrarily complex data filtering conditions

    - Use built-in utility functions for data manipulation

    - Secure execution in the browser environment (Web Worker sandbox)

    Environmental requirements: Supports browser environments only; Node.js environments will use fallback

    Note: selector and dynamicFilter cannot be used simultaneously; dynamicFilter has higher priority

    Chart dynamic filter configuration

    Implements filtering of chart marks (bars, points, etc.) via AI-generated JavaScript code

    type

    Type: "row-with-field"

    description

    Type: string | undefined

    Description

    User's filtering requirement description (natural language)

    Example "Highlight columns with sales greater than 1000"

    "Highlight the column with the highest profit margin in each area"

    code

    Type: string

    Description

    AI-generated JavaScript filtering code

    - Only built-in utility functions can be used (accessed via _ or R)

    - Input parameters: data (array), where each item includes a __row_index field representing the row number

    - Must return an array of row index and field combinations: Array<{ __row_index: number, field: string }>

    - __row_index represents the row number of the original data item; field represents the field to be highlighted

    - Forbidden: eval, Function, asynchronous operations, DOM API, network requests

    Example Highlight the sales field of data items with sales greater than 1000

    const filtered = _.filter(data, item => item.sales > 1000);
    return _.map(filtered, item => ({
    __row_index: item.__row_index,
    field: 'sales'
    }));

    Highlight data items with the highest profit margin in each area

    const grouped = _.groupBy(data, 'area');
    const maxItems = _.map(grouped, group =>
    _.maxBy(group, item => item.profit / item.sales)
    );
    return _.flatten(
    _.map(maxItems, item => [
    { __row_index: item.__row_index, field: 'product' },
    { __row_index: item.__row_index, field: 'profit' }
    ])
    );

    Highlight data items filtered by multiple conditions

    const filtered = _.filter(data, item => {
    const profitRate = item.profit / item.sales;
    return profitRate > 0.2 && item.sales > 5000;
    });
    return _.flatten(
    _.map(filtered, item => [
    { __row_index: item.__row_index, field: 'product' },
    { __row_index: item.__row_index, field: 'sales' }
    ])
    );

    fallback

    Type: Selector | Selectors | undefined

    Description

    Fallback plan when code execution fails or the environment is not supported

    field

    Type: string

    Description

    Dimension field; ID of a specific dimension item

    operator

    Type: "in" | "not in" | undefined

    Description

    Operator

    - in: Select data items whose dimension field value is within the specified value

    - not in: Select data items whose dimension field value is not within the specified value

    op

    Type: "in" | "not in" | undefined

    Description

    Operator

    - in: Select data items whose dimension field value is within the specified value

    - not in: Select data items whose dimension field value is not within the specified value

    Same as operator

    value

    Type: string | number | (string | number)[]

    Description

    Select dimension field values; supports arrays

    result

    Type: DynamicFilterExecutionResult<RowWithFieldRes> | undefined

    Description

    Dynamic filter execution result (runtime field)

    Written during the prepare() phase; read-only at runtime

    success

    Type: false | true

    data

    Type: T[] | undefined

    error

    Type: string | undefined

    legend

    Type: Legend | undefined

    Description

    Legend

    Legend configuration, used to define the display, position, and style of the Sankey chart's color legend

    enable

    Type: boolean | undefined

    Description

    Whether legend functionality is enabled

    Example enable: true

    border

    Type: boolean | undefined

    Description

    Whether legend border is enabled

    Warning

    Only effective for discrete legends

    Example border: true

    labelColor

    Type: string | undefined

    Description

    Legend font color

    pagerIconColor

    Type: string | undefined

    Description

    Pager icon color

    pagerIconDisableColor

    Type: string | undefined

    Description

    Pager icon disabled color

    labelFontSize

    Type: number | undefined

    Description

    Legend font size

    Example labelFontSize: 10

    labelFontColor

    Type: string | undefined

    Description

    Legend font color

    labelFontWeight

    Type: string | number | undefined

    Description

    Legend font weight

    Example labelFontWeight: 400

    shapeType

    Type: "circle" | "cross" | "diamond" | "square" | "arrow" | "arrow2Left" | "arrow2Right" | "wedge" | "thinTriangle" | "triangle" | "triangleUp" | "triangleDown" | "triangleRight" | "triangleLeft" | "stroke" | "star" | "wye" | "rect" | "arrowLeft" | "arrowRight" | "rectRound" | "roundLine" | undefined

    Description

    Legend shape

    Warning

    Only effective for discrete legends

    Example shapeType: 'circle'

    position

    Type: "left" | "leftTop" | "leftBottom" | "lt" | "lb" | "top" | "topLeft" | "topRight" | "tl" | "tr" | "right" | "rightTop" | "rightBottom" | "rt" | "rb" | "bottom" | "bottomLeft" | "bottomRight" | "bl" | "br" | undefined

    Description

    Legend position

    Example position: 'rightTop'

    maxSize

    Type: number | undefined

    Description

    Maximum number of columns or rows for the legend when there are many legend items

    If position is horizontal (bottom, bottomLeft, bottomRight, bl, br, top, topLeft, topRight, tl, tr), maxSize controls the number of displayed columns

    If position is vertical (left, leftTop, leftBottom, lt, lb, right, rightTop, rightBottom, rt, rb), maxSize controls the number of displayed rows

    Warning

    Only effective for discrete legends

    Example maxSize: 2

    tooltip

    Type: Tooltip | undefined

    Description

    Tooltip

    Tooltip configuration, used to define the chart's tooltips, including content, format, style, etc.

    enable

    Type: false | true

    Description

    Whether tooltips are enabled

    theme

    Type: Theme | undefined

    Description

    Chart theme

    Theme

    Built-in light and dark themes; new themes can be customized via registerTheme.

    length

    Type: number

    brand

    Type: brand

    locale

    Type: "zh-CN" | "en-US" | "ja-JP" | "de-DE" | "id-ID" | "fr-FR" | "ko-KR" | "vi-VN" | undefined

    Description

    Language

    Chart language configuration, supports 'zh-CN' and 'en-US'