g2_sankey: g2_sankey

View source: R/rg2.R

g2_sankeyR Documentation

g2_sankey

Description

opt param in rg2 is the PlotOptions for G2Plot. You can construct an opt using function with g2_ prefix and g2_opt(). https://g2plot.antv.antgroup.com/en/api for details

Usage

g2_sankey(data, sourceField, targetField, weightField, rawFields = NULL)

Arguments

data

required. Data frame for plot.

sourceField

source field

targetField

target field

weightField

weight field

rawFields

raw fields

See Also

Other g2: g2_area(), g2_bar(), g2_bidirectional_bar(), g2_box(), g2_bullet(), g2_chord(), g2_circle_packing(), g2_column(), g2_dual_axes(), g2_funnel(), g2_gauge(), g2_heatmap(), g2_histogram(), g2_line(), g2_liquid(), g2_pie(), g2_progress(), g2_radar(), g2_radial_bar(), g2_ring_progress(), g2_rose(), g2_scatter(), g2_stock(), g2_sunburst(), g2_tiny_area(), g2_tiny_column(), g2_treemap(), g2_venn(), g2_violin(), g2_waterfall(), g2_word_cloud(), g2()

Examples

data = jsonlite::fromJSON('[
{ "source": "首次打开","target": "首页 UV", "value": 160 },
{ "source": "结果页",  "target": "首页 UV", "value": 40 },
{ "source": "验证页",  "target": "首页 UV", "value": 10 },
{ "source": "我的",    "target": "首页 UV", "value": 10 },
{ "source": "朋友",    "target": "首页 UV", "value": 8 },
{ "source": "其他",    "target": "首页 UV", "value": 27 },
{ "source": "首页 UV", "target": "理财",    "value": 30 },
{ "source": "首页 UV", "target": "扫一扫",  "value": 40 },
{ "source": "首页 UV", "target": "服务",    "value": 35 },
{ "source": "首页 UV", "target": "蚂蚁森林","value": 25 },
{ "source": "首页 UV", "target": "跳失",    "value": 10 },
{ "source": "首页 UV", "target": "借呗",    "value": 30 },
{ "source": "首页 UV", "target": "花呗",    "value": 40 },
{ "source": "首页 UV", "target": "其他流向","value": 45 }
]')
g2_sankey(data, 'source', 'target', 'value') |> g2()

g2_sankey(data, 'source', 'target', 'value') |> g2_opt(nodeWidthRatio=0.008,nodePaddingRatio=0.03) |> g2()


13kay/rg2 documentation built on Feb. 16, 2024, 10:22 p.m.