admin管理员组

文章数量:1027515

Power BI Deneb 玫瑰图

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

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

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

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

代码语言:javascript代码运行次数:0运行复制
{
  "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 删除模型拖拽bifield对象

Power BI Deneb 玫瑰图

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

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

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

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

代码语言:javascript代码运行次数:0运行复制
{
  "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 删除模型拖拽bifield对象

本文标签: Power BI Deneb 玫瑰图