gpt4 book ai didi

data-visualization - 选择转换为文本/标题

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

如何将选定点上的变换显示为标题或副标题中的文本?

{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/stocks.csv"},
"transform": [{"filter": "datum.symbol==='GOOG'"}],
"width": 800,
"title": {
"text": "Google's stock price over time.",
"subtitle": "selected average: ???"
},
"selection": {
"interval": {
"type": "interval",
"encodings": ["x"]
}
},
"mark": "point",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
}
}
总和变换不适合任何图形/视觉表示。一个想法是将其作为选择工具提示,但 is not possible .所以我选择了一个副标题。

最佳答案

我不认为有一种简单的方法可以在字幕中插入计算值,但是您可以使用带有包含计算值的文本标记的图层图来实现相同的效果。
例如( open in editor ):

{
"data": {"url": "data/stocks.csv"},
"transform": [{"filter": "datum.symbol==='GOOG'"}],
"width": 800,
"title": {"text": "Google's stock price over time."},
"layer": [
{
"transform": [
{"filter": {"selection": "interval"}},
{"aggregate": [{"op": "sum", "field": "price", "as": "total_price"}]}
],
"mark": "text",
"encoding": {
"x": {"value": 400},
"y": {"value": -10},
"text": {"field": "total_price", "type": "quantitative"}
}
},
{
"mark": "point",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
},
"selection": {"interval": {"type": "interval", "encodings": ["x"]}}
}
]
}
enter image description here
注意文本层有 xy以图表左上角的像素为单位指定的编码值。

关于data-visualization - 选择转换为文本/标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66235486/

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