pyecharts 旭日图

from pyecharts.charts import Sunburst
from pyecharts import options as opts
from pyecharts.globals import ThemeType
data=[{"name":"烟","itemStyle": {"color": "#da0d68"},
       "children":[{"name": "黄鹤楼", "value": 10, "itemStyle": {"color": "#975e6d"},
                    'children':[{"name":"硬","value": 2,"itemStyle": {"color": "#d78823"}},
                                {"name":"软","value": 3,"itemStyle": {"color": "#da5c1f"}},
                                 {"name":"1919","value": 5,"itemStyle": {"color": "#f89a80"}}]},
                   {"name": "南京", "value": 12, "itemStyle": {"color": "#e0719c"}},
                   {"name": "白鲨", "value": 15, "itemStyle": {"color": "#dd4c51"}},
                   {"name": "泰山", "value": 17, "itemStyle": {"color": "#c94a44"}}]},


      {"name":"酒","itemStyle": {"color": "#c94a44"},
       "children": [{"name": "茅台", "value": 7, "itemStyle": {"color": "#e65656"}},
                    {"name": "五粮液", "value": 9, "itemStyle": {"color": "#4eb849"}},
                    {"name": "酒鬼酒", "value": 21, "itemStyle": {"color": "#f68a5c"}},
                    {"name": "白云边", "value": 13, "itemStyle": {"color": "#baa635"}}]},
{"name":"茶","itemStyle": {"color": "##ebb40f"},
       "children": [{"name": "大红袍", "value": 3, "itemStyle": {"color": "#e2631e"}},
                    {"name": "碧螺春", "value": 6, "itemStyle": {"color": "#fde404"}},
                    {"name": "毛尖", "value": 12, "itemStyle": {"color": "#7eb138"}},
                    {"name": "白茶", "value": 15, "itemStyle": {"color": "#d0b24f"}}]}
]

c = (Sunburst(init_opts=opts.InitOpts(width="1000px", height="600px"))
    .add(
        "",
        data_pair=data,
        highlight_policy="ancestor",
        radius=[0, "95%"],
        sort_="null",
        levels=[
            {},
            {
                "r0": "15%",
                "r": "35%",
                "itemStyle": {"borderWidth": 2},
                "label": {"rotate": "tangential"},
            },
            {"r0": "35%", "r": "70%", "label": {"align": "right"}},
            {
                "r0": "70%",
                "r": "72%",
                "label": {"position": "outside", "padding": 3, "silent": False},
                "itemStyle": {"borderWidth": 3},
            },
        ],
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="旭日图"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}"))
    .render("cost.html"))

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值