gpt4 book ai didi

powerbi - Vega-lite 项目 : Risk matrix

转载 作者:行者123 更新时间:2023-12-05 04:29:20 29 4
gpt4 key购买 nike

在谈到 Vega 时,我是一个新手,非常感谢任何帮助。我目前正在创建一个风险矩阵,其中包含“潜在损害”和“风险暴露”两个维度。最终目标是在 PowerBI 中使用。

我的当前状态可以在这里看到:https://vega.github.io/editor/#/gist/d534904674d14f005e7cb08811dc8b62/spec.json

现在我面临两个主要挑战:

  • 如何给字段着色,使矩阵看起来像这个:risk matrix picture
  • 如何用 0 填充到目前为止没有数字的字段(在本例中:损坏:中;曝光:中)?

欢迎任何帮助。 :)

最佳答案

给你。

Editor.

enter image description here

{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"url": "https://gist.githubusercontent.com/Hatico90/ec1d58ef5fe5d91cf6438e66fcd40bf0/raw/c5737c70fd45807a8435f2a97fe17fbc03bddf2b/riskmatrix",
"format": {"type": "json"}
},
"width": 500,
"height": 500,
"transform": [
{
"pivot": "Exposure",
"groupby": ["Damage"],
"value": "Index",
"op": "count"
},
{"fold": ["high", "low", "medium"]}
],
"encoding": {
"y": {
"field": "key",
"type": "ordinal",
"scale": {"domain": ["high", "medium", "low"]}
},
"x": {
"field": "Damage",
"type": "ordinal",
"scale": {"domain": ["low", "medium", "high"]}
}
},
"layer": [
{
"mark": "rect",
"data": {
"values": [
{"x": "low", "y": "low", "t": "green"},
{"x": "low", "y": "medium", "t": "green"},
{"x": "low", "y": "high", "t": "yellow"},
{"x": "medium", "y": "low", "t": "green"},
{"x": "medium", "y": "medium", "t": "yellow"},
{"x": "medium", "y": "high", "t": "red"},
{"x": "high", "y": "low", "t": "yellow"},
{"x": "high", "y": "medium", "t": "red"},
{"x": "high", "y": "high", "t": "red"}
]
},
"encoding": {
"color": {
"type": "nominal",
"field": "t",
"scale": {"range": {"field": "t"}},
"legend": null
},
"y": {
"field": "y",
"type": "ordinal",
"scale": {"domain": ["high", "medium", "low"]}
},
"x": {
"field": "x",
"type": "ordinal",
"scale": {"domain": ["low", "medium", "high"]}
}
}
},
{
"mark": {"type": "text"},
"encoding": {"text": {"field": "value", "type": "quantitative"}}
}
],
"config": {"axis": {"grid": true, "tickBand": "extent"}}
}

关于powerbi - Vega-lite 项目 : Risk matrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72351715/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com