gpt4 book ai didi

elasticsearch - Vega-lite热图将文本添加到变量

转载 作者:行者123 更新时间:2023-12-02 23:48:09 25 4
gpt4 key购买 nike

"data": {
"values": [
{"x": 0, "y": 0, "z": 0},
{"x": 1, "y": 0, "z": 1},
{"x": 2, "y": 0, "z": 5},
{"x": 2, "y": 0, "z": 10},
{"x": 4, "y": 0, "z": 16},
{"x": 0, "y": 1, "z": 1},
{"x": 1, "y": 1, "z": 2},
{"x": 2, "y": 1, "z": 5},
{"x": 3, "y": 1, "z": 10},
{"x": 5, "y": 1, "z": 26}
]},

如何将文本添加到变量,例如“AVG:”?
enter image description here

Vega Editor

最佳答案

您可以使用计算转换来创建特殊格式的文本以在文本标记中显示。例如(vega editor):

{
"data": {
"values": [
{"x": 0, "y": 0, "z": 0},
{"x": 1, "y": 0, "z": 1},
{"x": 2, "y": 0, "z": 5},
{"x": 2, "y": 0, "z": 10},
{"x": 4, "y": 0, "z": 16},
{"x": 0, "y": 1, "z": 1},
{"x": 1, "y": 1, "z": 2},
{"x": 2, "y": 1, "z": 5},
{"x": 3, "y": 1, "z": 10},
{"x": 5, "y": 1, "z": 26}
]
},
"transform": [
{
"aggregate": [{"op": "mean", "field": "z", "as": "z"}],
"groupby": ["x", "y"]
},
{"calculate": "'avg: ' + datum.z", "as": "z"}
],
"mark": "text",
"encoding": {
"x": {"field": "x", "type": "ordinal"},
"y": {"field": "y", "type": "ordinal"},
"text": {"field": "z", "type": "nominal"}
},
"width": 300,
"height": 100
}

enter image description here

关于elasticsearch - Vega-lite热图将文本添加到变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59731790/

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