g2_sunburst | R Documentation |
The data for sunburst chart has a special format, if your data Node do not follow its key name, you need to specify the hierarchyConfig
in g2_opt()
g2_sunburst(data, colorField = NULL, rawFields = NULL)
data |
required. Data frame for plot. |
colorField |
color field |
rawFields |
raw fields |
data schema
type Node = { name: string; value?: number; children: Node[]; }
an example data looks like:
{ name: 'root', children: [ { name: 'type1', value: 1 }, { name: 'type2', value: 3, children: [{ name: 'type2-1', value: 2 }] } ] }
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_sankey()
,
g2_scatter()
,
g2_stock()
,
g2_tiny_area()
,
g2_tiny_column()
,
g2_treemap()
,
g2_venn()
,
g2_violin()
,
g2_waterfall()
,
g2_word_cloud()
,
g2()
jsonlite::fromJSON('https://gw.alipayobjects.com/os/antfincdn/ryp44nvUYZ/coffee.json') |> g2_sunburst() |> g2()
# Data Node with label/uv/sum/count (default Node with name/value/children)
df = jsonlite::fromJSON("https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json",simplifyVector=TRUE)
g2_sunburst(df, 'label') |> g2_opt(hierarchyConfig = list(field='sum')) |> g2()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.