前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Power BI Deneb 玫瑰图

Power BI Deneb 玫瑰图

作者头像
wujunmin
发布于 2025-05-05 05:36:54
发布于 2025-05-05 05:36:54
6700
代码可运行
举报
文章被收录于专栏:wujunminwujunmin
运行总次数:0
代码可运行

李伟坚老师最近在Easyshu更新了大量的vega图表,Power BI 也支持Vega/Vega lite(使用Deneb视觉对象),我从李老师那里抄了一个玫瑰图到Power BI:

玫瑰图(Rose Chart),也称为极坐标柱状图南丁格尔玫瑰图,是一种将数据以极坐标形式展示的圆形统计图表。它通过扇形的半径或角度来反映数值大小,形似花瓣,因此得名“玫瑰图”。

Deneb视觉对象拖拽模型中的维度和度量:

点击视觉对象上的...-编辑-空白vega-lite,粘贴以下代码,即可复刻:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
{
  "data": {"name": "dataset"},
  "transform": [
    {
      "calculate": "datum.城市 + ' ' + format(datum.KPI__highlight, '.1f')",
      "as": "label"
    }
  ],
  "layer": [
    {
      "mark": {
        "type": "arc",
        "innerRadius": 20,
        "outerRadius": 100,
        "cornerRadius": 0,
        "stroke": "#fff",
        "tooltip": true
      },
      "encoding": {
        "theta": {
          "field": "KPI__highlight",
          "type": "quantitative",
          "stack": true
        },
        "radius": {
          "field": "KPI__highlight",
          "scale": {"type": "sqrt", "zero": true}
        },
        "color": {
          "field": "城市",
          "type": "nominal",
          "legend": null,
          "sort": {"field": "KPI__highlight", "order": "descending"}
        },
        "order": {
          "field": "KPI__highlight", 
          "sort": "descending"
        },
        "opacity": {
          "condition": {
            "test": {"field": "__selected__", "equal": "off"},
            "value": 0.3
          },
          "value": 1
        }
      }
    },
    {
      "mark": {
        "type": "text",
        "radiusOffset": 50,
        "size": 14,
        "color": "#333"
      },
      "encoding": {
        "theta": {
          "field": "KPI__highlight",
          "type": "quantitative",
          "stack": true
        },
        "radius": {
          "field": "KPI__highlight",
          "scale": {"type": "sqrt", "zero": true}
        },
        "text": {"field": "label", "type": "nominal"},
        "order": {
          "field": "KPI__highlight", 
          "sort": "descending"
        }
      }
    }
  ],
  "view": {"stroke": null},
  "config": {
    "view": {"stroke": "transparent"},
    "text": {
      "baseline": "middle",
      "align": "center"
    }
  }
}

可以略微修改中间加上总体值:

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-05-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 wujunmin 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档